How to get a country place ID for an associated locality place ID?

試著忘記壹切 提交于 2020-02-05 06:33:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!