简体   繁体   中英

Google Maps SDK Geocoding

Problem:

The problem is that Android's built-in Geocoder backend varies between forks of AOSP and implementations of IGeocodingProvider . For consistency, it would be better to use Google Maps Geocoding API. In my search, I have not found a way to do Geocoding with the Google Play Services SDK.

There exists a Geocoding REST API but I would lose the ability to restrict the API key to my Android App.

Question:

Is there a Google Play Services SDK for Geocoding that has to ability to restrict the API key?

Unfortunately, Google Maps Android API v2 included in Google Play Services SDK doesn't have its own Geocoder that can be used with an API key with Android app restrictions.

The feature request was created in 2013, but it looks like Google didn't set high priority on this task. You can see the feature request and star it in the Google issue tracker:

https://issuetracker.google.com/issues/35823852

Currently, the only alternative to Android's built-in Geocoder is the REST API. There is a Java client library for Google Maps API Web Services that makes it easier to integrate Geocoding REST API with Java code, however, the API key in REST API may be restricted only by IP address:

https://developers.google.com/maps/faq#keysystem

In order to apply IP restriction you will need to add an intermediate server that will send web service requests to Google and pass responses back to your mobile application. In this case you can protect an API key by IP address of your server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM