socib / Leaflet.TimeDimension

Add time dimension capabilities on a Leaflet map.
MIT License
433 stars 138 forks source link

Does the plugin support a list of times (vs a range)? #221

Open sgofferj opened 1 year ago

sgofferj commented 1 year ago

I'm trying to get the plugin work for a small project of mine. I download satellite images of my area and run them through some processing. I would like to display them through Leaflet. I have set up a MapServer instance and it works in QGIS but I can't get it to work in Leaflet. Becaause the images are in irregular intervals, my server gives a list of available times rather than a range - like this: <Dimension name="time" units="ISO8601" default="2022-11-15T15:57:30Z" nearestValue="0">2022-10-22T04:42:09Z,2022-10-22T15:57:31Z,2022-10-27T04:50:17Z,2022-11-03T04:42:09Z,2022-11-03T15:57:30Z,2022-11-08T04:50:16Z,2022-11-15T15:57:30Z</Dimension>

My leaflet code looks like this:

var map = L.map('map', {
    zoom: 12,
    center: [61.2712,24.0333],
    timeDimension: true,
    timeDimensionControl: true,
});

var baseLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '© OpenStreetMap contributors'
}).addTo(map);

var satLayer = L.tileLayer.wms("https://mapserver.gofferje.net/?map=sat", {
    tileSize: 1024,
    layers: 'Sentinel-1-VVVH-ratio',
    format: 'image/png',
    transparent: true,
    attribution: 'VLK radar'
});

var tsatLayer = L.timeDimension.layer.wms(satLayer, {
    requestTimeFromCapabilities: true,
    updateTimeDimension: true,
//    updateTimeDimensionMode: "replace",
//    setDefaultTime: true,
    //wmsVersion: "1.3.0"
});
tsatLayer.addTo(map);
var marker = L.marker([61.2712,24.0333]).addTo(map);

I have tried setting the time dimension extent in the map section but to no avail. I just can't make it work.