Select to view content in your preferred language

Get the symbol renderer information for a dynamic layer

1445
2
02-09-2011 03:46 AM
RichardKaufholz
Deactivated User
Hi there,

This seems like a simple question, but has me stumped! I would like to get a handle to the symbol renderer information for a layer published in a JSAPI application. Exactly what I want to do is shown when viewing a layer in the ArcGIS Services Directory - for point layers, it shows a bitmap of the symbol (marker symbols), for lines and polygons e.g.:

Renderer:
Simple Renderer:
Symbol:
Simple Fill Symbol:
Style: esriSFSSolid, Color: [Undefined]
Outline:
Simple Line Symbol:
Style: esriSLSSolid, Color: [230, 0, 0, 255], Width: 3


I can see that information is stored as a Renderer object but that is as far as I can tell (a) only exposed to Feature Layers and (b) not seem to have a "get" function of any description.

I need this information to help construct a custom TOC/Legend tool that shows all the information above along with a checkbox for visibility (and an opacity button in future).

Any help would be great!

Thanks,
Richard.
0 Kudos
2 Replies
GregSpiridonov
Occasional Contributor
I don't believe this is available yet in anything but a FeatureLayer and ArcGIS Server 10, I believe it is possible to get the symbol information through the soap connection, and therefore build the legend from that... It's not easy, but it can be done... this link shows how.  This functionality will only get better as 10 progresses, 10.1 will make it much easier as well.
0 Kudos
RichardKaufholz
Deactivated User
Hi Greg,

Thanks for your reply. Actually, I have managed to get this by using the REST API - I just had to figure out a whole new language for accessing the json data via a dojo deferred request (esri.request). What I also discovered is that the REST API includes a "Legend resource" which publishes small images (swatch) for each layer in a service.

At first I created swatches manually using dojo canvas and the renderer info. But after some cross-browser problems I discovered the Legend resource and that seems to work fine (and was easier to build!).

Not something I would volunteer to do again, but certainly is possible!

Cheers,
Richard.

P.S. I am using v10.
0 Kudos