Select to view content in your preferred language

Clearing map lods (Flex beta 2.0)

1961
7
06-08-2010 08:10 AM
DarcyDechene
New Contributor
Hi,

I�??m trying to toggle between a dynamic map (with no lods) and a tiled map service (with lods) then back again. Going from the dynamic to tile map service is fine, however after going back and clearing the map lods (map.lods = null) I get exceptions when panning/zomming:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
 at com.esri.ags.components::Navigation/map_extentChangeHandler()
 at flash.events::EventDispatcher/dispatchEventFunction()
 at flash.events::EventDispatcher/dispatchEvent()
 at mx.core::UIComponent/dispatchEvent()
 at com.esri.ags::Map/tweenEndHandler()
 at flash.events::EventDispatcher/dispatchEventFunction()
 at flash.events::EventDispatcher/dispatchEvent()
 at MoveResize/enterFrameHandler()


This �??feature�?� worked with the Flex 1.x API, so is there another way to do this in the Flex 2.x API or will this simply no longer work. I have attached a Flex 1.x example and a Flex 2.x example.

Any ideas how this can be done in Flex 2.x beta?

Thanks,
Darcy
0 Kudos
7 Replies
by Anonymous User
Not applicable
Original User: dpaddock

Thanks for this bug report and test case.

To workaround this issue, you can set the map.level after setting the map.lods.

e.g.

map.lods = base.tileInfo.lods;
map.level = 0;
0 Kudos
DarcyDechene
New Contributor
I just tried this with the final Flex 2.0 API (2010-06-25), and I still have the problem.

The workaround does not help as the problems start when you set the map.lods to null.

map.lods = null;
map.level = 0;
0 Kudos
by Anonymous User
Not applicable
Original User: dpaddock

This issue was not resolved in 2.0 final.

If you set the lods to null, you can't set the level. You can set the scale instead.
0 Kudos
WilliamRidgeway
Emerging Contributor
Hello,  I am also encountering this error with the same problem.  Can somebody post the workaround.  Even if I set the map.scale property (which I may not be doing correctly), I still continue to get the error.  Thanks.

-Jason
0 Kudos
by Anonymous User
Not applicable
Original User: odoe

Has anyone found a clean way to dynamically switch the Nav from LODS to dynamic and back?

protected static const SCALE:Number = 1128.497176;
protected var lods:Array;
protected function onMapExtentChange_handler(event:ExtentEvent):void {
 trace(map.scale);
 trace(map.level);
 if (map.level == 19) {
  lods = map.lods;
  map.lods = null; // tried map.lods = [], get same error
  map.scale = SCALE; // tried setting scale manually here
  trace(map.scale);
 }
 else if (map.level < 0 && map.scale >= SCALE) {
  map.lods = lods;
 }
}


I get the same null object error.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
 at com.esri.ags.components::Navigation/map_extentChangeHandler()
 at flash.events::EventDispatcher/dispatchEventFunction()
 at flash.events::EventDispatcher/dispatchEvent()
 at mx.core::UIComponent/dispatchEvent()
 at com.esri.ags::Map/tweenEndHandler()
 at flash.events::EventDispatcher/dispatchEventFunction()
 at flash.events::EventDispatcher/dispatchEvent()
 at MoveResize/enterFrameHandler()


Basically, I have a need to turn on a dynamic layer of detailed imagery when the user hits the maximum zoom level and zoom in further, then turn the LOD's back on when the user hits the scale equal to the Tiled layers maximum zoom level and turn the detailed imagery off. I don't want to add LOD's.

Has anyone come up with a clean solution to this?

man, that map_extentChangeHandler() seems to be a private function. Trying esri_internal to see if I can trick it, but no go.
0 Kudos
ReneRubalcava
Honored Contributor
Has anyone been able to find a work around for this. The main complaint I am getting from users is the inability to zoom in further than they can now, especially because this functionality worked in the 1.3 API.

Do I need to completely remove my tiled services from the project to do this? It used to be that I could disable the map.lods, turn off tiled services and zoom in on the map as far as I wanted. Now I can't do that. Any help would be appreciated here, or how can we file this as a bug?
0 Kudos
by Anonymous User
Not applicable
Original User: dpaddock

This should be fixed in the next release. As a work-around, try creating a new Navigation component when you do the switch. Here's a sample. (zoomSliderVisible is set to false on the map.)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                xmlns:esri="http://www.esri.com/2008/ags"
                layout="absolute">

    <mx:Script>
        <![CDATA[
            import com.esri.ags.components.Navigation;

            import mx.events.FlexEvent;

            private var navigation:Navigation;

            private function toggleBase():void
            {
                if (tiledLyr.visible)
                {
                    // switch to dynamic layer
                    tiledLyr.visible = false;
                    dynamicLyr.visible = true;

                    map.lods = null;
                    map.scale = 100000000;
                }
                else
                {
                    // switch to tiled layer
                    tiledLyr.visible = true;
                    dynamicLyr.visible = false;

                    map.lods = tiledLyr.tileInfo.lods;
                    map.scale = 100000000;
                }
                setNavigation();
            }

            private function map_initializeHandler(event:FlexEvent):void
            {
                setNavigation();
            }

            private function setNavigation():void
            {
                if (navigation)
                {
                    navigation.map = null;
                    map.staticLayer.removeElement(navigation);
                }
                navigation = new Navigation();
                navigation.map = map;
                map.staticLayer.addElement(navigation);
            }
        ]]>
    </mx:Script>

    <esri:Map id="map"
              initialize="map_initializeHandler(event)"
              zoomSliderVisible="false">
        <esri:ArcGISTiledMapServiceLayer id="tiledLyr"
                                         url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"
                                         visible="true"/>
        <esri:ArcGISDynamicMapServiceLayer id="dynamicLyr"
                                           url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Petroleum/KGS_OilGasFields_Kansas/MapServer"
                                           visible="false"/>
    </esri:Map>

    <mx:Button right="10" top="10"
               click="toggleBase()"
               label="Toggle"/>

</mx:Application>
0 Kudos