Skip to content

Commit 89cf3cc

Browse files
authored
VectorLayer support options.roundPoint config close #1264 (#1265)
1 parent 34ce592 commit 89cf3cc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/layer/VectorLayer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const TEMP_EXTENT = new PointExtent();
2121
* @property {Boolean} [options.altitudeProperty=altitude] - geometry's altitude property name, if enableAltitude is true, "altitude" by default
2222
* @property {Boolean} [options.drawAltitude=false] - whether to draw altitude: a vertical line for marker, a vertical polygon for line
2323
* @property {Boolean} [options.sortByDistanceToCamera=false] - markers Sort by camera distance
24+
* @property {Boolean} [options.roundPoint=false] - round point before painting to improve performance, but will cause geometry shaking in animation
2425
* @property {Number} [options.altitude=0] - layer altitude
2526
* @property {Boolean} [options.debug=false] - whether the geometries on the layer is in debug mode.
2627
* @memberOf VectorLayer
@@ -37,6 +38,7 @@ const options = {
3738
'altitudeProperty': 'altitude',
3839
'drawAltitude': false,
3940
'sortByDistanceToCamera': false,
41+
'roundPoint': false,
4042
'altitude': 0
4143
};
4244

src/renderer/geometry/Painter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class Painter extends Class {
214214
glZoom = map.getGLZoom();
215215
}
216216
let cPoints;
217+
const roundPoint = this.getLayer().options['roundPoint'];
217218
function pointsContainerPoints(viewPoints = [], alts = []) {
218219
const pts = map._pointsToContainerPoints(viewPoints, glZoom, alts);
219220
for (let i = 0, len = pts.length; i < len; i++) {
@@ -222,6 +223,11 @@ class Painter extends Class {
222223
if (dx || dy) {
223224
p._add(dx || 0, dy || 0);
224225
}
226+
if (roundPoint) {
227+
//使用 round 会导致左右波动,用floor,ceil 要好点
228+
p.x = Math.ceil(p.x);
229+
p.y = Math.ceil(p.y);
230+
}
225231
}
226232
return pts;
227233
}

0 commit comments

Comments
 (0)