Select to view content in your preferred language

FeatureLayer not displaying Default symbology

664
1
12-25-2011 07:47 AM
KannanAnandavel
New Contributor
I was trying to follow the Datagrid with zoom example to my scenario.

map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer ("http://mid036807/ArcGIS/rest/services/SARS/Sudan/MapServer"));

var maxOffset = function maxOffset(map, pixelTolerance) {
return Math.floor(map.extent.getWidth() / map.width) * pixelTolerance;
};

// outFields:["Incident","actor","OBJECTID"]
//add the states demographic data
statesLayer = new esri.layers.FeatureLayer("http://mid036807/ArcGIS/rest/services/SARS/SICCQuery/FeatureServer/0",{
mode:esri.layers.FeatureLayer.MODE_SELECTION,
maxAllowableOffset:maxOffset(map,1),
outFields:["*"]
});

statesLayer.setDefinitionExpression("Incident='Bombing'");
//define a selection symbol
// var highlightSymbol = new esri.symbol.SimpleFillSymbol().setColor( new dojo.Color([50,205,50,.25]));
var symbol = new esri.symbol.SimpleMarkerSymbol();
symbol.setColor(new dojo.Color([0,0,255]));

statesLayer.setSelectionSymbol(symbol);

dojo.connect(statesLayer,'onLoad',function(layer){
var query = new esri.tasks.Query();
query.where = "1=1";
layer.queryFeatures(query,function(featureSet){
var items = dojo.map(featureSet.features,function(feature){
return feature.attributes;
});
var data = {
identifier:"OBJECTID",
items:items};
store = new dojo.data.ItemFileReadStore({data:data});
grid.setStore(store);
grid.setSortIndex(1,"true"); //sort on the state name
});


});
map.addLayer(statesLayer);

//modify the grid so only the STATE_NAME field is sortable
grid.canSort = function(col){ if(Math.abs(col) == 2) { return true; } else { return false; } };


I was able to add and get all the features into the grid but nothing is displayed in the map. Though nothing is displayed on the map i was able to Zoom into the object using my own symbology.

My expectation is on adding the featurelayer it should render with the default symbology as mentioned in the Map service /Feature service.

I am using Arcgis Server 10.
0 Kudos
1 Reply
HemingZhu
Frequent Contributor
I was trying to follow the   Datagrid with zoom example to my scenario. 

map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer ("http://mid036807/ArcGIS/rest/services/SARS/Sudan/MapServer"));

var maxOffset = function maxOffset(map, pixelTolerance) {
return Math.floor(map.extent.getWidth() / map.width) * pixelTolerance;
};

// outFields:["Incident","actor","OBJECTID"]
//add the states demographic data
statesLayer = new esri.layers.FeatureLayer("http://mid036807/ArcGIS/rest/services/SARS/SICCQuery/FeatureServer/0",{
mode:esri.layers.FeatureLayer.MODE_SELECTION,
maxAllowableOffset:maxOffset(map,1),
outFields:["*"]
});

statesLayer.setDefinitionExpression("Incident='Bombing'");
//define a selection symbol
// var highlightSymbol = new esri.symbol.SimpleFillSymbol().setColor( new dojo.Color([50,205,50,.25]));
var symbol = new esri.symbol.SimpleMarkerSymbol();
symbol.setColor(new dojo.Color([0,0,255]));

statesLayer.setSelectionSymbol(symbol);

dojo.connect(statesLayer,'onLoad',function(layer){
var query = new esri.tasks.Query();
query.where = "1=1";
layer.queryFeatures(query,function(featureSet){
var items = dojo.map(featureSet.features,function(feature){
return feature.attributes;
});
var data = {
identifier:"OBJECTID",
items:items};
store = new dojo.data.ItemFileReadStore({data:data});
grid.setStore(store);
grid.setSortIndex(1,"true"); //sort on the state name
});


});
map.addLayer(statesLayer);

//modify the grid so only the STATE_NAME field is sortable
grid.canSort = function(col){ if(Math.abs(col) == 2) { return true; } else { return false; } };


I was able to add and get all the features into the grid but nothing is displayed in the map. Though nothing is displayed on the map i was able to Zoom into the object using my own symbology. 
  
My expectation is on adding the featurelayer it should render with the default symbology as mentioned in the Map service /Feature service. 

I am using Arcgis Server 10.


Since you used MODE_SELECTION. For selected features to display, you have to use selectFeatures to specify the selected features. Otherwise on features are selected and therefore not display. Look into the API for info.
0 Kudos