Select to view content in your preferred language

ESRI point clustering example using featurelayer or querytask as input?

17454
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
Avisaroussi
New Contributor II

hi 

tried to implement Tracy's code

but i get an error "Object doesn't support this action"

when instantiating the cluster layer

new ClusterLayer({ 

"data": inputInfo.data, 

"distance": 100, 

"id": "clusters"

"labelColor": "#fff",

"spatialReference": SR,

"labelOffset": 10, 

"resolution": map.extent.getWidth() / map.width, 

"singleColor": "#888"

"singleTemplate": infoTemplate 

  }); 

i checked that all parameters sent are valid .

  • inputInfo.data has features data
  • sr is defined
  • map.width and map.extent.getWidth has relevant values
  • infoTemplate is defined in a general way to fit

    infoTemplate = new InfoTemplate("Attributes", "${*}");

any idea what might be in the way?

0 Kudos
derekswingley1
Frequent Contributor II
I can't believe I got it work!  This method executes much faster than the forum example, so I'm glad I switched.


That's awesome! Glad you got it working.
0 Kudos
TracySchloss
Frequent Contributor
Do you have any thoughts on the error I'm getting in location.pathname.replace?  It seems like I would be better of with this type of syntax instead of changing it to be more "hard coded".
0 Kudos
Jay_Gregory
Regular Contributor
One question I have about this: is there any way to configure a cluster layer for a feature service so it isn't limited by the 1000 feature return limit on Server?  It seems that one of the benefits of clustering would be being able to visualize total number of events in an area, even if the total events are greater than 1000. 

Jay
0 Kudos
derekswingley1
Frequent Contributor II
One question I have about this: is there any way to configure a cluster layer for a feature service so it isn't limited by the 1000 feature return limit on Server?  It seems that one of the benefits of clustering would be being able to visualize total number of events in an area, even if the total events are greater than 1000. 


Change the limit on the server, or do multiple requests to retrieve your data before handing it off to the cluster layer.
0 Kudos
muhammadalmas
New Contributor
Any chance of having 'flare effect' with this clustering (just like silverlight/flex counterpar)?
0 Kudos
TracySchloss
Frequent Contributor
Don't hold your breath.  There is quite a bit of animation that easily used in FLEX that isn't there in JS.  I actually started out with the FLEX version, but have had to move away from it because of lack of mobile support.  Yes, I know it can be written as an app, but that's not a popular alternative in this office.
danbonab
New Contributor II
I'm sorry but I don't care much for ClusterLayer. Clustering is a feature of a graphic based layer (esri.layers.GraphicsLayer).
Why should my layer lets say a featureLayer (which is a graphicsLayer subclass) morph into a different type of layer to display feature clusters? It doesn't make any sense!
Silverlight API got this right. In Silverlight, GraphicsLayer has a Clusterer property which encapsulates all the clustering logic, so if you need clustering you don't need to create a different type of layer and add it to the map.
Clustering in Silverlight happens when graphics are being added and you could easily extend the OnGraphicsAdded event handler to apply your own clustering logic or use existing FlareClusterer which works decently.
I'm not expecting all the flare animation, I'm aware of the challenges of that when it comes to running in different browsers, the only thing I'm expecting is a clusterer property for graphicsLayer and a defaultClusterer that would support basic clustering properties like maxFeatureCount, radius, and color.
0 Kudos
StephenLead
Regular Contributor III
a clusterer property for graphicsLayer and a defaultClusterer that would support basic clustering properties like maxFeatureCount, radius, and color.


+1, that would be very nice. Ideally it would work for a featureLayer too.
0 Kudos
bdv_works
New Contributor
Hi, we did it through the server-side clustering solutions and use Esri js-apis to plot the JSON outputs;
pls see the app link:

http://www.bigdatavisulization.com:8...er_locate.html

// we can remove the house number when searching, which will give 70 million records on-the-fly...
0 Kudos