Leaflet Playback provides the ability to replay GPS Tracks in the form of GeoJSON objects. Rather than simply animating a marker along a polyline, the speed of the animation is synchroized to a clock. The playback functionality is similar to a video player--you can start and stop playback, change the playback speed, load GPS tracks, as well as set the playback time with a slider or calendar/time-picker widget.
Basic example of LeafletPlayback plugin, that pre-loads some GPS GeoJSON tracks and lets you play them back.
Use vis.js timeline as slider control
Custom interface example - Includes the usage of Maki Markers and Twitter Bootstrap.
Leaflet Playback consumes GPS tracks in the form of GeoJSON. The next feature to be implemented for the plugin is the added ability to parse GPX tracks as well. The schema of the GeoJSON data is as follows:
{
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": [/*array of [lng,lat] coordinates*/]
},
"properties": {
"time": [/*array of UNIX timestamps*/]
}
}
Other attributes may be added to the GeoJSON object, but this is the required minimum schema for the plug-in to work.
There are three leaflet controls defined in src/Controls.js
:
- L.Playback.DateControl - Current tick date/time;
- L.Playback.PlayControl - Play/stop button to control time flow of LeafletPlayback;
- L.Playback.SliderControl - Simple time slider;
var playback = new L.Playback(map, geoJSON, onPlaybackTimeChange, options);
-
map
- LeafLet map object. Required. -
geoJSON
- GeoJSON object or an array of GeoJSON objects. Passnull
if you don't have any data yet. Required. -
onPlaybackTimeChange
- A function with signature(timestamp)
that will send thetimestamp
value on each tick. Required. -
options
- An options object. Optional.
-
tickLen
- Set tick length in miliseconds. Increasing this value, may improve performance, at the cost of animation smoothness. Default:250
. -
speed
- Setfloat
multiplier for default animation speed. Default:1
. -
maxInterpolationTime
- Set max interpolation time in seconds. Default:5*60*1000
(5 minutes). -
tracksLayer
- Settrue
if you want to show layer control on the map. Default:true
. -
playControl
- Settrue
if play button is needed. Default:false
. -
dateControl
- Settrue
if date label is needed. Default:false
. -
sliderControl
- Settrue
if slider control is needed. Default:false
. -
layer
- Object or function with signature(featureData)
that returns geoJSON layer options object. Useful for setting path color. Default:{}
. -
marker
- Object or function with signature(featureData)
that returns leaflet marker options, to extendL.Playback.MoveableMarker
. Useful for custom icons. Default:{}
.
Reset current data and add new.
geoJSON
- GeoJSON object or an array of GeoJSON objects. Required.
Add new data.
geoJSON
- GeoJSON object or an array of GeoJSON objects. Required.
Clear all data and tracks layer.
- @hallahan - Nicholas Hallahan
- @recallfx - Marius
- @lbuter - Luke Butler
- @dgorissen - Dirk Gorissen