Skip to content

Commit

Permalink
Merge pull request #26 from juliensoret/showAllOnStartOption
Browse files Browse the repository at this point in the history
Add option to show all markers at start or not
  • Loading branch information
dwilhelm89 committed Mar 14, 2015
2 parents add7cb5 + bca7dce commit e063907
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions SliderControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ L.Control.SliderControl = L.Control.extend({
layers: null,
maxValue: -1,
minValue: 0,
showAllOnStart: false,
markers: null,
range: false,
follow: false,
Expand Down Expand Up @@ -78,9 +79,16 @@ L.Control.SliderControl = L.Control.extend({

startSlider: function () {
_options = this.options;
var index_start = _options.minValue;
if(_options.showAllOnStart){
index_start = _options.maxValue;
if(_options.range) _options.values = [_options.minValue,_options.maxValue];
else _options.value = _options.maxValue;
}
$("#leaflet-slider").slider({
range: _options.range,
value: _options.minValue,
value: _options.value,
values: _options.values,
min: _options.minValue,
max: _options.maxValue,
step: 1,
Expand Down Expand Up @@ -138,9 +146,11 @@ L.Control.SliderControl = L.Control.extend({
}
});
if (!_options.range && _options.alwaysShowDate) {
$('#slider-timestamp').html(_options.markers[_options.minValue].feature.properties.time.substr(0, 19));
$('#slider-timestamp').html(_options.markers[index_start].feature.properties.time.substr(0, 19));
}
for (i = _options.minValue; i <= index_start; i++) {
_options.map.addLayer(_options.markers[i]);
}
_options.map.addLayer(_options.markers[_options.minValue]);
}
});

Expand Down

0 comments on commit e063907

Please sign in to comment.