我应该怎么做才能将 Google 地图 link 解析为位置坐标?

What should i do to parse Google Maps link to location coordinates?

在我的 iPhone 的搜索结果中复制了 Google 地图 link,它看起来像:

https://maps.google.com.tw/maps?hl=zh-tw&client=safari&yv=2&um=1&ie=UTF-8&fb=1&gl=tw&entry=s&sa=X&ftid=0x89c259594d6968cd:0x122305eef8f02a47&gmm=CgIgAQ%3D%3D

当我在浏览器中打开link时,它最终会被重定向到下面的link:

https://www.google.com.tw/maps/place/Best+Pizza/@40.7155798,-73.955601,17z/data=!3m1!4b1!4m2!3m1!1s0x89c259594d6968cd:0x122305eef8f02a47?hl=zh-tw

其中包含我要查找的位置坐标。

但是,我应该怎么做才能从这个 link 中找到位置坐标而不通过浏览器发送它?

我认为 "ftid" 是用于在地图中查找位置的参数。但是我找不到与 "ftid".

相关的任何内容

我遇到了同样的问题,这是我将如何处理您提供的 link(分享 google 地图中的 link)

https://www.google.com/maps/place/The+address+seperated+with+plus/@9.419263,99.957389,17z/data=!3m1!4b1!4m5!3m4!1s0x3054f4c49057b05d:0xb45d09053b0298d4!8m2!3d9.419263!4d99.959583

使用 php 我将该字符串转换为数组

$pts = explode('/',$string);

这给了我:

[0] => https:
    [1] => 
    [2] => www.google.com
    [3] => maps
    [4] => place
    [5] => 4170,+Tambon+Taling+Ngam,+Amphoe+Ko+Samui,+Chang+Wat+Surat+Thani+84140,+Thailand
    [6] => @9.419263,99.957389,17z
    [7] => data=!3m1!4b1!4m5!3m4!1s0x3054f4c49057b05d:0xb45d09053b0298d4!8m2!3d9.419263!4d99.959583

我只需要密钥 6,它总是一样的,你总是有 0 - 5

接下来我对其[6]

做同样的事情
$cords = explode(',',$pts[6]);

这给了我

[0] => @9.419263
[1] => 99.957389
[2] => 17z
I use this to store the lon / lat
$lon = str_replace('@','',$cords[0]);
$lat = $cords[1];

希望对您有所帮助,它对我有用!