AnsweredAssumed Answered

Filter Feature Layer by Multiple Button Clicks

Question asked by gschwitz on Nov 8, 2013
Latest reply on Nov 12, 2013 by gschwitz
In my application I have a few filters (as buttons) that are currently applying a definition query to a feature layer.  Currently you can only select one button at a time and add one definition query.  Is there a preferred method to incorporating multiple button clicks into a single feature layer query? I feel like this may need to be done with a graphics layer and not against a feature layer.

Each button click has the following callback but I need to apply both of these clicks/queries to the resulting map features :
                function executeHandicapQuery(handicapBtn) {                     map.graphics.clear();                     map.infoWindow.hide();                     elm = dojo.byId('handicapBtn');                     str = "Yes";                     query.where = "HANDICAPACCESS = '" + str + "'";                     queryTask.execute(query, showResults);                     populateGrid(Memory, query.where);//populate dgrid with results                     fl.setDefinitionExpression(query.where);                 }                 function executeRestroomQuery(restroomBtn) {                     map.graphics.clear();                     map.infoWindow.hide();                     elm = dojo.byId('restroomBtn');                     str = "Yes";                     query.where = "RESTROOMS = '" + str + "'";                     queryTask.execute(query, showResults);                     populateGrid(Memory, query.where);//populate dgrid with results                     fl.setDefinitionExpression(query.where);                 }


These functions are then passed to the showResults function and zoom to the result extent:
                function showResults(featureSet) {                     //map.graphics.clear();//clear graphics from map                     map.infoWindow.hide();//hide infowindow                                    var resultFeatures = featureSet.features;//Performance enhancer - assign featureSet array to a single variable.                     for (var i = 0, il = resultFeatures.length; i < il; i++) {//loop through all features                         if (resultFeatures.length == 1) {                             var graphic = resultFeatures[i];                             graphic.setSymbol(symbol);                             //Set the infoTemplate.                             //graphic.setInfoTemplate(infoTemplate);                             //Add graphic to the map graphics layer.                             nameGraphic = map.graphics.add(graphic);                             var thePoint = resultFeatures[0].geometry;                             map.centerAndZoom(thePoint, 5);                         }                         else if (resultFeatures.length > 1) {                             graphic = resultFeatures                             var extent = esri.graphicsExtent(graphic);                             map.setExtent(extent); //use to get whole extent//map.setExtent(extent.expand(3));                          }                         else {                             var myFeatureExtent = esri.graphicsExtent(resultFeatures);                             map.setExtent(myFeatureExtent);                         }                         //msg = "Selected Features:" + "\n" + resultFeatures.length                         //document.getElementById('rightPane').innerHTML = msg;                     }                    }


Thanks,
Geoff

Outcomes