Skip to content

Commit 5f967a2

Browse files
author
corvis
committed
Merge remote-tracking branch 'origin/master'
2 parents beb9775 + f8af130 commit 5f967a2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/locationpicker.jquery.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@
176176
});
177177
}
178178
if (inputBinding.locationNameInput && gmapContext.settings.enableAutocomplete) {
179+
var blur = false;
179180
gmapContext.autocomplete = new google.maps.places.Autocomplete(inputBinding.locationNameInput.get(0));
180181
google.maps.event.addListener(gmapContext.autocomplete, 'place_changed', function() {
182+
blur = false;
181183
var place = gmapContext.autocomplete.getPlace();
182184
if (!place.geometry) {
183185
gmapContext.settings.onlocationnotfound(place.name);
@@ -189,6 +191,27 @@
189191
[GmUtility.locationFromLatLng(context.location), context.radius, false]);
190192
});
191193
});
194+
$(inputBinding.locationNameInput)
195+
.change(function() {
196+
blur = true;
197+
})
198+
.blur(function() {
199+
setTimeout(function() {
200+
var address = $(inputBinding.locationNameInput).val();
201+
if (address.length > 5 && blur) {
202+
blur = false;
203+
gmapContext.geodecoder.geocode({'address': address}, function(results, status) {
204+
if(status == google.maps.GeocoderStatus.OK) {
205+
GmUtility.setPosition(gmapContext, results[0].geometry.location, function(context) {
206+
updateInputValues(inputBinding, context);
207+
context.settings.onchanged.apply(gmapContext.domContainer,
208+
[GmUtility.locationFromLatLng(context.location), context.radius, false]);
209+
});
210+
}
211+
});
212+
}
213+
}, 1000);
214+
});
192215
}
193216
if (inputBinding.latitudeInput) {
194217
inputBinding.latitudeInput.on("change", function() {

0 commit comments

Comments
 (0)