Skip to content

optimize vectormarker event performance when it symbol has function-type #2186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/renderer/geometry/symbolizers/VectorMarkerSymbolizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getDefaultVAlign, getDefaultHAlign, DEFAULT_MARKER_SYMBOLS } from '../.

const MARKER_SIZE = [];
const TEMP_EXTENT = new PointExtent();
const DEFAULT_ANCHOR = new Point(0, 0);

export default class VectorMarkerSymbolizer extends PointSymbolizer {

Expand Down Expand Up @@ -59,15 +60,26 @@ export default class VectorMarkerSymbolizer extends PointSymbolizer {
_drawMarkers(ctx, cookedPoints, resources) {
for (let i = cookedPoints.length - 1; i >= 0; i--) {
let point = cookedPoints[i];
const size = calVectorMarkerSize(MARKER_SIZE, this.style);
const [width, height] = size;
// const origin = this._rotate(ctx, point, this._getRotationAt(i));
let extent;
const origin = this.getRotation() ? this._rotate(ctx, point, this._getRotationAt(i)) : null;
if (origin) {
const pixel = point.sub(origin);
point = origin;
const rad = this._getRotationAt(i);
extent = getMarkerRotationExtent(TEMP_EXTENT, rad, width, height, point, DEFAULT_ANCHOR);
extent._add(pixel);
}

this._drawVectorMarker(ctx, point, resources);
if (origin) {
ctx.restore();
this._setBBOX(ctx, extent.xmin, extent.ymin, extent.xmax, extent.ymax);
} else {
const { x, y } = point;
this._setBBOX(ctx, x, y, x + width, y + height);
}
}
}
Expand Down