Thanks again for the reply!
I am trying to set-up a situation where if the user of the map manually selects overlapping features using the Identify task, both results will display in seperate datagrids at the bottom of the screen.
I have it working if only one layer is selected, results are displayed in the datagrid. I also have it working where if two layers are selected, they highlight as such on the map. I am just stuck on how to show the results of the selection in 2 datagrids at the bottom of the page. I am also open to having a propmt that allows the user to chose which results to show after selecting both layers.
I hope that makes sense. The part that seems to be broken is where I try and get results for both layers using the && operator. The alert does not even display in the section of code.Below is the relevant code.
I really appreciate any advice you have!! Sorry to be such a newbie.:confused:
//SELECT STUFF
dojo.connect(map, 'onLoad', function(theMap) {
navToolbar.deactivate();
identifyTask = new esri.tasks.IdentifyTask("http://slcarcgisdev1/SLCOGIS/rest/services/public/Surveyor/MapServer");
identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.tolerance = 3;
identifyParams.returnGeometry = true;
identifyParams.layerIds = [0,2];
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
identifyParams.width = map.width;
identifyParams.height = map.height;
//initialize the toolbar
toolBar = new esri.toolbars.Draw(map);
dojo.connect(toolBar, "onDrawEnd",onDrawEnd);
navToolbar.deactivate();
//resize the map when the browser resizes
dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
});
function onDrawEnd(extent){
navToolbar.deactivate();
executeIdentifyTask(extent);
}
function executeIdentifyTask(geom) {
//clear the graphics layer
map.graphics.clear();
var polygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DOT, new dojo.Color([151, 249,0,.80]), 3), new dojo.Color([151, 249, 0, 0.45]));
var markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 20, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 0]), 1), new dojo.Color([25,50,225,0.3]));
identifyParams.geometry = geom;
identifyParams.mapExtent = map.extent;
identifyTask.execute(identifyParams,function(response){
var controlItems = [];
var surveyItems = [];
dojo.forEach(response,function(result){
var feature = result.feature;
//add selected feature to graphics layer
feature.setSymbol(polygonSymbol);
feature.setSymbol(markerSymbol);
map.graphics.add(feature);
if (result.layerName === 'surveys' && result.layerName === 'Control Points'){
alert(result.layerName);
showSurveysNameGrid();
surveyItems.push(feature.attributes);
showPointNameGrid();
controlItems.push(feature.attributes);
var surveysStore = new dojo.data.ItemFileReadStore({data:{identifier:'DOCUMENT',items:surveyItems}});
var grid = dijit.byId('grid5');
grid.setStore(surveysStore);
var controlStore = new dojo.data.ItemFileReadStore({data:{identifier:'POINT_NAME',items:controlItems}});
var grid = dijit.byId('grid4');
grid.setStore(controlStore);
}else if(result.layerName === 'Control Points'){
alert(result.layerName);
showPointNameGrid();
controlItems.push(feature.attributes);
searchType = "selControl";
//update the data grid
var controlStore = new dojo.data.ItemFileReadStore({data:{identifier:'POINT_NAME',items:controlItems}});
var grid = dijit.byId('grid4');
grid.setStore(controlStore);
}else if(result.layerName === 'surveys'){
alert(result.layerName);
showSurveysNameGrid();
surveyItems.push(feature.attributes);
searchType="selSurveys2";
var surveysStore = new dojo.data.ItemFileReadStore({data:{identifier:'DOCUMENT_N',items:surveyItems}});
var grid = dijit.byId('grid5');
grid.setStore(surveysStore);
}
});
});
}
You might want to change you logic flow in your function. Here is the example:
function executeIdentifyTask(geom) {
//clear the graphics layer
map.graphics.clear();
identifyParams.geometry = geom;
identifyParams.mapExtent = map.extent;
identifyTask.execute(identifyParams,function(response){
var polygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DOT, new dojo.Color([151, 249,0,.80]), 3), new dojo.Color([151, 249, 0, 0.45]));
var markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 20, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 0]), 1), new dojo.Color([25,50,225,0.3]));
var controlItems = [];
var surveyItems = [];
dojo.forEach(response,function(result){
var feature = result.feature;
if (result.layerName =="surveys"){
//alert(result.layerName);
feature.setSymbol(polygonSymbol);
surveyItems.push(feature.attributes);
else{
feature.setSymbol(markerSymbol);
controlItems.push(feature.attributes);
}
//add selected feature to graphics layer
map.graphics.add(feature);
});
if(surveyItems.length >0){
var surveysStore = new dojo.data.ItemFileReadStore({data:{identifier:'DOCUMENT',items:surveyItems}});
var grid = dijit.byId('grid5');
grid.setStore(surveysStore);
showSurveysNameGrid();
}
if(controlItems.length >0){
var controlStore = new dojo.data.ItemFileReadStore({data:{identifier:'POINT_NAME',items:controlItems}});
var grid = dijit.byId('grid4');
grid.setStore(controlStore);
showPointNameGrid();
}
});
}