无法使用Google地理编码API验证地址

问题描述 投票:0回答:1

我正在使用Google Geocode来验证地址。我遇到了一个问题,每当我给出如下所示的输入如下所示:测试,城市:测试我得到的响应如下所示

 {
"results": [{
"address_components": [{
"long_name": "7007",
"short_name": "7007",
"types": ["street_number"]
}, {
"long_name": "College Boulevard",
"short_name": "College Blvd",
"types": ["route"]
}, {
"long_name": "Overland Park Plaza",
"short_name": "Overland Park Plaza",
"types": ["neighborhood", "political"]
}, {
"long_name": "Overland Park",
"short_name": "Overland Park",
"types": ["locality", "political"]
}, {
"long_name": "Johnson County",
"short_name": "Johnson County",
"types": ["administrative_area_level_2", "political"]
}, {
"long_name": "Kansas",
"short_name": "KS",
"types": ["administrative_area_level_1", "political"]
}, {
"long_name": "United States",
"short_name": "US",
"types": ["country", "political"]
}, {
"long_name": "66211",
"short_name": "66211",
"types": ["postal_code"]
}],
"formatted_address": "7007 College Blvd, Overland Park, KS 66211, USA",
"geometry": {
"location": {
"lat": 38.92663719999999,
"lng": -94.66484729999999
},
"location_type": "ROOFTOP",
"viewport": {
"northeast": {
"lat": 38.92798618029149,
"lng": -94.66349831970848
},
"southwest": {
"lat": 38.9252882197085,
"lng": -94.66619628029149
}
}
},
"place_id": "ChIJPTZ9JzjqwIcR0kOfM1L7n9E",
"plus_code": {
"compound_code": "W8GP+M3 Overland Park, Kansas, United States",
"global_code": "86C7W8GP+M3"
},
"types": ["establishment", "point_of_interest"]
}],
"status": "OK"
}

我无法理解它是如何为这样一个不正确的地址返回纬度和经度任何人都有一个想法请分享.... thnx提前

geocode
1个回答
0
投票

Google地理编码API不会验证地址。它不打算。相反,它返回与您的输入最相似的地址的lat-lon。对于您的“测试城市”地址,最接近的匹配恰好在堪萨斯州。它可能不是很近,但它是最接近的。

要验证地址,您需要一个地址验证API。我工作的公司生产YAddress。对于处理的每个地址,它会告诉您地址是否有效,如果没有,为什么不呢。例如,对于“测试城市”,您将收到错误消息“未找到城市”。

© www.soinside.com 2019 - 2024. All rights reserved.