使用地点 ID 或来自地点服务的其他数据直接 link 到 googlemaps
Direct link to googlemaps with place id or other data from placeservice
我使用 googles placeservice 在某些地点附近查找不同的东西...例如超市、public 交通等...
我想打开一个新的 window 直接在 maps.google 上显示该地点。
我可以用 lat/lng:
https://www.google.dk/maps/@56.045495,10.085505,14z?hl=da
它得到了正确的地理位置,但我想让它显示具体位置,就像这样,如果使用地图上的搜索找到:
我或多或少认识坐标,但不能重新创建数据部分
那么 - 如何从地点服务数据创建直接 link?
示例数据:
{
"geometry" : {
"location" : {
"lat" : 56.04549499999999,
"lng" : 10.085505
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "f4c0b42302c72de733cd130f6589b2142de4f1e7",
"name" : "Fakta",
"opening_hours" : {
"open_now" : true,
"weekday_text" : []
},
"photos" : [
{
"height" : 250,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/109513446981677175720\"\u003eFakta\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh3.googleusercontent.com/-zqiScJc18CQ/VTab-hXG8XI/AAAAAAAAAAQ/hwgNgYHwxMI/k/"
},
"width" : 250
}
],
"place_id" : "ChIJed7jq5NpTEYR3lWeEyv7NsA",
"reference" : "CmRZAAAAAzaJO9Ozk3HNrAoVShZdMa2112V_2lh9Pj4p-_EmjqrDdeUtb81vOQGQ29A2LIlRTfyOriRssdKDKA39T9AKfIgQpg196jnKwP0kEX_O3pnZKroB6iAthowx9xz8FmSLEhDGbQEtuJZadYXCYvw3euRoGhT9i_8nJqSdku-WX3GimtT2c69syw",
"scope" : "GOOGLE",
"types" : [
"grocery_or_supermarket",
"food",
"store",
"point_of_interest",
"establishment"
],
"vicinity" : "Solbjerg Hedevej 25, Solbjerg"
}
Place Details Request place_id
:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJed7jq5NpTEYR3lWeEyv7NsA&key=YOUR_KEY_HERE
响应包含一个 url
字段:
"result" : {
// ... snip ...
"url" : "https://maps.google.com/?cid=13850533866455848414",
URL 会直接带您到 Google 地图上的地点:https://maps.google.com/?cid=13850533866455848414。
我使用 googles placeservice 在某些地点附近查找不同的东西...例如超市、public 交通等...
我想打开一个新的 window 直接在 maps.google 上显示该地点。
我可以用 lat/lng:
https://www.google.dk/maps/@56.045495,10.085505,14z?hl=da
它得到了正确的地理位置,但我想让它显示具体位置,就像这样,如果使用地图上的搜索找到:
我或多或少认识坐标,但不能重新创建数据部分
那么 - 如何从地点服务数据创建直接 link?
示例数据:
{
"geometry" : {
"location" : {
"lat" : 56.04549499999999,
"lng" : 10.085505
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "f4c0b42302c72de733cd130f6589b2142de4f1e7",
"name" : "Fakta",
"opening_hours" : {
"open_now" : true,
"weekday_text" : []
},
"photos" : [
{
"height" : 250,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/109513446981677175720\"\u003eFakta\u003c/a\u003e"
],
"raw_reference" : {
"fife_url" : "https://lh3.googleusercontent.com/-zqiScJc18CQ/VTab-hXG8XI/AAAAAAAAAAQ/hwgNgYHwxMI/k/"
},
"width" : 250
}
],
"place_id" : "ChIJed7jq5NpTEYR3lWeEyv7NsA",
"reference" : "CmRZAAAAAzaJO9Ozk3HNrAoVShZdMa2112V_2lh9Pj4p-_EmjqrDdeUtb81vOQGQ29A2LIlRTfyOriRssdKDKA39T9AKfIgQpg196jnKwP0kEX_O3pnZKroB6iAthowx9xz8FmSLEhDGbQEtuJZadYXCYvw3euRoGhT9i_8nJqSdku-WX3GimtT2c69syw",
"scope" : "GOOGLE",
"types" : [
"grocery_or_supermarket",
"food",
"store",
"point_of_interest",
"establishment"
],
"vicinity" : "Solbjerg Hedevej 25, Solbjerg"
}
Place Details Request place_id
:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJed7jq5NpTEYR3lWeEyv7NsA&key=YOUR_KEY_HERE
响应包含一个 url
字段:
"result" : {
// ... snip ...
"url" : "https://maps.google.com/?cid=13850533866455848414",
URL 会直接带您到 Google 地图上的地点:https://maps.google.com/?cid=13850533866455848414。