Select to view content in your preferred language

basemaps swap according to scale

589
0
11-22-2010 07:36 AM
NicolaLugeri
Deactivated User
Hello everybody.
by combining code snippets from the following threads:
http://forums.esri.com/Thread.asp?c=158&f=2421&t=280475&m=900261#900261
and
http://forums.arcgis.com/threads/13126-Sample-Map-Viewer-1.3-Base-Map-Switcher-Buttons?p=40026&viewf...

I've tried to implement (in Flex Viewer 1.3) a scale-based basemap visibility swap (I need this because I need to make my own topographic map be loaded first with its custom LODs, but I want it to be displayed on top of the Street Map within a certain scale range).
The code included in MapManager.mxml is as follows:

   private function checkScale(evt:Event):void
   {
    var lyr1:Layer = SiteContainer.getInstance().controller.map.getLayer("Street Map");
    var lyr2:Layer = SiteContainer.getInstance().controller.map.getLayer("250igm");
        if( map.scale < 400000 && map.scale > 100000)
        {
     lyr1.visible = false;
     lyr2.visible = true;
     } else
     {
     lyr1.visible = true;
     lyr2.visible = false;
        }
  }

.....
//Add this to the case statement for tiled
tiledlayer.addEventListener(Event.COMPLETE, checkScale);


What happens is that it works when I zoom in from the full extent through the desired scale range, but when I exit this range (e.g. mapscale < 100000) the basemap visibility does not swap back as coded in the "else" statement.

I've put a couple of Alerts, and it seems that when the scale range is exited, the function is not accessed anymore.

Does anybode see what am I doing wrong?

Thanks

Nicola
Tags (2)
0 Kudos
0 Replies