-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [x] `FlutterMapAdapter` - [x] `MapLibreLayer` - [x] update example app - [x] add documentation
- Loading branch information
Showing
28 changed files
with
629 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
buildscript { | ||
ext.kotlin_version = '1.7.10' | ||
ext.kotlin_version = '1.9.0' | ||
repositories { | ||
google() | ||
mavenCentral() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
description: This file stores settings for Dart & Flutter DevTools. | ||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states | ||
extensions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// **Use your own key for your project!** | ||
/// This key will be rotated occasionally. | ||
/// Protomaps offers free usage for non commercial projects and affordable | ||
/// pricing for commercial projects. | ||
/// | ||
/// A list with a lot of compatible tile providers can be found here: | ||
/// https://github.com/maplibre/awesome-maplibre?tab=readme-ov-file#maptile-providers | ||
const protomapsKey = '48c711a2fc69c6f0'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_map/flutter_map.dart'; | ||
import 'package:flutter_map_maplibre/flutter_map_maplibre.dart'; | ||
import 'package:flutter_map_plugins_example/common/attribution_widget.dart'; | ||
import 'package:flutter_map_plugins_example/flutter_map_maplibre/config.dart'; | ||
import 'package:latlong2/latlong.dart'; | ||
|
||
class MapLibreFlutterMapPage extends StatefulWidget { | ||
const MapLibreFlutterMapPage({super.key}); | ||
|
||
@override | ||
State<MapLibreFlutterMapPage> createState() => _MapLibreFlutterMapPageState(); | ||
} | ||
|
||
class _MapLibreFlutterMapPageState extends State<MapLibreFlutterMapPage> { | ||
final _mapController = MapController(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
backgroundColor: Colors.white, | ||
title: const Text('MapLibre in FlutterMap'), | ||
), | ||
body: FlutterMap( | ||
mapController: _mapController, | ||
options: MapOptions( | ||
initialZoom: 4, | ||
initialCenter: const LatLng(0, 0), | ||
maxZoom: 20, | ||
// maplibre does not support an unbound latitude | ||
cameraConstraint: CameraConstraint.contain( | ||
bounds: LatLngBounds( | ||
const LatLng(-90, -180), | ||
const LatLng(90, 180), | ||
), | ||
), | ||
), | ||
children: [ | ||
const MapLibreLayer( | ||
initStyle: | ||
'https://api.protomaps.com/styles/v2/light.json?key=$protomapsKey', | ||
), | ||
const CircleLayer( | ||
circles: [ | ||
CircleMarker( | ||
point: LatLng(10, 20), | ||
radius: 15, | ||
color: Colors.blue, | ||
borderColor: Colors.black, | ||
borderStrokeWidth: 2, | ||
), | ||
], | ||
), | ||
const MarkerLayer( | ||
markers: [ | ||
Marker( | ||
point: LatLng(15, 5), | ||
width: 40, | ||
height: 40, | ||
child: Icon(Icons.location_on, color: Colors.red, size: 40), | ||
alignment: Alignment.topCenter, | ||
), | ||
], | ||
), | ||
PolylineLayer( | ||
polylines: [ | ||
Polyline( | ||
points: const [ | ||
LatLng(-20, -10), | ||
LatLng(-15, -15), | ||
LatLng(-20, -25), | ||
], | ||
color: Colors.purple, | ||
strokeWidth: 3, | ||
), | ||
], | ||
), | ||
PolygonLayer( | ||
polygons: [ | ||
Polygon( | ||
points: const [ | ||
LatLng(8, -25), | ||
LatLng(-5, -23), | ||
LatLng(5, -10), | ||
LatLng(10, -15), | ||
], | ||
color: Colors.pink.withOpacity(0.8), | ||
), | ||
], | ||
), | ||
const OsmAttributionWidget(), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_map/flutter_map.dart' as fm; | ||
import 'package:flutter_map_maplibre/flutter_map_maplibre.dart'; | ||
import 'package:flutter_map_plugins_example/flutter_map_maplibre/config.dart'; | ||
import 'package:latlong2/latlong.dart'; | ||
import 'package:maplibre/maplibre.dart'; | ||
|
||
class FlutterMapMapLibrePage extends StatefulWidget { | ||
const FlutterMapMapLibrePage({super.key}); | ||
|
||
@override | ||
State<FlutterMapMapLibrePage> createState() => _FlutterMapMapLibrePageState(); | ||
} | ||
|
||
class _FlutterMapMapLibrePageState extends State<FlutterMapMapLibrePage> { | ||
/// The MapLibreMap controller | ||
// ignore: unused_field, use_late_for_private_fields_and_variables | ||
MapController? _controller; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
backgroundColor: Colors.white, | ||
title: const Text('FlutterMap in MapLibre'), | ||
), | ||
body: MapLibreMap( | ||
onMapCreated: (controller) => _controller = controller, | ||
options: MapOptions( | ||
initCenter: Position(0, 0), | ||
initZoom: 3, | ||
maxPitch: 0, // flutter_map doesn't support pitch, disable it here | ||
initStyle: | ||
'https://api.protomaps.com/styles/v2/light.json?key=$protomapsKey', | ||
), | ||
children: [ | ||
const FlutterMapAdapter( | ||
child: fm.CircleLayer( | ||
circles: [ | ||
fm.CircleMarker( | ||
point: LatLng(10, 20), | ||
radius: 15, | ||
color: Colors.blue, | ||
borderColor: Colors.black, | ||
borderStrokeWidth: 2, | ||
), | ||
], | ||
), | ||
), | ||
const FlutterMapAdapter( | ||
child: fm.MarkerLayer( | ||
markers: [ | ||
fm.Marker( | ||
point: LatLng(15, 5), | ||
width: 40, | ||
height: 40, | ||
child: Icon(Icons.location_on, color: Colors.red, size: 40), | ||
alignment: Alignment.topCenter, | ||
), | ||
], | ||
), | ||
), | ||
FlutterMapAdapter( | ||
child: fm.PolylineLayer( | ||
polylines: [ | ||
fm.Polyline( | ||
points: const [ | ||
LatLng(-20, -10), | ||
LatLng(-15, -15), | ||
LatLng(-20, -25), | ||
], | ||
color: Colors.purple, | ||
strokeWidth: 3, | ||
), | ||
], | ||
), | ||
), | ||
FlutterMapAdapter( | ||
child: fm.PolygonLayer( | ||
polygons: [ | ||
fm.Polygon( | ||
points: const [ | ||
LatLng(8, -25), | ||
LatLng(-5, -23), | ||
LatLng(5, -10), | ||
LatLng(10, -15), | ||
], | ||
color: Colors.pink.withOpacity(0.8), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.