definitionExpression attribute of FeatureLayer works fine when the application is loaded, but when I click a button that changes the definitionExpression attribute of the layer, the displayed features disappear from the map but I don't see the new features based on the new definitionExpression, although the attribute is changed.
The code I am using:
| | |
| | var buildingsLyr = new FeatureLayer({ |
| | url: "myURL", |
| | id: "BuildingsBM", |
| | renderer: renderer, |
| | popupTemplate: { |
| | title: "{ID}", |
| | content: "{*}" |
| | }, |
| | outFields: ["ID", "Use", "Z"], |
| | definitionExpression: "Sector = 'S1'", // show only buildings within this sector |
| | }); |
| | map = new Map({ |
| | basemap: "streets", |
| |
| | layers: [buildingsLyr] |
| | }); |
| | view = new SceneView({ |
| | container: "viewDiv", |
| | map: map |
| | , |
| | camera: { |
| | position: [54, 24, 30000], |
| | heading: 0, |
| | tilt: 35 |
| | } |
| | }); |
// on button click, change the definitionExpression
| | on(document.getElementById("btnLocate"), "click", function (e) { |
| | |
| | buildingsLyr.definitionExpression = "Sector = 'S2'" |
| | }); |