Marker Cluster is rendering default google marker icon over custom marker icon

84 views Asked by At

I am using google map in one of my project that renders multiple markers one by one from the db data. I am using "@googlemaps/markerclusterer" to cluster nearby markers. The code queries the db to fetch point locations in DB within given radius. At smaller radius, things are working fine. But at larger radius, I am guessing because the number of markers are more, the clusterer is rendering default marker icons along with custom icons. I have tried a lot of ways to reduce loading and rendering time of markers. I have compressed the custom icon images and i am fetching them from s3, but this behaviour persists. How can i stop the default marker icon from getting loaded. Attaching a screenshot of map for better reference. As it can be seen in the picture the default red color icon is displaying over custom tomato color iconenter image description here

1

There are 1 answers

0
Dwaipayan Vidyanta On

Update: I fixed the issue. What I was missing is I was making a new marker cluster for every fetch and I was not freeing the previous marker cluster from memory. Whenever we apply marker cluster, always be sure to implement it as singleton pattern to avoid such issues:)