How to convert latitude and longitude to street address.please help.below my code

this.watch = this.geolocation.watchPosition(options).filter((p: any) => p.code === undefined).subscribe((position: Geoposition) => {

console.log(position);

// Run update inside of Angular’s zone
this.zone.run(() => {
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
alert(this.lat);
alert(this.lng);
});

});

Use google maps reverse geocoding, something along the lines of…

let geocoder = new google.maps.Geocoder;
let latlng = {lat: this.lat, lng: this.lng};
geocoder.geocode({'location': latlng}, (results, status) => {
   console.log(results); // read data from here
   console.log(status);
});

3 Likes

@michaelo actually am new in ionic where use this code ?can i send my whole code to you.

this is more of a javascript problem tbh, you can post a snippet of your code here and I can try point you to where you may have missed out

@michaelo