Leaflet.TimeDimension icon indicating copy to clipboard operation
Leaflet.TimeDimension copied to clipboard

Fire event on input time

Open majadinjar opened this issue 8 years ago • 1 comments

Is it possible to fire event when some time come, for example event when 10:17am on 2014-10-30 comes on time player? Need to show some info on some timestamps.

Thanks!

majadinjar avatar Sep 30 '16 17:09 majadinjar

Hi @majadinjar, you can use the event timeload, and check if an specific time has been loaded.

Something like this:

var messages = {
    '2015-07-08T08:00:00.000Z': 'First message',
    '2015-07-09T06:00:00.000Z': 'Second message',
};

map.timeDimension.on('timeload', function(data) {
    if (data.time == map.timeDimension.getCurrentTime()) {
        var isoDate = new Date(data.time).toISOString();
        if (messages.hasOwnProperty(isoDate)) {
            console.log(messages[isoDate]);
            // show message
        } else {
            // remove message
        }
    }
});

bielfrontera avatar Oct 11 '16 15:10 bielfrontera