地理编码 google 地图 api return 不同 place_id
geocoding google maps api return different place_id
Return
{ "results" : [
{
"address_components" : [
{
"long_name" : "3",
"short_name" : "3",
"types" : [ "street_number" ]
},
{
"long_name" : "Lubyanskiy proyezd",
"short_name" : "Lubyanskiy pr-d",
"types" : [ "route" ]
},
{
"long_name" : "Tsentralnyy administrativnyy okrug",
"short_name" : "Tsentralnyy administrativnyy okrug",
"types" : [ "sublocality_level_1", "sublocality", "political" ]
},
{
"long_name" : "Moskva",
"short_name" : "Moskva",
"types" : [ "locality", "political" ]
},
{
"long_name" : "gorod Moskva",
"short_name" : "g. Moskva",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Moscow",
"short_name" : "Moscow",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Russia",
"short_name" : "RU",
"types" : [ "country", "political" ]
},
{
"long_name" : "101000",
"short_name" : "101000",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Lubyanskiy proyezd, 3, Moskva, Russia, 101000",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 55.7587676,
"lng" : 37.6290579
},
"southwest" : {
"lat" : 55.7587612,
"lng" : 37.6290433
}
},
"location" : {
"lat" : 55.7587676,
"lng" : 37.6290579
},
"location_type" : "RANGE_INTERPOLATED",
"viewport" : {
"northeast" : {
"lat" : 55.76011338029149,
"lng" : 37.6303995802915
},
"southwest" : {
"lat" : 55.75741541970849,
"lng" : 37.6277016197085
}
}
},
"place_id" : "EkbQm9GD0LHRj9C90YHQutC40Lkg0L_RgNC-0LXQt9C0LCAzLCDQnNC-0YHQutCy0LAsINCg0L7RgdGB0LjRjywgMTAxMDAw",
"types" : [ "street_address" ]
},
{
"address_components" : [
{
"long_name" : "3",
"short_name" : "3",
"types" : [ "street_number" ]
},
{
"long_name" : "Lubyanskiy proyezd",
"short_name" : "Lubyanskiy pr-d",
"types" : [ "route" ]
},
{
"long_name" : "Tsentralnyy administrativnyy okrug",
"short_name" : "Tsentralnyy administrativnyy okrug",
"types" : [ "sublocality_level_1", "sublocality", "political" ]
},
{
"long_name" : "Moskva",
"short_name" : "Moskva",
"types" : [ "locality", "political" ]
},
{
"long_name" : "gorod Moskva",
"short_name" : "g. Moskva",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Moscow",
"short_name" : "Moscow",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Russia",
"short_name" : "RU",
"types" : [ "country", "political" ]
},
{
"long_name" : "109074",
"short_name" : "109074",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Lubyanskiy proyezd, 3, Moskva, Russia, 109074",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 55.7539059,
"lng" : 37.6355031
},
"southwest" : {
"lat" : 55.7538962,
"lng" : 37.6354968
}
},
"location" : {
"lat" : 55.7539059,
"lng" : 37.6354968
},
"location_type" : "RANGE_INTERPOLATED",
"viewport" : {
"northeast" : {
"lat" : 55.7552500302915,
"lng" : 37.6368489302915
},
"southwest" : {
"lat" : 55.7525520697085,
"lng" : 37.6341509697085
}
}
},
"partial_match" : true,
"place_id" : "EkbQm9GD0LHRj9C90YHQutC40Lkg0L_RgNC-0LXQt9C0LCAzLCDQnNC-0YHQutCy0LAsINCg0L7RgdGB0LjRjywgMTA5MDc0",
"types" : [ "street_address" ]
} ], "status" : "OK" }
但是当我尝试通过 place_id 从之前的结果中查找地点信息时,我得到的结果不正确。
查找地点
结果:
> { "html_attributions" : [], "result" : {
> "address_components" : [
> {
> "long_name" : "3",
> "short_name" : "3",
> "types" : [ "street_number" ]
> },
> {
> "long_name" : "Lubyanskiy proyezd",
> "short_name" : "Lubyanskiy pr-d",
> "types" : [ "route" ]
> },
> {
> "long_name" : "Tsentralnyy administrativnyy okrug",
> "short_name" : "Tsentralnyy administrativnyy okrug",
> "types" : [ "sublocality_level_1", "sublocality", "political" ]
> },
> {
> "long_name" : "Moskva",
> "short_name" : "Moskva",
> "types" : [ "locality", "political" ]
> },
> {
> "long_name" : "gorod Moskva",
> "short_name" : "g. Moskva",
> "types" : [ "administrative_area_level_2", "political" ]
> },
> {
> "long_name" : "Moscow",
> "short_name" : "Moscow",
> "types" : [ "administrative_area_level_1", "political" ]
> },
> {
> "long_name" : "Russia",
> "short_name" : "RU",
> "types" : [ "country", "political" ]
> },
> {
> "long_name" : "101000",
> "short_name" : "101000",
> "types" : [ "postal_code" ]
> }
> ],
> "adr_address" : "\u003cspan class=\"street-address\"\u003eLubyanskiy proyezd, 3\u003c/span\u003e,
> \u003cspan class=\"locality\"\u003eMoskva\u003c/span\u003e, \u003cspan
> class=\"country-name\"\u003eRussia\u003c/span\u003e, \u003cspan
> class=\"postal-code\"\u003e101000\u003c/span\u003e",
> "formatted_address" : "Lubyanskiy proyezd, 3, Moskva, Russia, 101000",
> "geometry" : {
> "location" : {
> "lat" : 55.7587676,
> "lng" : 37.6290579
> }
> },
> "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
> "id" : "38efff77618f372a66fe6aaadde36e46a8d9b0a8",
> "name" : "Lubyanskiy pr-d, 3",
> "place_id" : "Ej_Qm9GD0LHRj9C90YHQutC40Lkg0L_RgC4sIDMsINCc0L7RgdC60LLQsCwg0KDQvtGB0YHQuNGPLCAxMDEwMDA",
> "reference" : "CpQBiwAAAA6ClEFYu1E3xM-8kRNGEf0s6sLJTMfqfroDVdaujzEMomzMTJ7HB80Bb8X5JLNrChwXlcFyKs4Hxn1vwgBm4LBfyCgMLty6WewWGKg7MbJb7ZDBhK0kQMRTcbnPGQ7hAG5MNo9t8LIMfDu0kZmsoCosW1MDEHbiXIHC9uygPYplHN6VzNP71rjh8V0AbiaZ9BIQohpY3YsUs0bWEwDUr74NqRoUttzPvs4Mlv_1nLCiPb_yHz5hW5M",
> "scope" : "GOOGLE",
> "types" : [ "street_address" ],
> "url" : "https://maps.google.com/maps/place?q=Lubyanskiy+proyezd,+3,+Moskva,+Russia,+101000&ftid=0x46b54a5c1e406657:0xd25bbb02ec771347",
> "vicinity" : "Tsentralnyy administrativnyy okrug" }, "status" : "OK" }
你怎么看出来的,place_id请求和响应不一样
In request (last link): EkbQ......AxMDAw
In response: Ej_Qm9.....MDEwMDA
EkbQ......AxMDAw != Ej_Qm9.....MDEwMDA
同一个地方有两个不同的place_id。
我该如何解决这个问题?我需要帮助!
place_id 不是唯一的。这个地方是独一无二的。文档中没有任何内容说存在到 place_id 的一对一映射,仅从 place_id 到 place。事实上,文档明确指出 一个地点可以有多个地点 ID。
Note: Place IDs are also available through the Places API. A single place ID refers to only one place, but a place can have multiple place IDs. For more information, see the place ID overview.
回答你的问题,没有解决不了的问题。正如@geocodezip 所说,一个位置可能有多个位置 ID。您的两个地点 ID 均有效且稳定,您可以使用其中一个。这里有更多详细信息:https://developers.google.com/places/place-id#multiple-ids
When you request place details for a specific place ID, you receive
the details for the requested place. Note however that the place ID
may be different, if the place has received a new ID since your
previous request. You can safely continue to use the original place ID
to access the place, but it's recommended that you swap to using the
most recently-returned place ID whenever possible.
Return
{ "results" : [ { "address_components" : [ { "long_name" : "3", "short_name" : "3", "types" : [ "street_number" ] }, { "long_name" : "Lubyanskiy proyezd", "short_name" : "Lubyanskiy pr-d", "types" : [ "route" ] }, { "long_name" : "Tsentralnyy administrativnyy okrug", "short_name" : "Tsentralnyy administrativnyy okrug", "types" : [ "sublocality_level_1", "sublocality", "political" ] }, { "long_name" : "Moskva", "short_name" : "Moskva", "types" : [ "locality", "political" ] }, { "long_name" : "gorod Moskva", "short_name" : "g. Moskva", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Moscow", "short_name" : "Moscow", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Russia", "short_name" : "RU", "types" : [ "country", "political" ] }, { "long_name" : "101000", "short_name" : "101000", "types" : [ "postal_code" ] } ], "formatted_address" : "Lubyanskiy proyezd, 3, Moskva, Russia, 101000", "geometry" : { "bounds" : { "northeast" : { "lat" : 55.7587676, "lng" : 37.6290579 }, "southwest" : { "lat" : 55.7587612, "lng" : 37.6290433 } }, "location" : { "lat" : 55.7587676, "lng" : 37.6290579 }, "location_type" : "RANGE_INTERPOLATED", "viewport" : { "northeast" : { "lat" : 55.76011338029149, "lng" : 37.6303995802915 }, "southwest" : { "lat" : 55.75741541970849, "lng" : 37.6277016197085 } } }, "place_id" : "EkbQm9GD0LHRj9C90YHQutC40Lkg0L_RgNC-0LXQt9C0LCAzLCDQnNC-0YHQutCy0LAsINCg0L7RgdGB0LjRjywgMTAxMDAw", "types" : [ "street_address" ] }, { "address_components" : [ { "long_name" : "3", "short_name" : "3", "types" : [ "street_number" ] }, { "long_name" : "Lubyanskiy proyezd", "short_name" : "Lubyanskiy pr-d", "types" : [ "route" ] }, { "long_name" : "Tsentralnyy administrativnyy okrug", "short_name" : "Tsentralnyy administrativnyy okrug", "types" : [ "sublocality_level_1", "sublocality", "political" ] }, { "long_name" : "Moskva", "short_name" : "Moskva", "types" : [ "locality", "political" ] }, { "long_name" : "gorod Moskva", "short_name" : "g. Moskva", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Moscow", "short_name" : "Moscow", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "Russia", "short_name" : "RU", "types" : [ "country", "political" ] }, { "long_name" : "109074", "short_name" : "109074", "types" : [ "postal_code" ] } ], "formatted_address" : "Lubyanskiy proyezd, 3, Moskva, Russia, 109074", "geometry" : { "bounds" : { "northeast" : { "lat" : 55.7539059, "lng" : 37.6355031 }, "southwest" : { "lat" : 55.7538962, "lng" : 37.6354968 } }, "location" : { "lat" : 55.7539059, "lng" : 37.6354968 }, "location_type" : "RANGE_INTERPOLATED", "viewport" : { "northeast" : { "lat" : 55.7552500302915, "lng" : 37.6368489302915 }, "southwest" : { "lat" : 55.7525520697085, "lng" : 37.6341509697085 } } }, "partial_match" : true, "place_id" : "EkbQm9GD0LHRj9C90YHQutC40Lkg0L_RgNC-0LXQt9C0LCAzLCDQnNC-0YHQutCy0LAsINCg0L7RgdGB0LjRjywgMTA5MDc0", "types" : [ "street_address" ] } ], "status" : "OK" }
但是当我尝试通过 place_id 从之前的结果中查找地点信息时,我得到的结果不正确。
查找地点结果:
> { "html_attributions" : [], "result" : { > "address_components" : [ > { > "long_name" : "3", > "short_name" : "3", > "types" : [ "street_number" ] > }, > { > "long_name" : "Lubyanskiy proyezd", > "short_name" : "Lubyanskiy pr-d", > "types" : [ "route" ] > }, > { > "long_name" : "Tsentralnyy administrativnyy okrug", > "short_name" : "Tsentralnyy administrativnyy okrug", > "types" : [ "sublocality_level_1", "sublocality", "political" ] > }, > { > "long_name" : "Moskva", > "short_name" : "Moskva", > "types" : [ "locality", "political" ] > }, > { > "long_name" : "gorod Moskva", > "short_name" : "g. Moskva", > "types" : [ "administrative_area_level_2", "political" ] > }, > { > "long_name" : "Moscow", > "short_name" : "Moscow", > "types" : [ "administrative_area_level_1", "political" ] > }, > { > "long_name" : "Russia", > "short_name" : "RU", > "types" : [ "country", "political" ] > }, > { > "long_name" : "101000", > "short_name" : "101000", > "types" : [ "postal_code" ] > } > ], > "adr_address" : "\u003cspan class=\"street-address\"\u003eLubyanskiy proyezd, 3\u003c/span\u003e, > \u003cspan class=\"locality\"\u003eMoskva\u003c/span\u003e, \u003cspan > class=\"country-name\"\u003eRussia\u003c/span\u003e, \u003cspan > class=\"postal-code\"\u003e101000\u003c/span\u003e", > "formatted_address" : "Lubyanskiy proyezd, 3, Moskva, Russia, 101000", > "geometry" : { > "location" : { > "lat" : 55.7587676, > "lng" : 37.6290579 > } > }, > "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png", > "id" : "38efff77618f372a66fe6aaadde36e46a8d9b0a8", > "name" : "Lubyanskiy pr-d, 3", > "place_id" : "Ej_Qm9GD0LHRj9C90YHQutC40Lkg0L_RgC4sIDMsINCc0L7RgdC60LLQsCwg0KDQvtGB0YHQuNGPLCAxMDEwMDA", > "reference" : "CpQBiwAAAA6ClEFYu1E3xM-8kRNGEf0s6sLJTMfqfroDVdaujzEMomzMTJ7HB80Bb8X5JLNrChwXlcFyKs4Hxn1vwgBm4LBfyCgMLty6WewWGKg7MbJb7ZDBhK0kQMRTcbnPGQ7hAG5MNo9t8LIMfDu0kZmsoCosW1MDEHbiXIHC9uygPYplHN6VzNP71rjh8V0AbiaZ9BIQohpY3YsUs0bWEwDUr74NqRoUttzPvs4Mlv_1nLCiPb_yHz5hW5M", > "scope" : "GOOGLE", > "types" : [ "street_address" ], > "url" : "https://maps.google.com/maps/place?q=Lubyanskiy+proyezd,+3,+Moskva,+Russia,+101000&ftid=0x46b54a5c1e406657:0xd25bbb02ec771347", > "vicinity" : "Tsentralnyy administrativnyy okrug" }, "status" : "OK" }
你怎么看出来的,place_id请求和响应不一样
In request (last link): EkbQ......AxMDAw
In response: Ej_Qm9.....MDEwMDA
EkbQ......AxMDAw != Ej_Qm9.....MDEwMDA
同一个地方有两个不同的place_id。
我该如何解决这个问题?我需要帮助!
place_id 不是唯一的。这个地方是独一无二的。文档中没有任何内容说存在到 place_id 的一对一映射,仅从 place_id 到 place。事实上,文档明确指出 一个地点可以有多个地点 ID。
Note: Place IDs are also available through the Places API. A single place ID refers to only one place, but a place can have multiple place IDs. For more information, see the place ID overview.
回答你的问题,没有解决不了的问题。正如@geocodezip 所说,一个位置可能有多个位置 ID。您的两个地点 ID 均有效且稳定,您可以使用其中一个。这里有更多详细信息:https://developers.google.com/places/place-id#multiple-ids
When you request place details for a specific place ID, you receive the details for the requested place. Note however that the place ID may be different, if the place has received a new ID since your previous request. You can safely continue to use the original place ID to access the place, but it's recommended that you swap to using the most recently-returned place ID whenever possible.