2

I'm trying to use a renderer and a legend on data from a featureSet, it displayes symbols and popups but the renderer fails.

The data comes from a featureLayer but I display it with view.graphics so I think that may be the problem. Still I can't find an add graphic (maybe addAttachment but I could not make it work) .

This is my code:

var layer = new FeatureLayer({      url:'https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/la_county_labor_centroid/FeatureServer/0'});

  function succ(featureSet) {
  layer.applyEdits({addFeatures:featureSet})
    map.add(layer)
  };

  function fail(error) {
    console.error('An error ocurred in the query: ', error);
  };

  on(dom.byId('population'), 'change', function (e) {
    var population = e.target.value;
    if (population.length > 0) {


      var query = new Query();
      query.returnGeometry = true;
      query.outFields = ["*"];
      query.where = "TOTAL_POP > " + population;

      layer.queryFeatures(query).then(succ,fail)
    }
  });

  });      

heres my code pen:

https://codepen.io/segev-salman/pen/MdmrLB

the first time i use the select it refreshes the layer and adds the feature set but it doesnt query it(returns the full layer instead of asked data), but thats it, the promise returns the FeatureSet but it doesn't apply the edits Do I need a new featureLayer or can I use the one with the URL to the service to be displayed with the renderer with queryed data and if not do I really have to insert the data manually after the query does it just bring me back graphics or changes the layer?

I know about definitionExpression this is an example to help me learn how to edit and add data to layers.

  • Please place the relevant code sample in the body of the question using a code block. Third-party links fail over time, which invalidates the question content. – Vince May 17 at 10:43
  • I did thank you. @Vince – segev May 20 at 7:40
1

You can skip the query and use definitionExpression if you want to filter the displayed data. Here's a working example - based on your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.