Skip to content

Commit e0ded27

Browse files
authored
optimize vectormarker event performance when it symbol has function-type (#2186)
1 parent e097d5a commit e0ded27

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/renderer/geometry/symbolizers/VectorMarkerSymbolizer.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { getDefaultVAlign, getDefaultHAlign, DEFAULT_MARKER_SYMBOLS } from '../.
1212

1313
const MARKER_SIZE = [];
1414
const TEMP_EXTENT = new PointExtent();
15+
const DEFAULT_ANCHOR = new Point(0, 0);
1516

1617
export default class VectorMarkerSymbolizer extends PointSymbolizer {
1718

@@ -59,15 +60,26 @@ export default class VectorMarkerSymbolizer extends PointSymbolizer {
5960
_drawMarkers(ctx, cookedPoints, resources) {
6061
for (let i = cookedPoints.length - 1; i >= 0; i--) {
6162
let point = cookedPoints[i];
63+
const size = calVectorMarkerSize(MARKER_SIZE, this.style);
64+
const [width, height] = size;
6265
// const origin = this._rotate(ctx, point, this._getRotationAt(i));
66+
let extent;
6367
const origin = this.getRotation() ? this._rotate(ctx, point, this._getRotationAt(i)) : null;
6468
if (origin) {
69+
const pixel = point.sub(origin);
6570
point = origin;
71+
const rad = this._getRotationAt(i);
72+
extent = getMarkerRotationExtent(TEMP_EXTENT, rad, width, height, point, DEFAULT_ANCHOR);
73+
extent._add(pixel);
6674
}
6775

6876
this._drawVectorMarker(ctx, point, resources);
6977
if (origin) {
7078
ctx.restore();
79+
this._setBBOX(ctx, extent.xmin, extent.ymin, extent.xmax, extent.ymax);
80+
} else {
81+
const { x, y } = point;
82+
this._setBBOX(ctx, x, y, x + width, y + height);
7183
}
7284
}
7385
}

0 commit comments

Comments
 (0)