ESRI point clustering example using featurelayer or querytask as input?

16665
42
Jump to solution
10-05-2012 08:32 AM
TracySchloss
Frequent Contributor
I have tried to implement the ESRI forum example for clustering "Clustering with Javascript API" http://www.arcgis.com/home/item.html?id=c546bc8d4f0b4c0fbdf149b92223e681 with mixed results.  Sometimes the cluster layer draws fine and sometimes it doesn't draw at all.  Even when it draws it's very slow and I'm not sure the users will be satisfied.  There seems to be mixed reviews on this.  The fact that it's display seem to be intermittent for me is enough for me to look to another clustering solution. 

More recently, the ESRI sample "Point Clustering" was posted. http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/layers_point_c... I like the way this looks, but I'm having a hard time understanding how to make it work with a layer as input, since my data is already in a service.  It seems like either I should add a function to step through all my features to create properly formatted input data, or I should edit the custom layer to handle features of a featureset or featurelayer instead.

Has anyone modified ESRI's point clustering example to use something besides the input JSON file?
42 Replies
TracySchloss
Frequent Contributor

It's hard to know why you're getting that error w/o seeing the entire context.  The post you replied to is 2 years old and was in legacy (nonAMD) code.  Maybe you're getting stuck there.  There was both a legacy and AMD version of clusterLayers are one point, right when AMD first came out.  Generally when I have the sort of error you're describing, it's nothing to do with the function, it's because I don't have something right toward the top, either in my dojoConfig definition or when I'm setting all my requires.

0 Kudos
Avisaroussi
New Contributor II

hi again

not sure i understand what you mean by AMD.

is ther a new version ?

0 Kudos
TracySchloss
Frequent Contributor

It sounds like you need to do some more reading on the differences between AMD and legacy style code. AMD is not new. Throughout the samples and help pages, you'll see syntax that might say either 'legacy code' or AMD.  It has to do with how the modules are first loaded, among other things.

Here's another thread that discusses the differences.  It's hard to know specifically what your problem is from the small amount of code you've provided.

https://community.esri.com/thread/79966

0 Kudos
Avisaroussi
New Contributor II

sorry , i forgot that the A in AMD stands for Asynchronous 

i am  aware of that , and also am using it in my code . although i do not  fully understand all the fine lines.

i did do some reading though.

going back two emails ago.

is there an AMD sample with data comming from feature layer?

0 Kudos
ReneRubalcava
Frequent Contributor

I posted it earlier in this thread, but this version of the ClusterLayer is a FeatureLayer (almost) with clusters enabled.

odoe/esri-clusterfeaturelayer · GitHub

It takes a URL, does caching and more. It will even convert a service of polygons to points and cluster them. One of the samples tries to access an AGOL service that requires a login now though, so I need to update that.

0 Kudos
TracySchloss
Frequent Contributor

Not that I know of.  I don't think changing to a featureLayer gains you much, if anything.  The whole idea of the cluster is that is processes all your records and determines which should be combined. 

0 Kudos
Avisaroussi
New Contributor II

ok i moved on a little

now  i am getting this error:

"Object doesn't support property or method 'setRenderer'"

when i look into the clusterlayer object during debug  it doesnt have this method?

0 Kudos
Avisaroussi
New Contributor II

ok its working

and Tracy you were right there was a problem with the requires .

i added something to your function  .

it draws the extent of the points that are concluded in the cluster you hover on.

clusterLayer.on(mouse-over", function (a)

{

if(clusterExtentGraphic != undefined)

{

   map.graphics.remove(clusterExtentGraphic);

}

    

var geo = a.graphic.attributes.extent;

     if (geo != undefined)

     {

          var lineSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL,

          new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH,

          new dojo.Color([0, 0, 0]), 2));

          var extent = new Extent(geo[0], geo[1], geo[2], geo[3], new SpatialReference({ wkid: 2039 }));

                  clusterExtentGraphic = new Graphic(extent, lineSymbol);

                    map.graphics.add(clusterExtentGraphic);

     }

});

thanks ,

Avi Saroussi

Raven Radio.

0 Kudos
ShawnLanning
New Contributor II

Tracy,

Do you have a full working example of this that you would be willing to share?

0 Kudos
TracySchloss
Frequent Contributor

Let me dig around.  The problem is the project I created this for contains sensitive data, so the services are locked.  I think this one is working:

Cluster Example