【发布时间】:2017-10-01 22:49:00
【问题描述】:
我目前正在使用这个插件 https://github.com/sebastianbaar/cordova-plugin-nativegeocoder 在科尔多瓦/离子应用程序和 iOS 上,我收到一条错误消息,指出我需要提供双倍坐标。
文档清楚地说明了这一点,但是因为我使用https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-geolocation/ 来获取 ios 上的纬度和经度,这些以小数形式返回并且很长,并且不确定如何在 javascript 中执行此操作。我一直在这里搜索,即:https://stackoverflow.com/search?q=double+latitude+and+longitude,但这些答案都不是很清楚,也不是在 javascript / angularjs 中。这是我如何获取坐标的代码。
$cordovaGeolocation.getCurrentPosition().then(function (position) {
var lat = position.coords.latitude
var long = position.coords.longitude
谢谢
【问题讨论】:
-
是 lat 和 long 字符串吗?也许您只需要
+position.coords.latitude将值强制为 Number。 Javascript 没有浮点数、整数等类型,它只有Number。
标签: javascript angularjs ionic-framework double cordova-plugins