Quantcast
Channel: Forums - ArcGIS Viewer for Flex
Viewing all articles
Browse latest Browse all 2097

PopupRenderSkin with radio buttons part 2

$
0
0
I have taken the snippets from here:
http://forums.arcgis.com/threads/479...d=1#post243845

and am trying to get a radio button on the bottom of my popup window that turns on/off thier respective label service.
Everything seems to be working fine as far as the radio buttons, but the infoWinClose_Handler is giving me some issues. It works just fine for the first item/layer clicked on, however, if I get popup info from a "different" layer, I get reference to null object error when I close any other popup window (other than the first one I click on).

Here is what I've gotten so far (well, at least the portions I've added) I have tried several "if" statements to try to get it to only change visibility if it was one of the "toggle" layers, and ignore the "other" popups so I don't get the null issues, but have had no luck.

I need it to close the layer that was toggled on when the widget is closed. Would really be nice if it would close the toggled on layer when "switching" to a different layer as well. This would probalby solve the null issues.

The code that determines which layer to load, toggle on and off, and whether or not to include the toggle buttons is working fine, only the on close function that I'm having issues with.

Any ideas?

R_


Code:

        <fx:Script>
                <![CDATA[

                        [Bindable] var RBlabel:String;            // variable used to capture the current (identified) layer name
                        [Bindable] var RBlayer:String;          //variable used to tell which layer to toggle on/off
                        [Bindable] var RBonsel:Boolean = false;  // variable used to capture "selected" state of the radio button
                        [Bindable] var RBoffsel:Boolean = true;  // variable used to capture "selected" state of the radio button

                        private function skin_preinitializeHandler(event:FlexEvent):void
                        {
                                // set the link styles
//My Add
                                  off.visible = false;
                                on.visible = false;
                                RBlayer = "";
                                RBlabel = "";
                               
                                if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/Buildings/MapServer/3"){
                                        off.visible = true;
                                        on.visible = true;                               
                                        RBlayer = "Buildings";
                                        RBlabel = "Building Labels";
                                }
                                if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/All_Waste_Sites/MapServer/1"){
                                        off.visible = true;
                                        on.visible = true;                               
                                        RBlayer = "WasteSites";
                                        RBlabel = "Point Labels";
                                }
                                if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/All_Waste_Sites/MapServer/2"){
                                        off.visible = true;
                                        on.visible = true;                               
                                        RBlayer = "WasteSites";
                                        RBlabel = "Line Labels";
                                }
                                if (hostComponent.featureLayer.url == "http://gis01.wch-rcc.com/ArcGIS/rest/services/Base/All_Waste_Sites/MapServer/3"){
                                        off.visible = true;
                                        on.visible = true;                               
                                        RBlayer = "WasteSites";
                                        RBlabel = "Poly Labels";
                                }
//End My add
                                textLayoutConfiguration = new Configuration();
                                var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
                                textLayoutFormat.color = getStyle("linkActiveColor")
                                textLayoutFormat.textDecoration = TextDecoration.UNDERLINE;
                                textLayoutConfiguration.defaultLinkActiveFormat = textLayoutFormat;

                                vGroup.addElement(ToggleLayers);  // My Add - this is not where I have it, just wanted to include it somewhere.


//My Add
                        protected function layerRBgroup_changeHandler(event:Event):void
                        {
                                var map:Map = hostComponent.map;
                                if (event.currentTarget.selectedValue == "on"){
                                            map.getLayer(RBlabel).visible = true;
                                                RBonsel = true;
                                                              RBoffsel = false;
                                        }
                                if (event.currentTarget.selectedValue == "off"){
                                    map.getLayer(RBlabel).visible = false;
                                    RBoffsel = true;
                                        RBonsel = false;
                        }
                        }
                        private function infoWinClose_Handler(event:Event):void
                        {
                                var map:Map = hostComponent.map;
                                        map.getLayer(RBlabel).visible = false;
                                        RBoffsel = true;
                                        RBonsel = false;
                                }
                        }                       
//End My add
                ]]>
        </fx:Script>
                <fx:Declarations>
                <!--- @private -->
                <s:RadioButtonGroup id="layerRBgroup" change="layerRBgroup_changeHandler(event)" />
                                <!--- @private -->
                <s:HGroup gap="6" verticalAlign="middle" id="ToggleLayers">
                        <s:RadioButton id="on" value="on" group="{layerRBgroup}" label="Turn Labels On" selected="{RBonsel}" />
                        <s:RadioButton id="off" value="off" group="{layerRBgroup}" label="Turn Labels Off" selected="{RBoffsel}" />
                </s:HGroup>
        </fx:Declarations>
</s:SparkSkin>


Viewing all articles
Browse latest Browse all 2097

Trending Articles