目的:

在地图上点击一个点生成一个缓冲区。

1、制作GP工具:

GP工具制作按照http://help.arcgis.com/zh-cn/arcgisdesktop/10.0/help/index.html#//002v00000014000000来做。

2、发布GP工具:

3、分析GP服务:

将发布的GP服务地址在浏览器中输入:http://wade-pc/arcgis/rest/services/BufferService/GPServer/Buffer%20Points

4、在Silverlight中使用GP服务:

前台代码:

<UserControl xmlns:esri="http://schemas.esri.com/arcgis/client/2009" x:Class="GPServiceTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<!--输入点样式-->
<esri:SimpleMarkerSymbol x:Key="DefaultClickSymbol" Size="5" Color="Red"/>
<!--缓冲区样式-->
<esri:SimpleFillSymbol x:Key="DefaultBufferSymbol" Fill="#660000FF" BorderBrush="Blue" BorderThickness="2" />
</Grid.Resources>

<esri:Map x:Name="MyMap" Background="White"
MouseClick="MyMap_MouseClick" >
<!--底图-->
<esri:ArcGISDynamicMapServiceLayer ID="main"
Url="http://www.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineStreetWarm/MapServer"/>
<!--存放输入点-->
<esri:GraphicsLayer ID="MyGraphicsLayer">
</esri:GraphicsLayer>
</esri:Map>

<Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" >
<Rectangle Fill="#77919191" Stroke="Gray" RadiusX="10" RadiusY="10" Margin="0,0,0,5" >
<Rectangle.Effect>
<DropShadowEffect/>
</Rectangle.Effect>
</Rectangle>
<Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
<TextBlock x:Name="InformationText" Text="Click on map to set a location. A buffer of 1000 meters will be displayed."
Width="200" Margin="30,20,30,25" HorizontalAlignment="Left" TextWrapping="Wrap" />
</Grid>
</Grid>
</UserControl>

后台代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client.Tasks;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Symbols;

namespace GPServiceTest
{
public partial class MainPage : UserControl
{
Geoprocessor _geoprocessorTask;
public MainPage()
{
InitializeComponent();
_geoprocessorTask = new Geoprocessor("http://wade-pc/arcgis/rest/services/BufferService/GPServer/Buffer%20Points");
_geoprocessorTask.JobCompleted += new EventHandler<JobInfoEventArgs>(_geoprocessorTask_JobCompleted);
_geoprocessorTask.GetResultDataCompleted += new EventHandler<GPParameterEventArgs>(_geoprocessorTask_GetResultDataCompleted);
_geoprocessorTask.Failed += new EventHandler<TaskFailedEventArgs>(_geoprocessorTask_Failed);
}

void _geoprocessorTask_Failed(object sender, TaskFailedEventArgs e)
{//分析失败
MessageBox.Show("失败");
}

void _geoprocessorTask_GetResultDataCompleted(object sender, GPParameterEventArgs e)
{
//将分析结果显示在地图上
GraphicsLayer graphicsLayer = new GraphicsLayer();
GPFeatureRecordSetLayer featureSetLayer = e.Parameter as GPFeatureRecordSetLayer;
foreach (Graphic graphic in featureSetLayer.FeatureSet.Features)
{
graphic.Symbol = LayoutRoot.Resources["DefaultBufferSymbol"] as Symbol;
graphicsLayer.Graphics.Add(graphic);
}
MyMap.Layers.Add(graphicsLayer);
}

void _geoprocessorTask_JobCompleted(object sender, JobInfoEventArgs e)
{
if (e.JobInfo.JobStatus == esriJobStatus.esriJobFailed)
{
MessageBox.Show("服务请求失败:" + e.JobInfo.Messages.ToString());
}
else
{
_geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "OutputPolygons");//异步获取分析结果
}
}

private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
{//鼠标点击
//清除存放点击点的图层
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
//获取点击的点 并添加到地图中
e.MapPoint.SpatialReference = MyMap.SpatialReference;
Graphic graphic = new Graphic()
{
Geometry = e.MapPoint,
Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as Symbol
};
graphic.SetZIndex(1);
graphicsLayer.Graphics.Add(graphic);
//分析
List<GPParameter> parameters = new List<GPParameter>();
parameters.Add(new GPFeatureRecordSetLayer("Input_Features", e.MapPoint));//设置输入参数
parameters.Add(new GPLinearUnit("Distance", esriUnits.esriMeters, 10000));//设置缓冲半径
_geoprocessorTask.SubmitJobAsync(parameters);//提交异步分析
}
}
}

5、结果展示:

