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...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
FlutterMap(
mapController: _mapController,
options: MapOptions(),
children: [],
nonRotatedChildren: [],
);FlutterMap(
options: MapOptions(),
children: [
CircleLayer(
circles: [],
),
],
), retinaMode: MediaQuery.of(context).devicePixelRatio > 1.0,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.
return FlutterMap(
options: MapOptions(
center: LatLng(51.509364, -0.128928),
zoom: 9.2,
),
nonRotatedChildren: [
AttributionWidget.defaultWidget(
source: 'OpenStreetMap contributors',
onSourceTapped: null,
),
],
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.app',
),
],
); zoom: 13.0,
maxZoom: 19.0, bounds: LatLngBounds(
LatLng(51.74920, -0.56741),
LatLng(51.25709, 0.34018),
),
maxBounds: LatLngBounds(
LatLng(-90, -180.0),
LatLng(90.0, 180.0),
), rotation: 180.0, keepAlive: true,FlutterMap(
options: MapOptions(
center: LatLng(51.5, -0.09),
zoom: 13.0,
),
nonRotatedChildren: [
// This does NOT fulfill Mapbox's requirements for attribution
// See https://docs.mapbox.com/help/getting-started/attribution/
AttributionWidget.defaultWidget(
source: '© Mapbox © OpenStreetMap',
onSourceTapped: () async {
// Requires 'url_launcher'
if (!await launchUrl(Uri.parse("https://docs.mapbox.com/help/getting-started/attribution/"))) {
if (kDebugMode) print('Could not launch URL');
}
},
)
],
children: [
TileLayer(
urlTemplate: "https://api.mapbox.com/styles/v1/<user>/<tile-set-id>/tiles/<256/512>/{z}/{x}/{y}@2x?access_token={access_token}",
additionalOptions: {
"access_token": "<ACCESS-TOKEN>",
},
userAgentPackageName: 'com.example.app',
),
],
);FlutterMap(
options: MapOptions(
...
),
);flutter pub add flutter_mapdependency_overrides:
flutter_map:
git:
url: https://github.com/fleaflet/flutter_map.git
# ref: main import 'package:flutter_map/flutter_map.dart'; // Suitable for most situations
import 'package:flutter_map/plugin_api.dart'; // Only import if required functionality is not exposed by defaultVisit the Full API Reference for the full list of available options
subdomains: ['a', 'b', 'c'], tileBounds: LatLngBounds(
LatLng(32.2934590056236, 24.328924534719548),
LatLng(21.792152188247265, 37.19854583903912),
), errorImage: const NetworkImage('https://tile.openstreetmap.org/18/0/0.png'), tileBuilder: (context, widget, tile) =>
Stack(
fit: StackFit.passthrough,
children: [
widget,
Center(
child:
Text('${tile.coords.x.floor()} : ${tile.coords.y.floor()} : ${tile.coords.z.floor()}'),
),
],
); reset: resetController.stream,
// Elsewhere
final StreamController<void> resetController = StreamController.broadcast();
void resetMap() => resetController.add(null);@override
void initState(){
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// Use `MapController` as needed
});
}@override
Widget build(BuildContext context) =>
FlutterMap(
mapController: mapController,
options: MapOptions(
onMapReady: () {
// Use `MapController` as needed
},
),
);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
} enableScrollWheel: true,
scrollWheelVelocity: 0.005, onPositionChanged: (MapPosition position, bool hasGesture) {
// Your logic here. `hasGesture` dictates whether the change
// was due to a user interaction or something else. `position` is
// the new position of the map.
} onTap: (TapPosition position, LatLng location) {
// Your logic here. `location` dictates the coordinate at which the user tapped.
}@override
Widget build(BuildContext context) {
final mapState = FlutterMapState.maybeOf(context)!;
// Use `mapState` as necessary, for example `mapState.zoom`
} layers: [],
nonRotatedLayers: [], children: [],
nonRotatedChildren: [], layers: [
TileLayerOptions(),
MarkerLayerOptions(),
],
children: [
TileLayerWidget(options: TileLayerOptions()),
MarkerLayerWidget(options: MarkerLayerOptions()),
], children: [
TileLayer(),
MarkerLayer(),
],import 'package:latlong2/latlong.dart';<uses-permission android:name="android.permission.INTERNET"/>FlutterMap(
options: MapOptions(
center: LatLng(51.5, -0.09),
zoom: 13.0,
),
nonRotatedChildren: [
AttributionWidget.defaultWidget(
source: 'Stadia Maps © OpenMapTiles © OpenStreetMap contributors',
onSourceTapped: () async {
// Requires 'url_launcher'
if (!await launchUrl(Uri.parse("https://stadiamaps.com/attribution"))) {
if (kDebugMode) print('Could not launch URL');
}
},
)
],
children: [
TileLayer(
urlTemplate: "https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}{r}.png?api_key={api_key}",
additionalOptions: {
"api_key": "<API-KEY>",
},
userAgentPackageName: 'com.example.app',
maxNativeZoom: 20,
),
],
);saveLayers set to false (which is default). This will reduce rendering times, however it will also reduce the visual quality of the line at intersections.import '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 polylineFlutterMap(
options: MapOptions(),
nonRotatedChildren: [
AttributionWidget.defaultWidget(
source: '© OpenStreetMap contributors',
onSourceTapped: () {},
),
],
),FlutterMap(
options: MapOptions(),
children: [
TileLayer(
urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),
],
),