我正在使用以下请求(使用我的谷歌API密钥(调用谷歌地方地图API:
https://maps.googleapis.com/maps/api/geocode/json?address=32/36+Nagle+St,+Liverpool+NSW&components=postal_code:2170|国家:AU&key={your key}
它返回以下 JSON:
{
"results" : [
{
"address_components" : [
{
"long_name" : "32",
"short_name" : "32",
"types" : [ "subpremise" ]
},
{
"long_name" : "36",
"short_name" : "36",
"types" : [ "street_number" ]
},
{
"long_name" : "Nagle Street",
"short_name" : "Nagle St",
"types" : [ "route" ]
},
{
"long_name" : "Liverpool",
"short_name" : "Liverpool",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Liverpool City Council",
"short_name" : "Liverpool",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "New South Wales",
"short_name" : "NSW",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Australia",
"short_name" : "AU",
"types" : [ "country", "political" ]
},
{
"long_name" : "2170",
"short_name" : "2170",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "32/36 Nagle St, Liverpool NSW 2170, Australia",
"geometry" : {
"location" : {
"lat" : -33.92853530000001,
"lng" : 150.9219302
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : -33.92718631970851,
"lng" : 150.9232791802915
},
"southwest" : {
"lat" : -33.92988428029151,
"lng" : 150.9205812197085
}
}
},
"partial_match" : true,
"place_id" : "Ei0zMi8zNiBOYWdsZSBTdCwgTGl2ZXJwb29sIE5TVyAyMTcwLCBBdXN0cmFsaWE",
"types" : [ "subpremise" ]
}
],
"status" : "OK"
}
为什么当地址作为相同的结果"部分匹配"地址传入时,结果在这里有 partial_match = true?
"partial_match" : true
这可能是因为结果是插值的,它不是来自 Google 数据库的功能,位置是根据插值计算的。
查看响应中的地点 ID。
Ei0zMi8zNiBOYWdsZSBTdCwgTGl2ZXJwb29sIE5TVyAyMTcwLCBBdXN0cmFsaWE
通常,这些长位置 ID 对应于插值,结果是猜测的,我的假设是 API 在这种情况下设置部分匹配标志。
可以在Google数据库中找到的功能通常具有较短的地点ID。 ChIJARdFFWLRhIARK6RIUxEbJ30
.
https://developers.google.com/places/place-id#id-overview