Skip to content

Commit a68b04c

Browse files
committed
feat: add multi line support
1 parent 3f13a82 commit a68b04c

File tree

11 files changed

+161
-703
lines changed

11 files changed

+161
-703
lines changed

demos/simple/demo.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ function main() {
123123
trackManager.addPOI(event.coordinate);
124124
});
125125
});
126+
127+
document.querySelector('#createNewPart').addEventListener('click', () => {
128+
trackManager.createNewPart();
129+
});
130+
document.querySelector('#changeActivePart').addEventListener('click', () => {
131+
const nextPart = (trackManager.activePart() + 1) % trackManager.partsCount();
132+
trackManager.workOnPart(nextPart);
133+
});
126134
}
127135

128136
main();

demos/simple/simple.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
<a href="#" id="reverse">reverse</a>
5252
<br />
5353
<a href="#" id="addPoi">Add poi</a>
54-
</div>
54+
<br />
55+
<a href="#" id="createNewPart">Add a new line string</a>
56+
<br />
57+
<a href="#" id="changeActivePart">Change active line string</a>
58+
</div>
5559
<div id="map"></div>
5660
</main>
5761
</body>

demos/simple/style.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const sketchControlPoint = {
1212
export const trackLine = {
1313
"stroke-width": 6,
1414
"stroke-color": "purple",
15+
"text-value": ["concat", "", ["get", "part"]],
16+
"text-fill-color": "#fff",
1517
};
1618

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

3335
export const numberedControlPoint = {
3436
...controlPoint,
3537
"circle-fill-color": "#ffffffdd",
3638
"text-color": "blue",
3739
// use 'concat' to convert number to string
38-
"text-value": ["concat", ["get", "index"], ""],
40+
"text-value": ["concat", "", ["get", "part"]],
3941
};
4042

4143
export const snappedTrue = {

0 commit comments

Comments
 (0)