arcgis api for flex 开发入门(八)GP服务的使用
2013-06-05 22:17
761 查看
在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服
务,得到结果,表现结果。
完整代码:
服务有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>
相关文章推荐
- arcgis api for flex 开发入门(八)GP服务的使用
- arcgis api for flex 开发入门(八)GP服务的使用
- ArcGIS API for Silverlight开发入门(8):在程序中使用Virtual Earth的服务
- arcgis api for flex 开发入门(七)Geometry service 的使用<转>
- arcgis api for flex 开发入门(七)Geometry service 的使用
- arcgis api for flex 开发入门(九)webservices 的使用<转>
- arcgis api for flex 开发入门(九)webservices 的使用
- arcgis api for flex 开发入门(九)webservices 的使用
- ArcGIS API for javascript开发笔记(五)——GP服务调用之GP模型的发布及使用详解
- ArcGIS API for Silverlight开发入门(8):在程序中使用Virtual Earth的服务
- ArcGIS API for javascript开发笔记(五)——GP服务调用之GP模型的发布及使用详解
- arcgis api for flex 开发入门(四)Darw控件的使用
- 使用ArcGIS GP服务遇到的问题,原因以及解决方法 - 客户端API开发(Javascript/Flex/Silverlig 转载
- ArcGIS API for Silverlight开发入门(8):在程序中使用Virtual Earth的服务<转>
- arcgis api for flex 开发入门(三)地图浏览控件的使用
- ArcGIS API for Silverlight开发入门(8):在程序中使用Virtual Earth的服务
- arcgis api for flex 开发入门(三)地图浏览控件的使用
- ArcGIS API for Silverlight开发入门(8):在程序中使用Virtual Earth的服务
- arcgis api for flex 开发入门(四)Darw控件的使用
- arcgis api for flex 开发入门(四)Darw控件的使用