Skip to content

Commit 5408ae3

Browse files
committed
fix(ol-style): apply style correctly to ol-interaction-*
This fixes the behaviour that some style weren't applied correctly within interactions. Added a demo which shows how to style circle at pointer position as well. closes #351
1 parent 033c532 commit 5408ae3

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

Diff for: src/components/interaction/OlInteractionDraw.vue

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44

55
<script setup lang="ts">
66
import type { Ref } from "vue";
7-
import { provide, inject, watch, onMounted, onUnmounted, toRefs } from "vue";
7+
import {
8+
provide,
9+
inject,
10+
watch,
11+
onMounted,
12+
onUnmounted,
13+
toRefs,
14+
ref,
15+
} from "vue";
816
import Draw from "ol/interaction/Draw";
917
import type Map from "ol/Map";
1018
import type VectorSource from "ol/source/Vector";
@@ -123,7 +131,7 @@ onUnmounted(() => {
123131
map?.removeInteraction(draw);
124132
});
125133
126-
provide("stylable", draw);
134+
provide("stylable", ref(draw));
127135
128136
defineExpose({
129137
draw,

Diff for: src/components/interaction/OlInteractionModify.vue

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44

55
<script setup lang="ts">
66
import type { Ref } from "vue";
7-
import { provide, inject, watch, onMounted, onUnmounted, toRefs } from "vue";
7+
import {
8+
provide,
9+
inject,
10+
watch,
11+
onMounted,
12+
onUnmounted,
13+
toRefs,
14+
ref,
15+
} from "vue";
816
import type Collection from "ol/Collection";
917
import Modify from "ol/interaction/Modify";
1018
import type Map from "ol/Map";
@@ -93,7 +101,7 @@ onUnmounted(() => {
93101
map?.removeInteraction(modify);
94102
});
95103
96-
provide("stylable", modify);
104+
provide("stylable", ref(modify));
97105
98106
defineExpose({
99107
modify,

Diff for: src/components/styles/OlStyleCircle.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import CircleStyle from "ol/style/Circle";
1010
import Fill from "ol/style/Fill";
1111
import Stroke from "ol/style/Stroke";
1212
13-
import type { Ref } from "vue";
13+
import { type Ref } from "vue";
1414
import { inject, watch, onMounted, onUnmounted, provide, computed } from "vue";
1515
import type Draw from "ol/interaction/Draw";
1616
import type Modify from "ol/interaction/Modify";
@@ -64,7 +64,7 @@ watch(
6464
);
6565
6666
onMounted(() => {
67-
style?.value?.setImage(circle.value);
67+
applyStyle();
6868
});
6969
7070
onUnmounted(() => {

Diff for: src/demos/DrawDemo.vue

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<ol-style>
4343
<ol-style-stroke color="blue" :width="2"></ol-style-stroke>
4444
<ol-style-fill color="rgba(255, 255, 0, 0.4)"></ol-style-fill>
45+
<ol-style-circle :radius="5">
46+
<ol-style-fill color="#00dd11" />
47+
<ol-style-stroke color="blue" :width="2" />
48+
</ol-style-circle>
4549
</ol-style>
4650
</ol-interaction-draw>
4751
</ol-source-vector>

Diff for: src/demos/SnapModifyDemo.vue

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
v-if="modifyEnabled"
2626
:features="selectedFeatures"
2727
>
28+
<ol-style>
29+
<ol-style-circle :radius="5">
30+
<ol-style-fill color="#00dd11" />
31+
<ol-style-stroke color="blue" :width="2" />
32+
</ol-style-circle>
33+
</ol-style>
2834
</ol-interaction-modify>
2935
<ol-interaction-draw
3036
v-if="drawEnabled"

0 commit comments

Comments
 (0)