I created a project in ionic and I would like that when the user clicked on "save location", the position where he left the marker was saved in his user profile in firebase, however, I have no idea how to get the latitude and the length of the marker and save in the firebase, any solution ???
loadMap(){
this.geolocation.getCurrentPosition().then((position)=> {
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); // pegando localização atual
let mapOptions = { //opções do mapa
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disabledZoomDoubleClick: true,
fullscreenControl: true
}
this.map = new google.maps.Map(document.getElementById('map'), mapOptions); //adicionando mapa com as opçoes
let marker = new google.maps.Marker({ //Adicionando marcador
map: this.map,
animation: google.maps.Animation.DROP,
position: latLng,
draggable: true,
});
let data = {
lat: null,
lng: null
}
google.maps.event.addListener(marker, 'click', function(event){ //Aciona quando o usuario clica no marcador
data.lat = event.latLng.lat();
data.lng = event.latLng.lng();
});
}, (error) => {
console.log(error);
});
}
addFirebase(){ //aqui é a função do botão que vai salvar a localização
}