Feature Layer with ONDEMAND mode

752
1
04-25-2011 02:27 AM
KirillLykov
New Contributor
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
            });
0 Kudos
1 Reply
derekswingley1
Frequent Contributor
0 Kudos