When using a icon in singleMarkerMode, it will not work properly link
But when remove <l-icon />
, it will work normally
is it possible use both together?
28/02
In code 1, I think refreshClusters() will consider disableClusteringAtZoom.
So I tried to use refreshClusters() in mounted.
Result: The program does not consider disableClusteringAtZoom, and changes the icon immediately.
In code 2, I try to set the initial singleMarkerMode to false and use @update:zoom to check the zoom, when it < disableClusteringAtZoom, then set singleMarkerMode to true and use refreshClusters()
Result: The initial icon is a custom icon, and when the zoom is <15, the icon is changed, but after that, when the zoom is >= 15, it cannot be changed back to the custom icon.
Any ideas how to change back to custom icons? Or any method that makes singleMarkerMode work similar to markercluster (multi)
Code1
<template>
<div>
<div>
...
<l-marker-cluster
:options="{
singleMarkerMode: true,
spiderfyOnMaxZoom: false,
disableClusteringAtZoom: 15,
}"
ref="clusterRef"
>
<l-marker :lat-lng="marker">
<l-icon
:icon-url="icon.type.black"
:shadow-url="icon.shadowUrl"
:icon-size="icon.iconSize"
:icon-anchor="icon.iconAnchor"
:popup-anchor="icon.popupAnchor"
:shadow-size="icon.shadowSize" />
</l-marker>
</l-marker-cluster>
...
</div>
</template>
<script>
import ...
export default {
components: {...},
data() {...},
mounted() {
setTimeout(() => this.$refs.clusterRef.mapObject.refreshClusters(), 100);
}
};
</script>
Code2
...
<l-map :@update:zoom="changeZoom" ...>
...
<l-marker-cluster
:options="{
singleMarkerMode: singleMode,
spiderfyOnMaxZoom: false,
disableClusteringAtZoom: 15,
}"
ref="clusterRef"
>
<l-marker :lat-lng="marker">
<l-icon
:icon-url="icon.type.black"
:shadow-url="icon.shadowUrl"
:icon-size="icon.iconSize"
:icon-anchor="icon.iconAnchor"
:popup-anchor="icon.popupAnchor"
:shadow-size="icon.shadowSize" />
</l-marker>
</l-marker-cluster>
...
<script>
import ...
export default {
components: {...},
data() {
singleMode: false
...},
mounted() {},
methods: {
changeZoom(zoom) {
if(zoom < 15) {
this.singleMode = true;
setTimeout(() => this.$refs.clusterRef.mapObject.refreshClusters(), 100);
}
else this.singleMode = false;
}
}
};
</script>