|
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 | + inputBinding.locationNameInput.on("change", function(e) { |
| 196 | + if (!e.originalEvent) { return } |
| 197 | + blur = true; |
| 198 | + }); |
| 199 | + inputBinding.locationNameInput.on("blur", function(e) { |
| 200 | + if (!e.originalEvent) { return } |
| 201 | + setTimeout(function() { |
| 202 | + var address = $(inputBinding.locationNameInput).val(); |
| 203 | + if (address.length > 5 && blur) { |
| 204 | + blur = false; |
| 205 | + gmapContext.geodecoder.geocode({'address': address}, function(results, status) { |
| 206 | + if(status == google.maps.GeocoderStatus.OK && results && results.length) { |
| 207 | + GmUtility.setPosition(gmapContext, results[0].geometry.location, function(context) { |
| 208 | + updateInputValues(inputBinding, context); |
| 209 | + context.settings.onchanged.apply(gmapContext.domContainer, |
| 210 | + [GmUtility.locationFromLatLng(context.location), context.radius, false]); |
| 211 | + }); |
| 212 | + } |
| 213 | + }); |
| 214 | + } |
| 215 | + }, 1000); |
| 216 | + }); |
193 | 217 | } |
194 | 218 | if (inputBinding.latitudeInput) { |
195 | 219 | inputBinding.latitudeInput.on("change", function(e) { |
|
0 commit comments