Skip to content

Commit

Permalink
fix: ensure drawMany feature labes are incremental (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Sep 5, 2024
1 parent fd2b6b5 commit f1d0421
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ <h1 style="color:red;font-size:16px;">
maxZoom="23"
drawMode
drawMany
drawType="Point"
basemap="MapboxSatellite"
showCentreMarker
osCopyright="© Crown copyright and database rights 2024 OS (0)100024857"
Expand Down
6 changes: 3 additions & 3 deletions src/components/my-map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,9 @@ export class MyMap extends LitElement {
const sketches = drawingSource.getFeatures();

// Assign a label to each feature based on its' index
sketches.forEach((sketch, i) => {
// If this feature already exists and is only being modified, use its' current label, else use index (needs to be type string in order to be parsed by Style "Text")
const label = sketch.get("label") || `${i + 1}`;
sketches.forEach((sketch) => {
// If this feature already exists and is only being modified, use its' current label, else use feature length (needs to be type string in order to be parsed by Style "Text")
const label = sketch.get("label") || `${sketches.length}`;
sketch.set("label", label);
});

Expand Down

0 comments on commit f1d0421

Please sign in to comment.