-
Notifications
You must be signed in to change notification settings - Fork 139
/
Copy pathDrawDemo.vue
77 lines (68 loc) · 1.92 KB
/
DrawDemo.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<template>
<form>
<fieldset>
<label for="checkbox">Draw Mode Enabled</label>
<input type="checkbox" id="checkbox" v-model="drawEnable" />
</fieldset>
<fieldset>
<label for="type">Geometry Type</label>
<select id="type" class="select-default" v-model="drawType">
<option value="Point">Point</option>
<option value="LineString">LineString</option>
<option value="Polygon">Polygon</option>
<option value="Circle">Circle</option>
</select>
</fieldset>
</form>
<ol-map
:loadTilesWhileAnimating="true"
:loadTilesWhileInteracting="true"
style="height: 400px"
>
<ol-view
ref="view"
:center="center"
:zoom="zoom"
:projection="projection"
/>
<ol-tile-layer>
<ol-source-osm />
</ol-tile-layer>
<ol-vector-layer>
<ol-source-vector :projection="projection">
<ol-interaction-draw
v-if="drawEnable"
:type="drawType"
@drawend="drawend"
@drawstart="drawstart"
>
<ol-style>
<ol-style-stroke color="blue" :width="2"></ol-style-stroke>
<ol-style-fill color="rgba(255, 255, 0, 0.4)"></ol-style-fill>
</ol-style>
</ol-interaction-draw>
</ol-source-vector>
<ol-style>
<ol-style-stroke color="red" :width="2"></ol-style-stroke>
<ol-style-fill color="rgba(255,255,255,0.1)"></ol-style-fill>
<ol-style-circle :radius="7">
<ol-style-fill color="red"></ol-style-fill>
</ol-style-circle>
</ol-style>
</ol-vector-layer>
</ol-map>
</template>
<script setup>
import { ref } from "vue";
const center = ref([40, 40]);
const projection = ref("EPSG:4326");
const zoom = ref(8);
const drawEnable = ref(true);
const drawType = ref("Polygon");
const drawstart = (event) => {
console.log(event);
};
const drawend = (event) => {
console.log(event);
};
</script>