Google maps 有没有办法找到谷歌地图的目标url';s使用谷歌应用程序脚本缩短链接并提取纬度和经度?

Google maps 有没有办法找到谷歌地图的目标url';s使用谷歌应用程序脚本缩短链接并提取纬度和经度?,google-maps,redirect,google-apps-script,coordinates,short-url,Google Maps,Redirect,Google Apps Script,Coordinates,Short Url,我试过这个: function getCords() {//this function will extract coordinates from url url = <"short url getting from google map app in mobile"> var response = UrlFetchApp.fetch(url, {followRedirects: false}) var longUrl = decodeURIComponent(respons

我试过这个:

function getCords() {//this function will extract coordinates from url
 url = <"short url getting from google map app in mobile">

 var response = UrlFetchApp.fetch(url, {followRedirects: false})
 var longUrl = decodeURIComponent(response.getHeaders()['Location'])
 var matches = longUrl.match(/!3d([\-]?[0-9]*.[0-9]*)\!4d([\-]?[0-9]*.[0-9]*)/)
 Logger.log(longUrl)

 var lat = matches[1]
 var lng = matches[2]

 Logger.log("Latitude: " + lat + " Longitude: " + lng)
 }
function getCords(){//此函数将从url提取坐标
url=
var response=UrlFetchApp.fetch(url,{followRedirects:false})
var longUrl=decodeURIComponent(response.getHeaders()['Location']))
var matches=longUrl.match(/!3d([\-]?[0-9]*.[0-9]*)\!4d([\-]?[0-9]*.[0-9]*)/)
Logger.log(长URL)
var lat=匹配项[1]
var lng=匹配项[2]
Logger.log(“纬度:+lat+”经度:+lng)
}
这适用于大多数链接,但某些重定向链接不起作用。 例如:

https://maps.app.goo.gl/nkGyxKo1fr6nMWS57

它返回:
https://www.google.com/maps/place//data=!4m2!3m1!1s0x3b0871c9e03c4297:0x8ab1ea0cc97f9aab?utm_源=mstt_1

它不包含纬度和经度值。 我还尝试将
{followRedirects:false}
更改为
{followRedirects:true}
。但不起作用


有没有办法解决这个问题?

你是如何从应用程序中获取url的?@Pagemag在共享位置时,我们将获取url。您可以通过将其共享到剪贴板并粘贴到某个位置来测试它。