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()
<?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>
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; } }
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.