I'm using the places library with autocomplete and once the user selects an address from the list I parse the results to separate out street, city, state, etc.
var thestreet = place.address_components[0].short_name + ' ' + place.address_components[1].short_name; var thecity = place.address_components[2].short_name; var thestate = place.address_components[5].short_name; var thezip = (place.address_components[7] && place.address_components[7].short_name || ''); var thelat = place.geometry.location.lat(); var thelng = place.geometry.location.lng(); var theaddress = ''; var theaddress = place.address_components[0].short_name + ' ' + place.address_components[1].short_name + '<br>' + place.address_components[2].short_name + ', ' + place.address_components[5].short_name + ' ' + thezip + '<br>' + place.geometry.location.lat() + ', ' + place.geometry.location.lng(); The problem I'm having is that some addresses will return with the correct results and other have the results shifted. As an example, 126 Ardmore Way, Benicia, CA yields the correct results, but when I entered 35th Street, Sacramento, CA the street and city are correct but the state is returned as "US". The same thing happens with 28 Sherwood Way, Menlo Park, CA It isn't always just the State which is wrong as I've seen other fields shifted. Am I missing something about how the place.address_components array is created? -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/UTEaNo1iX7YJ. To post to this group, send email to google-maps-js-api-v3@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.