Assets Map Styles
This example showcases how to build a Flutter app featuring an interactive map with a custom style, seamlessly imported from the assets folder, using the Maps SDK for Flutter.
How it works
The example app demonstrates the following features:
- Display a map.
- Loading and applying map styles from the app assets folder.
Add style to project
In the root directory of your project, create a new folder named assets. Specify the path to the assets folder in the pubspec.yaml file. Modify the file as follows:
flutter:
uses-material-design: true
assets:
- assets/
Place a .style
file inside the assets directory.
UI and Map Integration
The following code builds an UI with a GemMap
widget and an app bar with a set map style button.
This code sets up the main screen with a map and a button that triggers the _applyStyle method to load a custom style file.
Loading and Applying Map Styles
This code loads the .style file as bytes, applies it to the map with a smooth transition, and centers the map on specified coordinates.
Loading the Style File
This method reads the .style file from assets and returns the data as Uint8List bytes.