eMapSwitcher - autoswitchtoscale

1067
4
Jump to solution
09-18-2012 09:34 AM
philippschnetzer
Occasional Contributor III
Lovin' the forcescaleonswitch and autoswitchtoscale features of the emapSwitcher - this is very useful when Esri's basemaps only go to 1:4000...

The tiled Esri basemaps I am using only go to 1:4513 but I need to make my map zoom to a scale of 1:564.  So, what I am doing, which works not too badly, is once I hit 1:2256 i use autoswitchtoscale to make sure Esri's Topo layer is selected (as dynamic) - this at least gives me a white background I can work with to overlay some of my own layers.  This works all the way down to 1:564.  What I need to do is be able to automatically have the dynamic version of the topo switch to tiled at 1:4513 when the user zooms back out...so pretty much the same method as autoswitchtoscale except that it also works in reverse when zooming back out. 

Or, does anyone have any suggestions to make sure the 'Image not yet available' never appears while at the same time autoamtically showing at least some sort of white background to overlay my operational layers on.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Phillip,

   In Flex Viewer 3.0 all layers now support a maxscale and minscale attribute in the main config.xml. You could use those and the optional sixth color in the main config.xml (set to white).

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Phillip,

   In Flex Viewer 3.0 all layers now support a maxscale and minscale attribute in the main config.xml. You could use those and the optional sixth color in the main config.xml (set to white).
0 Kudos
philippschnetzer
Occasional Contributor III
Genius! Thanks, Robert!
0 Kudos
philippschnetzer
Occasional Contributor III
Robert,

Uisng a combination of minscale, maxscale, autswitchtoscale and forcescaleonswitch I have my basemaps configured almost the way i want.  The only problem where a user may get confused is the fact that the aerial basemap image can be clicked in the basemap chooser at a scale of 1:100000, for example) and the screen just turns white (because I have the aerial minscale set to 36000).  What would be ideal is if the forcescaleonswitch worked in both directions; right now i have forcescaleonswitch set to 4500 so that when you're zoomed in to 1000 and just see a white background and you click aerial it takes you to 4500 where the aerial is available.  Could this be made to also zoom in to 36000 when the scale is larger than 36000 (ie, if you are at 200,000 and you click aerial it zooms to 36000).  Or, could the aerial thumbnail just be removed from the basemap choose box until the scale has reached 36000?

This is what my config looks like:

<layer label="Aerial  (36,111 and below)"    type="tiled" visible="false" maxscale="4513.9887049999998" minscale="36111.909643" forcescaleonswitch="4513.9887049999998" autoswitchtoscale="36111.909643"
                   icon="assets/images/aerial.png" 
                   url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
                                                    
                    <layer label="Topo  (72,223 and above)"    type="tiled" visible="true" maxscale="72223.819286"  forcescaleonswitch="72223.819286" autoswitchtoscale="72223.819286"
                   icon="assets/images/topo.png" 
                   url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>


Thank you!
0 Kudos
philippschnetzer
Occasional Contributor III
As stated above, I'm using the eMapSwitcher and trying to force the map to zoom in to 36000 if the aerial basemap ic clicked and the current scale is greater than 36000.

I've added the following to emapSwitcherWidget.mxml thinking it would do the trick, but it does nothing...any ideas?


private function basemapButtonBar_changeHandler(event:IndexChangeEvent):void
   {
    var layers:ArrayCollection = map.layers as ArrayCollection;
    basemapsButtonBar.fader.value = event.newIndex + 1;
    for (var x:int = 0; x < basemapList.length; x++){
     var basemapLabel:String = basemapList.getItemAt(x).label;
     for each (var layer:Layer in layers){
      if(basemapList.getItemAt(event.newIndex).label != basemapLabel)
       if(layer.id == basemapLabel)
        layer.visible = false;
      if(layer.id == basemapLabel)
       layer.alpha = 1;
     }
    }
    if(basemapList.getItemAt(event.newIndex).forcescaleonswitch && map.scale < basemapList.getItemAt(event.newIndex).forcescaleonswitch){
     map.scale = basemapList.getItemAt(event.newIndex).forcescaleonswitch;
     /* if(basemapList.getItemAt(basemapSelectionComponent.selectedIndex).label == "myspecialbasemap"){
      map.centerAt(new MapPoint(x,y, map.spatialReference));
     } */     
     
     if(basemapList.getItemAt(basemapSelectionComponent.selectedIndex).label == "Aerial  (36,111 and below)" && map.scale > 36111.909643)
      map.scale = 36111.909643;
    }
    AppEvent.dispatch(AppEvent.BASEMAP_SWITCH, basemapList.getItemAt(event.newIndex).id);
   }


Is it perhaps that my added code is interfering with the forcescaleonswitch code?
0 Kudos