Ill start out by just explaining what I'm trying to achieve. I'm running an arcgis application based on the javascript API. I'm Rendering a CSVLayer into my SceneView like such:

 require(["esri/Map", "esri/layers/CSVLayer", "esri/views/SceneView", "esri/widgets/BasemapToggle", "esri/Graphic", "esri/tasks/support/Query", "esri/widgets/Legend", "esri/widgets/Expand"],
        function (Map, CSVLayer, SceneView, BasemapToggle, Graphic, Query, Legend, Expand) {
 var csvLayer = new CSVLayer({
                url: numberLayers[0].Url,
                popupTemplate: template,
                featureReduction: {
                    type: "selection"
            csvLayer.renderer = {
                type: "simple",
                symbol: {
                    type: "simple-marker",
                    style: "circle",
                    color: [255, 255, 255, 1],
                    outline: { color: [0, 0, 0, 0.4] },
                    size: 16,
                label: "PurpleAir Sensors",
                visualVariables: [colorVisual]
var map = new Map({ basemap: "streets-navigation-vector", layers: csvLayer });
            var view = new SceneView({
                container: "divSensorMapContainer",
                camera: {
                    position: [
                map: map,
                center: centerPoint,
                constraints: {
                    altitude: {
                        min: 0,
                        max: 9000000,

What i want to do is filter this data based on the attributes defined in the CSVLayer. Ive tried doing this using the .whenLayerView function to capture the layerview and then run a .filter property to filter the dataset.

                .then(function (layerView) {
                  sensorLayerView = layerView;
                    var newQuery = csvLayer.createQuery();
                    newQuery.where = "PM25 > '40'";
                    sensorLayerView.filter = newQuery;
                    csvLayer.queryFeatures(newQuery).then(function (result) {
                        if (highlight) {
                        highlight = sensorLayerView.highlight(result.features);
                    view.ui.move(["compass", "zoom", "navigation-toggle"], "bottom-right");

Now in this .whenLayerView function we get the layerview, define a query based on the data set, and then do two things:

  1. Highlight sensors based on the query information.
  2. Run a filter property on the layerView. (The Api reference information is given here:https://developers.arcgis.com/javascript//latest/api-reference/esri-views-layers-CSVLayerView.html#filter)

This is the output:

The map should only show highlighted sensors. But it doesnt work.

So does anyone know what I'm doing wrong? I used a reference tutorial to get this far, you can find that here: https://developers.arcgis.com/javascript//latest/sample-code/featurefilter-attributes/index.html

  • 1
    Same question was posted to Stack Overflow: stackoverflow.com/questions/56659729/… – GavinR Jun 20 at 12:53
  • Please do not cross-post. Ask on one site only. If that yields no answer then delete from there and re-ask on a second site, if you think there may be one more suitable. – PolyGeo Jun 22 at 18:41
  1. The query action result is a list of features - it does not change features visibility
  2. In order to filter the displayed features - use definitionExpression
    csvLayer.definitionExpression= "PM25 > 40"
  3. I've prepared a codePen with a definitionExpression example (line 104)
  • 1
    Hey thank you so much man, so it works as per the requirement now. It took me forever to solve this. Should've properly checked the csvlayer api before even going into the csvlayer. Anyways thank you so much, have a good day. – Purple Samosa Jun 20 at 23:47
  • @PurpleSamosa you should probably close the issue in the main stack overflow, cheers! – NettaB Jun 21 at 11:09
  • Kind of new to all this, how do i exactly close the issue? – Purple Samosa Jun 23 at 8:42
  • @PurpleSamosa - I guess you can just edit the question and add: "This issue was solved in gis stackexchange " + link. – NettaB Jun 23 at 9:14

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.