Select to view content in your preferred language

Changing View Stack on Click

3468
4
09-22-2010 06:30 AM
JoshCalhoun
Emerging Contributor
He everyone,

I am looking for a public method to change a View Stack in side a widget from a button outside of that widget.

I have three buttons at the top of the map pointing to three different services. I have a widget with three tabs that show legends for each service. The problem is when the user clicks one of the map service buttons the legend does not update. You have to click on the tab with the appropriate  legend. I am looking for a way to make it easier for users to use the map.

I want the legend to update with the map service that the user clicks on. Below is a link to the site.

http://74.116.50.125/cwsmap/index.html


Any help you all can give me will be greatly appreciated.

thanks

Josh Calhoun
City of Chattanooga GIS
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Josh,

   The easiest route for you is to add a new event to the AppEvent.as and dispatch it from the buttons and listen for it in the widget. There are lots of examples of this in the viewer's code.
0 Kudos
JoshCalhoun
Emerging Contributor
Robert,

I kind of see what you are talking about but I am having trouble putting some things together.

The buttons I am using are loacated in the index.mxml (see code below). This is the code you created the other day showing a case statement that picks a map service baised on a button click.
Where should I place the call to dispatch to the AppEvent called SET_BASEMAP? 


public function setBasemap(basemap:String):void
            {
                var lyr:Layer = SiteContainer.getInstance().controller.map.getLayer("Leaf Collection Map");
                var lyr2:Layer = SiteContainer.getInstance().controller.map.getLayer("Recycle Collection Map");
                var lyr3:Layer = SiteContainer.getInstance().controller.map.getLayer("Garbage Collection Map");
                switch(basemap)
                {
                    case "Leaf Collection Map":
                    {
                        lyr.visible = true;
                        lyr2.visible = false;
                        lyr3.visible = false;
                        break;
                    }
                   
                   
                    case "Recycle Collection Map":
                    {
                        lyr.visible = false;
                        lyr2.visible = true;
                        lyr3.visible = false;
                        break;
                    }
                    case "Garbage Collection Map":
                    {
                        lyr.visible = false;
                        lyr2.visible = false;
                        lyr3.visible = true;
                        break;
                    }
                }
            }


Any help or advice robert will be greatly appreciated

thanks,
Josh Calhoun
City of Chattanooga GIS
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Josh,

   Something like this:
switch(basemap)
   {
    case "Leaf Collection Map":
    {
     lyr.visible = true;
     lyr2.visible = false;
     lyr3.visible = false;
     SiteContainer.dispatchEvent(new AppEvent(AppEvent.SET_BASEMAP, false, false, "Leaf Collection Map"));
     break;
    }
    
    
    case "Recycle Collection Map":
    {
     lyr.visible = false;
     lyr2.visible = true;
     lyr3.visible = false;
     SiteContainer.dispatchEvent(new AppEvent(AppEvent.SET_BASEMAP, false, false, "Recycle Collection Map"));
     break;
    }
    case "Garbage Collection Map":
    {
     lyr.visible = false;
     lyr2.visible = false;
     lyr3.visible = true;
     SiteContainer.dispatchEvent(new AppEvent(AppEvent.SET_BASEMAP, false, false, "Garbage Collection Map"));
     break;
    }
   }
0 Kudos
JoshCalhoun
Emerging Contributor
Thanks Robert,


I was just told today, to split the application into three separate Flex sites. No problem though, I can still use this code for another up and coming app.

Thanks a bunch for  all your help. We all appreciate all that you do.
0 Kudos