vtmap_gl 2.0.7 copy "vtmap_gl: ^2.0.7" to clipboard
vtmap_gl: ^2.0.7 copied to clipboard

A Flutter plugin for integrating Mapbox Maps inside a Flutter application on Android, iOS and web platfroms.

Flutter VTMaps GL #

Please note that this project is community driven and is not an official VTMaps product. We welcome feedback and contributions.

This Flutter plugin allows to show embedded interactive and customizable vector maps inside a Flutter widget. For the Android and iOS integration, we use VTMap-gl-native. For web, we rely on VTMap-gl-js. This project only supports a subset of the API exposed by these libraries.

screenshot.png

Running the example app #

  • Install Flutter and validate its installation with flutter doctor
  • Clone the repository with git clone git@github.com:tobrun/flutter-VTMap-gl.git
  • Add a VTMap access token to the example app (see next section)
  • Connect a mobile device or start an emulator, simulator or chrome
  • Locate the id of a the device with flutter devices
  • Run the app with cd flutter_VTMap/example && flutter packages get && flutter run -d {device_id}

Adding a VTMaps Access Token #

This project uses VTMaps vector tiles, which requires a VTMaps account and a VTMaps access token. Obtain a free access token on your VTMaps account page.

Even if you do not use VTMaps vector tiles but vector tiles from a different source (like self-hosted tiles) with this plugin, you will need to specify any non-empty string as Access Token as explained below!

The recommended way to provide your access token is through the VTMaps constructor's accessToken parameter, which is available starting from the v0.8 release. Note that you should always use the same token throughout your entire app.

An alternative method to provide access tokens that was required until the v0.7 release is described in this wiki article.

Using the SDK in your project #

This project is available on pub.dev, follow the instructions to integrate a package into your flutter application. For platform specific integration, use the flutter application under the example folder as reference.

Supported API #

Feature Android iOS Web
Style
Camera
Gesture
User Location
Symbol
Circle
Line
Fill

Map Styles #

Map styles can be supplied by setting the styleString in the MapOptions. The following formats are supported:

  1. Passing the URL of the map style. This can be one of the built-in map styles, also see VTMapStyles or a custom map style served remotely using a URL that start with 'http(s)://'
  2. Passing the style as a local asset. Create a JSON file in the assets and add a reference in pubspec.yml. Set the style string to the relative path for this asset in order to load it into the map.
  3. Passing the raw JSON of the map style. This is only supported on Android.

Offline Sideloading #

Support for offline maps is available by "side loading" the required map tiles and including them in your assets folder.

  • Create your tiles package by following the guide available here.

  • Place the tiles.db file generated in step one in your assets directory and add a reference to it in your pubspec.yml file.

   assets:
     - assets/cache.db
  • Call installOfflineMapTiles when your application starts to copy your tiles into the location where VTMap can access them. NOTE: This method should be called before the Map widget is loaded to prevent collisions when copying the files into place.
    try {
      await installOfflineMapTiles(join("assets", "cache.db"));
    } catch (err) {
      print(err);
    }

Location features #

To enable location features in an Android application:

You need to declare the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission in the AndroidManifest.xml and starting from Android API level 23 also request it at runtime. The plugin does not handle this for you. The example app uses the flutter 'location' plugin for this.

To enable location features in an iOS application:

If you access your users' location, you should also add the following key to your Info.plist to explain why you need access to their location data:

<key>NSLocationWhenInUseUsageDescription</key>
<string>[Your explanation here]</string>

VTMap recommends the explanation "Shows your location on the map and helps improve the map".

Documentation #

This README file currently houses all of the documentation for this Flutter project. Please visit VTMap.com/android-docs if you'd like more information about the VTMap Maps SDK for Android and VTMap.com/ios-sdk for more information about the VTMap Maps SDK for iOS.

Getting Help #

  • Need help with your code?: Look for previous questions on the #VTMap tag — or ask a new question.
  • Have a bug to report? Open an issue. If possible, include a full log and information which shows the issue.
  • Have a feature request? Open an issue. Tell us what the feature should do and why you want the feature.

Contributing #

We welcome contributions to this repository! If you're interested in helping build this VTMap/Flutter integration, please read the contribution guide to learn how to get started.

6
likes
110
pub points
78%
popularity

Publisher

verified publisherviettelmaps.vn

A Flutter plugin for integrating Mapbox Maps inside a Flutter application on Android, iOS and web platfroms.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (LICENSE)

Dependencies

flutter, vtmap_gl_platform_interface

More

Packages that depend on vtmap_gl