1

It is necessary that when you click on the map, the address (street, house, etc.) is displayed. Now when you click, I have latitude and longitude.

How to implement this? Send request with latitude and longitude?

1 Answer 1

0

You can use the reverse geocoding from https://nominatim.org/release-docs/develop/api/Reverse/ or https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse.

Example using openstreetmap api:

const reverseGeocoding = await axios.get(`https://nominatim.openstreetmap.org/reverse?lat=${latitude}&lon=${longitude}&format=jsonv2`,);

const { city, postcode, road, suburb, town } = reverseGeocoding.data.address;

const displayLocation = `${road}, ${suburb ? `${suburb},` : ''}${postcode}, ${city || town}`,

Not the answer you're looking for? Browse other questions tagged or ask your own question.