Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain longitude and latitude for a street address programmatically (and legally)

Supposedly, it is possible to get this from Google Maps or some such service. (US addresses only is not good enough.)

like image 270
Ola Eldøy Avatar asked Oct 01 '08 16:10

Ola Eldøy


People also ask

How do I find the latitude and longitude of a street address?

On the Google Maps app, you can't pull up a context menu. To find the address for your coordinates, hold your finger down over the red pin that shows your coordinates. Then, after 1-3 seconds, the address will pop up on the bottom of your screen.

How do I find the latitude and longitude of a zip code using Google API?

(We could force the locale – that the postcode is in the SG– by using"http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=POSTCODE,SG".) Simply call this url in a jquery-ajax and you will get the lat long in result.

Can Google Maps find latitude longitude?

To find a location using its latitude and longitude on any device, just open Google Maps. On your phone or tablet, start the Google Maps app. On a computer, go to Google Maps in a browser. Then enter the latitude and longitude values in the search field — the same one you would ordinarily use to enter an address.


2 Answers

The term you're looking for is geocoding and yes Google does provide this service.

  • New V3 API: http://code.google.com/apis/maps/documentation/geocoding/

  • Old V2 API: http://code.google.com/apis/maps/documentation/services.html#Geocoding

like image 92
Sijin Avatar answered Oct 03 '22 10:10

Sijin


In addition to the aforementioned Google geocoding web service, there is also a competing service provided by Yahoo. In a recent project where geocoding is done with user interaction, I included support for both. The reason is I have found that, especially outside the U.S., their handling of more obscure locations varies widely. Sometimes Google will have the best answer, sometimes Yahoo.

One gotcha to be aware of: if Google really thinks they don't know where your place is, they will return a 602 error indicating failure. Yahoo, on the other hand, if it can peel out a city/province/state/etc out of your bad address, will return the location of the center of that town. So you do have to pay attention to the results you get to see if they are really what you want. There are ancillary fields in some results that tell you about this: Yahoo calls this field "precision" and Google calls it "accuracy".

like image 37
Tim Farley Avatar answered Oct 03 '22 11:10

Tim Farley