๐Ÿš€ Android Maps KTX Flow Snippets Catalog

June 30, 2026 ยท View on GitHub

This directory contains standalone code snippets demonstrating how to consume the newly added Kotlin Flow extensions inside the maps-utils-ktx library.

All snippets are enclosed in standard developer documentation region tags to make them easily importable into public guides, and are verified automatically via mock unit tests to prevent regressions.

๐Ÿ“Š KTX Flow Snippet Status

FeatureStatusSource CodeVisual PreviewRegion TagDescription
Fine Location Flowโœ… VerifiedSource Code (Activity)Fine Location Flowmaps_android_ktx_flow_fine_locationStreams high-precision device coordinate updates reactively using GPS, with an automatic start/stop subscriber lifecycle.
Coarse Location Flowโœ… VerifiedSource Code (Activity)Coarse Location Flowmaps_android_ktx_flow_coarse_locationStreams coarse WiFi/Cell device coordinate updates reactively using network/passive providers, closing cleanly on setting disablement.
Cluster Clicksโœ… VerifiedSource Code (Activity)Cluster Click Flowmaps_android_ktx_flow_cluster_clicksReactively streams click events on clustered groups of markers instead of overriding standard camera callbacks.
Cluster Item Clicksโœ… VerifiedSource Code (Activity)Cluster Item Click Flowmaps_android_ktx_flow_cluster_item_clicksListens to individual marker click events within clusters. Demonstrates how to use .shareIn() to safely broadcast to multiple active observers.
Marker Collection Clicksโœ… VerifiedSource Code (Activity)Marker Collection Clicksmaps_android_ktx_flow_marker_collection_clicksListens to marker click events on separate styled collections managed by MarkerManager.
Circle Collection Clicksโœ… VerifiedSource Code (Activity)Circle Collection Clicksmaps_android_ktx_flow_circle_collection_clicksListens to circle click events on separate styled collections managed by CircleManager.
Map Init (Coroutines)โœ… VerifiedSource Code (Activity)Map Initmaps_android_ktx_coroutines_initRetrieves the GoogleMap instance safely inside a lifecycle-aware coroutine scope without legacy callback blocks.
Animate Camera (Coroutines)โœ… VerifiedSource Code (Activity)Camera Animationmaps_android_ktx_coroutines_animateSmoothly animates the map camera and suspends coroutine execution, resuming only after the animation fully completes.
Camera Idle Events Flowโœ… VerifiedSource Code (Activity)Idle statesmaps_android_ktx_flow_camera_eventsStreams map camera stationary idle state changes dynamically via Flow.
Polygon Containment Checkโœ… VerifiedSource Code (Activity)Boundary checksmaps_android_ktx_utils_polygon_containsPerforms robust polygon bounds checking to see if a LatLng coordinate is contained inside.
GeoJSON Overlay Builderโœ… VerifiedSource Code (Activity)GeoJSON linesmaps_android_ktx_utils_geojsonDynamically parses and overlay a styled GeoJSON vector layer on top of the map view.

๐Ÿงช Snippet Verification Testing

To ensure these snippets remain 100% correct and compile warning-free after library and dependency upgrades, they are covered by a dedicated unit test suite: ๐Ÿ“‚ SnippetVerificationTest.kt

You can execute these tests locally at any time:

./gradlew :app:test --tests "com.google.maps.android.ktx.demo.snippets.*"