Not showing geo location

Posted by Raja Kadali on 23-Feb-2016 04:31

HI

Need Help in Displaying , geo-location on map.

I have a Lat Long info. How can i show it in a map.

I have tried using this JavaScript as work around. But with no result


function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: -34.397, lng: 150.644},
    zoom: 6
  });
  var infoWindow = new google.maps.InfoWindow({map: map});

  // Try HTML5 geolocation.
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var pos = {
        lat: position.coords.latitude,
        lng: position.coords.longitude
      };

      infoWindow.setPosition(pos);
      infoWindow.setContent('Location found.');
      map.setCenter(pos);
    }, function() {
      handleLocationError(true, infoWindow, map.getCenter());
    });
  } else {
    // Browser doesn't support Geolocation
    handleLocationError(false, infoWindow, map.getCenter());
  }
}

function handleLocationError(browserHasGeolocation, infoWindow, pos) {
  infoWindow.setPosition(pos);
  infoWindow.setContent(browserHasGeolocation ?
                        'Error: The Geolocation service failed.' :
                        'Error: Your browser doesn\'t support geolocation.');
}

All Replies

Posted by Karthikeyan Bhaskaran on 23-Feb-2016 06:44

Hi Raja,

Where are you using this in Rollbase?

Is it working (along with some supporting HTML) as a plain HTML/JS page, say, on jsfiddle?

Do you see any errors in the Developer Tools Console?

 

Thanks, Karthikeyan

This thread is closed