Leaflet TimeDimension 2 days
by techGus
JavaScript
var map = L.map('map'
//, timeDimensionOptions: { times : "2006-01-01 06:00:00,2006-01-01 07:00:00,2006-01-01 08:00:00,2006-01-01 09:00:00,2006-01-01 10:00:00,2006-01-01 11:00:00,2006-01-01 12:00:00,2006-01-01 13:00:00,2006-01-01 14:00:00,2006-01-01 15:00:00,2006-01-01 16:00:00,2006-01-01 17:00:00,2006-01-02 06:00:00,2006-01-02 07:00:00,2006-01-02 08:00:00,2006-01-02 09:00:00,2006-01-02 10:00:00,2006-01-02 11:00:00,2006-01-02 12:00:00,2006-01-02 13:00:00,2006-01-02 14:00:00,2006-01-02 15:00:00,2006-01-02 16:00:00,2006-01-02 17:00:00"}
).fitBounds([[34.1995508059065,39.151200914031406],[34.199696966261726,39.15145937135462]]);
var timeDimension = new L.TimeDimension({
period: "PT1H"
// times: "2006-01-01 06:00:00,2006-01-01 07:00:00,2006-01-01 08:00:00,2006-01-01 09:00:00,2006-01-01 10:00:00,2006-01-01 11:00:00,2006-01-01 12:00:00,2006-01-01 13:00:00,2006-01-01 14:00:00,2006-01-01 15:00:00,2006-01-01 16:00:00,2006-01-01 17:00:00,2006-01-02 06:00:00,2006-01-02 07:00:00,2006-01-02 08:00:00,2006-01-02 09:00:00,2006-01-02 10:00:00,2006-01-02 11:00:00,2006-01-02 12:00:00,2006-01-02 13:00:00,2006-01-02 14:00:00,2006-01-02 15:00:00,2006-01-02 16:00:00,2006-01-02 17:00:00"
});
map.timeDimension = timeDimension;
var player = new L.TimeDimension.Player({
transitionTime: 100,
loop: false,
startOver:true
}, timeDimension);
var timeDimensionControlOptions = {
player: player,
timeDimension: timeDimension,
position: 'bottomleft',
autoPlay: true,
minSpeed: 1,
speedStep: 1,
maxSpeed: 15,
timeSliderDragUpdate: true
};
var timeDimensionControl = new L.Control.TimeDimension(timeDimensionControlOptions);
map.addControl(timeDimensionControl);
function getColor(d) {
return d > 420 ? 'rgba(215,25,28,1.0)' :
d > 360 ? 'rgba(237,110,67,1.0)' :
d > 300 ? 'rgba(254,186,110,1.0)' :
d > 240 ? 'rgba(255,232,164,1.0)' :
d > 180 ? 'rgba(231,245,203,1.0)' :
d > 120 ?...