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?
Solved! Go to Solution.
You're only creating a new graphic from the first feature in the featureset with this line.
var Geom = featureSet.features[0].geometry;
You'll want to loop through the featureset and do that to each feature.
array.forEach(featureSet, function (feature) {
Geom = feature.geometry;
gra = new Graphic(Geom, selectlineSymbol);
map.graphics.add(gra);
});
You're only creating a new graphic from the first feature in the featureset with this line.
var Geom = featureSet.features[0].geometry;
You'll want to loop through the featureset and do that to each feature.
array.forEach(featureSet, function (feature) {
Geom = feature.geometry;
gra = new Graphic(Geom, selectlineSymbol);
map.graphics.add(gra);
});
I incorporated this way. Cant get the graphics to show up.
featurelayername.queryFeatures(selectQuery, function (featureSet) {
array.forEach(featureSet, function (feature) {
var Geom = feature.geometry;
var gra = new Graphic(Geom, selectlineSymbol);
map.graphics.add(gra);
});
});
Are you seeing any messages in the console?
init.js:89 g {message: "Timeout exceeded", response: {…}, status: undefined, responseText: undefined, xhr: XMLHttpRequest, …}
also:
Active resource loading counts reached to a per-frame limit while the tab is in background. Network requests will be delayed until a previous loading finishes, or the tab is foregrounded. See <URL> for more details
Did you add the module for array?
require([...,"dojo/_base/array",...], function(...,array,...){
Q: Is featureSet a FeatureSet or an array of Graphic objects? If its a FeatureSet, then try looping over the 'features' property which is an array of Graphic objects:
array.forEach(featureSet.features, function (feature) {
// ... //
});
That did it. Great thanks.