原创arcgis server flex 实现在地图上绘制折线图,效果图:
代码:利用arcgis的infosysbol 用LineChart来渲染,数据从Graphic的attributes来进行传递
<?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:esri="http://www.esri.com/2008/ags" pageTitle="infosymbol" creationComplete="application1_creationCompleteHandler(event)" xmlns:mx="library://ns.adobe.com/flex/mx"> <fx:Style> .RightStyle { borderThickness: 1; info-placement:center; borderColor: #000005; backgroundColor: #ffffff; paddingLeft: 5; paddingRight: 5; paddingTop: 5; paddingBottom: 5; border-alpha:0; background-alpha:0; } </fx:Style> <fx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.geometry.MapPoint; import com.esri.ags.utils.WebMercatorUtil; import mx.collections.ArrayCollection; import mx.events.FlexEvent; [Bindable] private var valueAC:ArrayCollection = new ArrayCollection( [ { hour: "1", value: 1500 }, { hour: "2", value: 200 }, { hour: "3", value: 500 }, { hour: "4", value: 1200 }, { hour: "5", value: 575 } ]); [Bindable] private var valueAC2:ArrayCollection = new ArrayCollection( [ { hour: "1", value: 1000 }, { hour: "2", value: 500 }, { hour: "3", value: 700 }, { hour: "4", value: 1200 }, { hour: "5", value: 300 } ]); protected function application1_creationCompleteHandler(event:FlexEvent):void { map.extent=WebMercatorUtil.geographicToWebMercator(extent) as Extent; darwPointPloygon(); } private function darwPointPloygon():void { var point:XML; for each(point in points) { var mp:MapPoint=WebMercatorUtil.geographicToWebMercator(new MapPoint(point.@x,point.@y)) as MapPoint; var myAttributes:Object = {}; myAttributes.text=point.@text; myAttributes.datap=valueAC; if(point.@text=="point2" || point.@text=="point4"){ myAttributes.datap=valueAC2; } var infosys:InfoSymbol=new InfoSymbol(); infosys.containerStyleName="RightStyle"; infosys.infoRenderer=myInfoSymbol.infoRenderer; var g:Graphic = new Graphic(mp, infosys, myAttributes); infoPointglayer.add(g); } } ]]> </fx:Script> <fx:Declarations> <fx:XMLList id="points"> <point text="point1" x="118" y="26" /> <point text="point2" x="116" y="30" /> <point text="point3" x="113" y="25" /> <point text="point4" x="105" y="22" /> </fx:XMLList> <esri:InfoSymbol id="myInfoSymbol"> <esri:infoRenderer> <fx:Component> <s:DataRenderer> <mx:LineChart id="linechart" height="100" width="100" paddingLeft="5" paddingRight="5" showDataTips="true" dataProvider="{data.datap}"> <!--categoryField:横坐标数据节点--> <mx:horizontalAxis> <mx:CategoryAxis id="h1" categoryField="hour" /> </mx:horizontalAxis> <!--yField:纵坐标数据节点--> <mx:series> <!--纵坐标轴1--> <mx:LineSeries id="cs1" horizontalAxis="{h1}" form="curve" yField="value" displayName="时间(h)/降水量(MM)"> <mx:lineStroke> <mx:SolidColorStroke id = "s2" color="blue" weight="2"/> </mx:lineStroke> </mx:LineSeries> </mx:series> </mx:LineChart> </s:DataRenderer> </fx:Component> </esri:infoRenderer> </esri:InfoSymbol> <esri:Extent id="extent" xmin="27.25" ymin="59.01" xmax="174.38" ymax="-2.07"> <esri:SpatialReference wkid="4326"/> </esri:Extent> </fx:Declarations> <esri:Map id="map" level="4"> <esri:ArcGISTiledMapServiceLayer url="http://cache1.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineStreetColor/MapServer"/> <esri:GraphicsLayer id="infoPointglayer" /> </esri:Map> </s:Application>
相关推荐
本教程将深入讲解如何利用ArcGIS for Flex在地图上显示柱状图、饼状图和折线图,以便于用户更直观地理解地理数据。 首先,我们需要了解ArcGIS for Flex的基本概念。ArcGIS for Flex是一个基于Adobe Flex的开发库,...
Graphics对象是用于绘制和操作地图上的几何图形的关键对象,包括矩形范围(Extent)、点(MapPoint)、多点(Multipoints)、多边形(Polygon)、折线(Polyline)、信息符号(InfoSymbol)、文本符号(TextSymbol)...
在GIS(地理信息系统)领域,ArcGIS是一款广泛使用的软件,其Flex版本则提供了在Web上进行地图服务和地理处理的功能。本资源汇总聚焦于GrcGIS Flex中的图表应用,主要涉及ActionScript编程语言。ActionScript是Adobe...
### ArcGIS API for Flex 3.6类关系图解析 #### 概述 在地理信息系统(GIS)领域,Esri的ArcGIS平台以其强大的空间数据分析功能而闻名。ArcGIS API for Flex 3.6提供了丰富的类库来支持地图操作、空间分析等功能。...
### 打造精彩纷呈的WebGIS应用:深入解析ArcGIS API for Flex #### ArcGIS API for Flex简介 ArcGIS API for Flex 是一款强大的工具,它由Esri提供,旨在帮助开发者构建高度交互且功能丰富的地理信息系统(GIS)...