0

The problem is the script on my personal site continues to show "Unable to retrieve your location" If anyone can help it will be much appreciated. My personal site http://geolyft.com https://jsfiddle.net/yotzincastrejon/z29esxf3/4/

<!DOCTYPE html>
<html>
<body>


<p><button onclick="geoFindMe()">Show my location</button></p>
<div id="out"></div>

<script>
function geoFindMe() {
  var output = document.getElementById("out");

  if (!navigator.geolocation){
    output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
    return;
  }

  function success(position) {
    var latitude  = position.coords.latitude;
    var longitude = position.coords.longitude;

    output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>';

    var img = new Image();
    img.src = "https://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude + "&zoom=13&size=300x300&sensor=false";

    output.appendChild(img);
  }

  function error() {
    output.innerHTML = "Unable to retrieve your location";
  }

  output.innerHTML = "<p>Locating…</p>";

  navigator.geolocation.getCurrentPosition(success, error);
}

</script>
</body>
</html>
  • Clear your setting, it looks like you may have blocked your domain then from accessing your locaiton. https://support.google.com/chrome/answer/142065?hl=en – Pogrindis Dec 19 '16 at 17:44
  • 2
    I noticed in Chrome recently calls not made over https (SSL) won't allow you to send a location. I recently had to purchase an SSL just to get my location showing on a Google Map. – Djave Dec 19 '16 at 17:45
  • what browser do you use? if Chrome, open DevTools (F12) on the left of the CloseButton (x) choose Customize (three dots button) -> more tools -> sensors -> try to set geolocation manually – Paweł Dec 19 '16 at 17:52
  • I'm going to get a SSL. I read in the console looking at my website that getCurrentPosition no longer works on insecure origins – Yotzin Castrejon Dec 19 '16 at 18:02

0 Answers0