function runQuery(){ // layer 1 in the service contains all server locations and will be used to cluster var queryTask = new esri.tasks.QueryTask("http://<myserver>/ArcGIS/rest/services/ITSD/serverLocations/MapServer/1"); var query = new esri.tasks.Query(); query.returnGeometry = true; query.where = '1=1'; query.outFields = ["*"]; dojo.connect(queryTask, "onComplete", function(featureSet){ var inputInfo = {}; inputInfo.data = dojo.map(featureSet.features, function(feature){ var pointX = feature.geometry.x; var pointY = feature.geometry.y; var att = feature.attributes; return { "x": pointX, "y": pointY, "attributes": att }; }); // cluster layer that uses OpenLayers style clustering clusterLayer = new extras.ClusterLayer({ "data": inputInfo.data, "distance": 100, "id": "clusters", "labelColor": "#fff", "labelOffset": 10, "resolution": map.extent.getWidth() / map.width, "singleColor": "#888", "singleTemplate": infoTemplate }); var defaultSym = new esri.symbol.SimpleMarkerSymbol().setSize(4); var renderer = new esri.renderer.ClassBreaksRenderer(defaultSym, "clusterCount"); var blue = new esri.symbol.PictureMarkerSymbol("http://static.arcgis.com/images/Symbols/Shapes/BluePin1LargeB.png", 32, 32).setOffset(0, 15); var green = new esri.symbol.PictureMarkerSymbol("http://static.arcgis.com/images/Symbols/Shapes/GreenPin1LargeB.png", 64, 64).setOffset(0, 15); var red = new esri.symbol.PictureMarkerSymbol("http://static.arcgis.com/images/Symbols/Shapes/RedPin1LargeB.png", 72, 72).setOffset(0, 15); renderer.addBreak(0, 2, blue); renderer.addBreak(2, 200, green); renderer.addBreak(200, 1001, red); clusterLayer.setRenderer(renderer); map.addLayer(clusterLayer); // close the info window when the map is clicked // dojo.connect(map, "onClick", cleanUp); // close the info window when esc is pressed dojo.connect(map, "onKeyDown", function(e){ if (e.keyCode == 27) { cleanUp(); } }); dojo.connect(queryTask, "onError", function(err){ alert(err.details); }); }); queryTask.execute(query); }
Sometimes the cluster layer draws fine and sometimes it doesn't draw at all
I"m not sure why I would use an esri.request to the query endpoint as opposed to executing a standard query task. I usually execute my query tasks with a callback to generate my featureset. Is is faster to request the data or formatted differently if I use esri.request instead?
<script> var dojoConfig = { parseOnLoad: true, packages: [{ "name": "extras", "location": location.pathname.replace(/\/[^/]+$/, '') + "/extras" }] }; </script>
dojo.require("extras,ClusterLayer);
I see now that I still had all my references to version 2.5 <snip>
The code still isn't working right, but at least I'm past the first error.
I can't believe I got it work! This method executes much faster than the forum example, so I'm glad I switched.
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.
a clusterer property for graphicsLayer and a defaultClusterer that would support basic clustering properties like maxFeatureCount, radius, and color.
I noticed the link doesn't work, display's a blank map. Is there a different link to look at?We have the clustering working well on 100,000+ points but noticed that when the cluster marker has more than 1000 count it drops the marker graphic and only displays the label. Is this a limitation of the Javascript api or a bug with it? Could it be it is droping it because it can't fit a 4 digit label inside the graphic? I noticed ESRI example doesn't go over 999 either. https://developers.arcgis.com/en/javascript/jssamples/layers_point_clustering.htmlAnyone have suggestions on how to get the marker to work for counts of more than 999?Thanks,Brian
We have the clustering working well on 100,000+ points but noticed that when the cluster marker has more than 1000 count it drops the marker graphic and only displays the label. Is this a limitation of the Javascript api or a bug with it? Could it be it is droping it because it can't fit a 4 digit label inside the graphic? I noticed ESRI example doesn't go over 999 either. https://developers.arcgis.com/en/javascript/jssamples/layers_point_clustering.htmlAnyone have suggestions on how to get the marker to work for counts of more than 999?
renderer.addBreak(200, 1001, red);
I think there are 2 reasons why people aren't seeing more than 1000 markers:- by default ArcGIS Server / ArcGIS Online only return the first 1000 features from a query- if you've circumvented this (which it sounds like you have, if you're seeing 100k markers) check the renderer.The renderer in the sample above contains:renderer.addBreak(200, 1001, red);Try adding class breaks which contain a valid range for your data.
queryTask.on("complete", function(featureSet) { var inputInfo = {}; inputInfo.data = arrayUtils.map(featureSet.features, function(feature) { var pointX = feature.geometry.x; var pointY = feature.geometry.y; var att = feature.attributes; return { "x": pointX, "y": pointY, "attributes": att }; });
queryTask.on("complete", function(results)
dojo.connect(queryTask, "onComplete", function(featureSet)
queryTask.on("complete", function(results) { var inputInfo = {}; inputInfo.data = arrayUtils.map(results.featureSet.features, function(feature) { var pointX = feature.geometry.x; var pointY = feature.geometry.y; var att = feature.attributes; return { "x": pointX, "y": pointY, "attributes": att }; });
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 .
infoTemplate = new InfoTemplate("Attributes", "${*}");
any idea what might be in the way?
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.
hi again
not sure i understand what you mean by AMD.
is ther a new version ?
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
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?
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.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.