Hello,
I use this plugin http://ngcordova.com/docs/plugins/geolocation/ to geolocalize the user in my app.
Just before, i used the watchPosition(options) method but this way make my device (iphone 5S) very hot.
So i’ve decided to use the method getCurrentPosition(options) in a $interval every 30 seconds…
But the heat is always here…
I’m pretty sure this is caused by the geolocation plugin because CPU usage is never over 10%, sometime 50% when i scroll a collection-repeat, but the heat still here when i do nothing.
So my question is, is there a better way to geolocalize my users without melt their phones ?
Here is my geolocation service, maybe it could help:
angular.module('starter').factory('GeolocationService', function(
$rootScope,
$cordovaGeolocation,
$interval
) {
var geolocInterval = undefined;
var methods = {
stopGeolocation: function(){
console.log("Geolocation stopped");
if (angular.isDefined(geolocInterval)) {
$interval.cancel(geolocInterval);
geolocInterval = undefined;
}
},
startGeolocation: function(){
console.log("Geolocation started");
geolocInterval = $interval(function () {
$cordovaGeolocation.getCurrentPosition({
timeout : 10000,
enableHighAccuracy: false,
maximumAge: 5 * 60 * 1000
}).then(function (position) {
console.error("Position retreived: lat:" + position.coords.latitude +", lng:" + position.coords.longitude);
$rootScope.lat = position.coords.latitude
$rootScope.lng = position.coords.longitude
}, function(err) {
console.error(err);
});
}, 20000);
}
}
return methods;
})
`
Thank you very much for your help