I have an app that is consuming ArcGIS REST Services through the ArcGIS JavaScript API (10.2 or 10.3).
One of the available layers contains several Polylines. These lines belong to different groups, defined through a certain attribute (e.g., groupID
).
The user can click on a checkbox (among many) to select which group he wants to see. I am using setLayerDefinitions to filter the existing layer (ArcGISDynamicServiceLayer).
var queryStatement = "groupid = " + group_id
// group_id is provided by the selected checkbox
var layerDefinitions = []
layerDefinitions[23] = queryStatement
var layer = mapServiceLayer.getLayer("layer1")
layer.setLayerDefinitions(layerDefinitions)
This approach only allows to see one group at a time. How to see multiple groups at the same time and give them different colors in the map? I could combine multiple groups in the same queryStatement
, but then they would have the same color on the map.
Another possible approach is to create a FeatureLayer on-the-fly, after each checkbox is checked. Would this scale well?