Basemap Switcher - Slider

2165
4
07-28-2011 04:06 AM
RobertMueller
New Contributor
I've taken the code (below) from a previous post (http://forums.arcgis.com/threads/19078-Base-Map-Transparency-Slider-Code-Please?highlight=slider+alp...) that was trying to implement a basemap slider of sorts as found in this website; http://maps.hamiltontn.gov/hcflex/

My question is concerning the placement of this code. This code should be in a widget, similar to the original BaseMap switcher, although evidently lacks the correct "hook" into the map extent. However if put the code into the HeaderControllerWidget, a seperate map appears, but the code works.  Can anyone fill in my gap of understanding?

Thanks
Bob


<esri:Map id="MaryMap">
  
   <esri:ArcGISTiledMapServiceLayer
    visible="true"
    url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
   <esri:ArcGISTiledMapServiceLayer
    visible="true"
    alpha="{Math.max(1-mapTrans.value)}"
    url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" />
   <esri:ArcGISTiledMapServiceLayer
    visible="true"
    alpha="{Math.min(mapTrans.value-1)}"
    url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
  </esri:Map>
  <s:Group left="10" right="10" top="10" bottom="10">
  
   <s:VSlider
    id="mapTrans" width="10"
    minimum="0" maximum="2"
    snapInterval=".1"
    value="1"
    liveDragging="true" x="10" y="58">
   
   </s:VSlider>
   <s:ToggleButton x="10" y="5" label="Aerial" width="54" height="46"
       id="aerialButton"
       click="{mapTrans.value=0}" chromeColor="#1293BE"
       toolTip="Aerial Photo"/>
  
  
   <s:ToggleButton x="74" y="5" label="Base Map" width="54" height="46"
       id="baseButton"
       click="{mapTrans.value=1}"
       toolTip="Base Map"/>
  
   <s:ToggleButton x="145" y="5" label="Topo" width="54" height="46"
       id="topoButton"
       click="{mapTrans.value=2}"
       toolTip="Topo Map"/>
  
  
  </s:Group>
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Robert,

   This code was developed for a non Flex Viewer app as the one you reference in your link. It is in no way ready for the Flex Viewer. Quite a bit of work would have to be done to determine the base maps that are being used in the viewer and than adjust their alphas. If the base maps were static and not going to change from the 3 default ones that come pre-configured in the viewer than it would be easier, but as people can add and remove base maps at will this is more difficult to contend with.
0 Kudos
RobertMueller
New Contributor
Robert-

Thanks for the reply. No to long after I posted, I realized that this was in the viewer forum and not the Flex API.

I've been working on trying to compile with the given code into the Flex Viewer SDK. If the this code is in the HeaderController mxml it will compile and show an independent map that I can switch between. I thought maybe to modify the MapSwitcherWidget mxml as well, however the toggle button bar is throwing me.

There is a routine within the last mxml which has a changehandler,

private function tbb_changeHandler(event:IndexChangeEvent):void
            {
                ViewerContainer.dispatchEvent(new AppEvent(AppEvent.BASEMAP_SWITCH, mapList[event.newIndex].id));
            }

I'm just not sure how that will convey over to the slider code I provided.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Robert,

   As I mentioned not much of anything in that code is ready to be integrated in the Flex Viewer. The buttonbar in the MapSwitcherWidget just dispatches an AppEvent that the MapManager listens for and turns the visibility of one basemap on and the others off.
0 Kudos
RobertMueller
New Contributor
This functionality is really not that crucial to my app, so it will have to sit on the sidelines unless I find time before my deadline.

Thanks for your advice Robert.
Cheers.
0 Kudos