【问题标题】:Google Geocoding Api returning inconsistent dataGoogle Geocoding Api 返回不一致的数据
【发布时间】:2016-08-29 18:39:02
【问题描述】:

我正在尝试了解如何从 Google Geocoding api 获取正确的数据,但我无法理解如何获取正确的数据。

我正在尝试前往富埃特文图拉岛上的城市 Costa Calma 当我使用 url 查找城市时:https://maps.googleapis.com/maps/api/geocode/json?address=Costa%20Calma,%20Fuerteventura

我收到回复:

{  
"results":[  
    {  
        "address_components":[  
            {  
                "long_name":"Costa Calma",
                "short_name":"Costa Calma",
                "types":[  
                    "locality",
                    "political"
                ]
            },
            {  
                "long_name":"Pájara",
                "short_name":"Pájara",
                "types":[  
                    "administrative_area_level_4",
                    "political"
                ]
            },
            {  
                "long_name":"Jandía",
                "short_name":"Jandía",
                "types":[  
                    "administrative_area_level_3",
                    "political"
                ]
            },
            {  
                "long_name":"Las Palmas",
                "short_name":"Las Palmas",
                "types":[  
                    "administrative_area_level_2",
                    "political"
                ]
            },
            {  
                "long_name":"Canarias",
                "short_name":"CN",
                "types":[  
                    "administrative_area_level_1",
                    "political"
                ]
            },
            {  
                "long_name":"Spain",
                "short_name":"ES",
                "types":[  
                    "country",
                    "political"
                ]
            }
        ],
        "formatted_address":"Costa Calma, Las Palmas, Spain",
        "geometry":{  
            "bounds":{  
                "northeast":{  
                    "lat":28.1747078,
                    "lng":-14.2126396
                },
                "southwest":{  
                    "lat":28.147027,
                    "lng":-14.2368948
                }
            },
            "location":{  
                "lat":28.1585283,
                "lng":-14.2294205
            },
            "location_type":"APPROXIMATE",
            "viewport":{  
                "northeast":{  
                    "lat":28.1747078,
                    "lng":-14.2126396
                },
                "southwest":{  
                    "lat":28.147027,
                    "lng":-14.2368948
                }
            }
        },
        "partial_match":true,
        "place_id":"ChIJ2fWZIEOcRwwRjXhqKnxec8U",
        "types":[  
            "locality",
            "political"
        ]
    }
],
"status":"OK"}

我可以在回复中看到 Costa Calma 位于加那利群岛,但我看不到在哪个岛上,如果我查找 Fuerteventura,网址为:https://maps.googleapis.com/maps/api/geocode/json?address=Fuerteventura,%20Spanien 我得到了回应

{
"results": [{
    "address_components": [{
        "long_name": "Fuerteventura",
        "short_name": "Fuerteventura",
        "types": ["natural_feature", "establishment"]
    }, {
        "long_name": "Spain",
        "short_name": "ES",
        "types": ["country", "political"]
    }],
    "formatted_address": "Fuerteventura, Spain",
    "geometry": {
        "bounds": {
            "northeast": {
                "lat": 28.757003,
                "lng": -13.8224231
            },
            "southwest": {
                "lat": 28.0438891,
                "lng": -14.5101955
            }
        },
        "location": {
            "lat": 28.3982211,
            "lng": -14.0103493
        },
        "location_type": "APPROXIMATE",
        "viewport": {
            "northeast": {
                "lat": 28.757003,
                "lng": -13.8224231
            },
            "southwest": {
                "lat": 28.0438891,
                "lng": -14.5101955
            }
        }
    },
    "place_id": "ChIJgQ_Cr3OkRwwRI3-1tRMcxyo",
    "types": ["natural_feature", "establishment"]
}],
"status": "OK"}

我可以看到富埃特文图拉位于西班牙,但不在加那利群岛,但是如果我检查坐标,我可以看到坐标在同一个岛上,我该如何解决这个问题?

【问题讨论】:

    标签: missing-data google-geocoding-api


    【解决方案1】:

    Fuerteventura 似乎是位于Spain 的加那利群岛之一的岛屿

    【讨论】:

    • 是的,并且 Costa Calma 位于富埃特文图拉岛,但是当我查找 Costa Calma 时,它说它只是位于加那利群岛上,但是当我查找 Costa Calma 时,我该怎么做才能得到 Fuerteventura作为岛屿?
    • 我尝试了几种组合,似乎Google没有提供岛屿名称,只是提供岛屿的组名Canarias
    【解决方案2】:

    富埃特文图拉岛是一个岛屿,虽然它也可能是一个政治部门,但事实并非如此。这就是为什么您不会在加那利群岛的邮政地址中看到富埃特文图拉(或任何岛屿名称)。这就是为什么它永远不会出现在任何地理编码结果的address_components 中。

    我不确定当前的问题是什么,但我可以根据第一手经验告诉您,您不应该将“富埃特文图拉”作为地址的一部分。加那利群岛的地址仅使用地区、邮政编码和省份,并且只有 2 个省,每个省包含大约一半的加那利群岛。

    我认为这两个省份都以各自的省会城市命名可能会令人困惑:

    如果您想获得一般的岛屿,请参阅 Why is "natural_feature" excluded from Google Maps Geocoding and Places API searches?https://code.google.com/p/gmaps-api-issues/issues/detail?id=4759

    【讨论】:

    • 我之所以需要 Fuerteventura,是因为我在一个旅游目的地 API 工作,在这种情况下,重要的部分是:Fuerteventura 是加那利群岛的一部分,它是加那利群岛的一部分西班牙。城市本身并不是最重要的部分。
    猜你喜欢
    • 2016-09-18
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-15
    • 1970-01-01
    相关资源
    最近更新 更多