Skip to content

Commit fcf77b6

Browse files
committed
docs(ol-geom-line-string): add demo for changing coordinates
closes #387
1 parent 55d5fe4 commit fcf77b6

1 file changed

Lines changed: 31 additions & 20 deletions

File tree

src/demos/LineString.vue

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<template>
2+
<button class="btn-default" @click="addCoordinate" type="button">
3+
Add coordinate
4+
</button>
5+
26
<ol-map
37
:loadTilesWhileAnimating="true"
48
:loadTilesWhileInteracting="true"
@@ -18,26 +22,7 @@
1822
<ol-vector-layer>
1923
<ol-source-vector>
2024
<ol-feature ref="profileFeatureRef">
21-
<ol-geom-line-string
22-
:coordinates="[
23-
[116.544921, 40.451633],
24-
[116.545264, 40.451649],
25-
[116.545865, 40.451698],
26-
[116.546144, 40.451551],
27-
[116.546337, 40.451274],
28-
[116.546788, 40.451143],
29-
[116.547324, 40.451078],
30-
[116.547539, 40.450996],
31-
[116.547839, 40.450719],
32-
[116.54844, 40.450506],
33-
[116.548933, 40.450604],
34-
[116.549448, 40.450604],
35-
[116.550242, 40.450376],
36-
[116.550865, 40.450163],
37-
[116.551702, 40.449935],
38-
[116.552581, 40.449576],
39-
]"
40-
></ol-geom-line-string>
25+
<ol-geom-line-string :coordinates="coordinates"></ol-geom-line-string>
4126
<ol-style>
4227
<ol-style-stroke
4328
:color="strokeColor"
@@ -66,6 +51,32 @@ const zoom = ref(17);
6651
const strokeWidth = ref(10);
6752
const strokeColor = ref("red");
6853
const profileFeatureRef = ref(null);
54+
const coordinates = ref([
55+
[116.544921, 40.451633],
56+
[116.545264, 40.451649],
57+
[116.545865, 40.451698],
58+
[116.546144, 40.451551],
59+
[116.546337, 40.451274],
60+
[116.546788, 40.451143],
61+
[116.547324, 40.451078],
62+
[116.547539, 40.450996],
63+
[116.547839, 40.450719],
64+
[116.54844, 40.450506],
65+
[116.548933, 40.450604],
66+
[116.549448, 40.450604],
67+
[116.550242, 40.450376],
68+
[116.550865, 40.450163],
69+
[116.551702, 40.449935],
70+
[116.552581, 40.449576],
71+
]);
72+
73+
function addCoordinate() {
74+
const lastCoordinate = coordinates.value[coordinates.value.length - 1];
75+
coordinates.value.push([
76+
lastCoordinate[0] + Math.random() * 0.0005,
77+
lastCoordinate[1] - Math.random() * 0.0005,
78+
]);
79+
}
6980
7081
function over(event) {
7182
console.log(event);

0 commit comments

Comments
 (0)