google map update
change geocode to address. update switch to cover if street_address is available.
This commit is contained in:
parent
963dda5a77
commit
8a7c7bda23
1 changed files with 17 additions and 3 deletions
|
|
@ -195,7 +195,7 @@ export default {
|
||||||
this.autocomplete = new window.google.maps.places.Autocomplete(document.getElementById('autocomplete'), {
|
this.autocomplete = new window.google.maps.places.Autocomplete(document.getElementById('autocomplete'), {
|
||||||
componentRestrictions: { country: ['us'] },
|
componentRestrictions: { country: ['us'] },
|
||||||
fields: ['address_components'],
|
fields: ['address_components'],
|
||||||
types: ['geocode']
|
types: ['address']
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set up the Autocomplete place_changed event to call our method to fill in the 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.$nextTick(() => {
|
||||||
this.showAllFields = true;
|
this.showAllFields = true;
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
let processedStreetAddress = false;
|
||||||
|
let processedRoute = false;
|
||||||
for (const component of googlePlace.address_components) {
|
for (const component of googlePlace.address_components) {
|
||||||
const componentType = component.types[0];
|
const componentType = component.types[0];
|
||||||
|
|
||||||
switch (componentType) {
|
switch (componentType) {
|
||||||
case 'street_number': {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case 'route': {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case 'locality': {
|
case 'locality': {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue