在你的情况下,我瘦你必须创建一个新的JavaScript和过去我的下面的代码。并给您的这个新的JavaScript链接在您的index.html和链接cordova.js和添加地理位置插件。好吧,并复制我的代码。
在您的index.html
和
变种拉提= localStorage.getItem( 'masterLati');
var Long = localStorage.getItem('masterLong');
使用这个,如果你暂停你的应用程序仍然在应用程序背景此代码将工作。你仍然有任何困惑,然后给我发消息。
var watchID = null;
$(function() {
var options = { timeout: 50000 };
watchID = navigator.geolocation.watchPosition(onSuccess, onError, options);
});
function onSuccess(position) {
alert(position.coords.latitude);
alert(position.coords.longitude);
localStorage.setItem('masterLati',position.coords.latitude);
localStorage.setItem('masterLong',position.coords.longitude);
}
function onError(error) {
alert('Google Location Service is currently disable. Please On Google Location Service and Restart App.');
}