问题
In my project, I'm using Google Geocoding and Reverse Geocoding APIs to validate the addresses and latlngs provided by end users.
Given latlng -37.857866,144.950706, the Reverse Geocoding API (https://maps.googleapis.com/maps/api/geocode/json?latlng=-37.857866,144.950706) returns the nearest land address.
However on Google Map web page, that latlng actually is in the sea: https://www.google.com.au/maps/search/-37.857866,144.950706
Is there anyway that I can tell Google Reverse Geocoding API to not return me the nearest land address? In real project, actually I provide the API key and specify location types, e.g. https://maps.googleapis.com/maps/api/geocode/json?key=<API_Key>&location_type=ROOFTOP&latlng=-37.857866,144.950706 and I'm just thinking if the place specified by the latlng is not a ROOFTOP address, Google should return me ZERO_RESULTS.
Further update: just to clarify that in my project, customer's sites addresses are required, and some of the customers would rather provide site LatLng, therefore I need to convert the LatLng to actual address, and showing error message if a LatLng is invalid or in sea so that customer can double check. Using the nearest land address is error-prone.
If Reverse Geocoding API is not suitable for this, then please advise the proper Google Maps API for this. Thank you.
来源:https://stackoverflow.com/questions/41539432/google-maps-reverse-geocoding-api-returns-nearest-land-address-given-a-latlng-in