arcgis api for flex 开发入门(八)GP服务的使用
发布时间:2020-12-15 04:18:28 所属栏目:百科 来源:网络整理
导读:在arcgis api for flex中esri还为我们提供了GP服务,在ARCGISONLINE 上的gp 服务有CreateDriveTimePolygons和Viewshed,下面我们以 CreateDriveTimePolygons服务为例来看看在arcgis api for flex中如何使用GP 服务。 首先使用? ? esri:Geoprocessor 标签创建
在arcgis api for flex中esri还为我们提供了GP服务,在ARCGISONLINE 上的gp
服务有CreateDriveTimePolygons和Viewshed,下面我们以 CreateDriveTimePolygons服务为例来看看在arcgis api for flex中如何使用GP 服务。 首先使用? ? <esri:Geoprocessor >标签创建一个gp服务,url指向提供gp服务的 地址。 <esri:Geoprocessor? ?? ???id="gp"? ?? ??? url=" http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network /ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons"? ?? ???/> 剩下的步骤和上一讲Geometry service的使用基本相同,即设置参数,调用gp服 务,得到结果,表现结果。 完整代码:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" pageTitle="Service Area" xmlns:esri="http://www.esri.com/2008/ags" layout="absolute" > <mx:Script> <![CDATA[ // Synopsis: // The map has a click event that calls computeServiceArea (event) when you click the map // <esri:Map click="computeServiceArea(event)"> // The computeServiceArea function sends a request to a GP task to create the geometries for the different drive times // The return drivetime features are used as the graphicProvider for a graphics layer. // graphicsLayer.graphicProvider = fs.features; // The graphics layer is using a symbolFunction which will symbolize the drivetimes in different colors // <esri:GraphicsLayer id="graphicsLayer" symbolFunction="fillFunc"/> // The fillFunc() is using the "ToBreak" attributes,which the GP task returned,to set different symbols on different drive times. import com.esri.ags.Graphic; import com.esri.ags.symbol.Symbol; import com.esri.ags.tasks.ExecuteResult; import com.esri.ags.tasks.FeatureSet; import com.esri.ags.tasks.ParameterValue; import com.esri.ags.geometry.MapPoint; import com.esri.ags.geometry.Geometry; import mx.controls.Alert; import mx.rpc.AsyncResponder; import mx.utils.ObjectUtil; private var driveTimes:String = "1 2 3"; private function computeServiceArea( event : MouseEvent ) : void { graphicsLayer.clear(); var mapPoint : MapPoint = myMap.toMapFromStage (event.stageX,event.stageY); var graphic : Graphic = new Graphic(mapPoint,sms_circleAlphaSizeOutline); graphicsLayer.add(graphic); var featureSet:FeatureSet = new FeatureSet([graphic]); var params:Object = { "Input_Location" : featureSet,"Drive_Times" : driveTimes }; gp.execute(params,new AsyncResponder( onResult,onFault )); function onResult( gpResult : ExecuteResult,token : Object = null ) : void { var pv : ParameterValue = gpResult.parameterValues [0]; var fs : FeatureSet = pv.value as FeatureSet; graphicsLayer.graphicProvider = fs.features; } function onFault( info : Object,token : Object = null ) : void { Alert.show( info.toString() ); } } private function fillFunc( g : Graphic ) : Symbol { var toBreak : Number = g.attributes.ToBreak; if ( toBreak == 1 ) { return rFill; } if ( toBreak == 2 ) { return gFill; } return bFill; } ]]> </mx:Script> <esri:SimpleMarkerSymbol id="sms_circleAlphaSizeOutline" alpha="0.5" size="15" style="circle"/> <esri:SimpleFillSymbol id="rFill" alpha="0.5" color="0xFF0000"/> <esri:SimpleFillSymbol id="gFill" alpha="0.5" color="0x00FF00"/> <esri:SimpleFillSymbol id="bFill" alpha="0.5" color="0x0000FF"/> <esri:Map id="myMap" click="computeServiceArea(event)" openHandCursorVisible="false"> <esri:extent> <esri:Extent xmin="-95.41" ymin="38.86" xmax="-95.1" ymax="39.06"/> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap _World_2D/MapServer"/> <esri:GraphicsLayer id="graphicsLayer" symbolFunction="fillFunc"/> </esri:Map> <esri:Geoprocessor id="gp" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network /ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons" /> </mx:Application> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- koa 实现 react-view 原理
- 怎么写得更好? Ruby Sequel链接OR
- dynamic_cast vs公开父类中的虚函数(C)
- PostgreSQL:在timestamp上创建一个索引:: DATE
- c – 应该是std :: vector :: swap()与有状态的分
- ruby-on-rails – rails路由控制器动作更改
- NoSQL代表: Mongo DB(芒果数据库)
- Access、Hybrid和Trunk三种模式的理解 .
- Uncaught SyntaxError: missing ) after argumen
- ruby-on-rails – Wicked_pdf和utf8符号
热点阅读