diff --git a/src/VueGoogleAutocomplete.vue b/src/VueGoogleAutocomplete.vue index fad7e6d..fe01cb7 100644 --- a/src/VueGoogleAutocomplete.vue +++ b/src/VueGoogleAutocomplete.vue @@ -75,6 +75,15 @@ }, }, + boundLimits: { + type: Object, + default: null + }, + /* + Example: + :boundLimits="{sw:{lat:60.096670, lon:24.583181}, ne:{lat:60.391643, lon:25.214419}}" + */ + country: { type: [String, Array], default: null @@ -134,7 +143,7 @@ watch: { autocompleteText: function (newVal, oldVal) { - this.$emit('inputChange', { newVal, oldVal }, this.id); + this.$emit('inputChange', { newVal, oldVal }, this.id); }, country: function(newVal, oldVal) { this.autocomplete.setComponentRestrictions({ @@ -152,10 +161,17 @@ if (this.country) { options.componentRestrictions = { - country: this.country + country: this.country, }; } + if (this.boundLimits) { + var southWest = new google.maps.LatLng(this.boundLimits.sw.lat, this.boundLimits.sw.lon ); + var northEast = new google.maps.LatLng( this.boundLimits.ne.lat, this.boundLimits.ne.lon); + var bounds = new google.maps.LatLngBounds( southWest, northEast ); + options.bounds = bounds; + } + this.autocomplete = new google.maps.places.Autocomplete( document.getElementById(this.id), options