3

I'm trying to draw the features resulting from a query of a feature layer onto a graphics layer.

var query = abstracts.createQuery();
query.where = "ANUM = '1'";
query.returnGeometry = true;
var rl = map.findLayerById("graphics");
abstracts.queryFeatures(query).then(function (results) {
 rl.removeAll();
 var features = results.features.map(function (graphic) {
 graphic.symbol = new SimpleLineSymbol({
 size: 6.5,
 color: "darkorange"
 });
 return graphic;
 });
 rl.addMany(features);
});

When I set a breakpoint before the last line(rl.addMany(features)), I see that features contains the expected feature, and the symbol is set properly. Also, I know that the feature exists, but is not appearing on the map. Also, below is my declaration of feature layer and graphics layer.

 var abstracts = new FeatureLayer({
 url: "@arcgisServerServiceUrl/" + featureLayerId,
 outFields: ["*"],
 visible:false,
 mode: FeatureLayer.MODE_ONDEMAND,
 maxScale: 0,
 minScale: 290000,
 renderer: renderer,
 });
 var resultsLayer = new GraphicsLayer({id:"graphics"});
 map.layers.addMany([
 abstracts,
 resultsLayer,
 ]);
asked Mar 28, 2017 at 22:44

1 Answer 1

1

I can't answer why what I did above didn't work, but I can give the answer I found. For each feature in results.features above:

 var polygon = new Polygon({
 rings: feature.geometry.rings
 });
 var lineSymbol = new SimpleLineSymbol({
 color: [226, 119, 40],
 width: 4
 });
 var polygonGraphic = new Graphic({
 geometry: polygon,
 symbol: lineSymbol
 });
 resultsLayer.add(polygonGraphic);
answered Mar 30, 2017 at 1:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.