-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathApp.js
56 lines (54 loc) Β· 1.68 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React, { Component } from "react";
import "./App.css";
import LeafletReactTrackPlayer from "./laeflet-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: 14,
type: "time",
demo: demo,
icon: "/img/mech.svg",
show: true
};
render() {
const position = [demo[demo.length - 1].lat, demo[demo.length - 1].lng];
return (
<div className="App">
<button onClick={() => this.setState({show: !this.state.show})}>ss</button>
<Map center={position} zoom={this.state.zoom}>
{this.state.show ? (
<LeafletReactTrackPlayer
autoplay={false}
track={this.state.demo}
optionMultyIdxFn={function(p) {
return p.status;
}}
optionsMulty={[
{ color: "#b1b1b1" },
{ color: "#06a9f5" },
{ color: "#202020" },
{ color: "#D10B41" },
{ color: "#78c800" }
]}
useControl={true}
progressFormat={this.state.type}
customMarker={true}
defaultSpeed={10}
streamData={false}
changeCourseCustomMarker={true}
iconCustomMarker={this.state.icon}
/>
) : null}
<TileLayer
attribution="&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors"
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
</Map>
</div>
);
}
}
export default App;