-1

So for my work i implemented a simple address search that uses Googles AutoComplete API. This has worked fine for sometime now but recently we ran into an issue with incorrect addresses coming into the system. I worked out the issue occurs when you search for an address with a unit number.

To replicate the issue. Enter any address here that has a unit number. https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete

Eg. 10/311 Flemington Street

Select any result that comes up. The marker on the map will now instead show '10 Flemington Street'. So the unit number becomes the street number.

Here's a modified snippet of my code showing where the street number is lost and the unit number becomes the street number.

var input = document.getElementById('address_autocomplete')
var options = {
    types: ['address'],
    componentRestrictions: {country: 'au'}
};
autocomplete = new google.maps.places.Autocomplete(input, options); 
autocomplete.addListener('place_changed', addressCallBack);

function addressCallBack() {
     var place = autocomplete.getPlace();
     console.log(place.address_components); //unit number is now the street number
} 

I haven't been able to find any info on this so if i am missing something i'd love to know or at least make this issue known.

For now i have a work around hack to keep things running.

EDIT - Here is a test i did demonstrating the issue

I searched a randomly selected address. I then selected the first result "23/45 Wantirna Road, Ringwood VIC, Australia", which means Unit 23, 45 Wantirna road (in Australia at least)

After selecting the search result, a request is then sent to googles place service to get further details on the location. https://maps.googleapis.com/maps/api/place/js/PlaceService.GetPlaceDetails

Response

/**/_xdc_._knjkfp && _xdc_._knjkfp( {
"html_attributions" : [],
"result" : {
  "address_components" : [
     {
        "long_name" : "23",
        "short_name" : "23",
        "types" : [ "street_number" ]
     },
     {
        "long_name" : "Wantirna Road",
        "short_name" : "Wantirna Rd",
        "types" : [ "route" ]
     },
     {
        "long_name" : "Ringwood",
        "short_name" : "Ringwood",
        "types" : [ "locality", "political" ]
     },
     {
        "long_name" : "Maroondah City",
        "short_name" : "Maroondah",
        "types" : [ "administrative_area_level_2", "political" ]
     },
     {
        "long_name" : "Victoria",
        "short_name" : "VIC",
        "types" : [ "administrative_area_level_1", "political" ]
     },
     {
        "long_name" : "Australia",
        "short_name" : "AU",
        "types" : [ "country", "political" ]
     },
     {
        "long_name" : "3134",
        "short_name" : "3134",
        "types" : [ "postal_code" ]
     }
  ],
  "geometry" : {
     "location" : {
        "lat" : -37.8187267,
        "lng" : 145.2275479
     },
     "viewport" : {
        "northeast" : {
           "lat" : -37.8173781197085,
           "lng" : 145.2287786302915
        },
        "southwest" : {
           "lat" : -37.82007608029149,
           "lng" : 145.2260806697085
        }
     }
  },
  "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
  "name" : "23 Wantirna Rd"
},
"status" : "OK"
}
)

As you can see the response shows that the address is now "23 Wantirna Road, Ringwood VIC, Australia". This means that the Place service is mistaking the unit number as the street number. The street number in this case just needs to be 45 not 23.

jeffez
  • 185
  • 1
  • 12
  • What about providing a **complete** example of where it fails (according to your tests), and what the expected result would be? What version of the API are you using? What makes you think it's a newly introduced bug? etc. – MrUpsidown Jul 10 '18 at 10:22
  • I have now added an example test i did which shows exactly where its failing. Thanks. – jeffez Jul 11 '18 at 00:58

1 Answers1

1

Unfortunately, a unit number format is not supported in place autocomplete at the moment. There is a feature request in the public issue tracker to add support for unit numbers/subpremises in Place autocomplete. You can see the feature request here:

https://issuetracker.google.com/issues/35830389

Note that it was reopened on June 29, 2018 and Google asks to star this feature request to figure out how many people are interested in this feature.

Also, very similar issue to yours was reported in https://issuetracker.google.com/issues/111166659, but Google marked it as a duplicate of the #35830389.

xomena
  • 31,125
  • 6
  • 88
  • 117
  • Thanks for the link. Interesting to note that the issue was reopened just a few days before i started seeing issues on our system. I'm not sure if something has changed. My code does allow for a unit number which i was getting from "place.address_components". – jeffez Jul 11 '18 at 01:53
  • I don't know how people can possibly use this feature for a shipping address without it? It actually encourages people to NOT include an apartment number. It then becomes a nightmare for the postal delivery carrier who has to figure out which unit it goes to. Unless you then run the address through the postal service website to verify if a unit is needed. Ugh. – Simon_Weaver Dec 31 '18 at 02:51