Example project using Android Google maps SDK on Android with Jetpack compose.
This has changed within the last year or so. Now there’s a new compose API for Google maps. Previously we had to use an
AndroidView. Technically this new API (
GoogleMap) still uses an
AndroidView under the hood, but it’s easier to work with.
ACCESS_FINE_LOCATION permission. This is required to show the users location on the map.
Polygons with markers
Display polygons with markers.
Display your location (if you’ve accepted the permission).
Notes / Gotchas
- You will need to enable billing on your google cloud console to complete this example. You won’t be charged anything as long as you stay under the daily request limit. Then add your API key to
- If the user declines the permission request twice they will need to manually enable the permission from system settings for the app (or uninstall and reinstall). That’s a whole other topic – I’m just assuming they accept in this example.
MapEffect. I was seeing an
AppCompatTextViewexception being thrown if I didn’t include it.
- Google maps SDK for Android https://developers.google.com/maps/documentation/android-sdk/config
- Utility library https://developers.google.com/maps/documentation/android-sdk/utility/setup
- Maps android kotlin extensions https://developers.google.com/maps/documentation/android-sdk/ktx
- note there is also a ktx version of the utility library listed above.
- Google maps for compose library