Skip to content

Commit

Permalink
docs(ol-geom-line-string): add demo for changing coordinates
Browse files Browse the repository at this point in the history
closes #387
  • Loading branch information
d-koppenhagen committed Dec 17, 2024
1 parent 55d5fe4 commit fcf77b6
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions src/demos/LineString.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<template>
<button class="btn-default" @click="addCoordinate" type="button">
Add coordinate
</button>

<ol-map
:loadTilesWhileAnimating="true"
:loadTilesWhileInteracting="true"
Expand All @@ -18,26 +22,7 @@
<ol-vector-layer>
<ol-source-vector>
<ol-feature ref="profileFeatureRef">
<ol-geom-line-string
:coordinates="[
[116.544921, 40.451633],
[116.545264, 40.451649],
[116.545865, 40.451698],
[116.546144, 40.451551],
[116.546337, 40.451274],
[116.546788, 40.451143],
[116.547324, 40.451078],
[116.547539, 40.450996],
[116.547839, 40.450719],
[116.54844, 40.450506],
[116.548933, 40.450604],
[116.549448, 40.450604],
[116.550242, 40.450376],
[116.550865, 40.450163],
[116.551702, 40.449935],
[116.552581, 40.449576],
]"
></ol-geom-line-string>
<ol-geom-line-string :coordinates="coordinates"></ol-geom-line-string>
<ol-style>
<ol-style-stroke
:color="strokeColor"
Expand Down Expand Up @@ -66,6 +51,32 @@ const zoom = ref(17);
const strokeWidth = ref(10);
const strokeColor = ref("red");
const profileFeatureRef = ref(null);
const coordinates = ref([
[116.544921, 40.451633],
[116.545264, 40.451649],
[116.545865, 40.451698],
[116.546144, 40.451551],
[116.546337, 40.451274],
[116.546788, 40.451143],
[116.547324, 40.451078],
[116.547539, 40.450996],
[116.547839, 40.450719],
[116.54844, 40.450506],
[116.548933, 40.450604],
[116.549448, 40.450604],
[116.550242, 40.450376],
[116.550865, 40.450163],
[116.551702, 40.449935],
[116.552581, 40.449576],
]);
function addCoordinate() {
const lastCoordinate = coordinates.value[coordinates.value.length - 1];
coordinates.value.push([
lastCoordinate[0] + Math.random() * 0.0005,
lastCoordinate[1] - Math.random() * 0.0005,
]);
}
function over(event) {
console.log(event);
Expand Down

0 comments on commit fcf77b6

Please sign in to comment.