@@ -13,10 +13,12 @@ import { Geometry } from '../../../geometry';
1313import Painter from '../Painter' ;
1414import { Extent } from '../../../geo' ;
1515import { ResourceCache } from '../../layer/LayerAbstractRenderer' ;
16+ import { getDefaultBBOX , resetBBOX } from '../../../core/util/bbox' ;
1617
1718const MARKER_SIZE : [ number , number ] = [ 0 , 0 ] ;
1819const TEMP_EXTENT = new PointExtent ( ) ;
1920const DEFAULT_ANCHOR = new Point ( 0 , 0 ) ;
21+ const TEMP_BBOX = getDefaultBBOX ( ) ;
2022
2123export default class VectorMarkerSymbolizer extends PointSymbolizer {
2224 //@internal
@@ -66,14 +68,16 @@ export default class VectorMarkerSymbolizer extends PointSymbolizer {
6668 this . geometry . getLayer ( ) . getMask ( ) === this . geometry ||
6769 this . _dynamic ||
6870 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 ) ;
7073 } else {
7174 this . _drawMarkersWithCache ( ctx , cookedPoints , resources ) ;
7275 }
7376 }
7477
78+ //rename to _drawMarkersWithDynamic
7579 //@internal
76- _drawMarkers ( ctx : CanvasRenderingContext2D , cookedPoints : any [ ] , resources : ResourceCache ) {
80+ _drawMarkersWithDynamic ( ctx : CanvasRenderingContext2D , cookedPoints : any [ ] , resources : ResourceCache ) {
7781 for ( let i = cookedPoints . length - 1 ; i >= 0 ; i -- ) {
7882 let point = cookedPoints [ i ] ;
7983 const size = calVectorMarkerSize ( MARKER_SIZE , this . style ) ;
@@ -90,13 +94,17 @@ export default class VectorMarkerSymbolizer extends PointSymbolizer {
9094 this . rotations . push ( rad ) ;
9195 }
9296
93- this . _drawVectorMarker ( ctx , point , resources ) ;
97+ const bbox = this . _drawVectorMarker ( ctx , point , resources ) ;
9498 if ( origin ) {
9599 ctx . restore ( ) ;
96100 this . _setBBOX ( ctx , extent . xmin , extent . ymin , extent . xmax , extent . ymax ) ;
97101 } 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+ }
100108 }
101109 }
102110 }
@@ -203,15 +211,21 @@ export default class VectorMarkerSymbolizer extends PointSymbolizer {
203211
204212 //@internal
205213 _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 ;
207217 }
208218
209219 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+
213226 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+
215229 }
216230
217231 translate ( ) : any {
0 commit comments