openscales2.2的CustomMarker.createUrlBasedMarker直接报错,使用CustomMarker.createDisplayObjectMarker只能map1.addElement(s); 一次,第二次就报错,彻底晕了,暂时记下,看有无更好解决方法:
这个是CustomMarker.createDisplayObjectMarker添加一个元素可以看到效果的:
//添加已知图像
var _markerlayer:VectorLayer =_map.getLayerByIdentifier("worklayer") as VectorLayer;if(_markerlayer==null){Alert.show("没有找到目标图层");return;}
//
var s:spark.components.Image=new spark.components.Image();
//s.source="http://localhost:8080/dbserver/6_1.png";
s.source="assets/2_24x24.png";
map1.addElement(s);
//
var lox:Location=new Location(114.156915973307,35.726901271851,_map.projection);
var marker:CustomMarker=CustomMarker.createDisplayObjectMarker(s,lox);
_markerlayer.addFeature(marker);
_markerlayer.redraw(true);
这是2个feature也可以看到效果的:
//添加已知图像
var _markerlayer:VectorLayer =_map.getLayerByIdentifier("worklayer") as VectorLayer;
if(_markerlayer==null){Alert.show("没有找到目标图层");return;}
//
var s:spark.components.Image=new spark.components.Image();
//s.source="http://localhost:8080/dbserver/6_1.png";
s.source="assets/2_24x24.png";
//map1.addElement(s);
var lox:Location=new Location(114.156915973307,35.726901271851,_map.projection);
var marker:CustomMarker=CustomMarker.createDisplayObjectMarker(s,lox);
_markerlayer.addFeature(marker);
//
//
var xx1:spark.components.Image=new spark.components.Image();
//s.source="http://localhost:8080/dbserver/6_1.png";
xx1.source="assets/2_24x24.png";
//map1.addElement(xx1);
var lox1:Location=new Location(114.166915973307,35.736901271851,_map.projection);
var marker1:CustomMarker=CustomMarker.createDisplayObjectMarker(xx1,lox1,null,30,30);
//var marker1:CustomMarker=CustomMarker.createUrlBasedMarker("http://localhost:8080/dbserver/6_1.png",lox1);
_markerlayer.addFeature(marker1);
//必须在最后,否则报错!!
map1.addElement(s);
map1.addElement(xx1);
//
_markerlayer.redraw(true);
CustomMarker.createUrlBasedMarker报错内容(跟踪到loadurl,里面乱的很,改了也不行):
TypeError: Error #1009: 无法访问空对象引用的属性或方法。
at org.openscales.core.feature::CustomMarker/loadUrl()[D:\workspace\openscales\target\checkout\openscales-core\src\main\flex\org\openscales\core\feature\CustomMarker.as:97]
at org.openscales.core.feature::CustomMarker$/createUrlBasedMarker()[D:\workspace\openscales\target\checkout\openscales-core\src\main\flex\org\openscales\core\feature\CustomMarker.as:52]
at test_scale/button31_clickHandler()[F:\F\flashgis\test_scale\src\test_scale.mxml:899]
at test_scale/___test_scale_Button37_click()[F:\F\flashgis\test_scale\src\test_scale.mxml:120]