socib / Leaflet.TimeDimension

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

Geojson, Heatmap, TimeDimension #155

Open BehzadKhorram opened 6 years ago

BehzadKhorram commented 6 years ago

hello there, how could I do something like example 12 with a js file as below :

var json = { "type": "FeatureCollection", "features": [ { "geometry": {"type": "Point", "coordinates": [ ... ] }, "type": "Feature", "properties": {"iconSize": [10, 10 ], "time": "2018-07-14 12:50:25"} }, { "geometry": {"type": "Point", "coordinates": [ ... ]}, "type": "Feature", "properties": {"iconSize": [10, 10 ],
"time": "2018-07-27 10:26:07"} }, .... and so on

pazrg commented 6 years ago

Hi @BehzadKhorram ,

LeafletTimeDimension will look for the time coordinate at the 'properties' (See here the reference. This can be expressed as 'coordTimes' for lineStrings:
"type": "Feature", "properties": { "coordTimes": [ArrayOfTimes], "name" : '' }, "geometry": { "type": "LineString", "coordinates": [] } or as single 'time' per feature properties in case of 'Points'.

It seems you have implemented the second approach, as yout time is a single time per-point-feature specified in its properties. So the only think I see that might be causing you problems is the date format used. Have you tried expressing the time as ISO 8601 Data elements (YYYY-MM-DDTHH:MM:SS) ?

Also have a look to the json source for example 12 here. It is a very particular one, so the case is built for dealing with it and not with one with a different layout (like yours). In this scenario you can either change the code to adapt to your json layout instead or, not touching the code itself but adapting your json layour to mimic the one used in the example.

Please let me know from you,

Paz rg