let button = document.getElementById(“button”);
button.addEventListener(“click”, () => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
// Set latitude and longitude with the current position
let latitude = position.coords.latitude;
let longitude = position.coords.longitude;
// get exact location name
let cityName = Here how i find the city name
**// here i want to get the exact location or city name without using any Other API**
console.log(latitude)
console.log(longitude)
});
} else {
console.log("Geolocation is not supported by this browser.");
}
});
New contributor
Anuraga Sahoo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.