I need to have different markers for different mapType
s, and I'm pushing them to a MarkerClusterer.
I "hide" the markers with:
cluster.set("map", null);
cluster.resetViewport();
cluster.redraw();
And "show" them with:
cluster.set("map", MAP);
cluster.resetViewport();
cluster.redraw();
The problem is that MarkerClusterer seems to not like set("map", null)
; it throws the error TypeError: Object #<a MarkerClusterer> has no method 'remove'
. How can I show/hide them the proper way?
In the Javascript API v3 it is sufficient to say:
clusterer.setMap(null);
If you set your map back to the existing map object, the clusters will reappear.
clusterer.setMap( this.map );
Also, I would suggest not to name your Clusterer 'cluster', like in your example. The MarkerClusterer contains Cluster objects, which are the actual clustered markers and not the ClusterER itself.