I need to convert a lat/long coordinates to a address. I could use the Google Maps API but I would need a XML Response.
I have looked at Convert Lat Long to address Google Maps ApiV2 but I need to be able to do this in JavaScript.
My Question is: How To Convert a Lat/Long coordinate to an address?
Asked
Active
Viewed 3.1k times
3

Community
- 1
- 1

user2574350
- 1,383
- 3
- 10
- 7
3 Answers
2
You can use GeoNames' FindNearestAddress.
It takes a latitude and longitude parameter and returns the nearest address in XML format.
From the 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>

Jeroen Vannevel
- 43,651
- 22
- 107
- 170
-
Do you know if there is any API that can give a closer address? – user2574350 Jul 11 '13 at 21:29
-
That's all I know, sorry. – Jeroen Vannevel Jul 11 '13 at 21:29
-
Sorry, I didn't see that it game the street number, Thanks Again – user2574350 Jul 11 '13 at 21:33
2
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# it works me

Thamaraiselvam
- 6,961
- 8
- 45
- 71
0
this is an alternate method. U can use the following google api for getting the address as json script .You can parse the same in your application to get the address.

Jobin Philip
- 1
- 1
-
remember to replace the origin and destination with your coordinates. Hopes it will help you. :-) – Jobin Philip Sep 11 '14 at 09:29