Skip to content

Commit 2e845e7

Browse files
authored
Merge pull request #1923 from Conengmo/docs-missing-plugins
Fix small issues with Timeline and TreeLayerControl docs
2 parents 6458cb6 + 967fc4d commit 2e845e7

File tree

4 files changed

+62
-57
lines changed

4 files changed

+62
-57
lines changed

docs/user_guide/plugins.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ Plugins
3131
plugins/side_by_side_layers
3232
plugins/tag_filter_button
3333
plugins/terminator
34+
plugins/timeline
3435
plugins/timeslider_choropleth
3536
plugins/timestamped_geojson
37+
plugins/treelayercontrol
3638
plugins/vector_tiles
3739
plugins/WmsTimeDimension
3840

@@ -96,10 +98,14 @@ Plugins
9698
- Creates a Tag Filter Button to filter elements based on different criteria.
9799
* - :doc:`Terminator <plugins/terminator>`
98100
- Overlay day and night regions on a map.
101+
* - :doc:`Timeline <plugins/timeline>`
102+
- Create a timeline with a time slider for geojson data with start and end times.
99103
* - :doc:`Timeslider Choropleth <plugins/timeslider_choropleth>`
100104
- Create a choropleth with a timeslider for timestamped data.
101105
* - :doc:`Timestamped GeoJSON <plugins/timestamped_geojson>`
102-
- Add time-aware GeoJSON into the map.
106+
- Add GeoJSON data with timestamps to a map.
107+
* - :doc:`TreeLayerControl <plugins/treelayercontrol>`
108+
- Add a control for a tree of layers with checkboxes for visibility control.
103109
* - :doc:`Vector Tiles using VectorGridProtobuf <plugins/vector_tiles>`
104110
- Display gridded vector data (GeoJSON or TopoJSON sliced with geojson-vt, or protobuf vector tiles).
105111
* - :doc:`WMS Time Dimension <plugins/WmsTimeDimension>`

docs/user_guide/plugins/timeline.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Depending on your input geojson, one plugin may be more convenient than the othe
2828
The `Timeline` plugin can only show data from the past. If you want live updates,
2929
you need the `Realtime` plugin.
3030

31+
### Example of Timeline and TimelineSlider
32+
3133
```{code-cell} ipython3
3234
import folium
3335
from folium.utilities import JsCode

docs/user_guide/plugins/treelayercontrol.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ from folium.plugins.treelayercontrol import TreeLayerControl
2020
from folium.features import Marker
2121
2222
m = folium.Map(location=[46.603354, 1.8883335], zoom_start=5)
23-
osm = folium.TileLayer("openstreetmap").add_to(m)
2423
2524
overlay_tree = {
2625
"label": "Points of Interest",
@@ -71,5 +70,7 @@ overlay_tree = {
7170
]
7271
}
7372
74-
control = TreeLayerControl(overlay_tree=overlay_tree).add_to(m)
73+
TreeLayerControl(overlay_tree=overlay_tree).add_to(m)
74+
75+
m
7576
```

folium/plugins/timeline.py

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,36 @@
1111

