YulongW
9/15/2015 - 7:00 PM

Get GeoLocation Info from HTML5 Geolocation API and Google Geolocation API

Get GeoLocation Info from HTML5 Geolocation API and Google Geolocation API

window.navigator.geolocation.getCurrentPosition(function(pos) {
  console.log(pos);	// position info from HTML5 Geo API
  $.getJSON(  
    'http://maps.googleapis.com/maps/api/geocode/json?latlng=' 
      + pos.coords.latitude + ',' + pos.coords.longitude+'&sensor=true', 
    function( data ) {
      console.log(data);  // more info from Google Geo API from coordinates
    }
  );
})