I have a graphic layer.
I want to cluster this data and display cluster on map(Arcgis JavaScript 3.x)
Any idea?
Is it possible to add clustering to graphics layer in version 4.27 ?featureReduction props is not available in the docs also.
https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#properties-summary
Is it possible to have clustering if it has only points geometry in graphics layer ? i know Polygon and Line string is not supported
Hi Adithya, Can you pls tell me which module have you imported for ClusterLayer? Currently i'm using 4.20 JS API version.
Hi ADITYA KUMAR, the data will be
photoInfo.data = arrayUtils.map(resp, function(p) { var latlng = new Point(parseFloat(p.lng), parseFloat(p.lat), wgs); var webMercator = webMercatorUtils.geographicToWebMercator(latlng); var attributes = { "Caption": p.caption, "Name": p.full_name, "Image": p.image, "Link": p.link }; return { "x": webMercator.x, "y": webMercator.y, "attributes": attributes };
so basically an array with the following structure.
{ "x": 120, "y": -32, "attributes": {
"Caption": "caption", "Name": "a name", "Image": small.jpg, "Link": "http link"
} };
This is how I would turn on clustering
<SPAN class="keyword token">var</SPAN> layer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN>serviceUrl<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> featureReduction<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> type<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"cluster"</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Here is a simple sample to demonstrate the code above
Hi Ben,
clusterLayer = new ClusterLayer({ "data": photoInfo.data, "distance": 100, "id": "clusters", "labelColor": "#fff", "labelOffset": 10, "resolution": map.extent.getWidth() / map.width, "singleColor": "#888", "singleTemplate": popupTemplate });
In my case what will be the data?
Thanks
Kumar
Hi Aditya,
Here are some samples for clustering in 3x:
Point clustering | ArcGIS API for JavaScript 3.29
Toggle point clustering | ArcGIS API for JavaScript 3.29
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.