|
177 | 177 | });
|
178 | 178 | }
|
179 | 179 | if (inputBinding.locationNameInput && gmapContext.settings.enableAutocomplete) {
|
| 180 | + var blur = false; |
180 | 181 | gmapContext.autocomplete = new google.maps.places.Autocomplete(inputBinding.locationNameInput.get(0));
|
181 | 182 | google.maps.event.addListener(gmapContext.autocomplete, 'place_changed', function() {
|
| 183 | + blur = false; |
182 | 184 | var place = gmapContext.autocomplete.getPlace();
|
183 | 185 | if (!place.geometry) {
|
184 | 186 | gmapContext.settings.onlocationnotfound(place.name);
|
|
190 | 192 | [GmUtility.locationFromLatLng(context.location), context.radius, false]);
|
191 | 193 | });
|
192 | 194 | });
|
| 195 | + if(gmapContext.settings.enableAutocompleteBlur) { |
| 196 | + inputBinding.locationNameInput.on("change", function(e) { |
| 197 | + if (!e.originalEvent) { return } |
| 198 | + blur = true; |
| 199 | + }); |
| 200 | + inputBinding.locationNameInput.on("blur", function(e) { |
| 201 | + if (!e.originalEvent) { return } |
| 202 | + setTimeout(function() { |
| 203 | + var address = $(inputBinding.locationNameInput).val(); |
| 204 | + if (address.length > 5 && blur) { |
| 205 | + blur = false; |
| 206 | + gmapContext.geodecoder.geocode({'address': address}, function(results, status) { |
| 207 | + if(status == google.maps.GeocoderStatus.OK && results && results.length) { |
| 208 | + GmUtility.setPosition(gmapContext, results[0].geometry.location, function(context) { |
| 209 | + updateInputValues(inputBinding, context); |
| 210 | + context.settings.onchanged.apply(gmapContext.domContainer, |
| 211 | + [GmUtility.locationFromLatLng(context.location), context.radius, false]); |
| 212 | + }); |
| 213 | + } |
| 214 | + }); |
| 215 | + } |
| 216 | + }, 1000); |
| 217 | + }); |
| 218 | + } |
193 | 219 | }
|
194 | 220 | if (inputBinding.latitudeInput) {
|
195 | 221 | inputBinding.latitudeInput.on("change", function(e) {
|
|
369 | 395 | locationNameInput: null
|
370 | 396 | },
|
371 | 397 | enableAutocomplete: false,
|
| 398 | + enableAutocompleteBlur: false, |
372 | 399 | enableReverseGeocode: true,
|
373 | 400 | draggable: true,
|
374 | 401 | onchanged: function(currentLocation, radius, isMarkerDropped) {},
|
|
0 commit comments