I followed This API Tutorial to create Cluster Points on the map. Now I would like to have a function to hide them. I already tried like?
clusterLayer.hide();
but it didn't work! I also tried to bind the clusterLayer to a GraphicsLayer like below
var clayer = new esri.layers.GraphicsLayer(); clayer.add(clusterLayer); clayer.hide();
but still not working
After hours of working I find a sample on google at this Demo doing the job of switching between Points and Cluster but it is supper complicated to me!
Can you please let me know how I can hide and show the cluster layer on demand?
Solved! Go to Solution.
Behrouz,
Instead of using show() and hide() have you tried using the .setVisibility method? I took a look at the CrimeMapper example and that is the method they used to toggle the visibility.
You can look at the reference here:
GraphicsLayer | API Reference | ArcGIS API for JavaScript
Regards,
Tom
I suspect clusterLayer.hide() is not working for you because the clusterLayer variable is declared within the anonymous function called by ready(function () { var clusterLayer; // only available within this function }).
A simple fix within the sample is to declare clusterLayer as a global along with map; then clusterLayer.hide() will work OR add the layer toggling logic within the aforementioned function.
Behrouz,
Instead of using show() and hide() have you tried using the .setVisibility method? I took a look at the CrimeMapper example and that is the method they used to toggle the visibility.
You can look at the reference here:
GraphicsLayer | API Reference | ArcGIS API for JavaScript
Regards,
Tom