谷歌Places API的:是" place_id"或QUOT; ID"唯一在世界上任何一个城市? [英] Google Places API: Are "place_id" or "id" unique to any city in the world?

查看:171
本文介绍了谷歌Places API的:是" place_id"或QUOT; ID"唯一在世界上任何一个城市?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在做一个自动完成API调用的位置,我要求从谷歌的JSON响应。

有什么ID和place_id字符串?

之间的区别

是这两个ID的独特能力在世界上任何一个城市?

谷歌是否名额分配一个id,每个城市在世界上?

例如,不萨默斯,纽约,美国有相同的ID为萨默斯,纽约,美国?

有一种简单的方法来获得一个城市一个id? (从谷歌地图网址什么的?)

下面是萨默斯美国纽约的自动完成API调用的JSON响应:

  {
   html_attributions:[],
   结果:{
      address_components:[
         {
            LONG_NAME:萨默斯,
            SHORT_NAME:萨默斯
            类型:administrative_area_level_3,政治]
         },
         {
            LONG_NAME:威彻斯特县
            SHORT_NAME:威彻斯特县
            类型:administrative_area_level_2,政治]
         },
         {
            LONG_NAME:纽约,
            SHORT_NAME:NY,
            类型:administrative_area_level_1,政治]
         },
         {
            LONG_NAME:美的,
            SHORT_NAME:美国,
            类型:国家,政治]
         }
      ]
      adr_address:\\ u003cspan类= \\本地\\\\ u003eSomers \\ u003c / SPAN \\ u003e \\ u003cspan类= \\区域\\\\ u003eNY \\ u003c / SPAN \\ u003e \\ u003cspan类= \\国名\\\\ u003eUSA \\ u003c / SPAN \\ u003e
      的formatted_address:萨默斯,NY,USA
      几何体:{
         位置 : {
            纬度:41.29963050000001,
            LNG:-73.7360175
         },
         视口:{
            东北:{
               纬度:41.3550988,
               LNG:-73.65881709999999
            },
            西南:{
               纬度:41.2379047,
               LNG:-73.78000709999999
            }
         }
      },
      图标:http://maps.gstatic.com/mapfiles/place_api/icons/geo$c$c-71.png
      ID:8e846f7cdf419380d138e6d605137e739075b777
      名:萨默斯
      place_id:ChIJ6wv7yGixwokRIwjh6OWI4I0,
      参考: \"CoQBcgAAAKxvwwjlyK3ZaVA5DAM52DU8tMMplyvamYxXVJuMyDplQ3SUs-9ONvZgIN4sDW_sUz9z7wdoBCmPcgWHY9Oi_l0hImvMtiE8s6TKaUCDju2vzlcSEGXtDW0bvixVbbuF35AP2stRw80YjcrnwuMDglKEHKUVdH8vzSVG91WNOcOcEhBda300E-VstT6ZQ1zCx30eGhQBUGcFLuUeB484h1AzDw75Aw5wxA\",
      范围:GOOGLE
      类型:administrative_area_level_3,政治]
      URL: \"https://maps.google.com/maps/place?q=Somers,+NY,+USA&ftid=0x89c2b168c8fb0beb:0x8de088e5e8e10823\"
   },
   状态:OK
}


解决方案

id和参考已经去precated,并将从2015年中期的结果中删除。他们在这个意义上,你可以从这些信息中查找的地方不是唯一。

Placeid是不同的 - 它是既独特的位置的的位置的通常只有一个Placeid。 (这是在大多数情况下,正确的。然而,一个地方可以有指不同范围的附加标识(谷歌范围VS用户范围内),或者如果一个企业已经转移到一个不同的地方给它一个新的place_id。然而,在所有的情况下, place_id仍然坚持不懈。)此外,您使用Placeid访问详细的API。

在这里看到德precation通知: https://developers.google.com/地方/文档/搜索


  

