Hi all,
I have a Javascript web map in which the user manually selects layers by dragging a box, using the Identify Task. I have it working where if features from one layer are selected, the results are displayed in a datagrid. The problem I am having is if two layers overlap and the user selects them both, I can't figure out how to display results for both. I have tried multiple things and am yet to come up with a solution. I am open to either having both datagrids displayed at the bottom, or giving the user a choice through a pop-up window of which grid results to show. The last chunk of the else/if statement where I try to put both the layers together does not seem to be working....any ideas????
Thanks so much!!!
Code: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 === 'Control Points'){ showPointNameGrid(); controlItems.push(feature.attributes); searchType = "selControl"; 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'){ showSurveysNameGrid(); surveyItems.push(feature.attributes); searchType="selSurveys"; var surveysStore = new dojo.data.ItemFileReadStore({data:{identifier:'DOCUMENT_N',items:surveyItems}}); var grid = dijit.byId('grid5'); grid.setStore(surveysStore); }else if((result.layerName === 'surveys') && (result.layerName === 'Control Points')){ 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); } }); }); }

Reply With Quote





Bookmarks