关于supermap api for Flex 中FeaturesLayer的clear方法连续执行
发布时间:2020-12-15 05:07:56 所属栏目:百科 来源:网络整理
导读:首先来看下报错信息: TypeError: Error #1009: 无法访问空对象引用的属性或方法。at Hashtable/http://www.supermap.com/iclient/2010/internal::add()[E:SuperMapiClient60 1_SourceCodebranchesFlex_610_8129_BiClientFlexLib6Rsrccomsupermapwe
首先来看下报错信息: TypeError: Error #1009: 无法访问空对象引用的属性或方法。 at Hashtable/http://www.supermap.com/iclient/2010/internal::add()[E:SuperMapiClient60 1_SourceCodebranchesFlex_610_8129_BiClientFlexLib6RsrccomsupermapwebmappingHashtable.as:56] at com.supermap.web.mapping::FeaturesLayer/addHashTableIDs()[E:SuperMapiClient60 1_SourceCodebranchesFlex_610_8129_BiClientFlexLib6RsrccomsupermapwebmappingFeaturesLayer.as:683] at com.supermap.web.mapping::FeaturesLayer/collectionAddHandler()[E:SuperMapiClient60 1_SourceCodebranchesFlex_610_8129_BiClientFlexLib6RsrccomsupermapwebmappingFeaturesLayer.as:594] at com.supermap.web.mapping::FeaturesLayer/collectionChangeHandler()[E:SuperMapiClient60 1_SourceCodebranchesFlex_610_8129_BiClientFlexLib6RsrccomsupermapwebmappingFeaturesLayer.as:549] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.collections::ListCollectionView/dispatchEvent()[E:dev4.xframeworksprojectsframeworksrcmxcollectionsListCollectionView.as:1024] at mx.collections::ListCollectionView/addItemsToView()[E:dev4.xframeworksprojectsframeworksrcmxcollectionsListCollectionView.as:1137] at mx.collections::ListCollectionView/listChangeHandler()[E:dev4.xframeworksprojectsframeworksrcmxcollectionsListCollectionView.as:1284] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.collections::ArrayList/internalDispatchEvent()[E:dev4.xframeworksprojectsframeworksrcmxcollectionsArrayList.as:673] at mx.collections::ArrayList/addItemAt()[E:dev4.xframeworksprojectsframeworksrcmxcollectionsArrayList.as:394] at mx.collections::ListCollectionView/addItemAt()[E:dev4.xframeworksprojectsframeworksrcmxcollectionsListCollectionView.as:596] at mx.collections::ListCollectionView/addItem()[E:dev4.xframeworksprojectsframeworksrcmxcollectionsListCollectionView.as:560] at com.supermap.web.mapping::FeaturesLayer/addFeature()[E:SuperMapiClient60 1_SourceCodebranchesFlex_610_8129_BiClientFlexLib6RsrccomsupermapwebmappingFeaturesLayer.as:889] at Test/add()[D:ObjectObj8.6FlexTestsrcTest.mxml:61] at Function/Test/protected:application1_creationCompleteHandler/a()[D:ObjectObj8.6FlexTestsrcTest.mxml:42] at flash.utils::Timer/_timerDispatch() at flash.utils::Timer/tick() 测试代码: <?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:ic="http://www.supermap.com/iclient/2010" xmlns:is="http://www.supermap.com/iserverjava/2010" width="100%" height="100%" pageTitle="点样式示例" creationComplete="application1_creationCompleteHandler(event)"> <!--点要素样式--> <fx:Declarations> <!--定义点要素的默认显示样式--> <!--样式1--> <s:ArrayCollection id="alist"> <fx:Object LGTD="113.224" LTTD="22.34" STNM="123" STCD="1"/> <fx:Object LGTD="113.234" LTTD="22.34" STNM="123" STCD="1"/> <fx:Object LGTD="113.124" LTTD="22.34" STNM="123" STCD="1"/> </s:ArrayCollection> </fx:Declarations> <fx:Script> <![CDATA[ import com.supermap.web.core.Feature; import com.supermap.web.core.Point2D; import com.supermap.web.core.geometry.GeoPoint; import com.supermap.web.mapping.FeaturesLayer; import mx.controls.Alert; import mx.events.FlexEvent; public var fl:FeaturesLayer=new FeaturesLayer(); protected function application1_creationCompleteHandler(event:FlexEvent):void { map.addLayer(fl); var i:int=0; var ti:Timer=new Timer(100); ti.addEventListener(TimerEvent.TIMER,a); function a(e:TimerEvent):void{ add(alist); //Alert.show("a"); i=i+1; mess.text=i.toString(); } ti.start(); } private function add(list:ArrayCollection):void{ fl.clear(); if(list && list.length>0) { for(var i:int=0;i<list.length;i++) { var p:GeoPoint=new GeoPoint(list[i].LGTD,list[i].LTTD); var f:Feature=new Feature(p); fl.addFeature(f); } } } ]]> </fx:Script> <!--加载地图--> <ic:Map id="map" scales="{[3.35e-7,6.7e-7,1.34e-6,2.68e-6,5.36e-6,1.07e-5]}"> <is:TiledDynamicRESTLayer url="http://localhost:8090/iserver/services/map-gd22/rest/maps/gd"/> </ic:Map> <s:Label id="mess"/> </s:Application>理论上来说,上面的代码将永远执行下去不会发生错误,但是当程序执行到167次时,发生报错,而且这个次数随着所添加的点,即alist记录的条数面变化,如果alist.lenght=6,则执行83次后报错,相当诡异!暂时认为是supermap api的问题 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |