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); }
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.
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?
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.
Tracy,
Do you have a full working example of this that you would be willing to share?
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
Thanks.
Hello Everyone,
I have found one sample for clustering on featureLayer. Please refer to this.
Regards,
Vaibhav Grigo
can you provide whole working code please. Because your above code is not working for me so
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.