|
171 | 171 | });
|
172 | 172 | }
|
173 | 173 | if (inputBinding.locationNameInput && gmapContext.settings.enableAutocomplete) {
|
| 174 | + var blur = false; |
174 | 175 | gmapContext.autocomplete = new google.maps.places.Autocomplete(inputBinding.locationNameInput.get(0));
|
175 | 176 | google.maps.event.addListener(gmapContext.autocomplete, 'place_changed', function() {
|
| 177 | + blur = false; |
176 | 178 | var place = gmapContext.autocomplete.getPlace();
|
177 | 179 | if (!place.geometry) {
|
178 | 180 | gmapContext.settings.onlocationnotfound(place.name);
|
|
184 | 186 | [GmUtility.locationFromLatLng(context.location), context.radius, false]);
|
185 | 187 | });
|
186 | 188 | });
|
| 189 | + $(inputBinding.locationNameInput) |
| 190 | + .change(function() { |
| 191 | + blur = true; |
| 192 | + }) |
| 193 | + .blur(function() { |
| 194 | + setTimeout(function() { |
| 195 | + var address = $(inputBinding.locationNameInput).val(); |
| 196 | + if (address.length > 5 && blur) { |
| 197 | + blur = false; |
| 198 | + var geocoder = new google.maps.Geocoder(); |
| 199 | + geocoder.geocode({'address': address}, function(results, status) { |
| 200 | + if(status == google.maps.GeocoderStatus.OK) { |
| 201 | + GmUtility.setPosition(gmapContext, results[0].geometry.location, function(context) { |
| 202 | + updateInputValues(inputBinding, context); |
| 203 | + context.settings.onchanged.apply(gmapContext.domContainer, |
| 204 | + [GmUtility.locationFromLatLng(context.location), context.radius, false]); |
| 205 | + }); |
| 206 | + } |
| 207 | + }); |
| 208 | + } |
| 209 | + }, 1000); |
| 210 | + }); |
187 | 211 | }
|
188 | 212 | if (inputBinding.latitudeInput) {
|
189 | 213 | inputBinding.latitudeInput.on("change", function() {
|
|
0 commit comments