在 Google 地图 API 中四舍五入 place.geometry.location 值
Rounding the place.geometry.location value in Google Maps API
我正在使用 Google 地图 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)
并导致一些崩溃。
任何帮助将不胜感激。谢谢
precision?:number
代码必须用整数替换。
place.geometry.location.toUrlValue(WriteYourDesiredPrecisionHere)
本题应该是:
place.geometry.location.toUrlValue(7)
我正在使用 Google 地图 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)
并导致一些崩溃。
任何帮助将不胜感激。谢谢
precision?:number
代码必须用整数替换。
place.geometry.location.toUrlValue(WriteYourDesiredPrecisionHere)
本题应该是:
place.geometry.location.toUrlValue(7)