flex+openscales+bingMap轨迹回放

来源:互联网 发布:js 私有变量 编辑:程序博客网 时间:2024/05/16 16:56
因为最近需要开发个轨迹回放的小控件,最初打算用googleearth,回来发现googleearth不支持windows8,而且二次开发接口不丰富。然后又打算用arcglobe,之前用的比较少,花了些时间,然后弄出来了个所谓的“com”控件。但是同事用python无法调用,只好废弃了。同事说python可以直接调用flash,然后考虑用arcgis for flex 调用天地图,写了个图层类,好不容易天地图可以用了,却发现坐标有点偏差。 最后考虑使用openscales,说实话我不喜欢这个gis框架。

 

 

开发环境:

    flexbuilder4.0+4.0sdk+openscales2.2

环境搭建:

    1、新建Flex项目

    2、引用下列openscales swc

        

  核心代码:

    1、创建地图控件

    

<Map id="fxMap" width="100%" height="100%"  creationComplete="fxMap_creationCompleteHandler(event)" resolution="0.1804262234744723" center="102,34" maxExtent="-180,-90,180,90" projection="EPSG:900913"><Bing key="" imagerySet="Aerial" /><KeyBoardHandler id="keyboardHandler" /><DragHandler id="dragHandler" /><WheelHandler id="wheelHandler" /><LayerManager y="10" left="10" visible="false"><rendererOptions><fx:ObjectdisplayZoomToExtent="true" /></rendererOptions> </LayerManager><Zoom id="zoom1" x="{fxMap.width-135}" y="10" visible="false" /><DataOriginatorsDisplay x="10" y="{height-90}" /></Map>

    2、创建标注方法

public function createMarker(x:Number,y:Number):void{    var glayer = new VectorLayer("CarMark");    glayer.projection = "EPSG:4326";    glayer.minResolution = fxMap.map.minResolution;    glayer.maxResolution = fxMap.map.maxResolution;    fxMap.map.addLayer(glayer);    var point:org.openscales.geometry.Point  =      new org.openscales.geometry.Point(x,y);    var markerStyle:Style = new Style();     markerStyle.rules.push(new Rule());     [Embed('assets/icon20.png')]     var picEmbeddedClass:Class;     var mk:DisplayObjectMarker = new DisplayObjectMarker(picEmbeddedClass,-16,-16);     markerStyle.rules[0].symbolizers.push(new PointSymbolizer(mk));     markerStyle.rules[0].symbolizers.push(new TextSymbolizer("name", new  org.openscales.core.style.font.Font(15,0xFFFFFF,0.8,null,null, org.openscales.core.style.font.Font.BOLD)));    var pfeatrue:PointFeature =  new PointFeature(point,{"name":"沪XXX"},markerStyle);    glayer.addFeature(pfeatrue);}

 

开发中遇到的小问题:

    1、以某一点地图居中,因为之前用arcgis for flex比较多,以为centerAt就可以了。但openscales里是没有这个方法。但可以修改center,

      fxMap.center =new  Location(x,y);

    2、移动Marker对象,试了好多方法和属性,貌似openscales没有移动Marker的方法。只好删了再创建。

    

if(pfeatrue!=null){pfeatrue.destroy();glayer.removeFeature(pfeatrue,true);}pfeatrue =  new PointFeature(point,{"name":""},markerStyle);glayer.addFeature(pfeatrue);


 


 

原创粉丝点击