Select to view content in your preferred language

Turning on/off a Layer in the TOC Programmatically

1016
4
10-16-2012 09:39 AM
by Anonymous User
Not applicable
Original User: rduke40

I am trying to turn on a layer programmatically within widget code.  I want to be able to trigger a layer to turn on programmatically when I click on a widget.  The same action that comes from selecting a layer from the layers list is the same action I want to duplicate when selecting a particular widget from the widget list. with   For example we have a Zones layer in our TOC list.  When you select it, all the different zones will be highlighted on the map. I want to do the exact same thing programmatically when a widget is opened.


This is a pic of the map before the zones layer is selected: [ATTACH=CONFIG]18460[/ATTACH]

This is a pic of the map after the zones layer is selected: [ATTACH=CONFIG]18461[/ATTACH]

I want to duplicate this programmatically.

Thanks,
Ray
0 Kudos
4 Replies
RhettZufelt
MVP Notable Contributor
The SwipeSpotlight widget has the option to turn on a layer if you select it and it is not visible.

perhaps you can get the coding/ideas from that to accomplish what you want.  Look in the layerChanged function and askAbout.

R_
0 Kudos
by Anonymous User
Not applicable
Original User: rduke40

Rzufelt,
Thanks for the reply.  I have looked at Robert's Swipe/Spotlight widget and it will not provide a solution for me.  I need just to have programmatic control of a sublayer and that widget is unable to do that. I saw that you have had some issues with that widget as well.  Can you recommend anything else that might be beneficial?  Thanks, Rzufelt.

Ray
0 Kudos
RhettZufelt
MVP Notable Contributor
I think Robert has fixed the "issues" with that widget.

The other issues I had were because I was trying to make it do things it was never intended to do.

I'm pretty new to this Flex stuff, but you might get some ideas here:
http://resources.arcgis.com/en/help/flex-api/samples/index.html#/Dynamic_Map_Layers_on_off/01nq00000...

R_
0 Kudos
RhettZufelt
MVP Notable Contributor
Ray,

Just noticed this post:  http://forums.arcgis.com/threads/2106-Radio-Button-on-off-Layers?highlight=remove+listener

Thought you might get some ideas from it.

R_
0 Kudos