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.
WAB 2.6 has not been tested to work with JS API 3.23. It is only validated to work with 3.22. You will need WAB 2.7 if you want a WAB that has been validated with 3.23.
Also is there any scope to show the "featureReduction" feature for dynamically added points??
I do not understand...
Shaikh,
That feature as added at 3.22 so it is not available in 3.21 API you are using.
https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#enablefeaturereduction
So you need to use the latest version of WAB instead.
I would say you need to update WAB.
Robert,
I did the changes. I updated the WAB version from 2.5 to 2.6 with AGS 3.23.. But no luck.. same error "Cannot read property 'call' of undefined" while executing my widget." . if i comment the above line (i.e. on FeatureLayer load event), it works fine.
while debugging it is going smoothly to the last line of the "_getStateResults" method without any exception.After that, error added on console.
Shaikh,
From what I understand feature reduction does not work on FeatureLayers coming from FeatureCollections.
Robert,
OK.. Actually after configuring, I am not able to run the widget due to above error. How can I make my widget work??
Robert,
I have tried with JS API 3.22 with WAB 2.6. Its working without any issue !!! But why its not working with 3.23 with WAB 2.6 ??
Also is there any scope to show the "featureReduction" feature for dynamically added points??
WAB 2.6 has not been tested to work with JS API 3.23. It is only validated to work with 3.22. You will need WAB 2.7 if you want a WAB that has been validated with 3.23.
Also is there any scope to show the "featureReduction" feature for dynamically added points??
I do not understand...
Robert,
In my requirement, I have to show more than lakhs of points on map. Where these points shall be uploaded from excel sheet or from flat table with lat-long. Also i have to perform class break renderer analysis on those points.
Drawing all those points at a time lead to performance degradation. So, i would like to cluster those points, along with renderer.