Skip to content

Commit

Permalink
Merge pull request #27 from bnordlund/patch-1
Browse files Browse the repository at this point in the history
Fix follow and simplify add/removeLayer logic
  • Loading branch information
dwilhelm89 committed Mar 16, 2015
2 parents e063907 + fbdff7a commit febf127
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions SliderControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,35 +112,24 @@ L.Control.SliderControl = L.Control.extend({
}

var i;
// clear markers
for (i = _options.minValue; i <= _options.maxValue; i++) {
if(_options.markers[i]) map.removeLayer(_options.markers[i]);
}
if(_options.range){
// jquery ui using range
for (i = ui.values[0]; i <= ui.values[1]; i++){
if(_options.markers[i]) map.addLayer(_options.markers[i]);
}
for (i = _options.maxValue; i > ui.values[1]; i--) {
if(_options.markers[i]) map.removeLayer(_options.markers[i]);
}
for (i = _options.minValue; i < ui.values[0]; i++) {
if(_options.markers[i]) map.removeLayer(_options.markers[i]);
}
}else if(_options.follow){
for (i = _options.minValue; i < (ui.value - _options.follow); i++) {
if(_options.markers[i]) map.removeLayer(_options.markers[i]);
}
for (i = (ui.value - _options.follow); i < ui.value ; i++) {
for (i = ui.value - _options.follow + 1; i <= ui.value ; i++) {
if(_options.markers[i]) map.addLayer(_options.markers[i]);
}
for (i = ui.value; i <= _options.maxValue; i++) {
if(_options.markers[i]) map.removeLayer(_options.markers[i]);
}
}else{
// jquery ui for point before
for (i = _options.minValue; i <= ui.value ; i++) {
if(_options.markers[i]) map.addLayer(_options.markers[i]);
}
for (i = (ui.value + 1); i <= _options.maxValue; i++) {
if(_options.markers[i]) map.removeLayer(_options.markers[i]);
}
}
}
}
Expand All @@ -156,4 +145,4 @@ L.Control.SliderControl = L.Control.extend({

L.control.sliderControl = function (options) {
return new L.Control.SliderControl(options);
};
};

0 comments on commit febf127

Please sign in to comment.