()
| 14 | |
| 15 | |
| 16 | def test_timeline(): |
| 17 | m = folium.Map() |
| 18 | |
| 19 | data = json.load(open("./examples/data/historical_country_borders.json")) |
| 20 | timeline = plugins.Timeline( |
| 21 | data, |
| 22 | ).add_to(m) |
| 23 | GeoJsonPopup(fields=["name"], labels=True).add_to(timeline) |
| 24 | slider = ( |
| 25 | plugins.TimelineSlider( |
| 26 | auto_play=False, |
| 27 | show_ticks=True, |
| 28 | enable_keyboard_controls=True, |
| 29 | playback_duration=30000, |
| 30 | ) |
| 31 | .add_timelines(timeline) |
| 32 | .add_to(m) |
| 33 | ) |
| 34 | |
| 35 | out = normalize(m._parent.render()) |
| 36 | |
| 37 | # Verify the imports. |
| 38 | assert ( |
| 39 | '<script src="https://cdn.jsdelivr.net/npm/leaflet.timeline@1.6.0/dist/leaflet.timeline.min.js"></script>' |
| 40 | in out |
| 41 | ) |
| 42 | assert ( |
| 43 | '<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>' |
| 44 | in out |
| 45 | ) |
| 46 | |
| 47 | # Verify that the script is okay. |
| 48 | tmpl = Template( |
| 49 | """ |
| 50 | {% macro header(this,kwargs) %} |
| 51 | <style> |
| 52 | .leaflet-bottom.leaflet-left { |
| 53 | width: 100%; |
| 54 | } |
| 55 | .leaflet-control-container .leaflet-timeline-controls { |
| 56 | box-sizing: border-box; |
| 57 | width: 100%; |
| 58 | margin: 0; |
| 59 | margin-bottom: 15px; |
| 60 | } |
| 61 | </style> |
| 62 | {% endmacro %} |
| 63 | |
| 64 | {% macro script(this, kwargs) %} |
| 65 | var {{ this.get_name() }}_options = {{ this.options|tojavascript }}; |
| 66 | {% for key, value in this.functions.items() %} |
| 67 | {{ this.get_name() }}_options["{{key}}"] = {{ value }}; |
| 68 | {% endfor %} |
| 69 | |
| 70 | var {{ this.get_name() }} = L.timelineSliderControl( |
| 71 | {{ this.get_name() }}_options |
| 72 | ); |
| 73 | {{ this.get_name() }}.addTo({{ this._parent.get_name() }}); |
nothing calls this directly
no test coverage detected