Create Legend for Cluster Layer

1477
2
Jump to solution
10-01-2013 10:57 AM
CameronPlouffe
New Contributor
Hello,

I've recently been employing the ClusterLayer module (https://developers.arcgis.com/en/javascript/jssamples/layers_point_clustering.html) to represent point clusters in a web mapping application, and I'm interested in being able to display the different symbols for cluster sizes in a Legend object.  Essentially, what I want is each classification symbol followed by a label which tells the user the range of the number of points which would be represented by that symbol.  I've considered just making a static image to depict this, but that approach seems kind of hackish, and if the symbology were to be changed, I'd like the legend to be able to dynamically reflect that.

I'm aware that the ClusterLayer is a modified GraphicsLayer object, and have read that the best way to display GraphicsLayer symbology in a Legend object is by converting the layer into a feature collection, and from that using a FeatureLayer to populate the Legend.  I'm not quite sure how I would go about that using a ClusterLayer, as the symbology is not tied to any particular attribute, but rather the proximity of features to one another.

I'm wondering if anybody has any experience addressing this problem, or a problem similar to it.  Obviously, if necessary, I can take the approach of creating a static legend image I suggested above, but I'd like to avoid this if at all possible.

Please, let me know if anyone has ideas for a solution to this issue.

Thanks a lot,
Cam
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Original User: nliu


what I want is each classification symbol followed by a label which tells the user the range of the number of points which would be represented by that symbol. 


You would need loop through the renderer, use esri.symbol.jsonUtils.getShapeDescriptors() to generate a graphic surface for each symbol, then use dojo's graphic API to put it in a DOM element.

If that sounds like a lot of work, you can use this widget: http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109

I just found out it works with cluster layer directly, as in this sample:
http://gmaps-utility-gis.googlecode.com/svn/trunk/agsjs/test/toc_cluster.html

View solution in original post

0 Kudos
2 Replies
by Anonymous User
Not applicable
Original User: nliu


what I want is each classification symbol followed by a label which tells the user the range of the number of points which would be represented by that symbol. 


You would need loop through the renderer, use esri.symbol.jsonUtils.getShapeDescriptors() to generate a graphic surface for each symbol, then use dojo's graphic API to put it in a DOM element.

If that sounds like a lot of work, you can use this widget: http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109

I just found out it works with cluster layer directly, as in this sample:
http://gmaps-utility-gis.googlecode.com/svn/trunk/agsjs/test/toc_cluster.html
0 Kudos
CameronPlouffe
New Contributor
I just found out it works with cluster layer directly, as in this sample:
http://gmaps-utility-gis.googlecode.com/svn/trunk/agsjs/test/toc_cluster.html

Wow, this is pretty much exactly what I was looking for, and on top of that, seemingly easy to implement.  Thanks a ton for the quick response.  I'll let you know how it goes, but I don't envision having too many major problems.

Thanks again,
Cam
0 Kudos