Coder Social home page Coder Social logo

somethingbear / leaflet-react-track-player Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arg0navt/leaflet-react-track-player

0.0 1.0 0.0 8.86 MB

This is plugin for react-leaflet. It create player for control of track. ๐Ÿƒ๐ŸŒŽโš”

JavaScript 87.24% CSS 11.76% HTML 1.00%

leaflet-react-track-player's Introduction

Leaflet-react-track-player

Build Status CircleCI GitHub repo size in bytes


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

Prop Type Default Description
track Array [] The points that define the polyline
optionMultyIdxFn Function () => {} Function to defined track segment colors
optionsMulty Array [] The colors used for track segments
customMarker Boolean false Should use a custom marker icon
iconCustomMarker String "" Path to your marker icon
customCourse Boolean false Need changing course of marker? You need have course in points. See demo
timeFormat String "YYMMDDHHmmss000" Time format is for mode "time". You need times stamps in points. See demo
styleMarker String "" Inline style for the marker
speedArray Array [] List of speeds
progressFormat String "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
useControl Bollean false Show or hide control panel
streamData Bollean false Update player after add new points
showDots Bollean false Show or hide points in progress line
defaultSpeed Number undefined Constant for speed (pixel/second)
callbackFinish Function () => {} Called after one full track run
callbackNext Function () => {} Called after next point in the polyline is reached
callbackPrev Function () => {} Called after previous point in the polyline is reached
callbackSpeed Function () => {} Called after changing spead
callbackFly Function () => {} Called after fly polyline
callbackStream Function () => {} Called after changing stream mode

leaflet-react-track-player's People

Contributors

arg0navt avatar jbccollins avatar madhums avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.