Hi, I'm looking to create an onscreen button that when clicked simply toggles certain layers on and off. I'm able to get the layer via the var OutageLayer = map.getLayer("Outages"); and then set to show or hide, but what else needs to be in the widget.js? Is there any other widgets that i could copy the guts out of to use? The idea is that during an storm our dispatch folks and click the "Storm Mode" button and the layers will be set to a predetermined visibility to avoid search through layers. Any help is appreciated.
Thanks,
Brian
Brain,
If you are just looking for a widget template then just copy the
[install Dir]\client\stemapp\widgets\samplewidgets\CustomWidgetTemplate
Thanks Robert, I'm familiar with flex and i can see similarities between the two but am still learning the new system. Ill dig into the sample a little more and see if I can figure it out. Thanks again.
I seem to be making some progress thanks to Robert Scheitlin, GISP. I have however run into a bit of a road block. I am able to use the this.map.getLayer() method to grab layers by their ID but cannot figure out how to reference sublayers. I have a number of sublayers in groups that i need to grab in order to turn them on/off on click. Any help is appreciated!
Thanks,
Brain,
An ArcGISDynamicMapServiceLayer does have sublayers but they are not actual layers that you can get from the map. You would just get the parent ArcGISDynamicMapServiceLayer and then set the ArcGISDynamicMapServiceLayer visibleLayers property.
That did the trick! I'm noticing now that when I change layer visibility
it doesn't update the layerlist, is there a way for force a layerlist
refresh?
Brain,
Unfortunately the Layer List Widget is not listening for programmatic changes to layer visibility.
Don't forget to mark this thread as answered
Are you able to provide the code you are using on a custom button to toggle layer visibility?
I was able to get the button to toggle visibility but was never able to get
it to check or unchecked the layer list to show the current visibility.
I'll see if I can package it up and send it to you.
If I manage to get the current visibility refresh going Ill let you know...(cross fingers for newer releases) If Robert says not possible, then... shrug
Greatly appreciated!
-Mike