0

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?

1 Answer 1

1

you have more than one option:

  1. as you mentioned, you can definitely create your own FeatureLayer with custom Unique Value Renderer to draw vector graphics clientside
  2. if the ArcGIS Server map service supports dynamic layers you can ask for the same custom Unique Value Render to applied to the layer before it is drawn server side.

more info: http://server.arcgis.com/en/server/latest/publish-services/windows/about-dynamic-layers.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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