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

start date and end date is not work with geojson data

Open junghee00 opened this issue 4 years ago • 2 comments

I read README and I used the form "String formed by start date/end date/period " But It isn't work! How do I make the features have their own period? (Ex. One feature show up at 2015-08-01 and hide at 2016-08-02, and another feature show up and hide not the same period! )

My code :

{ "id": "0", "type": "Feature", "properties": { "nuts_id": "ES", "levl_code": 0, "cntr_code": "ES", "nuts_name": "ESPAÑA", "fid": "ES", "name": "ESPAÑA", "value": 279.1763000488281, "times": "2015-08-01/2016-08-02/P1D" //--->Not Work! },

junghee00 avatar Oct 05 '21 06:10 junghee00

This is only for timeDimension itself. Features on geoJSON only support time or times array : https://github.com/socib/Leaflet.TimeDimension#ltimedimensionlayergeojson

You can change this behavior by overriding _getFeatureTimes or _getFeatureBetweenDates on a geoJSON layer subclass. Change _getFeatureTimes to return an array of time based on the period parsing. see Example 15

r1m avatar Oct 06 '21 08:10 r1m

L.TimeDimension.Layer.GeoJsonWithPeriod = L.TimeDimension.Layer.GeoJson.extend({
    _getFeatureTimes: function(feature) {
        if (!feature.properties) {
            return [];
        }
        if (feature.properties.hasOwnProperty('times')) {
            return  L.TimeDimension.Util.parseTimesExpression(feature.properties.times);
        }
        return [];
    }
})

Something like that.

r1m avatar Oct 06 '21 08:10 r1m