Google Places API - 谷歌如何确定城市/县的纬度/经度?

时间:2016-10-04 16:23:51

标签: google-maps google-places-api

我已尝试使用Google搜索并检查documentation以查找Google商家信息JavaScript API,但尚未找到此问题的答案。

当我搜索某个特定城市时,例如加利福尼亚州旧金山,我得到的答案如下:

/**/_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
         },

Google如何确定像城市或县实际上是某个地区的地方的纬度和经度值?

它似乎没有使用我所能看到的城市的地理中心或任何其他一致的方法,而且我无法在文档中的任何地方找到这一点。

1 个答案:

答案 0 :(得分:2)

让我回答一个问题:你为什么关心?

多年前,我记得谷歌地图在搜索城市时会在市政厅前面放一根针。这在几个国家相当一致,最后是我熟悉的那些国家(西班牙,爱尔兰,英国,美国......),我总是想知道,为什么我还想要任何针脚点呢?

现在看一下,当您搜索某个城市时,Google地图不再会在任何地方放置图钉,而是会突出显示相关区域。我认为这是一个强烈的信号,一个大地方的点位置可能不是很有用。这也可能是此功能请求迄今为止最受欢迎的原因之一:https://code.google.com/p/gmaps-api-issues/issues/detail?id=109

我熟悉的一些地方的中心似乎是一个突出的地标,我认为这些地方很能代表大多数人认为是这些城市的“中心”:

San FranciscoZurich中的情况一样,其他人似乎只在主要道路的十字路口中占据中心位置。其他人,主要是在小城镇,老实说我真的没有意义。

我的看法是,一个城市或县的中心只是作为市区,城市或大多数人居住的地方的粗略近似,在一个大的不均匀/人口稀少的地区。这样的点只有在低缩放级别才有用。

这似乎与一个城市或一个县并没有真正拥有“中心”的想法有些一致,这一点绝对是每个人都会用手指说“这里,这是这个城市的核心”

但是即使/当有这样的观点时,它也可能并不总是你正在寻找的东西。例如,如果您乘坐火车在城市之间旅行,您可能不在乎这些点,而是关心他们的火车站。

示例:transit directions from San Jose to San Francisco返回从San Jose Diridon站(37.33068,-121.902382)开始并在旧金山站(37.776687,-122.394857)结束的路线,因为这些是每个城市的相关点在这种情况下。