Google maps Google Places API-Google如何确定城市/县的纬度/经度?
我尝试过谷歌搜索并检查Google Places的JavaScript API,但没有找到这个问题的答案 当我搜索一个特定的城市,比如旧金山,CA,我得到这样的回答:Google maps Google Places API-Google如何确定城市/县的纬度/经度?,google-maps,google-places-api,Google Maps,Google Places Api,我尝试过谷歌搜索并检查Google Places的JavaScript API,但没有找到这个问题的答案 当我搜索一个特定的城市,比如旧金山,CA,我得到这样的回答: /**/_xdc_._a1fter && _xdc_._a1fter( { "html_attributions" : [], "result" : { "address_components" : [ { "long_name" : "San Fr
/**/_xdc_._a1fter && _xdc_._a1fter( {
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "San Francisco",
"short_name" : "SF",
"types" : [ "locality", "political" ]
},
{
"long_name" : "San Francisco County",
"short_name" : "San Francisco County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "California",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
}
],
"adr_address" : "\u003cspan class=\"locality\"\u003eSan Francisco\u003c/span\u003e, \u003cspan class=\"region\"\u003eCA\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eUSA\u003c/span\u003e",
"formatted_address" : "San Francisco, CA, USA",
"geometry" : {
"location" : {
"lat" : 37.7749295,
"lng" : -122.4194155
},
"viewport" : {
"northeast" : {
"lat" : 37.812,
"lng" : -122.3482
},
"southwest" : {
"lat" : 37.70339999999999,
"lng" : -122.527
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
"id" : "1b9ea3c094d3ac23c9a3afa8cd4d8a41f05de50a",
"name" : "San Francisco",
"photos" : [
{
"height" : 2448,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/103231451031314314785/photos\"\u003eTrigby Perea\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh4.googleusercontent.com/-aP4oMIc1OZ0/V2g8WKNFqpI/AAAAAAAANbU/w0Ii2GYhpyofvMqPjzEH0RcL-KkdMblEQCLIB/k/"
},
"width" : 3264
},
{
"height" : 3651,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/111642936581150005827/photos\"\u003eCraig Foster\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh5.googleusercontent.com/-Fp-Ds7Nltp0/Vke8Hc4KbZI/AAAAAAAB3lg/Zyh3nNGV_ZMhm5zFXBxQk4fToCLikK2bQ/k/"
},
"width" : 5477
},
{
"height" : 1441,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/105870396459094511944/photos\"\u003eAbbey Taylor\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh5.googleusercontent.com/-zohVGEyuXoc/VlHp_eA5DnI/AAAAAAAARKc/pyOWLnMEJnActbiE-NGo8aRxmAnLmyTgA/k/"
},
"width" : 1920
},
{
"height" : 1520,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/114911123719406241256/photos\"\u003eChristine Tallon\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh6.googleusercontent.com/-4ImN1qnn6mg/V87uASQ2tOI/AAAAAAAAAH8/z_2yiFXWTdQsxG-RTTqC0_TKQROHDUkIACLIB/k/"
},
"width" : 2688
},
{
"height" : 1836,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/111652642356832495715/photos\"\u003eLau Dora\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh5.googleusercontent.com/-ylvq826HIy0/V5EgFJrFBjI/AAAAAAAAlj4/EGL_L-RflOgu6rTFVvFvUl8Wkxw3nnzJgCLIB/k/"
},
"width" : 3264
},
{
"height" : 1944,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/112904178425011771283/photos\"\u003eGlenn Meyer\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh3.googleusercontent.com/-daHOav_w_QY/V2WuYuir_1I/AAAAAAAAPso/RhsZzyz05ygoeu4kjL_4bbNEepSNn_auwCLIB/k/"
},
"width" : 3456
},
{
"height" : 2592,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110340141477234279592/photos\"\u003eZaw Khun Naw Hpunggan\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh4.googleusercontent.com/-EjAUXW008Xo/Vmy-JD612FI/AAAAAAAAMMc/km2jOrx8-dwPYFHaTqfCw2PVMu5bQxZFA/k/"
},
"width" : 4608
},
{
"height" : 2988,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/112146856900507552674/photos\"\u003eJustin Wah Kan\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh6.googleusercontent.com/-Hk2UJFlS4HE/V2Q8KN1Q09I/AAAAAAABAMg/IFdiQdW1EfkQmIOkx_vZE1ZIQu-Oc80bQCLIB/k/"
},
"width" : 5312
},
{
"height" : 3024,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/101062424435478354204/photos\"\u003eNitesh Misra\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh6.googleusercontent.com/-KaFyc8uLu3E/V52S4rwKZ0I/AAAAAAAABNw/OoqMzR3BhWIEbP57UEYlxlhrc_JrjGZ0QCLIB/k/"
},
"width" : 4030
},
{
"height" : 3265,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/101841506952017923314/photos\"\u003eAlejandro Villa Renteria\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh3.googleusercontent.com/-d9HUyuzGUrI/VyDZ3QJAk1I/AAAAAAACAbk/PkZyTBaBQnI233l3sDWivzPKzFmhfBU9QCLIB/k/"
},
"width" : 4898
}
],
"place_id" : "ChIJIQBpAG2ahYAR_6128GcTUEo",
"reference" : "CoQBcwAAAPXngWwN52gpBv2Gpbi1kgRDZYEO6VclmIOEH8LyQKzEf8onqG72eVhCZSEoFLHpPmO2obfQRHO34oNkSprGBSZ4Mt0PvfUcABiPGKzmO2iALQPYh5pLv_3C6yst3Y-WZFq08ZHCBk5dOUo1o3HEyDjXwxE3gPIH9IXpfYvXCn5dEhCuC8FoVZo8pKqcMpm494tcGhTh80nRCEJD3U2Aozn3Tm83E8-_Jw",
"scope" : "GOOGLE",
"types" : [ "locality", "political" ],
"url" : "https://maps.google.com/?q=San+Francisco,+CA,+USA&ftid=0x80859a6d00690021:0x4a501367f076adff",
"utc_offset" : -420,
"vicinity" : "San Francisco"
},
"status" : "OK"
}
)
我好奇的是这一部分的具体内容:
"geometry" : {
"location" : {
"lat" : 37.7749295,
"lng" : -122.4194155
},
谷歌如何确定像城市或县这样的地方的纬度和经度值,而这实际上是一个地区
它似乎没有使用城市的地理中心或我能识别的任何其他一致的方法,我在文档中的任何地方都找不到这一点。让我用一个问题来回答:你为什么在意 几年前,我记得谷歌地图在搜索城市时会在市政厅前放置一个别针。这在几个国家是相当一致的,最后是我有点熟悉的国家(西班牙、爱尔兰、英国、美国等等),我总是想知道,为什么我会想要任何别针点呢 现在来看,当你搜索一个城市时,谷歌地图不再在任何地方放置pin,而是突出显示相关区域。我认为这是一个强烈的信号,一个大地方的点位置可能不是很有用。这也可能是此功能请求目前最受欢迎的原因之一: 我熟悉的一些地方的点中心似乎是突出的地标,我认为这些地标相当代表了大多数人认为的这些城市的“中心”:
- ,在都柏林(爱尔兰)
- ,在马德里(西班牙)
示例:返回在SAN若泽DIDION站(37.33068,121.902382)开始的路由,结束于旧金山站(37.776687,-122.394857),因为在这种情况下,这些是每个城市的相关点。
我做了一些测试,看起来主要位置纬度/经度非常接近东北和西南边界之间的中点。这是一张谷歌地图,上面展示了MN区域的一些例子:不是官方的答案,但这是一个开始。感谢您的回复!我们之所以关心这个问题,是因为客户端有一个现有的搜索函数,它使用从GoogleMapsAPI返回的纬度/经度作为基于位置的搜索的中心点。客户希望能够告知用户,如果他们搜索某个区域(如城市或zipcode),他们的搜索将如何处理。邮政编码或小城市通常会有一个合理的中心,因此您可以使用它来确定搜索半径的中心。它不像完整的几何图形那样精确,但对于邮政编码或小城市来说应该无关紧要。对于较大的城市和地区,地址组件是最好的过滤器。