Hi,
I am adding large amount of points as a dynamic feature layer, and try to cluster those point features by using the below code:
.............................................................................
.....
var jsonFS = new Object();
jsonFS.geometryType = "esriGeometryPoint";
jsonFS.features = features;
var featureSet = new FeatureSet(jsonFS);
var featureCollection = {
layerDefinition:
{
"displayFieldName": "",
"geometryType": "esriGeometryPoint",
"spatialReference": {
"latestWkid": 4326,
"wkid": 4326
},
"fields": [
{
"name": "objectid",
"type": "esriFieldTypeOID",
"alias": "objectid"
},
{
"name": "AGE",
"type": "esriFieldTypeString",
"alias": "AGE"
},
{
"name": "SEX",
"type": "esriFieldTypeString",
"alias": "SEX"
},
{
"name": "HS_NM",
"type": "esriFieldTypeString",
"alias": "HS_NM",
"length": 54
},
{
"name": "HS_NMBR",
"type": "esriFieldTypeString",
"alias": "HS_NMBR",
"length": 24
},
{
"name": "DED_PAN",
"type": "esriFieldTypeString",
"alias": "DED_PAN",
"length": 24
},
{
"name": "PAY_AMNT",
"type": "esriFieldTypeInteger",
"alias": "PAY_AMNT"
},
{
"name": "shape",
"type": "esriFieldTypeGeometry",
"alias": "shape"
}
],
},featureSet: featureSet};
var infoTemplate = new InfoTemplate("PAN : ${DED_PAN}", "AGE : ${AGE}<br>GENDER: ${SEX}<br>HOUSE NAME: ${HS_NM}<br>HOUSE NO.: ${HS_NMBR}<br>POI: ${POI}<br>PAYMENT AMOUNT: ${PAY_AMNT}<br>" );
this.dynamicFL=null;
//this.dynamicFL = new FeatureLayer(hsFeatureCollection, featureLayerOptions);
var featureLayerOptions ={
mode: FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"],
infoTemplate: infoTemplate,
//featureReduction:{type="cluster"},
id: "Entity Map"
};
this.dynamicFL = new FeatureLayer(featureCollection,featureLayerOptions);
var extent = graphicsUtils.graphicsExtent(featureSet.features);
this.map.setExtent(extent.expand(1.2));
this.dynamicFL.enableFeatureReduction();
this.dynamicFL.setFeatureReduction({
type:"cluster",
clusterRadius:20
});
I am getting this error : this.dynamicFL.enableFeatureReduction is not a function
Do feature reduction supports for dynamic layer?? How can i achieve this??
Solved! Go to Solution.
Shaikh,
Oh, I thought you said you got feature reduction to work.
I have tried with JS API 3.22 with WAB 2.6. Its working without any issue !!!
Robert,
Actually i got rid of this "Cannot read property 'call' of undefined" earlier.
Now after setting cluster radius properly its working fine...
Best Regards,
Shaikh
Hi Shaikh,
I realise that this was a while ago now, but do you remember how you set the "cluster radius properly"?
Thanks,
Gill
Hi Gill,
Its depends on how your points closed to each other, I did it based on the visualization. Please refer the below link
https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#setfeaturereduction
Regards
Shaikh
Thank you