Skip to content

Commit 07c2247

Browse files
feat(routing): add drag to markers
1 parent f579f1e commit 07c2247

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/plugins/routing/composables/useMarkerLayer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Ref } from 'vue'
55

66
import { Feature } from 'ol'
77
import { Point } from 'ol/geom'
8+
import Modify from 'ol/interaction/Modify'
89
import VectorLayer from 'ol/layer/Vector'
910
import { Circle, Fill, Stroke, Style } from 'ol/style'
1011
import { onScopeDispose, watch } from 'vue'
@@ -42,4 +43,16 @@ export function useMarkerLayer(
4243
}
4344
})
4445
})
46+
47+
const modify = new Modify({ source: markerSource })
48+
modify.on('modifyend', () => {
49+
route.value = markerSource.getFeatures().map((feature) => {
50+
const geometry = feature.getGeometry()
51+
if (geometry instanceof Point) {
52+
return geometry.getCoordinates()
53+
}
54+
return []
55+
})
56+
})
57+
map.addInteraction(modify)
4558
}

0 commit comments

Comments
 (0)