gpt4 book ai didi

angularjs - Uncaught ReferenceError : backgroundGeolocation is not defined cordova-plugin-mauron85-background-geolocation

转载 作者:行者123 更新时间:2023-12-02 22:31:22 26 4
gpt4 key购买 nike

我是 AngularJS 和 Ionic 的新手。我正在 Ionic(版本 1)中构建一个应用程序,它将在后台收集设备的 GPS 位置。我正在尝试使用cordova-plugin-mauron85-background-geolocation用于此目的的插件。但我收到错误Uncaught ReferenceError:backgroundGeolocation未定义。

我的app.js

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'firebase', 'ngMaterial'])


.factory('BackgroundGeolocationService', ['$q', '$http', function ($q, $http) {
var callbackFn = function(location) {
$http({
//request options to send data to server
});
backgroundGeolocation.finish();
},

failureFn = function(error) {
console.log('BackgroundGeoLocation error ' + JSON.stringify(error));
},

//Enable background geolocation
start = function () {
//save settings (background tracking is enabled) in local storage
window.localStorage.setItem('bgGPS', 1);

//...........ERROR IS ON THE FOLLOWING LINE.........
backgroundGeolocation.configure(callbackFn, failureFn, {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
locationService: 'ANDROID_DISTANCE_FILTER',
debug: false,
stopOnTerminate: false
});

backgroundGeolocation.start();
};

return {
start: start,

// Initialize service and enable background geolocation by default
init: function () {
var bgGPS = window.localStorage.getItem('bgGPS');
if (bgGPS == 1 || bgGPS == null) {
start();
}
},

// Stop data tracking
stop: function () {
window.localStorage.setItem('bgGPS', 0);
backgroundGeolocation.stop();
}
}
}])


.run(function($ionicPlatform, BackgroundGeolocationService) {
$ionicPlatform.ready(function() {
BackgroundGeolocationService.init();
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);

}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})

我在这里缺少什么?

最佳答案

该插件是exposed via the backgroundGeolocation global namespace但您将其引用为 backgroundGeoLocation

请注意区别:您使用的是大写 L。Javascript 区分大小写,因此您需要注意大小写。

关于angularjs - Uncaught ReferenceError : backgroundGeolocation is not defined cordova-plugin-mauron85-background-geolocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42897174/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com