AnsweredAssumed Answered

How to use Where clauses in labeldefinition

Question asked by Crittermap on Oct 12, 2018
Latest reply on Oct 15, 2018 by xander_bakker

I was trying out some label definitions in Android on a GraphicsOverlay


static final
String labelPolygon = "{" +
        "\"labelExpressionInfo\": {" + // Define a labeling expression that will show the address attribute value
        "\"expression\": \"return $feature.geometryName;\"}," +
        "\"labelPlacement\": \"esriServerPolygonPlacementAlwaysHorizontal\"," + // Align labels horizontally
        "\"where\": \"$feature.geometryType='Polygon'\"}," +
        "\"symbol\": {" + // Use a black bold text symbol
        "\"color\": [0,0,0,255]," +
        "\"haloColor\": [255,255,255,96]," +
        "\"haloSize\": 2," +

        "\"font\": {\"size\": 10}," +
        "\"type\": \"esriTS\"}" +
        "}";

static final String labelPolyline = "{" +
        "\"labelExpressionInfo\": {" + // Define a labeling expression that will show the address attribute value
        "\"expression\": \"return $feature.geometryName;\"}," +
         "\"where\": \"$feature.geometryType='Polyline'\"}," +
        "\"labelPlacement\": \"esriServerLinePlacementAboveAlong\"," + // Align labels horizontally
        "\"symbol\": {" + // Use a black bold text symbol
        "\"color\": [0,0,0,255]," +
        "\"haloColor\": [255,255,255,96]," +
        "\"haloSize\": 2," +
        "\"font\": {\"size\": 10}," +
        "\"type\": \"esriTS\"}" +
        "}";

static final String labelPoint = "{" +
        "\"labelExpressionInfo\": {" + // Define a labeling expression that will show the address attribute value
        "\"expression\": \"return $feature.geometryName;\"}," +
        "\"where\": \"$feature.geometryType='Point'\"}," +
        "\"labelPlacement\": \"esriServerPointLabelPlacementBelowCenter\"," + // Align labels horizontally
        "\"symbol\": {" + // Use a black bold text symbol
        "\"color\": [0,0,0,255]," +
        "\"haloColor\": [255,255,255,96]," +
        "\"haloSize\": 2," +
        "\"font\": {\"size\": 10}," +
        "\"type\": \"esriTS\"}" +
        "}";

I thought perhaps that since they have a rule for polygon, polyline, and point, that they would

That wasn't the case, and I got too many labels. I get one below and above a point symbol.

I tried adding "where" clause to restrict the polygon labels to polygons and so forth.
Then all labels dissappear.

I have found little to no guidance on what syntax should be followed in a where clause. I don't even know if it is SQL
or an Arcade Expression.

Outcomes