Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 790883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:44:48+00:00 2026-05-14T21:44:48+00:00

I’m connecting to the Google Maps API from PHP to geocode some starting points

  • 0

I’m connecting to the Google Maps API from PHP to geocode some starting points for a rental station locator application.

Those starting points don’t have to be exact addresses; city names are enough. Geocoding responses with an accuracy equal to or grater than 4 (city/locality level) are used as starting points, and the surrounding rental stations searched.

The application is supposed to work in Germany. When a locality name is ambiguous (i.e. there are more than one place of that name) I want to display a list of possibilities.

That is not a problem in general: If you make an ambiguous search, Google’s XML output returns a list of <PlaceMark> elements instead of just one.

Obviously, I need to bias the geocoding towards Germany, so if somebody enters a postcode or the name of a locality that exists in other countries as well, only hits in Germany actually come up.

I thought I could achieve this by adding , de or , Deutschland to the search query. This works mostly fine, but produces bizarre and intolerable results in some cases.

There are, for example, 27 localities in Germany named Neustadt. (Wikipedia)

When I search for Neustadt alone:

http://maps.google.com/maps/geo/hl=de&output=xml&key=xyz&q=Neustadt

I get at least six of them, which I could live with (it could be that the others are not incorporated, or parts of a different locality, or whatever).

When, however, I search for Neustadt, de, or Neustadt, Deutschland, or Neustadt, Germany, I get only one of the twenty-seven localities, for no apparent reason – it is not the biggest, nor is it the most accuracy accurate, nor does it have any other unique characteristics.

Does anybody know why this is, and what I can do about it?

I tried the region parameter but to no avail – when I do not use , de, postcodes (like 50825 will be resolved to their US counterparts, not the german ones.

My current workaround idea is to add the country name when the input is numeric only, and otherwise filter out only german results, but this sounds awfully kludgy. Does anybody know a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:44:49+00:00Added an answer on May 14, 2026 at 9:44 pm

    This is definitely not an exhaustive answer, but just a few notes:

    1. You are using the old V2 version of the Geocoding API, which Google have recently deprecated in favour of the new V3 API. Google suggests to use the new service from now on, and while I have no real experience with the new version, it seems that they have improved the service on various points, especially with the structure of the response. You do not need an API key to use the new service, and you simply need to use a slightly different URL:

      http://maps.google.com/maps/api/geocode/xml?address=Neustadt&sensor=false

    2. You mentioned that you were filtering for placemarks on their accuracy property. Note that this field does not appear anymore in the results of the new Geocoding API, but in any case, I think it was still not very reliable in the old API.

    3. You may want to try to use the bounds and region parameters of the new API, but I still doubt that they will solve your problem.

    I believe that the Google Geocoder is a great tool for when you give it a full address in at least a “street, locality, country” format, and it is also very reliable in other formats when it doesn’t have to deal with any ambiguities (Geocoding “London, UK” always worked for me).

    However, in your case, I would really consider pre-computing all the coordinates of each German locality and simply handle the geocoding yourself from within your database. I think this is quite feasible especially since your application is localized to just one country. Each town in the Wikipedia “List of German Towns” appears to have the coordinates stored inside a neat little <span> which looks very easy to parse:

    <span class="geo">47.84556; 8.85167</span>
    

    There are sixteen Neustadts in that list, which may be better than Google’s six 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 431k
  • Answers 431k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Libraries are meant to provide reusable functionality for your application,… May 15, 2026 at 2:11 pm
  • Editorial Team
    Editorial Team added an answer I was able to resolve this and improve the code… May 15, 2026 at 2:11 pm
  • Editorial Team
    Editorial Team added an answer You should call start() instead of run(). From the Documentation:… May 15, 2026 at 2:11 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.