Can labels be restyled via the REST API? Stuck on syntax.

776
2
10-02-2017 07:39 AM
JosephElfelt1
Occasional Contributor

I am using the ArcGIS Server REST API to display MapServer data that supports dynamic layers. I know how to restyle line and polygon geometry when my code calls for the tiles.

Question: Is it also possible to restyle labels?

The following link displays one tile with label data:

https://services.nationalmap.gov/arcgis/rest/services/govunits/MapServer/export?bboxSR=4326&layers=s...

And here is my call for the same tile where I am trying to make the text magenta:

https://services.nationalmap.gov/arcgis/rest/services/govunits/MapServer/export?bboxSR=4326&layers=s...

However my call results in the following nastygram:

{"error":{"code":400,"message":"Invalid dynamic layer definition for labeling classes.","details":[]}}

Can anyone shed light and show where I have gone astray in the syntax?

Joseph Elfelt
https://mappingsupport.com

0 Kudos
2 Replies
AlexThomas1
New Contributor II

1) Validate json through this tool: 

https://jsonformatter.curiousconcept.com/ 

2) Make sure the request you are making respects the scale.  In your request, I modified the bounding box to be 1/4 the size of what it was

3) Use the labelingInfo that's defined on the mapLayer as a starting point, then make your tweaks as needed

https://services.nationalmap.gov/arcgis/rest/services/govunits/MapServer/15?f=pjson 

Final result

https://services.nationalmap.gov/arcgis/rest/services/govunits/MapServer/export?bbox=-94.921875%2C30... 

JosephElfelt1
Occasional Contributor

Thanks Alex.

I will give your suggestions a try.

0 Kudos