Skip to content

Commit

Permalink
feat: add multi line support
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Sep 4, 2024
1 parent 2b6b570 commit f369e29
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 824 deletions.
8 changes: 8 additions & 0 deletions demos/simple/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ function main() {
trackManager.addPOI(event.coordinate);
});
});

document.querySelector('#createNewPart').addEventListener('click', () => {
trackManager.createNewPart();
});
document.querySelector('#changeActivePart').addEventListener('click', () => {
const nextPart = (trackManager.activePart() + 1) % trackManager.partsCount();
trackManager.workOnPart(nextPart);
});
}

main();
6 changes: 5 additions & 1 deletion demos/simple/simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
<a href="#" id="reverse">reverse</a>
<br />
<a href="#" id="addPoi">Add poi</a>
</div>
<br />
<a href="#" id="createNewPart">Add a new line string</a>
<br />
<a href="#" id="changeActivePart">Change active line string</a>
</div>
<div id="map"></div>
</main>
</body>
Expand Down
6 changes: 4 additions & 2 deletions demos/simple/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const sketchControlPoint = {
export const trackLine = {
"stroke-width": 6,
"stroke-color": "purple",
"text-value": ["concat", "", ["get", "part"]],
"text-fill-color": "#fff",
};

export const trackLineModifying = {
Expand All @@ -27,15 +29,15 @@ export const poiPoint = {
"text-font": "bold 11px Inter",
"text-fill-color": "#000",
// use 'concat' to convert number to string
"text-value": ["concat", ["get", "index"], ""],
"text-value": ["concat", "", ["get", "part"]],
};

export const numberedControlPoint = {
...controlPoint,
"circle-fill-color": "#ffffffdd",
"text-color": "blue",
// use 'concat' to convert number to string
"text-value": ["concat", ["get", "index"], ""],
"text-value": ["concat", "", ["get", "part"]],
};

export const snappedTrue = {
Expand Down
Loading

0 comments on commit f369e29

Please sign in to comment.