This Flutter plugin allows to show embedded interactive and customizable vector maps as a Flutter widget.
This project only supports a subset of the API exposed by these libraries.
| Feature | Android | iOS | Web |
|---|---|---|---|
| Style | ✅ | ✅ | ✅ |
| Camera | ✅ | ✅ | ✅ |
| Gesture | ✅ | ✅ | ✅ |
| User Location | ✅ | ✅ | ✅ |
| Symbol | ✅ | ✅ | ✅ |
| Circle | ✅ | ✅ | ✅ |
| Line | ✅ | ✅ | ✅ |
| Fill | ✅ | ✅ | ✅ |
| Fill Extrusion | ✅ | ✅ | ✅ |
| Heatmap Layer | ✅ | ✅ | ✅ |
Add gebeta_gl to your project by running this command:
flutter pub add gebeta_glor add it directly as a dependency to your pubspec.yaml file:
dependencies:
gebeta_gl: ^0.19.0There is no specific setup for iOS needed.
If you access your users' location, you should also add the following key
to ios/Runner/Info.plist to explain why you need access to their location
data:
<dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>[Your explanation here]</string>
</dict>A possible explanation could be: "Shows your location on the map".
There is no specific setup for android needed to use the package.
If you want to show the user's location on the map you need to add
the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission in the
application manifest android/app/src/main/AndroidManifest.xml.:
<manifest>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
</manifest>Starting from Android API level 23 you also need to request it at runtime. This plugin does not handle this for you. Our example app uses the flutter "location" plugin for this.
Map styles can be supplied by setting the styleString in the GebetaMap
constructor. The following formats are supported:
- Passing the URL of the map style. This should be a custom map style served
remotely using a URL that start with
http(s):// - Passing the style as a local asset. Create a JSON file in the
assetsand add a reference inpubspec.yml. Set the style string to the relative path for this asset in order to load it into the map. - Passing the style as a local file. create an JSON file in app directory (e.g. ApplicationDocumentsDirectory). Set the style string to the absolute path of this JSON file.
- Passing the raw JSON of the map style. This is only supported on Android.
- Check the API documentation.
Click here to expand / hide.
Update buildTypes in android\app\build.gradle
buildTypes {
release {
// other configs
ndk {
abiFilters 'armeabi-v7a','arm64-v8a','x86_64', 'x86'
}
}
}Click here to expand / hide.
Please include the NSLocationWhenInUseUsageDescription as
described here
Click here to expand / hide.
Have a look in your LayerProperties object, if you supply a lineColor
argument, (or any color argument) the issue might come from here.
Android supports the following format : 'rgba(192, 192, 255, 1.0)', but on
iOS, this doesn't work!
You have to have the color in the following format : #C0C0FF
iOS crashes with error: 'NSInvalidArgumentException', reason: 'Invalid filter value: filter property must be a string'
Click here to expand / hide.
Check if one of your expression is : ["!has", "value"]. Android support this
format, but iOS does not.
You can replace your expression with : ["!",["has", "value"] ] which works
both in Android and iOS.
Note : iOS will display the
error : NSPredicate: Use of 'mgl_does:have:' as an NSExpression function is forbidden,
but it seems like the expression still works well.