【发布时间】:2016-06-12 09:36:48
【问题描述】:
有人知道谷歌地图在显示搜索位置的纬度/经度方面是否有任何默认设置?
我正在使用 Google Maps Geocoding API 来查找用户输入的搜索地址的地理位置 lat/lng 值。我想尽可能地将结果与 Google 地图匹配 - 是否可以像始终获取 API 返回的第一个结果一样简单?
示例:如果我在 Google 地图中搜索“卡塞尔”,则 lat/lng 结果为 51.3149724,9.3904035。
Google Maps result for searching "Kassel"
使用 Google API 搜索会产生两个结果,其中第一个结果的位置值比第二个更接近 Google 地图:
{
"results" : [
{
"address_components" : [
{
"long_name" : "Kassel",
"short_name" : "Kassel",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Kassel",
"short_name" : "KS",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Hesse",
"short_name" : "HE",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Germany",
"short_name" : "DE",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Kassel, Germany",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 51.36940509999999,
"lng" : 9.570128199999999
},
"southwest" : {
"lat" : 51.2603671,
"lng" : 9.3511015
}
},
"location" : {
"lat" : 51.3127114,
"lng" : 9.4797461
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 51.36940509999999,
"lng" : 9.570128199999999
},
"southwest" : {
"lat" : 51.2603671,
"lng" : 9.3511015
}
}
},
"place_id" : "ChIJHWx6n04_u0cRRxciWD1jhC8",
"types" : [ "locality", "political" ]
},
{
"address_components" : [
{
"long_name" : "Kassel",
"short_name" : "Kassel",
"types" : [ "sublocality_level_1", "sublocality", "political" ]
},
{
"long_name" : "Biebergemünd",
"short_name" : "Biebergemünd",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Darmstadt",
"short_name" : "DA",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Hessen",
"short_name" : "HE",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Germany",
"short_name" : "DE",
"types" : [ "country", "political" ]
},
{
"long_name" : "63599",
"short_name" : "63599",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Kassel, 63599 Biebergemünd, Germany",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 50.2173498,
"lng" : 9.3059744
},
"southwest" : {
"lat" : 50.18299649999999,
"lng" : 9.271353399999999
}
},
"location" : {
"lat" : 50.2066898,
"lng" : 9.279060399999999
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 50.2173498,
"lng" : 9.286410699999999
},
"southwest" : {
"lat" : 50.2006739,
"lng" : 9.271353399999999
}
}
},
"place_id" : "ChIJG4zo1CMvvUcRQPWOqlJDIgo",
"types" : [ "sublocality_level_1", "sublocality", "political" ]
}
],
"status" : "OK"
}
我能找到的唯一文档如下:
为什么 Google Maps API 地理编码器提供的位置与 Google Maps 不同? API 地理编码器和谷歌地图地理编码器有时使用不同的数据集(取决于国家)。 API 地理编码器偶尔会使用新数据进行更新,因此您可以预期结果会随着时间的推移而发生变化或改进。
【问题讨论】:
标签: google-maps google-maps-api-3