Skip to content

Commit 6c99fb4

Browse files
committed
#56 added property 'markerInCenter' to display marker always in map center
1 parent b7fddd8 commit 6c99fb4

File tree

4 files changed

+49
-17
lines changed

4 files changed

+49
-17
lines changed

dist/locationpicker.jquery.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jquery-locationpicker - v0.1.13 - 2016-09-12 */
1+
/*! jquery-locationpicker - v0.1.13 - 2016-09-13 */
22
(function($) {
33
function GMapContext(domElement, options) {
44
var _map = new google.maps.Map(domElement, options);
@@ -313,18 +313,34 @@
313313
markerVisible: settings.markerVisible
314314
});
315315
$target.data("locationpicker", gmapContext);
316+
function displayMarkerWithSelectedArea() {
317+
GmUtility.setPosition(gmapContext, gmapContext.marker.position, function(context) {
318+
var currentLocation = GmUtility.locationFromLatLng(gmapContext.location);
319+
context.settings.onchanged.apply(gmapContext.domContainer, [ currentLocation, context.radius, true ]);
320+
updateInputValues(gmapContext.settings.inputBinding, gmapContext);
321+
});
322+
}
323+
if (settings.markerInCenter) {
324+
gmapContext.map.addListener("bounds_changed", function() {
325+
if (!gmapContext.marker.dragging) {
326+
gmapContext.marker.setPosition(gmapContext.map.center);
327+
updateInputValues(gmapContext.settings.inputBinding, gmapContext);
328+
}
329+
});
330+
gmapContext.map.addListener("idle", function() {
331+
if (!gmapContext.marker.dragging) {
332+
displayMarkerWithSelectedArea();
333+
}
334+
});
335+
}
316336
google.maps.event.addListener(gmapContext.marker, "drag", function(event) {
317-
updateInputValues(gmapContext.settings.inputBinding, gmapContext);
318337
if (gmapContext.settings.inputBinding.locationNameInput) {
319338
GmUtility.updateLocationName(gmapContext);
320339
}
340+
updateInputValues(gmapContext.settings.inputBinding, gmapContext);
321341
});
322342
google.maps.event.addListener(gmapContext.marker, "dragend", function(event) {
323-
GmUtility.setPosition(gmapContext, gmapContext.marker.position, function(context) {
324-
var currentLocation = GmUtility.locationFromLatLng(gmapContext.location);
325-
context.settings.onchanged.apply(gmapContext.domContainer, [ currentLocation, context.radius, true ]);
326-
updateInputValues(gmapContext.settings.inputBinding, gmapContext);
327-
});
343+
displayMarkerWithSelectedArea();
328344
});
329345
GmUtility.setPosition(gmapContext, new google.maps.LatLng(settings.location.latitude, settings.location.longitude), function(context) {
330346
updateInputValues(settings.inputBinding, gmapContext);

dist/locationpicker.jquery.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)