gpt4 book ai didi

javascript - 将 Google Location LatLong 整数转换为 float

转载 作者:行者123 更新时间:2023-11-30 08:41:53 25 4
gpt4 key购买 nike

我正在开发一种工具,可以将 Google 位置历史记录提供的 JSON 转换为不同的格式,因此我可以将它与 Leaflet 热图插件一起使用。现在的问题是转换整数。我想要实现的是:

Positive Longitudes
1717485672 -> 171.7485672
115855930 -> 11.5855930
99811421 -> 9.9811421

Negative Longitudes
-99811421 -> -9.9811421

到目前为止我尝试了什么:

var longitude = "99811421";
longitude.replace(/(^([2-9]|1[0-9]))/, '$1.');

但是,这只适用于从 20000000 到 190000000 的范围。这对德国来说足够了,但对全世界来说还不够 ;)

知道怎么做吗?

最佳答案

此函数将为您“转换”数字,但实际上它所做的只是将数字除以 107

function num(x){ return x/10000000 }

关于javascript - 将 Google Location LatLong 整数转换为 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25587005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com