Get Current Location Coordinates, GeoCodes , Google Maps Link
First Allow Location Access, then using geolocation API we can get Latitude and Longitude
JavaScript for Location Coordinates
/*
<div id="locationCoords"></div>
*/
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(displayCoords);
}
else{
document.getElementById("locationCoords").innerHTML=`
<p>If you are seeing this, you blocked location access. Go to site settings and enable location access and reload the page</p>`;
}
function displayCoords(position){
console.log(position);
document.getElementById("locationCoords").innerHTML=`
<ul>
<li>Latitude : ${position.coords.latitude}</li>
<li>Longitude : ${position.coords.longitude}</li>
<li>Geocodes : ${position.coords.latitude},${position.coords.longitude} </li>
<li>Google Maps Link : <a class="normalLink" href="https://www.google.com/maps/search/${position.coords.latitude},${position.coords.longitude}" target="_blanc">View on Maps</a></li>
</ul>
`;
}
ALTERNATE TITLES