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?