I'm building a web app that actually allow the user to see the marker for a selected a address. Also, I'm trying to build a feature that when a user drag the pin it should update the lat, lang value. Though I was able to get the current location of a user using the code below but the big question is How can I get the new lat, lang of the user whenever the user drags the pin anywhere
? Any response is much appreciated, thank you. Btw, I am using this addon https://github.com/asennikov/ember-g-map
/component.js
getCurrentLocation() {
if (navigator.geolocation) {
console.log(navigator.geolocation);
navigator.geolocation.getCurrentPosition((position) => {
this.set('selectedLatitude', position.coords.latitude);
this.set('selectedLongitude', position.coords.longitude);
this.set('hasSelectedFromAutoCompleteOrCurrentLocation', true);
this.reverseGeoCode(position.coords.latitude, position.coords.longitude).then((resp) => {
this.set('formattedAddress', resp);
}).catch((error) => console.log(error));
});
} else {
console.log("Your browser doesn't support geo location");
}
},
/template.hbs
Aucun commentaire:
Enregistrer un commentaire