问题
I have a "locality" type place_id
(e.g. ChIJT-bVPNJAh0gRzCSbulDuSWs
) (that I got by querying location 5.768757,-2.004222).
I want to get the associated "country" type place_id
.
I have tried looking up the same location but with result_type=country
. However, that gives zero results.
https://maps.googleapis.com/maps/api/geocode/json?latlng=53.352118%2C-6.393696&result_type=country
This (53.352118, -6.393696) location now started to return results for
result_type=country
. This however, does not solve the underlying issue – that this data is not always available.As an example, lookup (53.177459,-6.797582). Here is the request & result for the query at the time of this writing.
I have also tried using the coordinates obtained from locality.geometry.location.<lat|lng>
. This sometimes works and sometimes doesn't work. Here is an example of when it doesn't work:
- locality query
- country query
Is there a reliable way to get "country" type place_id
using "locality" type place_id
?
来源:https://stackoverflow.com/questions/40402602/how-to-get-a-country-place-id-for-an-associated-locality-place-id