【发布时间】:2015-07-06 12:14:59
【问题描述】:
我使用了 cordova 插件地理定位: https://github.com/apache/cordova-plugin-geolocation
通过命令安装cordova的插件: cordova 插件添加 org.apache.cordova.geolocation
它在关闭位置的 Android 版本 Jelly Bean(Samsung Galaxy Tab 2 版本 4.1.2 Jelly Bean、Samsung Galaxy Grand 2 版本 4.1.2 Jelly Bean)中运行良好,但在 Android 版本 Kitkat(Samsung Note 2版本 4.4.2 Kitkat)。
navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError);
function geolocationSuccess(position) {
var latlng = "Latitude :" + position.coords.latitude + ", Longitude :" + position.coords.longitude);
$ionicPopup.alert({
title: "User Current Location",
subTitle: "Location",
template: latlng
});
}
function geolocationError(error) {
$ionicPopup.alert({
title: "Pajhwok Location",
subTitle: "Error",
template: JSON.stringify(error)
});
}
【问题讨论】:
-
template: JSON.stringify(error)想将该错误打印到控制台/复制并粘贴到这里?调试控制台中出现的任何其他问题(因为您使用的是 kitkat,所以您可以使用 chrome 开发工具!) -
cordova 地理定位插件不再包含本机代码,所以如果它不起作用是 webview 的错,你无能为力
-
Cordova Geolocation 插件在 android 手机上打开位置的情况下工作正常。如果位置关闭,则在选项中设置超时后错误也会起作用
标签: android cordova geolocation cordova-plugins