When working with a large number of markers or clusters, passing features directly to ol-source-vector can cause performance issues, such as rendering errors, blocked interactive elements, or memory leaks.
Recommendation: Instead of passing feature objects directly, request features from a URL (e.g., using a GeoJSON endpoint). This allows the source to manage data loading more efficiently.
<template>
<ol-map
:loadTilesWhileAnimating="true"
:loadTilesWhileInteracting="true"
style="height: 400px"
>
<ol-animated-cluster-layer :animationDuration="500" :distance="40">
<ol-source-vector :url="url" :format="geoJson" />
</ol-animated-cluster-layer>
</ol-map>
</template>
<script setup lang="ts">
import { computed, inject } from "vue";
// ...
const format = inject("ol-format");
const geoJson = new format.GeoJSON();
const url = computed(() => {
return `http://localhost:3000/${count.value}`;
});
</script>