File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const TEMP_EXTENT = new PointExtent();
21
21
* @property {Boolean } [options.altitudeProperty=altitude] - geometry's altitude property name, if enableAltitude is true, "altitude" by default
22
22
* @property {Boolean } [options.drawAltitude=false] - whether to draw altitude: a vertical line for marker, a vertical polygon for line
23
23
* @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
24
25
* @property {Number } [options.altitude=0] - layer altitude
25
26
* @property {Boolean } [options.debug=false] - whether the geometries on the layer is in debug mode.
26
27
* @memberOf VectorLayer
@@ -37,6 +38,7 @@ const options = {
37
38
'altitudeProperty' : 'altitude' ,
38
39
'drawAltitude' : false ,
39
40
'sortByDistanceToCamera' : false ,
41
+ 'roundPoint' : false ,
40
42
'altitude' : 0
41
43
} ;
42
44
Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ class Painter extends Class {
214
214
glZoom = map . getGLZoom ( ) ;
215
215
}
216
216
let cPoints ;
217
+ const roundPoint = this . getLayer ( ) . options [ 'roundPoint' ] ;
217
218
function pointsContainerPoints ( viewPoints = [ ] , alts = [ ] ) {
218
219
const pts = map . _pointsToContainerPoints ( viewPoints , glZoom , alts ) ;
219
220
for ( let i = 0 , len = pts . length ; i < len ; i ++ ) {
@@ -222,6 +223,11 @@ class Painter extends Class {
222
223
if ( dx || dy ) {
223
224
p . _add ( dx || 0 , dy || 0 ) ;
224
225
}
226
+ if ( roundPoint ) {
227
+ //使用 round 会导致左右波动,用floor,ceil 要好点
228
+ p . x = Math . ceil ( p . x ) ;
229
+ p . y = Math . ceil ( p . y ) ;
230
+ }
225
231
}
226
232
return pts ;
227
233
}
You can’t perform that action at this time.
0 commit comments