Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start date and end date is not work with geojson data #213

Open
junghee00 opened this issue Oct 5, 2021 · 2 comments
Open

start date and end date is not work with geojson data #213

junghee00 opened this issue Oct 5, 2021 · 2 comments

Comments

@junghee00
Copy link

junghee00 commented Oct 5, 2021

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!
},

@r1m
Copy link
Contributor

r1m commented Oct 6, 2021

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
Copy link
Contributor

r1m commented Oct 6, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants