kirill_lykov

Feature Layer with ONDEMAND mode

Discussion created by kirill_lykov on Apr 25, 2011
Latest reply on Apr 25, 2011 by DSwingley-esristaff
I can't understand how to display all features from the feature layer. In the code bellow I specified 2 features in the layer and set in feature layer's mode to esri.layers.FeatureLayer.MODE_SNAPSHOT. According esri documentation this options means that all features will be selected and displayed. But they are not. The code is:

var jsonFS = {
                "displayFieldName": "Name",
                "fieldAliases": {
                    "Name": "Name"
                },
                "geometryType": "esriGeometryPoint",
                "spatialReference": {
                    "wkid": 4326
                },
                "fields": [{
                    "name": "Name",
                    "type": "esriFieldTypeString",
                    "alias": "Name",
                    "length": 255
                }],
                "features": [{
                    "attributes": {
                        "Name": "bla"
                    },
                    "geometry": {
                        "x": -8919439.31450887,
                        "y": 4928270.761925456
                    }
                },
                {
                    "attributes": {
                        "Name": "bla bla"
                    },
                    "geometry": {
                        "x": -8155495.379532158,
                        "y": 5075380.311392084
                    }
                }]
            };
            var fs = new esri.tasks.FeatureSet(jsonFS);

            var featureCollection = {
                layerDefinition: {
                  "geometryType": "esriGeometryPoint",
                  "fields": [
                  {
                    "name": "Name",
                    "type": "esriFieldTypeString",
                    "alias": "Name"
                  }
                  ]
                },
                featureSet: fs
            };

        var featureLayer = new esri.layers.FeatureLayer(featureCollection, {
                mode: esri.layers.FeatureLayer.MODE_SNAPSHOT
            });

Outcomes