请注意:id和参考字段pcated为2014年6月24日的德$ P $。
  它们是由新的地方的ID,一个唯一的标识符,可以是取代
  用于比较的地方,并检索有关地点的信息。该
  地方API目前返回所有响应的place_id,并接受
  在地方详情一个placeid和地点删除请求。不久
  2015年6月24日,该API将停止返回ID和引用字段
  在响应。一段时间后,该API将不再接受
  在请求中参考。我们建议您更新code使用
  新发生的ID,而不是ID和参考尽快


When doing a autocomplete API call for a location, I request a JSON response from google.

What is the difference between the "id" and "place_id" string?

Are these two id's unique to any city in the world?

Does google places assign every city in the world an id?

For example, does Somers, NY, USA have the same id as Somers, New York, United States?

Is there an easy way to get an id for a city? (from a google maps url or something?)

Here is the JSON response from a autocomplete api call of Somers NY USA:

    {
   "html_attributions" : [],
   "result" : {
      "address_components" : [
         {
            "long_name" : "Somers",
            "short_name" : "Somers",
            "types" : [ "administrative_area_level_3", "political" ]
         },
         {
            "long_name" : "Westchester County",
            "short_name" : "Westchester County",
            "types" : [ "administrative_area_level_2", "political" ]
         },
         {
            "long_name" : "New York",
            "short_name" : "NY",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "United States",
            "short_name" : "US",
            "types" : [ "country", "political" ]
         }
      ],
      "adr_address" : "\u003cspan class=\"locality\"\u003eSomers\u003c/span\u003e, \u003cspan class=\"region\"\u003eNY\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eUSA\u003c/span\u003e",
      "formatted_address" : "Somers, NY, USA",
      "geometry" : {
         "location" : {
            "lat" : 41.29963050000001,
            "lng" : -73.7360175
         },
         "viewport" : {
            "northeast" : {
               "lat" : 41.3550988,
               "lng" : -73.65881709999999
            },
            "southwest" : {
               "lat" : 41.2379047,
               "lng" : -73.78000709999999
            }
         }
      },
      "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
      "id" : "8e846f7cdf419380d138e6d605137e739075b777",
      "name" : "Somers",
      "place_id" : "ChIJ6wv7yGixwokRIwjh6OWI4I0",
      "reference" : "CoQBcgAAAKxvwwjlyK3ZaVA5DAM52DU8tMMplyvamYxXVJuMyDplQ3SUs-9ONvZgIN4sDW_sUz9z7wdoBCmPcgWHY9Oi_l0hImvMtiE8s6TKaUCDju2vzlcSEGXtDW0bvixVbbuF35AP2stRw80YjcrnwuMDglKEHKUVdH8vzSVG91WNOcOcEhBda300E-VstT6ZQ1zCx30eGhQBUGcFLuUeB484h1AzDw75Aw5wxA",
      "scope" : "GOOGLE",
      "types" : [ "administrative_area_level_3", "political" ],
      "url" : "https://maps.google.com/maps/place?q=Somers,+NY,+USA&ftid=0x89c2b168c8fb0beb:0x8de088e5e8e10823"
   },
   "status" : "OK"
}

解决方案

"id" and "reference" have been deprecated and will be removed from the results in mid-2015. They were not "unique" in the sense that you could look up somewhere from that info.

Placeid is different - it is both unique to the location and the location generally only has one Placeid. (This is true in most cases. However a "place" can have additional IDs that refer to different scopes (Google scope vs user scope) or if a business has moved to a different place giving it a new place_id. However in all cases, place_id is still persistent.) Furthermore you use the Placeid to access the Details API.

See the deprecation notice here: https://developers.google.com/places/documentation/search

Note: The id and reference fields are deprecated as of June 24, 2014. They are replaced by the new place ID, a unique identifier that can be used to compare places and to retrieve information about a place. The Places API currently returns a place_id in all responses, and accepts a placeid in the Place Details and Place Delete requests. Soon after June 24, 2015, the API will stop returning the id and reference fields in responses. Some time later, the API will no longer accept the reference in requests. We recommend that you update your code to use the new place ID instead of id and reference as soon as possible.

这篇关于谷歌Places API的:是" place_id"或QUOT; ID"唯一在世界上任何一个城市?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