0

All I want is to get the geocode for the given address.Im doing it in Java. Earlier I used the url like

"http://maps.google.com/maps/geo?q=" +URLEncoder.encode(addrToFind, ENCODING) + "&output=csv&key=" + MyKEY

it returned me comma separated result like (status_code,lat,lng,precision) Then for some alien reasons this url started giving me status code 610(invalid api key) I regenerated the Browser key from Google but in vain.

Then i got another way to geocode the new url just trucated the 'geo' word in previous url

"http://maps.google.com/maps?q="+URLEncoder.encode(postcode, "UTF-8");

I extracted latitude and longitude from end result of this url but i noticed that this url gives me the whole html page as its response while all i want is just lat lng and precision.

Then I finally found a whole new url "//maps.googleapis.com/maps/api/geocode/json?sensor=false&address="+address_to_geocode; This gives me the Json response from which i extracted required information.This url doesnt ask for api key too. What is the correct way of doing Geocod from above 3 or is there any other optimal way ?

Michael Geary
  • 28,450
  • 9
  • 65
  • 75
user1759484
  • 43
  • 3
  • 7

1 Answers1

0

For the first URL, see this, that is the deprecated v2 Geocoding API, its lifetime has been extended, but it is not recommended for new development.

The second URL is a Google Map, and is not documented for use as a Geocoder.

The current v3 Geocoding API is the one you should be using.

Community
  • 1
  • 1
geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • Thanks.So the third url which im using is the V3. Just out of curiosity what about the second url i specified in my question is it one of the ways or is just a bad practice ? – user1759484 Apr 06 '13 at 05:54