Select to view content in your preferred language

Initiate panel upon zoom level

1092
9
12-07-2011 09:28 PM
BenKane
Regular Contributor
I am trying to generate a panel popup when the zoom level exceeds a certain scale.  I have been able to use lods to switch from one map service to another at the specified scale, but I would like to have a popup that explains the reason for the switch.

Specifically, I am trying to figure out how to call a specific LOD from my lods array with com.esri.ags.Map.zoomEnd, only initiating the popup panel for a specified zoom level.  Right now it will popup at any zoomEvent, but I only want it at one LOD.

I am using Flex API 2.4.

Any ideas?

Thanks
Tags (2)
0 Kudos
9 Replies
BenKane
Regular Contributor
I've used a layerUpdateStartHandler() to create an alert panel when the map is zoomed to a certain scale...the next problem is how to prevent the function from firing on layer updates after the first event (e.g. I don't want the alert to show if the map is panned after reaching this zoom scale).

Any guidance would be appreciated.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ben,

  Check and see if the map.scale is the same as when the panel was fired.
0 Kudos
BenKane
Regular Contributor
Robert,
map.scale is the same each time the panel fires when panning after the initial zoom level is reached.

Perhaps a I could put a panEvent function that cancels the layerUpdate event?  Do you think that would work, or do you have and idea for a different solution?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ben,

   That's what I meant if it is the same (because you are just panning) then don't display the panel.
0 Kudos
BenKane
Regular Contributor
Robert,

I've been trying to do that but have been unable to figure out the syntax for this...can you provide example code please?

Thanks
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ben,

   Share what you have and I will see if I can fix it.
0 Kudos
BenKane
Regular Contributor
Robert,
The scale at the zoom level is 72223.819286.
Here is my code, I'm relatively new to Flex and I don't have much understanding of the interaction between elements:

   protected function _updateStartHandler(event:LayerEvent):void
   {
    
     var Layer:ArcGISDynamicMapServiceLayer = event.target as ArcGISDynamicMapServiceLayer;    
     Alert.show("You have reached the limit of the zoom level for this layer."); 
     
    }
   protected function myMap_panStartHandler(event:PanEvent):void
   {
    if (myMap.scale == 72223.819286)
    {
     _updateStartHandler(null)
    }
    
   }


And the code for map:
  <esri:Map id="myMap" logoVisible="false"
      load="addLODs() + onMapLoad()"
      level="3"
      extent="{initialExtent}"
      top="89"
      panStart="myMap_panStartHandler(event)"
      panEnd="myMap_panStartHandler(event)"
      panUpdate="myMap_panStartHandler(event)"
      >


Code for the layer the handler is attached to:
   <esri:ArcGISDynamicMapServiceLayer id="zoomMax" alpha="0" 
            url="http://*mylayer*/MapServer"
            minScale="72223.819286"
            updateStart="_updateStartHandler(event)"
            />


Thanks
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ben,

  I had to find time to write an sample:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:esri="http://www.esri.com/2008/ags"
               minWidth="955" minHeight="600">
    <fx:Script>
        <![CDATA[
            import com.esri.ags.events.LayerEvent;
            import com.esri.ags.events.MapEvent;
            import com.esri.ags.layers.supportClasses.LOD;
            
            import mx.controls.Alert;
            
            private var LastMapExt:Extent;
            private var PanelShown:Boolean;
            
            protected function zoomMax_updateStartHandler(event:LayerEvent):void
            {
                if (myMap.scale == 72223.819286){
                    LastMapExt = myMap.extent;
                    if(LastMapExt && !PanelShown){
                        PanelShown = true;
                        Alert.show("You have reached the limit of the zoom level for this layer.");
                    }
                }else{
                    PanelShown = false;
                    LastMapExt = null;
                }
            }
            
            private function addLODs(event:MapEvent):void
            {                
                var lods:Array = myMap.lods;
                lods.push(new LOD(19, 0.149291071, 564.2485881));
                lods.push(new LOD(18, 0.29858214171376, 1128.4971762));
                lods.push(new LOD(17, 0.59716428342752, 2256.9943525));
                lods.push(new LOD(16, 1.19432856685505, 4513.988705));
                lods.push(new LOD(15, 2.38865713397468, 9027.977411));
                lods.push(new LOD(14, 4.77731426794937, 18055.954822));
                lods.push(new LOD(13, 9.55462853563415, 36111.909643));
                lods.push(new LOD(12, 19.1092570712683, 72223.819286));
                lods.push(new LOD(11, 38.2185141425366, 144447.638572));
                lods.push(new LOD(10, 76.4370282850732, 288895.277144));
                myMap.lods = lods;
            }

            
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    
    <esri:Map id="myMap"
              logoVisible="false"
              load="addLODs(event)">
        <esri:extent>
            <esri:Extent xmin="-9598200" ymin="3968200" xmax="-9500400" ymax="4026200">
                <esri:SpatialReference wkid="102100"/>
            </esri:Extent>
        </esri:extent>
        
        <esri:ArcGISTiledMapServiceLayer url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
        <esri:ArcGISDynamicMapServiceLayer id="zoomMax" alpha="1" 
                                           url="http://*mylayer*/MapServer"
                                           visible="true" minScale="72223.819286" 
                                           updateStart="zoomMax_updateStartHandler(event)"/>
    </esri:Map>
</s:Application>
0 Kudos
BenKane
Regular Contributor
Robert, thank you so much, that works beautifully!  Really appreciate your time and help.

Ben
0 Kudos