Skip to content

Commit

Permalink
Optimize setting line style
Browse files Browse the repository at this point in the history
  • Loading branch information
cdauth committed Mar 2, 2024
1 parent 8d857d4 commit b13025c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion leaflet/src/lines/lines-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,13 @@ export default class LinesLayer extends FeatureGroup {
}

(this.linesById[line.id] as any).line = line;
this.linesById[line.id].setLatLngs(splitLatLngs).setStyle(style);

// Set style before setting coordinates, so a new line doesn't have to be rendered twice
if (Object.entries(style).some(([k, v]) => (this.linesById[line.id].realOptions as any)[k] !== v)) {
this.linesById[line.id].setStyle(style);
}

this.linesById[line.id].setLatLngs(splitLatLngs);

if (line.name && line.id != null) { // We don't want a popup for lines that we are drawing right now
const quoted = quoteHtml(line.name);
Expand Down

0 comments on commit b13025c

Please sign in to comment.