2.0.0 • Published 4 years ago

leaflet-react-track-player v2.0.0

Weekly downloads
97
License
MIT
Repository
github
Last release
4 years ago

Leaflet-react-track-player

Build Status CircleCI GitHub repo size in bytes

npm.io


This is package was created as a plugin for react-leaflet . It creates a player which animates along a polyline. It provides functions for pause, play and playback speed. The track colors may be customized.

Install

npm install leaflet-react-track-player
yarn add leaflet-react-track-player

import React, { Component } from "react";
import LeafletReactTrackPlayer from "leaflet-react-track-player";
import demo from "./demo";
import { Map, TileLayer } from "react-leaflet";

class App extends Component {
  state = {
    lat: 47.445745,
    lng: 40.272891666666666,
    zoom: 15,
    type: "distance",
    demo: demo
  };

  render() {
    const position = [demo[0].lat, demo[0].lng];
    return (
      <div className="App">
        <Map center={position} zoom={this.state.zoom}>
          <LeafletReactTrackPlayer
            track={this.state.demo}
            optionMultyIdxFn={function(p) {
              return p.status;
            }}
            optionsMulty={[
              { color: "#b1b1b1" },
              { color: "#06a9f5" },
              { color: "#202020" },
              { color: "#D10B41" },
              { color: "#78c800" }
            ]}
            progressFormat={this.state.type}
            customMarker={true}
            changeCourseCustomMarker={true}
            iconCustomMarker={"/img/mech.svg"}
          />
          <TileLayer
            attribution='&amp;copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
            url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
          />
        </Map>
      </div>
    );
  }
}

Params

PropTypeDefaultDescription
trackArray[]The points that define the polyline
optionMultyIdxFnFunction() => {}Function to defined track segment colors
autoplayBooleantrueAutoplay after init player or not
optionsMultyArray[]The colors used for track segments
customMarkerBooleanfalseShould use a custom marker icon
iconCustomMarkerString""Path to your marker icon
customCourseBooleanfalseNeed changing course of marker? You need have course in points. See demo
timeFormatString"YYMMDDHHmmss000"Time format is for mode "time". You need times stamps in points. See demo
styleMarkerString""Inline style for the marker
speedArrayArray[]List of speeds
progressFormatString"default"Mode "default" uses the number of points as the value for progress. Mode "time" uses time stamps as the value for progress. Mode "distance" uses range in meters as the value for progress
useControlBolleanfalseShow or hide control panel
streamDataBolleanfalseUpdate player after add new points
showDotsBolleanfalseShow or hide points in progress line
defaultSpeedNumberundefinedConstant for speed (pixel/second)
callbackFinishFunction() => {}Called after one full track run
callbackNextFunction() => {}Called after next point in the polyline is reached
callbackPrevFunction() => {}Called after previous point in the polyline is reached
callbackSpeedFunction() => {}Called after changing spead
callbackFlyFunction() => {}Called after fly polyline
callbackStreamFunction() => {}Called after changing stream mode
2.0.0

4 years ago

1.3.5

5 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago