@@ -12,17 +12,47 @@ vector maps** as a Flutter widget.
1212 of [ flutter-mapbox-gl] ( https://github.com/tobrun/flutter-mapbox-gl ) ,
1313 replacing its usage of Mapbox GL libraries with the open
1414 source [ MapLibre GL] ( https://github.com/maplibre ) libraries.
15- - The repository has been transferred to
16- the [ MapLibre] ( https://github.com/maplibre )
17- organization. You shouldn't see any negative effects, as GitHub automatically
18- redirects references from the old URL to the new URL. Please
19- see [ #221 ] ( https://github.com/maplibre/flutter-maplibre-gl/issues/221 ) for
20- more information.
15+
16+ ### Table of Contents
17+
18+ <details >
19+ <summary >Click to expand</summary >
20+
21+ <!-- TOC -->
22+ * [ Flutter MapLibre GL] ( #flutter-maplibre-gl )
23+ * [ Table of Contents] ( #table-of-contents )
24+ * [ Supported Platforms] ( #supported-platforms )
25+ * [ Supported API] ( #supported-api )
26+ * [ Getting Started] ( #getting-started )
27+ * [ Platform specific setup] ( #platform-specific-setup )
28+ * [ iOS] ( #ios )
29+ * [ Location Feature] ( #location-feature )
30+ * [ Android] ( #android )
31+ * [ Kotlin Version] ( #kotlin-version )
32+ * [ Location Feature] ( #location-feature-1 )
33+ * [ Web] ( #web )
34+ * [ In code usage] ( #in-code-usage )
35+ * [ Map Styles] ( #map-styles )
36+ * [ Tile sources requiring an API key] ( #tile-sources-requiring-an-api-key )
37+ * [ Documentation] ( #documentation )
38+ * [ Getting Help] ( #getting-help )
39+ * [ Common problems & frequent questions] ( #common-problems--frequent-questions )
40+ * [ Loading .mbtiles tile files or sprites/glyphs from the assets shipped with the app] ( #loading-mbtiles-tile-files-or-spritesglyphs-from-the-assets-shipped-with-the-app )
41+ * [ Avoid Android UnsatisfiedLinkError] ( #avoid-android-unsatisfiedlinkerror )
42+ * [ iOS app crashes when using location based features] ( #ios-app-crashes-when-using-location-based-features )
43+ * [ Layer is not displayed on IOS, but no error] ( #layer-is-not-displayed-on-ios-but-no-error )
44+ * [ iOS crashes with error:] ( #ios-crashes-with-error )
45+ * [ Contributing] ( #contributing )
46+ <!-- TOC -->
47+
48+ </details >
2149
2250### Supported Platforms
2351
24- - Support for ** web** through [ maplibre-gl-js] ( https://github.com/maplibre/maplibre-gl-js )
25- - Support for ** android** and ** iOS** through [ maplibre-native] ( https://github.com/maplibre/maplibre-native )
52+ - Support for ** web**
53+ through [ maplibre-gl-js] ( https://github.com/maplibre/maplibre-gl-js )
54+ - Support for ** android** and ** iOS**
55+ through [ maplibre-native] ( https://github.com/maplibre/maplibre-native )
2656
2757This project only supports a subset of the API exposed by these libraries.
2858
@@ -41,87 +71,111 @@ This project only supports a subset of the API exposed by these libraries.
4171| Fill Extrusion | ✅ | ✅ | ✅ |
4272| Heatmap Layer | ✅ | ✅ | ✅ |
4373
44- ## Get Started
45-
46- #### Add as a dependency
47-
48- Add ` maplibre_gl ` to your project by running this command:
49-
50- ``` bash
51- flutter pub add maplibre_gl
52- ```
53-
54- or add it directly as a dependency to your ` pubspec.yaml ` file:
74+ ## Getting Started
5575
56- ``` yaml
57- dependencies :
58- maplibre_gl : ^0.19.0
59- ` ` `
76+ For installing the plugin, follow
77+ the [ instructions on pub.dev] ( https://pub.dev/packages/maplibre_gl/install ) .
6078
61- ### iOS
79+ ### Platform specific setup
6280
63- There is no specific setup for iOS needed any more to use the package.
64- If you added specific lines in an earlier version, you'll have to remove them
65- or your project won't build.
66-
67- <details>
68- <summary>View obsolete code</summary>
81+ #### iOS
6982
70- ` ` ` ruby
71- source 'https://cdn.cocoapods.org/'
72- source 'https://github.com/m0nac0/flutter-maplibre-podspecs.git'
73-
74- pod 'MapLibre'
75- pod 'MapLibreAnnotationExtension'
76- ```
77-
78- </details >
83+ ###### Location Feature
7984
80- #### Use the location feature
85+ In order to access the device location, you need to add the following key
86+ to the ` ios/Runner/Info.plist ` file, to explain why you need access to their
87+ location data:
8188
82- If you access your users' location, you should also add the following key
83- to ` ios/Runner/Info.plist ` to explain why you need access to their location
84- data:
89+ ``` xml
8590
86- ``` xml
8791<dict >
88- <key >NSLocationWhenInUseUsageDescription</key >
89- <string >[Your explanation here]</string >
92+ <key >NSLocationWhenInUseUsageDescription</key >
93+ <string >[Your explanation here]</string >
9094</dict >
9195```
9296
93- A possible explanation could be: "Shows your location on the map".
97+ #### Android
9498
95- ### Android
99+ ###### Kotlin Version
96100
97- There is no specific setup for android needed to use the package.
101+ The minimum supported Kotlin version is ` 1.9.0 ` . Accordingly, you will have to
102+ set your Kotlin version in the ` android/settings.gradle ` file like so:
98103
99- #### Use the location feature
104+ ``` groovy
105+ plugins {
106+ id "org.jetbrains.kotlin.android" version "1.9.0" apply false
107+ }
108+ ```
109+
110+ ###### Location Feature
100111
101112If you want to show the user's location on the map you need to add
102113the ` ACCESS_COARSE_LOCATION ` or ` ACCESS_FINE_LOCATION ` permission in the
103- application manifest ` android/app/src/main/AndroidManifest.xml ` . :
114+ application manifest ` android/app/src/main/AndroidManifest.xml ` :
104115
105116``` xml
117+
106118<manifest >
107- <uses-permission android : name =" android.permission.ACCESS_FINE_LOCATION" />
108- <uses-permission android : name =" android.permission.ACCESS_COARSE_LOCATION" />
119+ <uses-permission android : name =" android.permission.ACCESS_FINE_LOCATION" />
120+ <uses-permission android : name =" android.permission.ACCESS_COARSE_LOCATION" />
109121</manifest >
110122```
111123
112124Starting from Android API level 23 you also need to request it at runtime. This
113125plugin does not handle this for you. Our example app uses the
114126flutter "[ location] ( https://pub.dev/packages/location ) " plugin for this.
115127
116- ### Web
128+ #### Web
117129
118- Include the following JavaScript and CSS files in the ` <head> ` of
119- your ` web/index.html ` file:
130+ For the map to work in the web, include the following JavaScript and CSS files
131+ in the ` <head> ` of your ` web/index.html ` file:
120132
121133``` html
134+
122135<script src =' https://unpkg.com/maplibre-gl@^4.3/dist/maplibre-gl.js' ></script >
123136<link href =' https://unpkg.com/maplibre-gl@^4.3/dist/maplibre-gl.css'
124137 rel =' stylesheet' />
138+ ```
139+
140+ ### In code usage
141+
142+ The following shows you how to add the map widget to your code and start
143+ interacting with it. For more examples, head over to
144+ the [ example project] ( https://github.com/maplibre/flutter-maplibre-gl/tree/main/example ) .
145+
146+ ``` dart
147+
148+ class MapParentWidgetState extends State<MapParentWidget> {
149+ final Completer<MapLibreMapController> mapController = Completer();
150+ bool canInteractWithMap = false;
151+
152+ @override
153+ Widget build(BuildContext context) {
154+ return Scaffold(
155+ floatingActionButtonLocation: FloatingActionButtonLocation
156+ .miniCenterFloat,
157+ floatingActionButton: canInteractWithMap
158+ ? FloatingActionButton(
159+ onPressed: _moveCameraToNullIsland,
160+ mini: true,
161+ child: const Icon(Icons.restore),
162+ )
163+ : null,
164+ body: MapLibreMap(
165+ onMapCreated: (controller) => mapController.complete(controller),
166+ initialCameraPosition: _nullIsland,
167+ onStyleLoadedCallback: () => setState(() => canInteractWithMap = true),
168+ ),
169+ );
170+ }
171+
172+ void _moveCameraToNullIsland() =>
173+ mapController.future.then((c) =>
174+ c.animateCamera(CameraUpdate.newCameraPosition(_nullIsland)));
175+ }
176+
177+
178+
125179```
126180
127181## Map Styles
@@ -217,7 +271,7 @@ buildTypes {
217271 <summary >Click here to expand / hide.</summary >
218272
219273Please include the ` NSLocationWhenInUseUsageDescription ` as
220- described [ here] ( #location-features )
274+ described [ here] ( #location-feature )
221275
222276---
223277</details >
@@ -237,7 +291,9 @@ You have to have the color in the following format : `#C0C0FF`
237291---
238292</details >
239293
240- ### iOS crashes with error: ` 'NSInvalidArgumentException', reason: 'Invalid filter value: filter property must be a string' `
294+ ### iOS crashes with error:
295+
296+ ` 'NSInvalidArgumentException', reason: 'Invalid filter value: filter property must be a string' `
241297
242298<details >
243299 <summary >Click here to expand / hide.</summary >
@@ -248,15 +304,28 @@ You can replace your expression with : `["!",["has", "value"] ]` which works
248304both in Android and iOS.
249305
250306Note : iOS will display the
251- error : ` NSPredicate: Use of 'mgl_does:have:' as an NSExpression function is forbidden ` ,
307+ error :
308+ ` NSPredicate: Use of 'mgl_does:have:' as an NSExpression function is forbidden ` ,
252309but it seems like the expression still works well.
253310
254311---
255312</details >
256313
257314## Contributing
258315
259- [ Feedback] ( https://github.com/maplibre/flutter-maplibre-gl/issues ) ,
260- contributing pull requests
316+ Setup [ melos] ( https://melos.invertase.dev/~melos-latest/getting-started ) and run
317+ the
318+
319+ ``` bash
320+ melos bootstrap
321+ ```
322+
323+ command in the plugin root directory. Run the example app and familiarize
324+ yourself with the plugin directory structure.
325+
326+ [ Feedback] ( https://github.com/maplibre/flutter-maplibre-gl/issues ) , contributing
327+ pull requests
261328and [ bug reports] ( https://github.com/maplibre/flutter-maplibre-gl/issues ) are
262- very welcome!
329+ very welcome - check
330+ the [ CONTRIBUTING.md] ( https://github.com/maplibre/flutter-maplibre-gl/blob/main/CONTRIBUTING.md )
331+ guidelines.
0 commit comments