Select to view content in your preferred language

PanEvent.PAN_END event being generated repeatedly even though map is not being panned

800
3
10-03-2012 11:43 AM
TerryCampbell
New Contributor
We are encountering a strange problem after zooming in/out a lot when the map is around London, England. The event listener for PanEvent.PAN_END is being called repeatedly even though the map is not being panned. Greenwich in SE London (and the prime meridian) are within the map boundaries for some of the maps and outside for others (depending on the scale / zoom level). In the call stack we can see that the enterFrameHandler function is called and that it calls dispatchPanEnd. Is there any scenario in which the dispatchPanEnd would be called repeatedly (every second or two), because that's what we're seeing when the problem occurs. We have not been able to reproduce the problem in the US, which makes us suspect some kind of issue at the prime meridian. The impact on the application is that it gets unresponsive as its trying to keep up with the onslaught of requests made every second or so. Do you have any recommendations for a workaround on our end? We are not really in a position to upgrade to a later version of the ESRI Flex API at this time. We are using a base map with no other layers. Interestingly, after the onslaught begins, if we stop the FlexViewer app and restart it (which brings up the map at the same extents as last time), the requests start up again. Note that we do change the map's extent to a user-defined envelope after the initial map load. We are using 2.4 version of ESRI Flex API.
Tags (2)
0 Kudos
3 Replies
DasaPaddock
Esri Regular Contributor
Can you try the 2.5 API?

Have you tried without the code for "Note that we do change the map's extent to a user-defined envelope after the initial map load."?

Can you share this code?
0 Kudos
TerryCampbell
New Contributor
Tried with 2.5 API and issue still occurred.

Commented out the code to change the map's extent to a user-defined envelope after the initial map load. World map came up initially. Zoomed into London area and was able to reproduce problem.

Created a sample app and got different results. With the code below, it brought up map with first extents, then switched to second set of extents then repeatedly got into map1_panEndHandler. We found that it didn't matter where the 2 sets of extents were. So, this is not the same as the problem originally reported, but could be related. It seems to be a situation where a pan end handler gets called repeatedly in an infinite loop. Any idea why?

<?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:esri="http://www.esri.com/2008/ags"
                     xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%">
      <fx:Script>
            <![CDATA[
                  import com.esri.ags.events.LayerEvent;
                  import com.esri.ags.events.PanEvent;
                  private var cntr:int = 0;
                  protected function map1_panEndHandler(event:PanEvent):void
                  {                      
                        trace('in pan end, ' + cntr++.toString());
                  }


                  protected function arcgistiledmapservicelayer1_loadHandler(event:LayerEvent):void
                  {
                        map.extent = DCExtent;
                  }

            ]]>
      </fx:Script>
      <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <esri:Extent id="londonExtent"
                              xmin="-149225.70420389052" ymin="6661356.208762923" xmax="43242.73301825692" ymax="6800930.222411709">
                  <esri:SpatialReference wkid="102100"/>
            </esri:Extent>
            <esri:Extent id="DCExtent"
                              xmin="-8600149.1564566" ymin="4687554.362114532" xmax="-8552032.047151148" ymax="4722447.865526669">
                  <esri:SpatialReference wkid="102100"/>
            </esri:Extent>
      </fx:Declarations>
      <esri:Map extent="{londonExtent}" id="map" wrapAround180="true" panEnd="map1_panEndHandler(event)">
            <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" updateEnd="arcgistiledmapservicelayer1_loadHandler(event)"/>           
      </esri:Map>
</s:Application>
0 Kudos
DasaPaddock
Esri Regular Contributor
Did you mean to call arcgistiledmapservicelayer1_loadHandler() on the updateEnd event? This is causing the loop since it's continually resetting the map's extent. If you call this on the layer's "load" event instead, it will only be called once.

<?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:esri="http://www.esri.com/2008/ags"
               width="100%" height="100%">
    <fx:Script>
        <![CDATA[
            import com.esri.ags.events.LayerEvent;
            import com.esri.ags.events.PanEvent;

            private var cntr:int = 0;

            protected function map1_panEndHandler(event:PanEvent):void
            {
                trace('in pan end, ' + cntr++);
            }

            protected function arcgistiledmapservicelayer1_loadHandler(event:LayerEvent):void
            {
                map.extent = DCExtent;
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <esri:Extent id="londonExtent"
                     xmin="-149225.70420389052" ymin="6661356.208762923" xmax="43242.73301825692" ymax="6800930.222411709">
            <esri:SpatialReference wkid="102100"/>
        </esri:Extent>
        <esri:Extent id="DCExtent"
                     xmin="-8600149.1564566" ymin="4687554.362114532" xmax="-8552032.047151148" ymax="4722447.865526669">
            <esri:SpatialReference wkid="102100"/>
        </esri:Extent>
    </fx:Declarations>
    <esri:Map id="map"
              extent="{londonExtent}"
              panEnd="map1_panEndHandler(event)"
              wrapAround180="true">
        <esri:ArcGISTiledMapServiceLayer id="lyr"
                                         load="arcgistiledmapservicelayer1_loadHandler(event)"
                                         url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
    </esri:Map>
</s:Application>
0 Kudos