Reputation: 1532
The topic appears to have been raised many times here on StackOverflow, but they're all quite dated. I'm asking again in case the requirements have since changed, and if it has become a paid-service.
My app utilizes a Google map with markers, and everything works well. The API key has been included and the map markers update as expected. However, I would also like to insert the addresses into the map markers and have discovered that this is achieved through the use of the GeoCoder. I have tried many examples but it's all failing with the SERVICE NOT AVAILABLE error. Here's one from the Ray Wenderlich site:
fun getAddress(latLng: LatLng): String {
val geocoder = Geocoder(this)
val addresses: List<Address>?
val address: Address?
var addressText = ""
try {
addresses = geocoder.getFromLocation(latLng.latitude, latLng.longitude, 1)
if (null != addresses && !addresses.isEmpty()) {
address = addresses[0]
for (i in 0 until address.maxAddressLineIndex) {
addressText += if (i == 0) address.getAddressLine(i) else "\n" + address.getAddressLine(i)
}
}
} catch (e: IOException) {
Log.e("GeoCoder", e.localizedMessage) // ==> throws "Service not Available"
}
return addressText
}
In my Google Developer Console, I found a GeoCoding API which is not enabled.
Q1. Is this required simply for converting latitude/longitude coordinates into a street address?
Q2. Does this mean that every street address lookup is chargeable as indicated in the pricing table?
Upvotes: 0
Views: 985
Reputation: 1040
Q1: Is this required simply for converting latitude/longitude coordinates into a street address?
A: Yes, but feel free to choose any alternative you find on internet. Right now, I can't find anything unfortunately, which is completely free
Q2. Does this mean that every street address lookup is chargeable as indicated in the pricing table?
A: Yes
Go here at https://cloud.google.com/maps-platform/pricing/
Click on Places, and check out the pricing yourself
Upvotes: 1