I am connecting to the Google Maps API with PHP to geocode some starting points for a rental station locator application.
These starting points do not have to be exact addresses; city ββnames are enough. As a starting point, answers to geocoding with accuracy equal to or greater than 4 (city / locality), and the search for surrounding rental stations are used.
The application should work in Germany. When a local name is ambiguous (i.e. there is more than one place for that name), I want to display a list of features.
This is not a problem in general: if you do an ambiguous search, the Google XML output returns a list of <PlaceMark> elements, not just one.
Obviously, I need to shift the geocoding towards Germany, therefore, if someone enters a zip code or the name of a place that exists in other countries, only hits in Germany actually appear.
I thought I could achieve this by adding , de or , Deutschland to the search query. This works mostly fine, but in some cases produces strange and unbearable results.
There are, for example, 27 settlements in Germany called Neustadt . ( Wikipedia )
When I search only Neustadt :
http://maps.google.com/maps/geo/hl=de&output=xml&key=xyz&q=Neustadt
I get at least six of them that I could live with (maybe others are not included, or parts of another locality or something else).
However, when I search for Neustadt, de or Neustadt, Deutschland , or Neustadt, Germany , I get only one of twenty-seven locations, for no apparent reason - this is not the largest, most accuracy are accurate and do not have other unique characteristics.
Does anyone know why this is so, and what can I do about it?
I tried the region parameter, but to no avail - when I do not use , de , zip codes (for example, 50825 will be allowed to their American colleagues, not German.
My current workaround is to add the name of the country when the input is only numeric, and otherwise filter out only the results in it, but that sounds awful kludgy. Does anyone know a better way?