The demo is a catalog of 20 Flutter API examples for Android and iOS. Each screen keeps its SDK calls close to its UI so you can find a feature, read the implementation and adapt it to your app.
For requirements, launch commands and API-key setup, see
Run the demo. The default lib/main.dart opens the
catalog on both platforms. lib/demo_main.dart contains its implementation and
also remains directly runnable.
Both hosts use the published GLMap 2.2.0 artifacts through the workspace
plugins: Maven on Android and exact-version SwiftPM on iOS. After updating the
checkout, run flutter pub get from the repository root and rebuild the demo;
hot reload is not enough to replace native binaries. No separately built native
SDK is required.
example/
├── lib/
│ ├── demo_main.dart # SDK startup, app theme and screen catalog
│ ├── demo/
│ │ ├── common.dart # Shared map-screen layout and small helpers
│ │ ├── map_examples.dart # Map display, themes, terrain and camera
│ │ ├── draw_examples.dart # Images, markers, vectors, tracks and location
│ │ ├── search_examples.dart # Search UI and map-object picking
│ │ ├── routing_examples.dart # Route building and navigation tracking
│ │ └── download_examples.dart # Regional and bounding-box downloads
│ ├── main.dart # Default entry: starts the catalog
│ ├── lifecycle_main.dart # Focused embedding and lifecycle sample
│ └── vector_main.dart # Focused vector-layer sample
├── assets/ # Bundled datasets and sample geometry/config
├── integration_test/ # Flutter tests using the native plugins
├── test_driver/ # Integration driver and screenshot output
├── android/ # Android host, permissions and input tests
├── ios/ # iOS host, permissions and input tests
└── pubspec.yaml # Flutter dependencies and asset declarations
The repository's Dart workspace resolves the four SDK packages from ../packages/.
The demo calls their public Dart APIs; native bridge implementations belong to
those packages, not to the demo's platform host directories.
main.dartforwards to the catalog implementation indemo_main.dart, which initializes Flutter and callsGLMapSDK.initializewithGLMAP_API_KEYfrom the build environment.- It registers
assets/Montenegro.vmwithGLMapSDK.addAssetDataSetfor offline map display and search. An initialization failure is shown in the catalog. DemoAppbuilds the Material theme.DemoCatalogfilters thedemoslist ofDemoEntryobjects and opens the selected screen with Flutter navigation. The key button reapplies SDK initialization with a session-only API key.- Most map screens extend
MapDemoStateincommon.dart. It creates theGLMapwidget, stores the controller, subscribes to taps and invokesready(controller). A screen suppliestitle,api,controls()and, when needed,tapped(). MapDemoState.run()shows busy/error state around asynchronous operations. The base class cancels its tap subscription on disposal. Individual screens cancel their own requests, timers and GPS/download subscriptions; route screens also close retained routes. The map widget owns its controller and drawable handles, which become invalid when it is removed.
common.dart also holds sample coordinates around Podgorica, pin-image and
GeoJSON helpers, and foregroundPositions() for permission-checked location
updates. Feature-specific SDK operations stay in each screen implementation.
Paths below are relative to lib/demo/.
| Source | Catalog screens |
|---|---|
| map_examples.dart | Online Map, Dark Theme, 3D Terrain, Fly To, Zoom to BBox |
| draw_examples.dart | Image, Image Group, Markers & Clustering, Balloon, Track Arrows, User Location, Lines & Polygons, GeoJSON, GPS Track |
| search_examples.dart | Search, POI Tap |
| routing_examples.dart | Route Building, Turn-by-Turn Navigation |
| download_examples.dart | Download Maps, Download BBox |
Notable implementation details:
- Search combines offline/online queries, debounced autocomplete, cancellation, markers and list selection. The bundled data covers Montenegro.
- POI Tap uses Search's map-object picking API on the map controller.
- Route Building accepts a tap for the destination and a long press for the
start, then requests a car/bicycle/pedestrian route. Offline road routing needs
downloaded navigation data and the configuration in
assets/valhalla.json. - Turn-by-Turn Navigation starts with a custom route from
GLRouteSDK.buildRoute.Next positionreplays coordinates into the native tracker without downloads;Use GPSenables foreground updates. A map tap requests an online road route. This is a tracking example, not a complete navigation app: it has no voice guidance, background service or automatic rerouting. - Downloads show Core's regional catalog, progress events, cancellation,
deletion and area downloads. The SDK retains completed area files in the app's
glmap-areasdirectory and re-registers them during initialization. Repeating the same bounds reuses completed files; partial downloads are not installed. - User Location / GPS Track share
LocationDemo; the catalog usesLocationDemo(record: true)for track recording. GPS permission is requested only after the user pressesUse GPS. - GeoJSON loads the UK postcode asset and uses native vector hit testing.
Assets are declared in pubspec.yaml:
| Asset | Use |
|---|---|
Montenegro.vm |
Offline map display and search in the catalog; not navigation or elevation data |
valhalla.json |
Configuration for offline road-routing requests |
uk_postcodes.geojson |
Geometry for the GeoJSON screen |
track-arrow.svg |
Arrow image for the Track Arrows screen |
stage-a.json |
Shared fixture for the focused map and vector samples |
Keep routing configuration compatible with the native SDK. Map data is © OpenStreetMap contributors; native SDK and data terms also apply.
lib/lifecycle_main.dart demonstrates embedding,
Flutter overlays, navigation and repeated map removal. Open it with the catalog's
Lifecycle sample toolbar action or flutter run -t lib/lifecycle_main.dart.
lib/vector_main.dart demonstrates vector geometry/style
updates and can be run with its own -t entry point.
Both samples initialize Core when launched directly and draw through the public
controller API. Opening the lifecycle screen from the catalog reuses its initialized
SDK and session key. There is no separate native demo renderer. The app name is
GLMap Flutter Demo, its Dart package is glmap_example, and its Android/iOS
application identifier is software.globus.glmap.flutter.demo.
- Put the screen in the matching
lib/demo/*_examples.dartfile. For a standard map screen, extendMapDemoStateand keep the SDK calls in the screen itself. - Add a
DemoEntrytodemosindemo_main.dartso the catalog can display it. - Register any new bundled assets in
pubspec.yaml. - Cancel screen-owned work on disposal and close any retained routes. Handle asynchronous results arriving after the screen has been removed.
- Update this guide and the matching integration tests. If adding a screen, update the catalog's displayed example count too.
integration_test/demo_test.dart covers the catalog. api_test.dart and
vector_test.dart exercise native API and lifecycle behavior. The focused entry
points have lifecycle_test.dart and vector_demo_test.dart; authenticated services
and retained downloads have online_test.dart and offline_restore_test.dart.
These tests require an Android or iOS target. Never share API keys or unreviewed authenticated logs.