Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion folium/plugins/timestamped_geo_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,18 @@ class TimestampedGeoJson(JSCSSMixin, MacroElement):
addlastPoint: {{ this.add_last_point|tojson }},
duration: {{ this.duration }},
}
).addTo({{this._parent.get_name()}});
);
// Without a duration Leaflet.TimeDimension starts at time 0, which
// hides features whose times are all before 1970.
{{this.get_name()}}._getFeatureBetweenDates = function(feature, minTime, maxTime) {
if (!this._duration) {
minTime = -Infinity;
}
return L.TimeDimension.Layer.GeoJson.prototype._getFeatureBetweenDates.call(
this, feature, minTime, maxTime
);
};
{{this.get_name()}}.addTo({{this._parent.get_name()}});
{% endmacro %}
""") # noqa

Expand Down
13 changes: 12 additions & 1 deletion tests/plugins/test_timestamped_geo_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,18 @@ def test_timestamped_geo_json():
addlastPoint: {{ this.add_last_point|tojson }},
duration: {{ this.duration }},
}
).addTo({{this._parent.get_name()}});
);
// Without a duration Leaflet.TimeDimension starts at time 0, which
// hides features whose times are all before 1970.
{{this.get_name()}}._getFeatureBetweenDates = function(feature, minTime, maxTime) {
if (!this._duration) {
minTime = -Infinity;
}
return L.TimeDimension.Layer.GeoJson.prototype._getFeatureBetweenDates.call(
this, feature, minTime, maxTime
);
};
{{this.get_name()}}.addTo({{this._parent.get_name()}});
""") # noqa
expected = normalize(tmpl.render(this=tgj))
assert expected in out
Expand Down