【发布时间】:2018-08-07 22:01:46
【问题描述】:
我正在使用 Google Maps API 进行反向地理编码(地址查找)。我的代码结果非常详细 Lat Long 为:
(-7.799250499999999, 110.40451239999993)
如何将place.geometry.location结果四舍五入成某位小数?
例如(-7.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)
并导致一些崩溃。
任何帮助将不胜感激。谢谢
【问题讨论】:
-
你试过toFixed方法吗?
-
I had tried to use:... 可能只需要place.geometry.location.toUrlValue(7) -
它有效。谢谢你杰罗姆
标签: javascript php google-maps-api-3 location coordinates