Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
Is there a way in arcgis javascript api, to return the geometry and the data associated with it from a geoprocessing service? –  Sam007 Nov 30 '12 at 6:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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