Skip to content

Commit 2123594

Browse files
authored
fix Path animateShow missing z (#2581)
1 parent 10ebfc9 commit 2123594

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

packages/maptalks/src/geometry/Path.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export class Path extends Geometry {
193193
this._animLenSoFar += segLen;
194194
}
195195
this._animIdx = i - 1;
196+
//is end
196197
if (this._animIdx >= l - 1) {
197198
this.setCoordinates(coordinates);
198199
return coordinates[coordinates.length - 1];
@@ -211,9 +212,12 @@ export class Path extends Geometry {
211212

212213
const c1 = coordinates[idx], c2 = coordinates[idx + 1];
213214
const cx = c1.x + (c2.x - c1.x) * r,
214-
cy = c1.y + (c2.y - c1.y) * r;
215+
cy = c1.y + (c2.y - c1.y) * r,
216+
cz = (c1.z || 0) + ((c2.z || 0) - (c1.z || 0)) * r;
215217
this._tempCoord.x = cx;
216218
this._tempCoord.y = cy;
219+
this._tempCoord.z = cz;
220+
217221
// const targetCoord = projection.unproject(lastCoord, this._tempCoord);
218222
const targetCoord = this._tempCoord;
219223
const isPolygon = !!this.getShell;

packages/maptalks/test/geometry/LineStringSpec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,34 @@ describe('Geometry.LineString', function () {
635635
});
636636
layer.addGeometry(line);
637637
});
638+
639+
it('fix missing z,the coordinates should carray z', function (done) {
640+
const c1 = map.getCenter();
641+
const c2 = c1.add(0.001, 0);
642+
c1.z = 10;
643+
c2.z = 20;
644+
var line = new maptalks.LineString([c1, c2], {
645+
symbol: [{
646+
'lineColor': '#1bbc9b',
647+
'lineWidth': 6,
648+
'lineJoin': 'round', //miter, round, bevel
649+
'lineCap': 'round', //butt, round, square
650+
'lineDasharray': null, //dasharray, e.g. [10, 5, 5]
651+
'lineOpacity ': 1
652+
}]
653+
});
654+
layer.addGeometry(line);
655+
656+
setTimeout(() => {
657+
const player = line.animateShow({ duration: 3000 }, ((frame, current) => {
658+
expect(current).to.be.a('object');
659+
expect(current.z).to.be.a('number');
660+
expect(current.z).to.be.within(10, 20);
661+
player.cancel();
662+
done();
663+
}));
664+
}, 100);
665+
});
638666
});
639667

640668
it('#2167 line draw altitude wall ', function (done) {

0 commit comments

Comments
 (0)