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); }
Tracy,
can you provide whole working code please. Because your above code is not working for me so
Hello Everyone,
I have found one sample for clustering on featureLayer. Please refer to this.
Regards,
Vaibhav Grigo
Thanks.
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
Do you have a full working example of this that you would be willing to share?
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.
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?
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.
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.
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?
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
hi again
not sure i understand what you mean by AMD.
is ther a new version ?
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
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?
queryTask.on("complete", function(results)
dojo.connect(queryTask, "onComplete", function(featureSet)
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) { 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 }; });
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.
renderer.addBreak(200, 1001, red);
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?
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
a clusterer property for graphicsLayer and a defaultClusterer that would support basic clustering properties like maxFeatureCount, radius, and color.
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.
I can't believe I got it work! This method executes much faster than the forum example, so I'm glad I switched.
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.
<script> var dojoConfig = { parseOnLoad: true, packages: [{ "name": "extras", "location": location.pathname.replace(/\/[^/]+$/, '') + "/extras" }] }; </script>
dojo.require("extras,ClusterLayer);
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?
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.