Currently, I am developing a Vue2 web application using Leaflet and marker-cluster. I am encountering an issue with the iconCreateFunction option in my template:
<v-marker-cluster :options="{ iconCreateFunction: iconCreateClsPrg}">
<l-marker ....>
<l-icon :class-name="programme.display ? 'custom-marker notDisplay' : 'custom-marker display'">
Here is a snippet of the iconCreateClsPrg method:
iconCreateClsPrg (marker_cluster) {
const childs = marker_cluster.getAllChildMarkers();
childs.forEach(child => {
const cssCluster = child.options.icon.options.className;
if (cssCluster && cssCluster.includes(this.css_marker_selected_simple)) {
nbSelected++;
}
}
...
}
The issue arises when the cssCluster const sometimes becomes undefined without any clear reason. This unexpected behavior occurs sporadically at certain zoom levels that are inconsistent. Any suggestions or ideas would be greatly appreciated!
I have attempted to resolve this by refreshing the map, waiting for it to become defined (but faced issues with async methods), restarting the method from scratch, switching to a for loop instead of forEach, among other attempts. Unfortunately, none of these solutions have proven successful.