0

While I am generally knowledgeable about using the ArcGIS Server REST API to work with dynamic MapServer layers, this is the first time I have tried to turn on labels.

Below is a call for a tile that will display a single green circle. The value of POITYPE is Visitor Center. I would like the label ‘Visitor Center’ to appear near the green circle.

Alas, I have been unable to conjure up just the right syntax to make that happen. What am I missing?

https://mapservices.nps.gov/arcgis/rest/services/NationalDatasets/NPS_Public_POIs/MapServer/export?bbox=-12205302.24789184,4667760.897033789,-12200410.278081588,4665802.198183983&size=1024,410&dpi=96&format=png24&transparent=true&bboxSR=3857&imageSR=3857&dynamicLayers=[{'source':{'type':'mapLayer','mapLayerId':0},'definitionExpression':"upper(POITYPE)='VISITOR+CENTER'",'drawingInfo':{'renderer':{'type':'simple','symbol':{'type':'esriSMS','style':'esriSMSCircle','color':[0,255,0,255],'size':8,'outline':{'color':[0,0,0,255],'width':1.5}}}},'showLabels':true,'labelingInfo':{'labelPlacement':'esriServerPointLabelPlacementAboveRight','labelExpression':[POITYPE],'useCodedValues':false,'symbol':{color:[0,255,255,255],'size':8,'fontFamily':'Arial','fontStyle':'normal','fontWeight':'bold','fontDecoration':'none'}}}]&layers=show:0&f=image

1

There are some issues with your dynamicLayers definition.

  • It's not valid JSON:
    • JSON uses double quotes, not single (use single quotes in upper(POITYPE)='VISITOR CENTER')
    • Missing quotes for labelExpression
    • Missing quotes for color
  • showLabels and labelingInfo should be inside drawingInfo
  • font should be a separate JSON object, i.e. "font": { "name": "Arial", etc }

See here for details: https://developers.arcgis.com/rest/services-reference/export-map.htm#

Here's a sample that should get you going:

[
    {
        "id": 0,
        "name": "NPS_Public_POIs",
        "source": {
            "type": "mapLayer",
            "mapLayerId": 0
        },
        "definitionExpression": "upper(POITYPE)='VISITOR CENTER'",
        "drawingInfo": {
            "renderer": {
                "type": "simple",
                "symbol": {
                    "color": [
                        0,
                        255,
                        0,
                        255
                    ],
                    "size": 8,
                    "type": "esriSMS",
                    "style": "esriSMSCircle",
                    "outline": {
                        "color": [
                            0,
                            0,
                            0,
                            255
                        ],
                        "width": 1.5,
                        "type": "esriSLS",
                        "style": "esriSLSSolid",
                        "marker": null
                    }
                }
            },
            "showLabels": true,
            "labelingInfo": [
                {
                    "labelExpression": "[POITYPE]",
                    "useCodedValues": false,
                    "maxScale": 0,
                    "minScale": 0,
                    "where": null,
                    "labelPlacement": "esriServerPointLabelPlacementAboveCenter",
                    "symbol": {
                        "color": [
                            0,
                            0,
                            0,
                            255
                        ],
                        "type": "esriTS",                        
                        "horizontalAlignment": "left",
                        "font": {
                            "size": 8,
                            "style": "normal",
                            "variant": "normal",
                            "decoration": "normal",
                            "weight": "normal",
                            "family": "Arial"
                        }
                    }
                }
            ]
        },
        "minScale": 0,
        "maxScale": 0
    }
]
1
  • Thanks for taking the time to help!
    – Gmap4 guy
    May 1 '20 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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