Skip to content

Commit f6138ca

Browse files
committed
Revert "refactor: make heatmapLayer and vectorLayer not a ref"
This reverts commit f6dca4c.
1 parent 4b61963 commit f6138ca

File tree

8 files changed

+17
-16
lines changed

8 files changed

+17
-16
lines changed

src/components/layers/OlAnimatedClusterLayer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ watch(properties, () => {
6161
});
6262
6363
onMounted(() => {
64-
map.addLayer(vectorLayer);
64+
map.addLayer(vectorLayer.value);
6565
vectorLayer.value.changed();
6666
map.changed();
6767
});
6868
6969
onUnmounted(() => {
70-
map.removeLayer(vectorLayer);
70+
map.removeLayer(vectorLayer.value);
7171
});
7272
7373
provide("vectorLayer", source);

src/components/layers/OlVectorLayer.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</template>
66

77
<script setup>
8-
import { inject, provide, onUnmounted, onMounted, watch } from "vue";
8+
import { inject, provide, onUnmounted, onMounted, watch, computed } from "vue";
99
1010
import VectorLayer from "ol/layer/Vector";
1111
import usePropsAsObjectProperties from "@/composables/usePropsAsObjectProperties";
@@ -34,18 +34,18 @@ const map = inject("map");
3434
3535
const { properties } = usePropsAsObjectProperties(props);
3636
37-
const vectorLayer = new VectorLayer(properties);
37+
const vectorLayer = computed(() => new VectorLayer(properties));
3838
3939
watch(properties, () => {
40-
vectorLayer.setProperties(properties);
40+
vectorLayer.value.setProperties(properties);
4141
});
4242
4343
onMounted(() => {
44-
map.addLayer(vectorLayer);
44+
map.addLayer(vectorLayer.value);
4545
});
4646
4747
onUnmounted(() => {
48-
map.removeLayer(vectorLayer);
48+
map.removeLayer(vectorLayer.value);
4949
});
5050
5151
provide("vectorLayer", vectorLayer);

src/components/map/OlFeature.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ watch(vectorSource, (newVal, oldVal) => {
4141
onMounted(() => {
4242
vectorSource.value.addFeature(feature.value);
4343
if (animation != null) {
44-
vectorLayer.animateFeature(feature.value, animation.value);
44+
vectorLayer.value.animateFeature(feature.value, animation.value);
4545
}
4646
});
4747

src/components/mapControls/OlAttributionControl.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<script setup>
66
import { Attribution } from "ol/control";
77
import useControl from "@/composables/useControl";
8-
import { useAttrs } from "vue";
8+
import { useAttrs, useSlots } from "vue";
99
1010
const props = defineProps({
1111
className: {

src/components/sources/OlSourceVector.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ const { properties } = usePropsAsObjectProperties(props);
5757
const source = computed(() => new VectorSource(properties));
5858
5959
const applySource = () => {
60-
layer.setSource(null);
61-
layer.setSource(source.value);
62-
layer.changed();
60+
layer.value.setSource(null);
61+
layer.value.setSource(source.value);
62+
layer.value.changed();
6363
};
6464
watch(properties, () => {
6565
applySource();
@@ -70,11 +70,11 @@ watch(layer, () => {
7070
});
7171
7272
onMounted(() => {
73-
layer.setSource(source.value);
73+
layer.value.setSource(source.value);
7474
});
7575
7676
onUnmounted(() => {
77-
layer.setSource(null);
77+
layer.value.setSource(null);
7878
});
7979
8080
provide("vectorSource", source);

src/composables/usePropsAsObjectProperties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { toRefs, watch, reactive, type ToRefs, ref } from "vue";
1+
import { toRefs, watch, reactive, type ToRefs, ref, type Ref } from "vue";
22

33
/**
44
* We can't use 'style' as a component prop since it's a reserved property

src/demos/ImageWMSDemo.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</ol-map>
2929
</template>
3030

31-
<script setup>
31+
<script>
3232
import { ref } from "vue";
3333
3434
const zoom = ref(4);

src/demos/SnapModifyDemo.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function vectorStyle() {
130130
return style;
131131
}
132132
133+
const geoJsonFormat = new GeoJSON();
133134
const selectConditions = inject("ol-selectconditions");
134135
const selectCondition = selectConditions.click;
135136

0 commit comments

Comments
 (0)