Jac*_*ack 9 gps android cordova ionic
尝试确定某人是否在Ionic/Cordova中关闭了他们的GPS时遇到了一些问题.
这是我目前正在尝试做的,这在浏览器中工作正常但不在android上.
navigator.geolocation.getCurrentPosition(function(pos) {}, function(err) {
alert('We were unable to determine your location, please turn on your GPS/Location services');
});
Run Code Online (Sandbox Code Playgroud)
另一件事是有人知道是否有可能提示用Ionic/cordova开启GPS?
有人有任何想法吗?
Muh*_*sin 17
请添加此插件,
cordova plugin add cordova.plugins.diagnostic
Run Code Online (Sandbox Code Playgroud)
1.确定是否有人在Ionic/Cordova中关闭了他的GPS
Contoller
if (window.cordova) {
cordova.plugins.diagnostic.isLocationEnabled(function(enabled) {
alert("Location is " + (enabled ? "enabled" : "disabled"));
}, function(error) {
alert("The following error occurred: " + error);
});
}
Run Code Online (Sandbox Code Playgroud)
2.提示打开GPS
Controller
if (window.cordova) {
cordova.plugins.diagnostic.switchToLocationSettings();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8581 次 |
| 最近记录: |