1212
class Timeline(GeoJson):
1313
"""
14-
Creates a layer from GeoJSON with time data to append
15-
into a map with Map.add_child.
14+
Create a layer from GeoJSON with time data to add to a map.
1615
17-
To add time data, you need to do one of the following:
16+
To add time data, you need to do one of the following:
1817
19-
* Add a 'start' and 'end' property to each feature. The start and end
20-
can be any comparable item.
18+
* Add a 'start' and 'end' property to each feature. The start and end
19+
can be any comparable item.
2120
22-
Alternatively, you can provide
23-
a `get_interval` function.
21+
Alternatively, you can provide a `get_interval` function.
2422
25-
* This function should be a JsCode object and take as parameter
26-
a GeoJson feature and return a dict containing values for
27-
'start', 'end', 'startExclusive' and 'endExcusive' (or false if no
28-
data could be extracted from the feature).
29-
* 'start' and 'end' can be any comparable items
30-
* 'startExclusive' and 'endExclusive' should be boolean values.
23+
* This function should be a JsCode object and take as parameter
24+
a GeoJson feature and return a dict containing values for
25+
'start', 'end', 'startExclusive' and 'endExcusive' (or false if no
26+
data could be extracted from the feature).
27+
* 'start' and 'end' can be any comparable items
28+
* 'startExclusive' and 'endExclusive' should be boolean values.
3129
32-
Parameters
33-
----------
34-
data: file, dict or str.
35-
The geojson data you want to plot.
30+
Parameters
31+
----------
32+
data: file, dict or str.
33+
The geojson data you want to plot.
3634
37-
get_interval: JsCode, optional
38-
Called for each feature, and should return either a time range for the
39-
feature or `false`, indicating that it should not be included in the
40-
timeline. The time range object should have 'start' and 'end' properties.
41-
Optionally, the boolean keys 'startExclusive' and 'endExclusive' allow the
42-
interval to be considered exclusive.
35+
get_interval: JsCode, optional
36+
Called for each feature, and should return either a time range for the
37+
feature or `false`, indicating that it should not be included in the
38+
timeline. The time range object should have 'start' and 'end' properties.
39+
Optionally, the boolean keys 'startExclusive' and 'endExclusive' allow the
40+
interval to be considered exclusive.
4341
44-
If `get_interval` is not provided, 'start' and 'end' properties are
45-
assumed to be present on each feature.
42+
If `get_interval` is not provided, 'start' and 'end' properties are
43+
assumed to be present on each feature.
4644
4745
Examples
4846
--------
@@ -142,35 +140,33 @@ def _get_self_bounds(self):
142140

143141
class TimelineSlider(JSCSSMixin, MacroElement):
144142
"""
145-
Creates a timeline slider for timeline layers.
146-
147-
Parameters
148-
----------
149-
auto_play: bool, default True
150-
Whether the animation shall start automatically at startup.
151-
152-
start: str, int or float, default earliest 'start' in GeoJson
153-
The beginning/minimum value of the timeline.
154-
end: str, int or float, default latest 'end' in GeoJSON
155-
The end/maximum value of the timeline.
156-
157-
date_options: str, default "YYYY-MM-DD HH:mm:ss"
158-
A format string to render the currently active time in the control.
159-
enable_playback: bool, default True
160-
Show playback controls (i.e. prev/play/pause/next).
161-
enable_keyboard_controls: bool, default False
162-
Allow playback to be controlled using the spacebar (play/pause) and
163-
right/left arrow keys (next/previous).
164-
show_ticks: bool, default True
165-
Show tick marks on the slider
166-
steps: int, default 1000
167-
How many steps to break the timeline into.
168-
Each step will then be (end-start) / steps. Only affects playback.
169-
playback_duration: int, default 10000
170-
Minimum time, in ms, for the playback to take. Will almost certainly
171-
actually take at least a bit longer -- after each frame, the next
172-
one displays in playback_duration/steps ms, so each frame really
173-
takes frame processing time PLUS step time.
143+
Creates a timeline slider for timeline layers.
144+
145+
Parameters
146+
----------
147+
auto_play: bool, default True
148+
Whether the animation shall start automatically at startup.
149+
start: str, int or float, default earliest 'start' in GeoJson
150+
The beginning/minimum value of the timeline.
151+
end: str, int or float, default latest 'end' in GeoJSON
152+
The end/maximum value of the timeline.
153+
date_options: str, default "YYYY-MM-DD HH:mm:ss"
154+
A format string to render the currently active time in the control.
155+
enable_playback: bool, default True
156+
Show playback controls (i.e. prev/play/pause/next).
157+
enable_keyboard_controls: bool, default False
158+
Allow playback to be controlled using the spacebar (play/pause) and
159+
right/left arrow keys (next/previous).
160+
show_ticks: bool, default True
161+
Show tick marks on the slider
162+
steps: int, default 1000
163+
How many steps to break the timeline into.
164+
Each step will then be (end-start) / steps. Only affects playback.
165+
playback_duration: int, default 10000
166+
Minimum time, in ms, for the playback to take. Will almost certainly
167+
actually take at least a bit longer -- after each frame, the next
168+
one displays in playback_duration/steps ms, so each frame really
169+
takes frame processing time PLUS step time.
174170
175171
Examples
176172
--------

0 commit comments

Comments
 (0)