flutter_map_smart 1.1.0
flutter_map_smart: ^1.1.0 copied to clipboard
A plug-and-play OpenStreetMap widget with clustering, image markers, user location, and nearby radius support.
Flutter Map Smart #
A plug-and-play OpenStreetMap widget for Flutter that handles:
- 📍 Clustering: Efficiently manages thousands of markers.
- 🖼️ Image Markers: Easily use asset or network images as markers.
- 🌍 User Location: Shows current location with an animated radius.
- 📏 Nearby Filtering: Automatically filters visible items based on user location.
- 🔍 Search & Pick: Built-in address search and location picker.
- 🎨 Custom Layers: Support for Polylines, Polygons, and Circles.
Installation #
dependencies:
flutter_map_smart: ^1.1.0
Quick Start #
1. Basic Usage (Display Markers) #
import 'package:flutter_map_smart/flutter_map_smart.dart';
FlutterMapSmart.simple(
items: myPlaces,
latitude: (place) => place.lat,
longitude: (place) => place.lng,
markerImage: (place) => place.imageUrl,
onTap: (place) => print('Tapped: ${place.name}'),
);
2. Controllable Map (Move & Zoom) #
You can allow programmatic control by passing a MapController.
final mapController = MapController();
FlutterMapSmart.simple(
items: items,
// ...
mapController: mapController, // Pass the controller
onMapTap: (pos, latLng) => print('Tapped map at: $latLng'),
);
// Later:
mapController.move(LatLng(51.5, -0.09), 15.0);
3. Custom Layers (Polylines) #
Draw routes or areas by adding children layers.
FlutterMapSmart.simple(
items: items,
// ...
children: [
PolylineLayer(
polylines: [
Polyline(points: [startPos, endPos], color: Colors.blue, strokeWidth: 4),
],
),
],
);
4. Search Address #
Use the built-in SmartOSMSearch utility to find coordinates.
final location = await SmartOSMSearch.search("Paris, France");
if (location != null) {
mapController.move(location, 13.0);
}
5. Location Picker #
Let users pick a location with a center pin.
SmartLocationPicker(
initialCenter: LatLng(28.61, 77.23),
onLocationChanged: (latLng) {
print("Picking: $latLng");
},
)
Features #
| Feature | Description |
|---|---|
| Simple API | No boilerplate. Just pass your list of objects. |
| Clustering | Uses flutter_map_marker_cluster for high performance. |
| Location | Integrated geolocator and latlong2. |
| Animations | Smooth camera movement and radius animations. |
| Permissions | Handles permission states (granted, denied, disabled) for you. |
Attribution #
This package calls the OpenStreetMap Nominatim API for search. Usage Policy: You must abide by the Nominatim Usage Policy.
- Limit your requests (max 1/sec).
- Provide a valid User-Agent.
Map tiles are provided by OpenStreetMap. © OpenStreetMap contributors.