从坐标中获取 Google 个地点 ID
Get Google Places ID from coordinates
我正在寻找一种从 Google 网络请求中找到 PlaceID
的方法。我有数百个地址(即坐标),我想找到一种方法将它们全部输入到 php
脚本中。
我正在努力处理 API 地点 API 的请求。我有以下要求:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=50.096332,8.673130&radius=1&key=APIKEY
这 returns 整个法兰克福市,但这不是我所追求的。如果我在 PlaceID finder on the Google Maps documentation site 中输入地址 Oskar-Sommer-Strasse 7, Frankfurt am Main, Deutschland
,我会得到 ID ChIJ-b9GgAUMvUcRYuYKJtGGlw4
.
的以下结果
我现在正在寻找一种方法来完成这项工作。我也使用 Google 地图 API 收集了坐标,所以它们应该匹配(或者至少我是这么想的)。
也许我需要使用其他请求类型?
使用地理编码 api 并向
发送请求
https://maps.googleapis.com/maps/api/geocode/json?address=Oskar-Sommer-Strasse+7+%20Frankfurt%20am%20Main%20&component=Deutschland
returns(我假设您需要地点 ID 字段)
{
"results" : [
{
"address_components" : [
{
"long_name" : "7",
"short_name" : "7",
"types" : [ "street_number" ]
},
{
"long_name" : "Oskar-Sommer-Straße",
"short_name" : "Oskar-Sommer-Straße",
"types" : [ "route" ]
},
{
"long_name" : "Frankfurt am Main Süd",
"short_name" : "Frankfurt am Main Süd",
"types" : [ "political", "sublocality", "sublocality_level_1" ]
},
{
"long_name" : "Frankfurt am Main",
"short_name" : "Frankfurt am Main",
"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" : "60596",
"short_name" : "60596",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Oskar-Sommer-Straße 7, 60596 Frankfurt am Main, Germany",
"geometry" : {
"location" : {
"lat" : 50.09665,
"lng" : 8.67299
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 50.0979989802915,
"lng" : 8.674338980291502
},
"southwest" : {
"lat" : 50.0953010197085,
"lng" : 8.671641019708497
}
}
},
"place_id" : "ChIJ-b9GgAUMvUcRYuYKJtGGlw4",
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
我正在寻找一种从 Google 网络请求中找到 PlaceID
的方法。我有数百个地址(即坐标),我想找到一种方法将它们全部输入到 php
脚本中。
我正在努力处理 API 地点 API 的请求。我有以下要求:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=50.096332,8.673130&radius=1&key=APIKEY
这 returns 整个法兰克福市,但这不是我所追求的。如果我在 PlaceID finder on the Google Maps documentation site 中输入地址 Oskar-Sommer-Strasse 7, Frankfurt am Main, Deutschland
,我会得到 ID ChIJ-b9GgAUMvUcRYuYKJtGGlw4
.
我现在正在寻找一种方法来完成这项工作。我也使用 Google 地图 API 收集了坐标,所以它们应该匹配(或者至少我是这么想的)。
也许我需要使用其他请求类型?
使用地理编码 api 并向
发送请求https://maps.googleapis.com/maps/api/geocode/json?address=Oskar-Sommer-Strasse+7+%20Frankfurt%20am%20Main%20&component=Deutschland
returns(我假设您需要地点 ID 字段)
{
"results" : [
{
"address_components" : [
{
"long_name" : "7",
"short_name" : "7",
"types" : [ "street_number" ]
},
{
"long_name" : "Oskar-Sommer-Straße",
"short_name" : "Oskar-Sommer-Straße",
"types" : [ "route" ]
},
{
"long_name" : "Frankfurt am Main Süd",
"short_name" : "Frankfurt am Main Süd",
"types" : [ "political", "sublocality", "sublocality_level_1" ]
},
{
"long_name" : "Frankfurt am Main",
"short_name" : "Frankfurt am Main",
"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" : "60596",
"short_name" : "60596",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Oskar-Sommer-Straße 7, 60596 Frankfurt am Main, Germany",
"geometry" : {
"location" : {
"lat" : 50.09665,
"lng" : 8.67299
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 50.0979989802915,
"lng" : 8.674338980291502
},
"southwest" : {
"lat" : 50.0953010197085,
"lng" : 8.671641019708497
}
}
},
"place_id" : "ChIJ-b9GgAUMvUcRYuYKJtGGlw4",
"types" : [ "street_address" ]
}
],
"status" : "OK"
}