AnsweredAssumed Answered

Selecting multiple features with graphics

Question asked by ajd018 on Oct 11, 2018
Latest reply on Oct 11, 2018 by ajd018

I am trying to select multiple polygon features and have a graphic drawn on top of the features to show selection with this code. Right now, the selection works and selects the features (I know this because it shows as selected in the featuretable). But the graphic only draws over a single feature. Is there a way to have it draw over multiple features?

 

var selectionToolbar;

map.on("load", initSelectToolbar);

var selectline = new SimpleLineSymbol();
selectline.setWidth(4);
selectline.setColor(new Color([0,255,255, 1]));
var selectlineSymbol = new SimpleFillSymbol();
selectlineSymbol.setOutline(selectline);
selectlineSymbol.setColor(new Color([46,191,240, 0]));

on(dom.byId("selectFieldsButton"), "click", function () {
selectionToolbar.activate(Draw.EXTENT);
});
on(dom.byId("clearSelectionButton"), "click", function () {
featurelayername.clearSelection();
map.graphics.clear();
});
function initSelectToolbar (event) {
selectionToolbar = new Draw(event.map);
var selectQuery = new Query();
on(selectionToolbar, "DrawEnd", function (geometry) {
selectionToolbar.deactivate();
selectQuery.geometry = geometry;

selectQuery.returnGeometry = true;
selectQuery.where = "1=1";

featurelayername.queryFeatures(selectQuery, function (featureSet) {
featurelayername.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW);
var Geom = featureSet.features[0].geometry;
var gra = new Graphic(Geom, selectlineSymbol);
map.graphics.add(gra);
});

});
}

Outcomes