【问题标题】:How do I get the parent city for a suburb using Google Maps API?如何使用 Google Maps API 获取郊区的父城市?
【发布时间】:2012-12-09 05:15:19
【问题描述】:

我正在使用 Google Places 自动完成 API。如果我搜索一个特定的郊区,比如澳大利亚维多利亚的里士满,我会返回以下地址组件:

0:Object
    long_name: "Richmond"
    short_name: "Richmond"
    types: Array[2]
        0: "locality"
        1: "political"

1: Object
    long_name: "Victoria"
    short_name: "VIC"
    types: Array[2]
        0: "administrative_area_level_1"
        1: "political"

2: Object
    long_name: "Australia"
    short_name: "AU"
    types: Array[2]
        0: "country"
        1: "political"

这很好,但是里士满是墨尔本的郊区,为了我的应用程序的目的,我需要知道这一点。如果地区在一个范围内,我如何让 API 返回父城市?如果您查看以下 URL,您会发现它将 Richmond 放置在澳大利亚维多利亚州墨尔本市,所以我假设可以通过 API 以某种方式获取此信息?

https://maps.google.com/maps/place?q=Richmond&ftid=0x6ad64259018db945:0x5045675218ce810

【问题讨论】:

    标签: google-maps google-maps-api-3


    【解决方案1】:

    可惜城市和/或地区信息不包含在地理编码 API 返回中。

    作为基于位置的搜索的粗略解决方案,我对城市和地区进行公里半径:

    Worldwide   No filter
    Country     Available from geocode
    State       Available from geocode
    Region      50 KM Radius from latlong
    City        20 KM Radius from latlong 
    Postcode    Available from geocode
    Suburb      Available from geocode (Locality)
    Radius      User defined radius from latlong 
    

    我确实尝试使用“边界”值,但没有真正成功 (https://developers.google.com/maps/documentation/geocoding/)。

    如果您需要比这更准确,那么您正在制作一个相当大的参考数据库。

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-25
        • 2012-11-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-31
        相关资源
        最近更新 更多