Archive for the ‘Uncategorized’ Category

google geocoding service

Tuesday, January 26th, 2010

google has a great geocoding service. it is possible to find out the latitude and the longitude of an address and the opposite is possible too. for a little project i had to get the coordinates of an address an user entered. if he enters only the city it might be possible that multiple cities exist and the geocoding service returns a list of all cities with details. for example if i search for “stein” (http://maps.google.com/maps/geo?q=stein&key=key) multiple entries in germany an multiple entries in austria are returned. the user is then asked to pick the proper location. i need this project only for germany so i add a postfix to the querystrings like “stein, germany” (http://maps.google.com/maps/geo?q=stein, germany&key=key). now there is only one result for germany instead of the multiples like before. i tried it with other cities and it looks like a general problem. even when i use the gl parameter like &gl=de instead of appending “, germany” to the query string it won’t work properly.

i have no idea why this happens and no idea how to fix this. it’s probably possible to “fix” this problem by using a viewport. so you can instruct to return only cities from the given bounding box. it’s not a really good solution but beter than nothing.