Skip to content

Commit 9e8c39b

Browse files
committed
Was added params constant for speed
1 parent 7c6e697 commit 9e8c39b

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class App extends Component {
3333
useControl={true}
3434
progressFormat={this.state.type}
3535
customMarker={true}
36-
streamData={true}
36+
defaultSpeed={10}
37+
streamData={false}
3738
changeCourseCustomMarker={true}
3839
iconCustomMarker={this.state.icon}
3940
/>

src/laeflet-react-track-player/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class LeafletReactTrackPlayer extends MapLayer {
7474
const course =
7575
this.props.customMarker &&
7676
this.props.customCourse &&
77-
this.state.track[0] &&
78-
this.state.track[0].course
79-
? this.state.track[0].course
77+
this.props.track[0] &&
78+
this.props.track[0].course
79+
? this.props.track[0].course
8080
: null;
8181
const finishMarker = L.marker(this.props.track[0], {
8282
icon: this.createIcon(course)
@@ -87,7 +87,8 @@ class LeafletReactTrackPlayer extends MapLayer {
8787
...paramsForMultiPolyline(this.props),
8888
timeFormat: this.props.timeFormat,
8989
progressFormat: this.props.progressFormat,
90-
startPosition: this.props.startPosition
90+
startPosition: this.props.startPosition,
91+
defaultSpeed: this.props.defaultSpeed,
9192
});
9293
this.props.leaflet.map.addLayer(snakePolyline);
9394
return {
@@ -561,6 +562,7 @@ LeafletReactTrackPlayer.propTypes = {
561562
startPosition: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
562563
streamData: PropTypes.bool,
563564
showDots: PropTypes.bool,
565+
defaultSpeed: PropTypes.number,
564566
callbackNext: PropTypes.func,
565567
callbackPrev: PropTypes.func,
566568
callbackSpeed: PropTypes.func,

src/laeflet-react-track-player/snake.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ L.Polyline.include({
1616
// It initialization polyline with animation
1717
snakeIn: function(e) {
1818
if (e && !this._latLngAnimation) this._latLngAnimation = e;
19+
for (let i in this._eventParents) {
20+
if (this._eventParents[i]._options.defaultSpeed) {
21+
this._defaultSpeed = this._eventParents[i]._options.defaultSpeed;
22+
}
23+
}
1924
if (this._snaking) {
2025
return;
2126
}
@@ -142,6 +147,9 @@ L.Polyline.include({
142147
let forward = this.maxDistance
143148
? (diff * (this.maxDistance / time)) / 1000
144149
: (diff * (1 / time)) / 1000;
150+
if (this._defaultSpeed) {
151+
forward = diff * (this._defaultSpeed * this._xSpeed) / 1000
152+
}
145153
this._snakingTime = this._now;
146154
this._latlngs.pop();
147155
this._forward = forward;
@@ -435,6 +443,7 @@ L.LayerGroup.include({
435443
}
436444
this.clearLayers();
437445
this._detailDistance = this._detailData.map(polyline => getDistance(polyline));
446+
console.log(this);
438447
if (this._options.startPosition) {
439448
this._initiateStartPosition();
440449
} else {

0 commit comments

Comments
 (0)