Feature Reduction not working for dynamic Feature Layer

2558
14
Jump to solution
01-02-2018 09:56 PM
ShaikhRizuan
New Contributor III

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

Error

Do feature reduction supports for dynamic layer?? How can i achieve this??

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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...

View solution in original post

14 Replies
RobertScheitlin__GISP
MVP Emeritus

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.

ShaikhRizuan
New Contributor III
I am using WAB 2.5 ver. and have changed the JS API  from 3.21 to 3.23. After updating only the API, I am getting this error: "Cannot read property 'call' of undefined" while executing my widget. PFB Image of the error.
Do I need to upgrade the WAB (i.e. WAB 2.6) also?? 
In case, if it should work after upgrading the JS API, then kindly help me. I am attaching my widget.js file. Here, i am trying to create class break renderer and adding context menu to the dynamic feature layer on "Load" event. While debugging, I found that if i comment the below line its working fine.
this.eventListner = this.dynamicFL.on("load",this.createToolbarContextMenu("state",this.secValueName,this.dbSelectCategory.options[this.dbSelectCategory.value].label,this.dbSelectSubCategory.options[this.dbSelectSubCategory.value].label));
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I would say you need to update WAB.

0 Kudos
ShaikhRizuan
New Contributor III

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. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Shaikh,

  From what I understand feature reduction does not work on FeatureLayers coming from FeatureCollections.

0 Kudos
ShaikhRizuan
New Contributor III

Robert,

OK.. Actually after configuring, I am not able to run the widget due to above error. How can I make my widget work?? 

0 Kudos
ShaikhRizuan
New Contributor III

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??

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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...

ShaikhRizuan
New Contributor III

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.

0 Kudos