Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Map<String, String> of custom headers. Note that the user agent that is automatically generated will not override any 'User-Agent' header if specified here. On the web, the 'User-Agent' header is not sent, as the browser controls the user agent.TileLayer
FlutterMap, containing a Marker, Polyline, Polygon, and RichAttributionLayer on top of a TileLayerCircleLayer(
circles: [
CircleMarker(
point: LatLng(51.50739215592943, -0.127709825533512),
radius: 10000,
useRadiusInMeter: true,
),
],
),
CircleMarkerflutter pub add flutter_map
flutter pub add latlong2dependency_overrides:
flutter_map:
git:
url: https://github.com/fleaflet/flutter_map.git
# ref: main import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:flutter_map/plugin_api.dart'; // Only import if required functionality is not exposed by defaultRotatedOverlayImageOverlayImageLayer(
circles: [
OverlayImage(
bounds: LatLngBounds(
LatLng(45.3367881884556, 14.159452282322459),
LatLng(45.264129635422826, 14.252585831779033),
),
imageProvider: NetworkImage(),
),
],
),CARTO/XYZ/Slippy Map Only
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),class CustomLayer extends StatelessWidget {
const CustomLayer({super.key});
@override
Widget build(BuildContext context) {
final mapState = FlutterMapState.maybeOf(context)!;
// Use `mapState` as necessary, for example `mapState.zoom`
}
}class CustomTileProvider extends TileProvider {
// Add your own custom properties, methods, etc.
CustomTileProvider({
// Suitably initialise your own custom properties
super.headers, // Use the Dart 2.17 `super` syntax to initialise the base's header `Map`
})
} @override
ImageProvider getImage(Coords<num> coords, TileLayerOptions options) =>
CustomImageProvider(
options: options,
coords: coords,
headers: {
...headers,
'User-Agent': headers['User-Agent'] == null
? '<pluginName> for flutter_map (unknown)'
: '<pluginName> for ${headers['User-Agent']}',
},
); @override
String getTileUrl(Coords coords, TileLayerOptions options) {
// Custom generation
}PolygonLayer(
polygons: [
Polygon(
points: [LatLng(30, 40), LatLng(20, 50), LatLng(25, 45)],
color: Colors.blue,
),
],
),
PolygonMarkerLayer(
markers: [
Marker(
point: LatLng(30, 40),
width: 80,
height: 80,
builder: (context) => FlutterLogo(),
),
],
),
Marker, using FlutterLogo as the child
Mapping package for Flutter, based off of 'leaflet.js'. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.

RichAttributionWidget
RichAttributionWidget, as in the example app
SimpleAttributionWidget, as in the example appnonRotatedChildren: [
RichAttributionWidget(
animationConfig: const ScaleRAWA(), // Or `FadeRAWA` as is default
attributions: [
TextSourceAttribution(
'OpenStreetMap contributors',
onTap: () => launchUrl(Uri.parse('https://openstreetmap.org/copyright')),
),
],
),
],nonRotatedChildren: [
SimpleAttributionWidget(
source: Text('OpenStreetMap contributors'),
),
],MapController, and keep it in an external state systemfinal mapController = MapController();
@override
Widget build(BuildContext context) =>
FlutterMap(
mapController: mapController,
options: MapOptions(
onMapReady: () {
mapController.mapEventStream.listen((evt) {});
// And any other `MapController` dependent non-movement methods
},
),
);falseimport 'package:latlong2/latlong.dart';
export 'package:google_polyline_algorithm/google_polyline_algorithm.dart'
show decodePolyline;
extension PolylineExt on List<List<num>> {
List<LatLng> unpackPolyline() =>
map((p) => LatLng(p[0].toDouble(), p[1].toDouble())).toList();
}import '<code_snippet_path>'
decodePolyline('<encoded-polyline>').unpackPolyline(); // Returns `List<LatLng>` for a map polyline
@override
Widget build(BuildContext context) {
return FlutterMap(
options: MapOptions(
center: LatLng(51.509364, -0.128928),
zoom: 9.2,
),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.app',
),
],
nonRotatedChildren: [
RichAttributionWidget(
attributions: [
TextSourceAttribution(
'OpenStreetMap contributors',
onTap: () => launchUrl(Uri.parse('https://openstreetmap.org/copyright')),
),
],
),
],
);
}