Skip to content

Commit 98c7390

Browse files
committed
fix bug with stream data
1 parent 60dc4cf commit 98c7390

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

lib/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ var LeafletReactTrackPlayer = function (_MapLayer) {
314314
// icon
315315
this.createIcon = function (rotate) {
316316
return _leaflet2.default.divIcon({
317-
html: "<div class=\"custom-marker-player" + (!_this2.props.customMarker ? " default" : "") + "\" style=\"background: url('" + (_this2.props.customMarker ? _this2.props.markerIcon : "https://unpkg.com/leaflet@1.3.4/dist/images/marker-icon-2x.png") + "') no-repeat center; height: 100%; transform: rotate(" + (_this2.props.customMarker && _this2.props.customCourse ? rotate : 0) + "deg)" + _this2.props.styleMarker + "\"></div>",
317+
html: "<div class=\"custom-marker-player" + (!_this2.props.customMarker ? " default" : "") + "\" style=\"background: url('" + (_this2.props.customMarker ? _this2.props.iconCustomMarker : "https://unpkg.com/leaflet@1.3.4/dist/images/marker-icon-2x.png") + "') no-repeat center; height: 100%; transform: rotate(" + (_this2.props.customMarker && _this2.props.customCourse ? rotate : 0) + "deg)" + _this2.props.styleMarker + "\"></div>",
318318
iconSize: [35, 35]
319319
});
320320
};
@@ -375,6 +375,9 @@ var LeafletReactTrackPlayer = function (_MapLayer) {
375375
this.updateProgressByTime(toProps, distanceNewPoints);
376376
}
377377
}
378+
if (fromProps.iconCustomMarker !== toProps.iconCustomMarker) {
379+
this.leafletElement.finishMarker._icon.children[0].style.background = "url(" + toProps.iconCustomMarker + ") center center no-repeat";
380+
}
378381
}
379382
}, {
380383
key: "render",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "leaflet-react-track-player",
33
"description": "This is plugin to react-leaflet. It create player for control of track.",
4-
"version": "1.2.2",
4+
"version": "1.2.4",
55
"private": false,
66
"main": "lib/index.js",
77
"homepage": "https://github.com/argonavt11/leaflet-react-track-player",

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,14 @@ L.LayerGroup.include({
267267
},
268268

269269
snakePlay: function() {
270-
this._snakingLayers.map(item => {
270+
const findLast = this._snakingLayers.some((itm) => itm._snaking);
271+
var goPlay = null;
272+
this._snakingLayers.map(function (item) {
271273
if (item._map && item._snaking) item.snakePlay();
272274
});
275+
if (findLast) {
276+
if(goPlay) goPlay.snakePlay();
277+
} else this._snakeNext();
273278
},
274279
// change position. This function stopping work of animation and initiate polylines with default state. Need timestamp
275280
changePosition: function(value) {
@@ -440,18 +445,19 @@ L.LayerGroup.include({
440445
_initiateStartPosition: function() {
441446
if (this._options.startPosition === "full") {
442447
if (this._options.progressFormat === "default") {
443-
this.changePosition(this._originalLatlngs.length - 1);
448+
this.changePosition(this._originalLatlngs.length);
444449
} else if (this._options.progressFormat === "distance") {
445450
const max = this._detailDistance.reduce((result, item) => {
446451
result = result + item;
447452
return result;
448453
}, 0);
449-
this.changePosition(max);
454+
this.changePosition(max + 1);
450455
} else if (this._options.progressFormat === "time") {
451456
this.changePosition(
452-
this._originalLatlngs[this._originalLatlngs.length - 1].t
457+
this._originalLatlngs[this._originalLatlngs.length - 1].t + 1
453458
);
454459
}
460+
this._snaking = false;
455461
this._end(true);
456462
} else {
457463
this.changePosition(this._options.startPosition);
@@ -460,7 +466,9 @@ L.LayerGroup.include({
460466
},
461467

462468
_snakeNext: function() {
463-
console.log(this);
469+
if(!this._snaking && this._snakingLayersDone < this._snakingLayers.length) {
470+
this._snaking = true;
471+
}
464472
if (this._snakingLayersDone >= this._snakingLayers.length) {
465473
this._end(true);
466474
this._snaking = false;
@@ -487,6 +495,8 @@ L.LayerGroup.include({
487495
});
488496
this._snakingLayers[prevRange + index].removePosition();
489497
});
490-
this.snakePlay();
498+
if (!this._snaking) {
499+
this.snakePlay();
500+
}
491501
}
492502
});

0 commit comments

Comments
 (0)