Skip to content

Commit 3567fb4

Browse files
author
Dmitry Berezovsky
committed
Fixed issue #1. OnChanged event doesn't fire when using input field for changing location.
1 parent 7f6337b commit 3567fb4

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

locationpicker.jquery.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,16 @@
112112
if (inputBinding.locationNameInput) {
113113
inputBinding.locationNameInput.val(gmapContext.locationName);
114114
}
115-
}
116-
115+
}
116+
117117
function setupInputListenersInput(inputBinding, gmapContext) {
118118
if (inputBinding) {
119119
if (inputBinding.radiusInput){
120120
inputBinding.radiusInput.on("change", function() {
121121
gmapContext.radius = $(this).val();
122-
GmUtility.setPosition(gmapContext, gmapContext.location);
122+
GmUtility.setPosition(gmapContext, gmapContext.location, function(context){
123+
context.settings.onchanged(GmUtility.locationFromLatLng(context.location), context.radius, false);
124+
});
123125
});
124126
}
125127
if (inputBinding.locationNameInput && gmapContext.settings.enableAutocomplete) {
@@ -130,11 +132,26 @@
130132
gmapContext.onlocationnotfound();
131133
return;
132134
}
133-
GmUtility.setPosition(gmapContext, place.geometry.location, function() {
134-
updateInputValues(inputBinding, gmapContext);
135+
GmUtility.setPosition(gmapContext, place.geometry.location, function(context) {
136+
updateInputValues(inputBinding, context);
137+
context.settings.onchanged(GmUtility.locationFromLatLng(context.location), context.radius, false);
135138
});
136139
});
137140
}
141+
if (inputBinding.latitudeInput) {
142+
inputBinding.latitudeInput.on("change", function() {
143+
GmUtility.setPosition(gmapContext, new google.maps.LatLng($(this).val(), gmapContext.location.lng()), function(context){
144+
context.settings.onchanged(GmUtility.locationFromLatLng(context.location), context.radius, false);
145+
});
146+
});
147+
}
148+
if (inputBinding.longitudeInput) {
149+
inputBinding.longitudeInput.on("change", function() {
150+
GmUtility.setPosition(gmapContext, new google.maps.LatLng(gmapContext.location.lat(), $(this).val()), function(context){
151+
context.settings.onchanged(GmUtility.locationFromLatLng(context.location), context.radius, false);
152+
});
153+
});
154+
}
138155
}
139156
}
140157

0 commit comments

Comments
 (0)