silverlight调用Geometry服务实现缓冲区
来源:互联网 发布:js防水涂料施工图集 编辑:程序博客网 时间:2024/05/16 07:25
Geometry服务发布:
前端代码:
<UserControl x:Class="SilverlightApplication5.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:esri="http://schemas.esri.com/arcgis/client/2009" 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:PictureMarkerSymbol x:Key="DefaultClickSymbol" OffsetX="11" OffsetY="39" Source="/car-red-16x16.png" /> <esri:SimpleFillSymbol x:Key="DefaultBufferSymbol" Fill="#660000FF" BorderBrush="Blue" BorderThickness="2" /> </Grid.Resources> <esri:Map Name="MyMap" MouseClick="Buffer_MouseClick" Extent="-122.5009,37.741,-122.3721,37.8089"> <esri:ArcGISTiledMapServiceLayer ID="ESRIMap" Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/> <esri:GraphicsLayer ID="MyGraphicsLayer"> </esri:GraphicsLayer> </esri:Map> <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,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="InformationTextBlock" Text="Click on map to set a location. A buffer of 5 miles will be displayed." Width="200" TextAlignment="Left" Margin="30,20,25,30" TextWrapping="Wrap" /> </Grid> </Grid></UserControl>
后台代码:
private void ArcGISDynamicMapServiceLayer_InitializationFailed(object sender, EventArgs e) { Layer layer = sender as Layer; MessageBox.Show(layer.InitializationFailure.Message); } private void Buffer_MouseClick(object sender, 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); GeometryService geometryService = new GeometryService("http://localhost/arcgis/rest/services/Geometry/GeometryServer"); geometryService.BufferCompleted += new EventHandler<GraphicsEventArgs>(geometryService_BufferCompleted); geometryService.Failed += new EventHandler<TaskFailedEventArgs>(geometryService_Failed); BufferParameters bufferParams = new BufferParameters() { Unit=LinearUnit.StatuteMile, BufferSpatialReference=new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326), OutSpatialReference=MyMap.SpatialReference }; bufferParams.Features.Add(graphic); bufferParams.Distances.Add(1); geometryService.BufferAsync(bufferParams); } void geometryService_Failed(object sender, TaskFailedEventArgs e) { MessageBox.Show("Geometry ServiceException error:"+e.Error); } void geometryService_BufferCompleted(object sender, GraphicsEventArgs e) { IList<Graphic> result = e.Results; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; foreach (Graphic graphic in result) { graphic.Symbol = LayoutRoot.Resources["DefaultBufferSymbol"] as Symbol; graphicsLayer.Graphics.Add(graphic); } }
结果:
- silverlight调用Geometry服务实现缓冲区
- silverlight调用GP服务实现缓冲区
- arcgis api for silverlight开发系列之六:缓冲区分析实现及Geometry service服务发布
- Silverlight调用WCF服务
- silverlight 调用天气服务
- silverlight中调用wcf服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- Silverlight同步(Synchronous)调用WCF服务
- 获取iOS系统版本 --- UIDevice的使用
- MYSQL解压版配置详解
- Cassandra数据分布和副本
- PHP安全设置
- 序列化泛型 反序列化JSON
- silverlight调用Geometry服务实现缓冲区
- Jsp与servlet的区别
- Camel blueprint + karaf 企业总线架构
- 抗1,倘若生活不顺天意,我死你们活
- jbpm流程设计之fork、join
- 利用反射将Datatable、SqlDataReader转换成List模型
- Windows server 2008 PHP环境搭建
- Serv-u安全设置
- android编译环境搭建的问题