Geolocation and google maps


#1

Hi everyone.
I am new to using natives, and I am encountering a problem with google map. In my app, the user press on any location in the google map and a marker will be added in the map, my problem is that I don’t know how to get the longitude and the latitude when the marker is added. I followed a tutorial to get the map displayed with my current location but I want to get the info of the position(longitude and latitude) when the user add a marker to save them in firebase and display them then to other users.

the add marker location function is: (the geolocation native is added but I have no idea how to make them work together)

addMarker() {

let marker = new google.maps.Marker({
  map: this.map,
  animation: google.maps.Animation.DROP,
  position: this.map.getCenter()
});

let content = "<p>This is your current position !</p>";
this.addInfoWindow(marker, content);
console.log(content)

}
addInfoWindow(marker, content){

let infoWindow = new google.maps.InfoWindow({
  content: content
});

google.maps.event.addListener(marker, 'click', () => {
  infoWindow.open(this.map, marker);
});

}


#2

Read this blog https://codeburst.io/native-google-maps-and-geolocation-ionic-fe635a00249d


#3

Use the marker object that is returned to get the location e.g map.addMarker().then((marker: Marker) => {
marker.getPosition().then(res => {
console.log(res.lat)
});
})