Skip to content

Commit

Permalink
refactor(ol-heatmap-layer): layer does not need to be a computed
Browse files Browse the repository at this point in the history
The properties are watched and applied on the existing layer once changed. There is no need to re-compute the layer
  • Loading branch information
d-koppenhagen committed Jun 7, 2023
1 parent 4546fba commit 5ec9c6b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/layers/OlHeatmapLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</template>

<script setup>
import { inject, provide, onUnmounted, onMounted, watch, computed } from "vue";
import { inject, provide, onUnmounted, onMounted, watch } from "vue";
import HeatmapLayer from "ol/layer/Heatmap";
import usePropsAsObjectProperties from "@/composables/usePropsAsObjectProperties";
Expand Down Expand Up @@ -35,18 +35,18 @@ const map = inject("map");
const { properties } = usePropsAsObjectProperties(props);
const heatmapLayer = computed(() => new HeatmapLayer(properties));
const heatmapLayer = new HeatmapLayer(properties);
watch(properties, () => {
heatmapLayer.value.setProperties(properties);
heatmapLayer.setProperties(properties);
});
onMounted(() => {
map.addLayer(heatmapLayer.value);
map.addLayer(heatmapLayer);
});
onUnmounted(() => {
map.removeLayer(heatmapLayer.value);
map.removeLayer(heatmapLayer);
});
provide("heatmapLayer", heatmapLayer);
Expand Down

0 comments on commit 5ec9c6b

Please sign in to comment.