hallahan / LeafletPlayback

This is a Leaflet plug-in that plays back points that have a time stamp synchronized to a clock.
http://leafletplayback.theoutpost.io
Other
482 stars 165 forks source link

LeafletPlayback

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.

Examples

Example 0

Basic example of LeafletPlayback plugin, that pre-loads some GPS GeoJSON tracks and lets you play them back.

Example 1

Use vis.js timeline as slider control

Example 2

Custom interface example - Includes the usage of Maki Markers and Twitter Bootstrap.

Example 3

Shows the ability to have markers orient themselves to the bearing of the track.

Virtual Fence Demo

I began my work on LeafletPlayback in my web mapping class at Oregon State University. My final project involved animating GPS tracks that triggered geo-fences. Note: this may stop working on August 2015 when Geoloqui will discontinue their web services.

GPS Data Format

Leaflet Playback consumes GPS tracks in the form of GeoJSON. Limited GPX import is provided with the L.Playback.Util.ParseGPX() convertion function. 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:

  1. L.Playback.DateControl - Current tick date/time;
  2. L.Playback.PlayControl - Play/stop button to control time flow of LeafletPlayback;
  3. L.Playback.SliderControl - Simple time slider;

Usage

API

new L.Playback(map, geoJSON, onPlaybackTimeChange, options)

parameters

var playback = new L.Playback(map, geoJSON, onPlaybackTimeChange, options);

options

playback#setData(geoJSON)

Reset current data and add new.

playback#addData(geoJSON)

Add new data.

playback#clearData()

Clear all data and tracks layer.

L.Playback.Util.ParseGPX(gpxString)

Convert gpxString content into geoJSON that can be used as input data for Playback().

Authors and Contributors