Skip to content

Commit 329661d

Browse files
committed
Add style option for each geojson feature
1 parent a11b842 commit 329661d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

folium/plugins/timestamped_geo_json.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def __init__(self, data, transition_time=200, loop=True, auto_play=True, add_las
124124
{{this._parent.get_name()}}.addControl({{this._parent.get_name()}}.timeDimensionControl);
125125
126126
var {{this.get_name()}} = L.timeDimension.layer.geoJson(
127-
L.geoJson({{this.data}}),
127+
L.geoJson({{this.data}}, {'style': function (feature) {
128+
return feature.properties.style
129+
}}),
128130
{updateTimeDimension: true,addlastPoint: {{'true' if this.add_last_point else 'false'}}}
129131
).addTo({{this._parent.get_name()}});
130132
{% endmacro %}

tests/plugins/test_timestamped_geo_json.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ def test_timestamped_geo_json():
5050
},
5151
"properties": {
5252
"times": [1435708800000+i*86400000 for
53-
i in np.linspace(0, 25, 25)]
54-
}
53+
i in np.linspace(0, 25, 25)],
54+
"style": {
55+
"color": "red"
56+
},
57+
},
5558
},
5659
{
5760
"type": "Feature",
@@ -123,7 +126,9 @@ def test_timestamped_geo_json():
123126
{{this._parent.get_name()}}.addControl({{this._parent.get_name()}}.timeDimensionControl);
124127
125128
var {{this.get_name()}} = L.timeDimension.layer.geoJson(
126-
L.geoJson({{this.data}}),
129+
L.geoJson({{this.data}}, {'style': function (feature) {
130+
return feature.properties.style
131+
}}),
127132
{updateTimeDimension: true,addlastPoint: {{'true' if this.add_last_point else 'false'}}}
128133
).addTo({{this._parent.get_name()}});
129134
""") # noqa

0 commit comments

Comments
 (0)