Client Side Clustering - Toggle Visibility


I'm trying to create a map where I can hide and show all points in a ClusteredEntityCollection. There currently is no way to do this, but I created a hack that makes this available. What I did was add a boolean property in the _options for visibility. Then, in the cluster method, I changed the first if statement to include my visible property (if (_data != null && _options.visible)) . I added a method to check if the Collection is visible here:
this.getVisible = function () {
       return _options.visible;
In addition, I had to make one change to the SetOptions method, as it was using the wrong variable when trying to set the option. Previously, it was grabbing the initial options and setting the options to that. By changing the variable name from "options" to "option", I was able to get the method pointing at the right options. Also for my personal use, I added a version of SetOptions using camel-case rather than Pascal-case, as other Collections use camel-case and I needed a generic method to call. Attached is my modified version of the Clustering. I'm sure there's a better way to do this, but I wanted to leave a partial solution for people to look at if a fix for this isn't forthcoming.

file attachments

Closed May 30, 2014 at 2:55 AM by rbrundritt
You should use the GetLayer/SetLayer methods and use the visibility property on there to toggle the layer on/off.