From 2c027402a46bc90ed31bf3b339933dc644755e69 Mon Sep 17 00:00:00 2001 From: Fawad Mirzad Date: Thu, 29 Apr 2021 02:46:52 +0200 Subject: [PATCH] Fix console errors in some cases --- src/components/cluster.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/cluster.vue b/src/components/cluster.vue index 48cdbd6..5699e7e 100644 --- a/src/components/cluster.vue +++ b/src/components/cluster.vue @@ -103,11 +103,14 @@ export default buildComponent({ }, beforeUnmount() { /* Performance optimization when destroying a large number of markers */ - this.$children.forEach((marker) => { - if (marker.$clusterObject === this.$clusterObject) { - marker.$clusterObject = null - } - }) + if (this.$children && this.$children.length) { + this.$children.forEach((marker) => { + if (marker.$clusterObject === this.$clusterObject) { + marker.$clusterObject = null + } + }) + } + if (this.$clusterObject) { this.$clusterObject.clearMarkers()