One compact Kotlin app demonstrates the GLMap 2.2.0 API. The catalog mirrors the iOS demo and groups each example by feature: map display, camera, draw objects, vector data, search, routing, and offline data.
The Demo Mode button runs the same 26-second Amalfi Coast walk as the iOS app: explore contour lines, find a restaurant, reveal a walking route, and follow a simulated walker in 3D. Search and routing use real online services and complete before the tour starts. The traversed route turns grey using GLMapTrack.setProgressIndex and setProgressColor; the camera and marker share a distance-based timeline. All map markers are native GLMapImage objects. Android views provide only captions and panels. The walking segment is labeled as an accelerated preview, not GPS navigation. The tour pauses in the background, offers Retry on service errors, and closes when tapped. The individual catalog screens remain the compact API examples to learn from.
- Create an API key at https://user.globus.software/apps/.
- Replace
YOUR_API_KEYinkotlinDemo/src/main/res/values/strings.xmllocally. Do not commit a real key. - Open this directory in Android Studio and run
kotlinDemo.
To build against the published SDK 2.2.0 (no parent SDK checkout is required):
./gradlew :kotlinDemo:assembleDebugTo build against the GLMap sources in the parent repository:
./gradlew :kotlinDemo:assembleDebug -PuseLocalGLMap=trueWithout useLocalGLMap, Gradle resolves the published globus:glmap, globus:glsearch, and globus:glroute artifacts for the version declared in build.gradle.
The demo targets Android SDK 37. Most screens construct their UI in Kotlin so the GLMap calls stay visible in one short feature file under kotlinDemo/src/main/java/globus/demo.
DemoAppcallsGLMapManager.Initializebefore any native SDK API. This initializes Core, Map, Search, and Route together; no separateGLSearch.Initializecall is needed. Its Boolean result reports initialization, not API-key validity.- Hit-testing and draw-attribute queries use a captured
GLMapViewState, closed with Kotlinuseafter each query. GLMapValue.getSpannedclones the supplied span objects. Search results useSearchColorSpan, aCloneablesubclass ofForegroundColorSpan; passing an ordinaryForegroundColorSpancrashes in the native bridge.GeoJSONActivityhandles theUpdateResultpassed tosetVectorObjects:Ready,Superseded,Cancelled, orFailed. Updates and completions run on the main thread;Readymeans geometry is ready to draw, not that a frame has been presented. Other examples passnullwhen no completion is needed.
Run the JVM tests for the shared tour timeline, distance-based progress, heading interpolation, and pause/resume clock:
./gradlew :kotlinDemo:testDebugUnitTestWith an emulator or device connected, run the offline-search, dataset re-registration, GPS lifecycle/bearing, GeoJSON recreation, and native tour marker/layout checks. These tests do not require an API key; synthetic route geometry exists only in the tests.
./gradlew :kotlinDemo:connectedDebugAndroidTestAPI documentation: https://globus.software/docs