舍入Google Maps API中的place.geometry.location值

问题描述 投票:-2回答:1

我正在使用Google Maps API执行反向地理编码(地址查找)。我的代码产生了非常详细的Lat Long

(-7.799250499999999, 110.40451239999993)

如何将place.geometry.location结果舍入到一定的数字小数?

EG (-p.7992505,110.4045124)

这是我的代码方案:

在我的HTML中

<div id="infowindow-content">
    <span id="place-coord"></span>
</div>

在我的Javascript中

...    
function() {
        ...
        infowindowContent.children['place-coord'].textContent = place.geometry.location;
        ...
}
...

我试过用:

place.geometry.location.toUrlValue(precision?:number)

要么

place.geometry.location.toUrlValue(precision?:7)

并导致一些崩溃。

任何帮助将受到高度赞赏。谢谢

javascript php google-maps-api-3 location coordinate
1个回答
0
投票

precision?:number代码必须替换为整数。

place.geometry.location.toUrlValue(WriteYourDesiredPrecisionHere)

在这个问题上,我应该是:

place.geometry.location.toUrlValue(7)
© www.soinside.com 2019 - 2024. All rights reserved.