Latitude / Longitude Conversion for Addressing

I need to convert lat / long coordinates to address. I could use the Google Maps API, but I need an XML response. I looked at Convert Lat Long for the Google Maps ApiV2 address , but I need to do this in JavaScript.
My question is: how to convert Lat / Long coordinate to address?

0
javascript api google-maps-api-3
Jul 11 '13 at 21:20
source share
3 answers

You can use GeoNames FindNearestAddress .

A latitude and longitude parameter is required and returns the nearest address in XML format.

From an example:

http://api.geonames.org/findNearestAddress?lat=37.451&lng=-122.18&username=demo 

 <address> <street>Roble Ave</street> <mtfcc>S1400</mtfcc> <streetNumber>649</streetNumber> <lat>37.45127</lat> <lng>-122.18032</lng> <distance>0.04</distance> <postalcode>94025</postalcode> <placename>Menlo Park</placename> <adminCode2>081</adminCode2> <adminName2>San Mateo</adminName2> <adminCode1>CA</adminCode1> <adminName1>California</adminName1> <countryCode>US</countryCode> </address> </geonames> 
+1
Jul 11 '13 at 21:24
source share
 var geocoder = new google.maps.Geocoder(); // create a geocoder object var location = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); // turn coordinates into an object geocoder.geocode({'latLng': location}, function (results, status) { if(status == google.maps.GeocoderStatus.OK) { // if geocode success var add=results[0].formatted_address; // if address found, pass to processing function document.write(add); 

source from https://gist.github.com/marchawkins/9406213/download# this works for me

+1
Jan 28 '15 at 11:39 on
source share

This is an alternative method. U can use the following google api to get the address as a json script. You can parse the same in your application to get the address.

https://maps.googleapis.com/maps/api/directions/json?origin=27.6325&destination=85.1453=end&sensor=false

0
Sep 11 '14 at 9:27
source share



All Articles