Silverlight调用GP工具实现缓冲分析的更多相关文章

  1. ArcGIS API for Silverlight 调用GP服务准备---GP模型建立、发布、测试

    原文:ArcGIS API for Silverlight 调用GP服务准备---GP模型建立.发布.测试 第一篇.GP降雨量等值线建模.发布及测试 在水利.气象等行业中,要在WebGIS中实现空间分 ...

  2. ArcGIS API for Silverlight 调用GP服务加载等值线图层

    原文:ArcGIS API for Silverlight 调用GP服务加载等值线图层 第二篇.Silverlight客户端调用GP服务 利用ArcGIS API for Silverlight实现G ...

  3. AE调用GP工具的方法(转)

    第一,首先要明确自己需要调用arctoolbox里面的什么工具,实现什么样的功能. 第二,按照需求看看在arctoolbox工具中是怎么实现功能的,然后确定需要的数据源. 第三,编写command或t ...

  4. ArcGIS API for Silverlight 调用GP服务绘制等值面

    原文:ArcGIS API for Silverlight 调用GP服务绘制等值面 GP服务模型如下图: 示例效果图片如下:

  5. 利用C#与AE调用GP工具

    转自原文 利用C#与AE调用GP工具 第一,首先要明确自己需要调用arctoolbox里面的什么工具,实现什么样的功能. 第三,编写command或tool工具,编写自己要的功能工具. 1)首先创建一 ...

  6. AE调用GP工具(创建缓冲区和相交为例)

    引用 Geoprocessing是ArcGIS提供的一个非常实用的工具,借由Geoprocessing工具可以方便的调用ArcToolBox中提供的各类工具,本文在ArcEngine9.2平台环境下总 ...

  7. c# 调用ArcEngine的GP工具

    转自原文c# 调用ArcEngine的GP工具,AE调用GP工具 IAoInitialize m_AoInitialize = new AoInitializeClass(); esriLicense ...

  8. ArcGIS API for Silverlight 使用GP服务实现要素裁剪功能

    原文:ArcGIS API for Silverlight 使用GP服务实现要素裁剪功能 昨天一QQ好友问了一个关于裁剪的问题,感觉自己也没有帮上什么忙,之后自己做了一个裁剪的例子,不过在做这个例子的 ...

  9. AE开发实现GP工具IDW

    IDW——空间插值 IDW(Inverse Distance Weighted)是一种常用而简便的空间插值方法,它以插值点与样本点间的距离为权重进行加权平均,离插值点越近的样本点赋予的权重越大. 设平 ...

随机推荐

  1. python_18(Django基础)

    第1章 web框架的本质 1.1 socket 1.2 空格后面是主体内容 1.3 HTTP协议 1.3.1 响应流程 1.4 HTTP请求方法 1.5 HTTP工作原理 1.6 URL 1.7 HT ...

  2. 通用全局CSS样式

    PC全局样式 *{padding:0;margin:0;} div,dl,dt,dd,form,h1,h2,h3,h4,h5,h6,img,ol,ul,li,table,th,td,p,span,a{ ...

  3. 開玩樹莓派(一):安裝Raspbian系統

    目錄: 開玩樹莓派(一):安裝Raspbian系統 開玩樹莓派(二):配置IP,實現無顯示器局域網內Putty連接和RDP遠程 開玩樹莓派(三):Python編程 開玩樹莓派(四):GPIO控制和遠程 ...

  4. [Luogu1343]地震逃生 最大流

    题目链接:https://www.luogu.org/problem/show?pid=1343 dinic跑最大流. #include<cstdio> #include<cstri ...

  5. Eclipse-运行符-数据类型转换-环境变量配置

    1.能够使用Eclipse快捷键 ctrl + /   单行注释:再按一次则取消: ctrl + shift + /  多行注释:  ctrl + shift + \  取消多行注释: ctrl + ...

  6. nconf修改密码

    修改nconf登录界面密码 [root@Cnyunwei config]# vi .file_accounts.php <?php/*## User/Password file for simp ...

  7. Oracle Flashback Technology【闪回技术】

    -------------------------与其他数据库相比,Oracle的闪回让开发者多了一条选择的路. Flashback的目的 先看下Oracle官方文档中的解释: Oracle Flas ...

  8. log explorer使用的几个问题[转载]

    1)对数据库做了完全 差异 和日志备份备份时选用了删除事务日志中不活动的条目再用Log explorer打试图看日志时提示No log recorders found that match the f ...

  9. iOS上架问题解决

    dns问题 http://iphone.91.com/tutorial/syjc/140509/21686339.html 网络问题 手机4g开wifi,上传提交多次 时间问题 东八区下午6点上架成功 ...

  10. Maven添加本地依赖

    在写本文的时候先来说明一下maven依赖的各种范围的意思 compile(编译范围)       compile 是默认的范围:如果没有提供一个范围,那该依赖的范围就是编译范围.编译范围依赖在所有的c ...