Hello !
I am actually in full dev of an App wich have a map integration.
Actually, I am trying to get the position of the user, and dynamically refresh the position of the user while he walks.
I am using mdg:geolocalisation to get the position of the user… But I HAVE To get the position inside a service, and the only way to get the position through mdg:geolocation is inside a helpers…
Hi @rollins i have a lot of experience using Geo stuff on Javascript, i dont understand what is a Service/Factory. Its an API ? a Method ?. Im confused.
But… getting away from that you can do this to set the Location:
someFn() {
const geolocation = (
canUseDOM && navigator.geolocation || {
getCurrentPosition: (success, failure) => {
alert(`Your browser dont support this feature.`);
},
}
);
geolocation.getCurrentPosition((position) => {
console.log(position.coords.latitude)
console.log(position.coords.longitude)
}, (reason) => {
//if there is an error set some default lat,lng
// or manage errors...
alert(`Error: (${ reason }).`);
});
}
That could work in JS… But I’m currently working on AngularJS. Arg. I forgot to tell that. I’m ashamed.
Anyway.
A service/Factory is a simplification of comunication between controller an DOM. But if you don’t use AngularJS, I doubt that you can help me through this !