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...
CARTO/XYZ/Slippy Map Only
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),flutter 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 defaultTileLayer
FlutterMap, containing a Marker, Polyline, Polygon, and RichAttributionLayer on top of a TileLayer
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.
@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')),
),
],
),
],
);
}RotatedOverlayImageOverlayImageLayer(
circles: [
OverlayImage(
bounds: LatLngBounds(
LatLng(45.3367881884556, 14.159452282322459),
LatLng(45.264129635422826, 14.252585831779033),
),
imageProvider: NetworkImage(),
),
],
),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`
}
}FlutterMap(
mapController: _mapController,
options: MapOptions(),
children: [],
nonRotatedChildren: [],
);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
}CircleLayer(
circles: [
CircleMarker(
point: LatLng(51.50739215592943, -0.127709825533512),
radius: 10000,
useRadiusInMeter: true,
),
],
),
CircleMarker

interactiveFlags - see InteractiveFlag for available options
Limits what methods the user can interact with the map through (for example, preventing rotation)final 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
RichAttributionWidgetRichAttributionWidget, as in the example appSimpleAttributionWidget, 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'),
),
],

