Question

I have created an application using intel XDK that determines the current location on a map. However I can not find any documentation or tutorials on how to convert the latitude and longitude to an address. Does anyone have any useful links or guidancce?

Thanks

Was it helpful?

Solution

Intel XDK does not have APIs for converting lat/lng to address, there are other reverse geocoding services, you can use google maps reverse geocoding to convert latitude/longitude to address, more information here, example below:

include google maps api script:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>

here is reverse geocoding method:

function reverseGeocode(lat, lng){
  var latlng = new google.maps.LatLng(lat, lng);
  var geocoder = new google.maps.Geocoder();
  geocoder.geocode({'latLng': latlng}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
      if (results[1]) {
        alert(results[1].formatted_address);
      } else {
        alert('No results found');
      }
    } else {
      alert('Geocoder failed due to: ' + status);
    }
  });
}

you can get address by running: reverseGeocode(45, -122)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top