Incorrect geocoding when suite number included in address

Created on 20 January 2023, almost 2 years ago
Updated 23 January 2023, almost 2 years ago

We're geocoding from an address field, using the GoogleMapsBusiness service. The following address:

408 Washington Avenue
Suite 100
West Plains, MO 65775
United States

...results in incorrect coordinates: 29.765458, -95.361446 (that's a location in Houston, TX).

If I remove the suite number:

408 Washington Avenue
West Plains, MO 65775
United States

...I get the correct coordinates: 36.730356, -91.852213

If I abbreviate "Suite" to "Ste" I get the same incorrect result. If I use "#100" instead, I get the correct result.

Searching for the full address on Google Maps produces the full result -- but I did notice that the first time I searched, when I had entered "408 Washington Avenue Suite 100" the autocomplete suggestion results started with a location in Texas. (After I completed the full search once, the autocomplete switched to Missouri locations.)

I noticed a similar issue reported several years ago for a 7.x version.

🐛 Bug report
Status

Postponed: needs info

Version

3.31

Component

Code

Created by

🇺🇸United States wrd-oaitsd

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Postponed: needs info almost 2 years ago
  • 🇮🇹Italy itamair

    Thanks for reporting this @wrd-oaitsd...
    could you be more specific (?) when you state:

    I noticed a similar problem reported several years ago for a 7.x release.

    pointing to/linking to the specific issue you are referring to, to give us more context.

    How can we / can we assume that this is actually a bug of the Drupal Geocoder module?
    From what you describe it seems rather a problem (or a specific result) of the GoogleMapsBusiness geocoder service (@see https://github.com/geocoder-php/Geocoder#world),
    and not something to input to the specific Drupal Geocoder module provider (which is just a wrapper/host of the former, via https://github.com/geocoder-php/google-maps-provider) .

    Or do you have the clear idea that all this depends on the Drupal Geocoder provider GoogleMapsBusiness? How can you prove it?

    Have you also checked other geocoding providers as a useful comparison?

  • 🇺🇸United States wrd-oaitsd

    I included the link to the other issue in the "Related issues", but to include it here as well, it can be found at: https://www.drupal.org/project/geocoder/issues/3059514

    Testing out Google's geocoding example code on jsfiddle:
    https://jsfiddle.net/gh/get/library/pure/googlemaps/js-samples/tree/mast...

    ...produces the same result if I input the address like so:

    Input: 408 Washington Avenue Suite 100 West Plains, MO 65775 United States

    {
      "results": [
        {
          "address_components": [
            {
              "long_name": "100",
              "short_name": "100",
              "types": [
                "subpremise"
              ]
            },
            {
              "long_name": "408",
              "short_name": "408",
              "types": [
                "street_number"
              ]
            },
            {
              "long_name": "Washington Avenue",
              "short_name": "Washington Ave",
              "types": [
                "route"
              ]
            },
            {
              "long_name": "Downtown Houston",
              "short_name": "Downtown Houston",
              "types": [
                "neighborhood",
                "political"
              ]
            },
            {
              "long_name": "Houston",
              "short_name": "Houston",
              "types": [
                "locality",
                "political"
              ]
            },
            {
              "long_name": "Harris County",
              "short_name": "Harris County",
              "types": [
                "administrative_area_level_2",
                "political"
              ]
            },
            {
              "long_name": "Texas",
              "short_name": "TX",
              "types": [
                "administrative_area_level_1",
                "political"
              ]
            },
            {
              "long_name": "United States",
              "short_name": "US",
              "types": [
                "country",
                "political"
              ]
            },
            {
              "long_name": "77002",
              "short_name": "77002",
              "types": [
                "postal_code"
              ]
            }
          ],
          "formatted_address": "408 Washington Ave #100, Houston, TX 77002, USA",
          "geometry": {
            "location": {
              "lat": 29.7654582,
              "lng": -95.3614463
            },
            "location_type": "RANGE_INTERPOLATED",
            "viewport": {
              "south": 29.7640738197085,
              "west": -95.3627994802915,
              "north": 29.7667717802915,
              "east": -95.3601015197085
            }
          },
          "place_id": "Ei80MDggV2FzaGluZ3RvbiBBdmUgIzEwMCwgSG91c3RvbiwgVFggNzcwMDIsIFVTQSI6GjgKMRIvChQKEgnJRi06Lr9AhhGV09IgdaweuhCYAyoUChIJM09JeVPHQIYRFNRygKFHGo0SAzEwMA",
          "types": [
            "subpremise"
          ]
        }
      ]
    }

    If I add a comma after the address and before the city name, the result is correct:

    Input: 408 Washington Avenue Suite 100, West Plains, MO 65775 United States

    {
      "results": [
        {
          "address_components": [
            {
              "long_name": "100",
              "short_name": "100",
              "types": [
                "subpremise"
              ]
            },
            {
              "long_name": "408",
              "short_name": "408",
              "types": [
                "street_number"
              ]
            },
            {
              "long_name": "Washington Avenue",
              "short_name": "Washington Ave",
              "types": [
                "route"
              ]
            },
            {
              "long_name": "Downtown Houston",
              "short_name": "Downtown Houston",
              "types": [
                "neighborhood",
                "political"
              ]
            },
            {
              "long_name": "Houston",
              "short_name": "Houston",
              "types": [
                "locality",
                "political"
              ]
            },
            {
              "long_name": "Harris County",
              "short_name": "Harris County",
              "types": [
                "administrative_area_level_2",
                "political"
              ]
            },
            {
              "long_name": "Texas",
              "short_name": "TX",
              "types": [
                "administrative_area_level_1",
                "political"
              ]
            },
            {
              "long_name": "United States",
              "short_name": "US",
              "types": [
                "country",
                "political"
              ]
            },
            {
              "long_name": "77002",
              "short_name": "77002",
              "types": [
                "postal_code"
              ]
            }
          ],
          "formatted_address": "408 Washington Ave #100, Houston, TX 77002, USA",
          "geometry": {
            "location": {
              "lat": 29.7654582,
              "lng": -95.3614463
            },
            "location_type": "RANGE_INTERPOLATED",
            "viewport": {
              "south": 29.7640738197085,
              "west": -95.3627994802915,
              "north": 29.7667717802915,
              "east": -95.3601015197085
            }
          },
          "place_id": "Ei80MDggV2FzaGluZ3RvbiBBdmUgIzEwMCwgSG91c3RvbiwgVFggNzcwMDIsIFVTQSI6GjgKMRIvChQKEgnJRi06Lr9AhhGV09IgdaweuhCYAyoUChIJM09JeVPHQIYRFNRygKFHGo0SAzEwMA",
          "types": [
            "subpremise"
          ]
        }
      ]
    }

    I'll see if I can test with a different geocoder and see if the result is different.

  • 🇺🇸United States wrd-oaitsd

    I'm getting the same result when using the Nominatim service.

Production build 0.71.5 2024