|
1 | 1 | <template> |
| 2 | + <button class="btn-default" @click="addCoordinate" type="button"> |
| 3 | + Add coordinate |
| 4 | + </button> |
| 5 | + |
2 | 6 | <ol-map |
3 | 7 | :loadTilesWhileAnimating="true" |
4 | 8 | :loadTilesWhileInteracting="true" |
|
18 | 22 | <ol-vector-layer> |
19 | 23 | <ol-source-vector> |
20 | 24 | <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> |
41 | 26 | <ol-style> |
42 | 27 | <ol-style-stroke |
43 | 28 | :color="strokeColor" |
@@ -66,6 +51,32 @@ const zoom = ref(17); |
66 | 51 | const strokeWidth = ref(10); |
67 | 52 | const strokeColor = ref("red"); |
68 | 53 | 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 | +} |
69 | 80 |
|
70 | 81 | function over(event) { |
71 | 82 | console.log(event); |
|
0 commit comments