From a4133036dc4a68f99f0401e4759a135510cb8e3e Mon Sep 17 00:00:00 2001 From: Aapo Virta Date: Mon, 20 Dec 2021 18:14:05 +0200 Subject: [PATCH 1/2] Added boundLimits prop --- src/VueGoogleAutocomplete.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/VueGoogleAutocomplete.vue b/src/VueGoogleAutocomplete.vue index fad7e6d..f1a169c 100644 --- a/src/VueGoogleAutocomplete.vue +++ b/src/VueGoogleAutocomplete.vue @@ -75,6 +75,11 @@ }, }, + boundLimits: { + type: Object, + default: null + }, + country: { type: [String, Array], default: null @@ -134,7 +139,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 +157,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 From f4558e40eb475a8f74c0b04db0f6a58524b96c72 Mon Sep 17 00:00:00 2001 From: Aapo Virta Date: Mon, 20 Dec 2021 18:14:53 +0200 Subject: [PATCH 2/2] Added boundLimits prop --- src/VueGoogleAutocomplete.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/VueGoogleAutocomplete.vue b/src/VueGoogleAutocomplete.vue index f1a169c..fe01cb7 100644 --- a/src/VueGoogleAutocomplete.vue +++ b/src/VueGoogleAutocomplete.vue @@ -79,6 +79,10 @@ type: Object, default: null }, + /* + Example: + :boundLimits="{sw:{lat:60.096670, lon:24.583181}, ne:{lat:60.391643, lon:25.214419}}" + */ country: { type: [String, Array],