openscales2.2的画点、线、多边形
主要是对WFC加载的图层一些后续的操作(增加特征,与原来1.2的版本有所不同)。
画点:
var pointLayer:VectorLayer = VectorLayer(map.getLayerByIdentifier("pointend_track")) ; var pointmarker:PointFeature = PointFeature.createPointFeature(new Location(123.85680,50.75336)); pointLayer.addFeature( pointmarker);
画线:
//获取WFC加载的地图层 var roadLayer:VectorLayer = VectorLayer(map.getLayerByIdentifier("road")) ; //组装坐标数据 var array:Vector.<Number> = new Vector.<Number>(); array.push(Number(104.094413757324),Number(30.7053699493408)); array.push(Number(104.081871032715),Number(30.6603736877441)); array.push(Number(104.110618591309),Number(30.640344619751)); array.push(Number(95),Number(33)); //创建线的对象 var lineMark:LineStringFeature = new LineStringFeature(new LineString(array)); //地图层增加线的特征 roadLayer.addFeature(lineMark);
画多边形:
//获取WFC加载的地图层 var roadLayer:VectorLayer = VectorLayer(map.getLayerByIdentifier("road")) ; //组装坐标数据 var pablepoints:Vector.<Number> = new Vector.<Number>(); pablepoints.push( Number(89),Number(38)); pablepoints.push( Number(91),Number(38)); pablepoints.push( Number(91),Number(35)); pablepoints.push( Number(87),Number(34)); pablepoints.push( Number(89),Number(38)); var pableLinearRing:Vector.<Geometry> = new Vector.<Geometry>(); pableLinearRing.push(new LinearRing(pablepoints)); //样式设置 var style:Style=new Style(); style.rules[0]=new Rule(); style.rules[0].symbolizers.push(new PolygonSymbolizer(new SolidFill(0x99D0F2,0.5), null)); //创建多边形的对象 var mappable:PolygonFeature = new PolygonFeature(new Polygon(pableLinearRing),null,style); //地图层增加线的特征 roadLayer.addFeature(mappable);