After many hours of work on this, I was not able to consistently extract the apartment / room / under-premise. Having this part was more important than being able to specifically separate it, so I went around it using this.
var componentForm = { locality: 'long_name', administrative_area_level_1: 'short_name', country: 'long_name', postal_code: 'short_name' }; function fillInAddress(place) { for (var component in componentForm) { document.getElementById(component).value = ''; document.getElementById(component).disabled = false; } for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; document.getElementById(addressType).value = val; } } var parts = $("#searchField").val().split(","); $("#street_number").val(parts[0]); }
I extracted information from autocomplete as usual, although I missed street_number and route. Then he performed a simple auto-completion split after selecting and used the first portion, returning the address of the street as a whole (including factory / flat / room and street name).
This work has given me results that work well for what I need. Good luck
source share