Google Maps
To use Google Maps API as your geocoding backend you will need to do the following:
Obtain an API key
First you will need to create a cloud project and enable the API
Create the API key
Copy your key
Create the Geocoder
Simple pass your API key to the Geocoder
function:
val geocoder = GoogleMapsGeocoder(apiKey = "your-api-key")
// Or this helper function
val geocoder = Geocoder(apiKey = "your-api-key")
Customizing Google Maps request
The Google Maps geocoding API has some optional parameters. You can modify these by passing them into the Geocoder
function:
val geocoder = GoogleMapsGeocoder(apiKey = "your-api-key") {
locationTypes(GoogleMapsLocationType.GeometricCenter)
}
Last updated
Was this helpful?