目的:

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

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. arcengine 将地图文件保存为图片(包括各种图片格式)

    1,最近做了个地图文件输出图片的功能,思想主要就是利用MapControl的ActiveView中的out方法: 2代码如下:欢迎交流指正 SaveFileDialog m_save = new Sa ...

  2. (wp8.1开发)添加数据(SQLite)库到app

    wp8.1只支持SQLite. 如何添加SQLite支持请看这里 我这里要说的是如何添加自己的数据库 1.添加数据库到项目中 2.右击选择属性 3.将生成操作改成内容 4.直接就可以引用数据库文件了

  3. 状态模式和php实现

    状态模式: 允许一个对象在其内部状态改变时改变它的行为,对象看起来似乎修改了它的类.其别名为状态对象(Objects for States),状态模式是一种对象行为型模式. 模式分析: 在很多情况下, ...

  4. hihocoder1776 序列

    思路: 考虑从左至右依次向每个位置放置数字,对于第i个位置,以i为结尾的i个前缀和模P是不能相等的(因为不存在和为P的倍数的子串),所以第i个位置只能放置P - i个不同的数字.则答案就是(P - 1 ...

  5. [POJ1185][NOI2001]炮兵阵地 状压DP

    题目链接:http://poj.org/problem?id=1185 很裸的状压,考虑对于一行用二进制储存每一种的状态,但是状态太多了做不了. 观察到有很多状态都是不合法的,于是我们预处理出合法的状 ...

  6. Sunday算法模板

    Sunday是一个线性字符串模式匹配算法.算法的概念如下: Sunday算法是Daniel M.Sunday于1990年提出的一种字符串模式匹配算法.其核心思想是:在匹配过程中,模式串并不被要求一定要 ...

  7. sizeof()用法汇总 zhuan

    sizeof()功能:计算数据空间的字节数1.与strlen()比较      strlen()计算字符数组的字符数,以"\0"为结束判断,不计算为'\0'的数组元素.       ...

  8. Android自定义view之仿微信录制视频按钮

    本文章只写了个类似微信的录制视频的按钮,效果图如下:             一.主要的功能: 1.长按显示进度条,单击事件,录制完成回调 2.最大时间和最小时间控制 3.进度条宽度,颜色设置 二.实 ...

  9. python基础一 day10(2)

    复习: # 三元运算符# 接收结果的变量 = 条件为真的结果 if 条件 else 条件为假的结果# 接收结果的变量 = “真结果” if 条件 else “假结果”## 命名空间 和 作用域# 三种 ...

  10. python 实例方法,类方法,静态方法,普通函数

    python中有实例方法,类方法,静态方法,普通函数 类方法需要@ classmethod 修饰并且有个隐藏参数 cls,实例方法必须有个参数 self, 静态方法必须有 @staticmethod修 ...