Merge pull request #734 from Safelite/feature/richardson/SSR-1294

google map update
This commit is contained in:
brich1212safe 2024-06-06 10:53:52 -04:00 committed by GitHub
commit 282e060fdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -195,7 +195,7 @@ export default {
this.autocomplete = new window.google.maps.places.Autocomplete(document.getElementById('autocomplete'), {
componentRestrictions: { country: ['us'] },
fields: ['address_components'],
types: ['geocode']
types: ['address']
});
// Set up the Autocomplete place_changed event to call our method to fill in the address
@ -229,16 +229,30 @@ export default {
this.$nextTick(() => {
this.showAllFields = true;
// eslint-disable-next-line no-restricted-syntax
let processedStreetAddress = false;
let processedRoute = false;
for (const component of googlePlace.address_components) {
const componentType = component.types[0];
switch (componentType) {
case 'street_number': {
self.addressModel.streetAddress = component.long_name;
if (processedRoute) {
self.addressModel.streetAddress = `${component.long_name} ${self.addressModel.streetAddress}`;
} else {
self.addressModel.streetAddress = component.long_name;
}
processedStreetAddress = true;
break;
}
case 'route': {
self.addressModel.streetAddress += ` ${component.short_name}`;
if (processedStreetAddress) {
self.addressModel.streetAddress += ` ${component.short_name}`;
} else {
self.addressModel.streetAddress = component.short_name;
}
processedRoute = true;
break;
}
case 'locality': {