1

I have created a featureLayer from featureCollection and I am able to add it to the map and when I execute, map.graphicsLayerIds, it also returns the id of the featureLayer, ["resultLayer"]. But I am not able to see it on the map. I have also set the renderer but still it makes no difference. This is the application.

It takes some time to execute (around a minute). This is the code I am using to create the featureLayer,

function addResults(results) {
        //console.log(results);
        var features = results.value.features;

        var layerDefinition = {
            "geometryType": "esriGeometryPolygon",
            "fields": [{
                "name": "FID",
                "alias": "ID",
                "type": "esriFieldTypeOID"
            }, {
                "name": "STATE_NAME",
                "alias": "State Name: ",
                "type": "esriFieldTypeString"
            }, {
                "name": "NAME",
                "alias": "County Name: ",
                "type": "esriFieldTypeString"
            }, {
                "name": "value",
                "type": "esriFieldTypeDouble",
                "alias": "Absolute Value"
            }, {
                "name": "RESULT2",
                "type": "esriFieldTypeDouble",
                "alias": "Percentage Change"
            }]
}
        var featureCollection = {
          "layerDefinition": layerDefinition,
          "featureSet": {
            "features": features
          }
        };
        var states_Symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, //EVENTS
                    new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,  //EVENTS
                    new dojo.Color([255,255,255,0.35]), 1),  //EVENTS
                    new dojo.Color([125,125,125,0.35]));

        var popupTemplate = new esri.dijit.PopupTemplate({
                title: "{NAME}",
                fieldInfos: [{
                    fieldName: "STATE_NAME",
                    visible: true,
                    label: "State Name: "
                },
                {
                    fieldName: "value",
                    visible: true,
                    label: "Absolute Change: $"
                },
                {
                    fieldName: "RESULT2",
                    visible: true,
                    label: "Percentage Change: "
                }
                ]
            });

        resultLyr = new esri.layers.FeatureLayer(featureCollection, {
          id: 'resultLayer',
          infoTemplate: popupTemplate
        });
        resultLyr.setRenderer(new esri.renderer.SimpleRenderer(states_Symbol));
        map.addLayers([resultLyr]);

        dojo.connect(resultLyr,"onClick",function(evt){
           map.infoWindow.setFeatures([evt.graphic]);
        });


    }

Any idea what I am missing?

1 Answer 1

2

After reviewing the data within resultLyr.graphics, the graphics have attributes, but no geometry. That's why they're not showing up on the map. Make sure your geoprocessing service is returning those geometries. Also, check that the layer the geoprocessing service accesses has access to the shape attribute of the feature.

1
  • Is there a way in arcgis javascript api, to return the geometry and the data associated with it from a geoprocessing service?
    – Sam007
    Commented Nov 30, 2012 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.