html geolocation
snippet in html

html geolocation

user4478

//Click the button to get your coordinates
<button onclick="getLocation()">Try It</button>
<script>
function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else { 
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}
function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude + 
  "<br>Longitude: " + position.coords.longitude;
}
</script>

geolocation javascript

user1578


 function showPosition(position) {
  var latlon = position.coords.latitude + "," + position.coords.longitude;

  var img_url = "https://maps.googleapis.com/maps/api/staticmap?center=

   "+latlon+"&zoom=14&size=400x300&sensor=false&key=YOUR_KEY";


   document.getElementById("mapholder").innerHTML = "<img src='"+img_url+"'>";

 }