The Web Blinders logo

Programming

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

Get google map link current location

get geocodes online current location

get latitude,longitude online

google map get geocodes

javascript geocode api example

current location google map link

Need developers ?

if so, send a message.

thewebblinders@gmail.com

More Programming from our blog

SEARCH FOR ARTICLES