When I apply an arcade expression to the value expression property of my unique value renderer, it doesn't seem to work as expected.
Here is a jsbin example using a modifyed sample that esri provides:
JS Bin - Collaborative JavaScript Debugging
Here is the line in question:
valueExpression: "When($feature.type == 'Gravel', 'test')",
I would expect this to filter the layer down and only show 7 features, just like when the filter is applied in the rest endpoint.
But instead, all of the features in the map adopt the uvr symbol:
Solved! Go to Solution.
Hello Jack,
As per documentation, Arcade expressions are not supported with MapImageLayers. Only FeatureLayers and SceneLayers are supported.
Hello Jack,
As per documentation, Arcade expressions are not supported with MapImageLayers. Only FeatureLayers and SceneLayers are supported.
Thank you for your reply. Do you know if this feature will be supported in a future release? If so, when?
And are there any possible workarounds to make something similar to this work?
Hello Jack,
If I am understanding what you are trying to do, you could do the following....
This would display only what you queried, as a custom Feature Layer. Below is sample code I came up with. Let me know if this is a misunderstanding of your question.
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/MapImageLayer",
"esri/tasks/support/Query",
"esri/tasks/QueryTask",
"esri/layers/FeatureLayer",
"dojo/domReady!"
],
function (Map, MapView, MapImageLayer, Query, QueryTask, FeatureLayer) {
//Create a new map and set the basemap to Dark gray
var map = new Map({
basemap: "dark-gray",
//layers: [featureLayer]
});
//set a new view and set the properties of the view
var view = new MapView({
container: "viewDiv",
map: map,
center: [-86.049, 38.485],
zoom: 3
});
var queryStatesTask = new QueryTask({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2"
});
var quakesRenderer = {
type: "simple", // autocasts as new SimpleRenderer()
symbol: {
type: "simple-fill", // autocasts as new SimpleMarkerSymbol()
//style: "circle",
size: 20,
color: [211, 255, 0, 0],
outline: {
width: 1,
color: "#FF0055",
style: "solid"
}
}
}
var query = new Query();
query.where = "state_name = 'California'";
query.returnGeometry = true;
queryStatesTask.execute(query).then(function (result) {
//console.log(result);
var fl = new FeatureLayer({
source: result.features, // autocast as an array of esri/Graphic
// create an instance of esri/layers/support/Field for each field object
fields: result.fields, // This is required when creating a layer from Graphics
objectIdField: "ObjectID", // This must be defined when creating a layer from Graphics
renderer: quakesRenderer, // set the visualization on the layer
spatialReference: result.spatialReference,
geometryType: result.geometryType // Must be set when creating a layer from Graphics
});
map.add(fl);
});
});