我正在寻找一种PlaceID
从Google网络请求中查找的方法.我有几百个地址(即坐标),我想找到一种方法让所有人在php
脚本中输入它们.
我正在努力处理place API的API请求.我有以下要求:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=50.096332,8.673130&radius=1&key=APIKEY
这将回归整个法兰克福市,但这不是我所追求的.如果我在Google Maps文档网站上Oskar-Sommer-Strasse 7, Frankfurt am Main, Deutschland
的PlaceID查找器中输入地址,我会得到以下ID结果ChIJ-b9GgAUMvUcRYuYKJtGGlw4
.
我现在正在寻找一种方法来完成这项工作.我也使用谷歌地图API收集坐标,所以他们应该匹配(或至少这是我的想法).
也许我需要使用其他一些请求类型?
使用geocode api并发送请求
https://maps.googleapis.com/maps/api/geocode/json?address=Oskar-Sommer-Strasse+7+%20Frankfurt%20am%20Main%20&component=Deutschland
返回(我假设你想要地方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" }