@@ -13,10 +13,12 @@ import { Geometry } from '../../../geometry';
13
13
import Painter from '../Painter' ;
14
14
import { Extent } from '../../../geo' ;
15
15
import { ResourceCache } from '../../layer/LayerAbstractRenderer' ;
16
+ import { getDefaultBBOX , resetBBOX } from '../../../core/util/bbox' ;
16
17
17
18
const MARKER_SIZE : [ number , number ] = [ 0 , 0 ] ;
18
19
const TEMP_EXTENT = new PointExtent ( ) ;
19
20
const DEFAULT_ANCHOR = new Point ( 0 , 0 ) ;
21
+ const TEMP_BBOX = getDefaultBBOX ( ) ;
20
22
21
23
export default class VectorMarkerSymbolizer extends PointSymbolizer {
22
24
//@internal
@@ -66,14 +68,16 @@ export default class VectorMarkerSymbolizer extends PointSymbolizer {
66
68
this . geometry . getLayer ( ) . getMask ( ) === this . geometry ||
67
69
this . _dynamic ||
68
70
this . geometry . getLayer ( ) . options [ 'cacheVectorOnCanvas' ] === false ) {
69
- this . _drawMarkers ( ctx , cookedPoints , resources ) ;
71
+ //动态样式或者不缓存,function-type style, or not cache vector on canvas
72
+ this . _drawMarkersWithDynamic ( ctx , cookedPoints , resources ) ;
70
73
} else {
71
74
this . _drawMarkersWithCache ( ctx , cookedPoints , resources ) ;
72
75
}
73
76
}
74
77
78
+ //rename to _drawMarkersWithDynamic
75
79
//@internal
76
- _drawMarkers ( ctx : CanvasRenderingContext2D , cookedPoints : any [ ] , resources : ResourceCache ) {
80
+ _drawMarkersWithDynamic ( ctx : CanvasRenderingContext2D , cookedPoints : any [ ] , resources : ResourceCache ) {
77
81
for ( let i = cookedPoints . length - 1 ; i >= 0 ; i -- ) {
78
82
let point = cookedPoints [ i ] ;
79
83
const size = calVectorMarkerSize ( MARKER_SIZE , this . style ) ;
@@ -90,13 +94,17 @@ export default class VectorMarkerSymbolizer extends PointSymbolizer {
90
94
this . rotations . push ( rad ) ;
91
95
}
92
96
93
- this . _drawVectorMarker ( ctx , point , resources ) ;
97
+ const bbox = this . _drawVectorMarker ( ctx , point , resources ) ;
94
98
if ( origin ) {
95
99
ctx . restore ( ) ;
96
100
this . _setBBOX ( ctx , extent . xmin , extent . ymin , extent . xmax , extent . ymax ) ;
97
101
} else {
98
- const { x, y } = point ;
99
- this . _setBBOX ( ctx , x , y , x + width , y + height ) ;
102
+ if ( bbox ) {
103
+ this . _setBBOX ( ctx , bbox [ 0 ] , bbox [ 1 ] , bbox [ 2 ] , bbox [ 3 ] ) ;
104
+ } else {
105
+ const { x, y } = point ;
106
+ this . _setBBOX ( ctx , x , y , x + width , y + height ) ;
107
+ }
100
108
}
101
109
}
102
110
}
@@ -203,15 +211,21 @@ export default class VectorMarkerSymbolizer extends PointSymbolizer {
203
211
204
212
//@internal
205
213
_drawVectorMarker ( ctx : CanvasRenderingContext2D , point : Point , resources : ResourceCache ) {
206
- drawVectorMarker ( ctx , point , this . style , resources ) ;
214
+ resetBBOX ( TEMP_BBOX ) ;
215
+ drawVectorMarker ( ctx , point , this . style , resources , TEMP_BBOX ) ;
216
+ return TEMP_BBOX ;
207
217
}
208
218
209
219
getFixedExtent ( ) : PointExtent {
210
- const isDynamic = this . isDynamicSize ( ) ;
211
- const w = this . style . markerWidth ;
212
- const h = this . style . markerHeight ;
220
+ // const isDynamic = this.isDynamicSize();
221
+ // const w = this.style.markerWidth;
222
+ // const h = this.style.markerHeight;
223
+ // this._fixedExtent = this._fixedExtent || new PointExtent();
224
+ // return getVectorMarkerFixedExtent(this._fixedExtent, this.style, isDynamic ? [128, 128 * (w === 0 ? 1 : h / w)] : null);
225
+
213
226
this . _fixedExtent = this . _fixedExtent || new PointExtent ( ) ;
214
- return getVectorMarkerFixedExtent ( this . _fixedExtent , this . style , isDynamic ? [ 128 , 128 * ( w === 0 ? 1 : h / w ) ] : null ) ;
227
+ return getVectorMarkerFixedExtent ( this . _fixedExtent , this . style , null ) ;
228
+
215
229
}
216
230
217
231
translate ( ) : any {
0 commit comments