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,0" > <Rectangle Fill="#77919191" stroke="Gray" RadiusX="10" RadiusY="10" margin="0,5" > <Rectangle.Effect> <DropShadowEffect/> </Rectangle.Effect> </Rectangle> <Rectangle Fill="#FFFFFFFF" stroke="DarkGray" RadiusX="5" RadiusY="5" margin="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调用Geometry服务实现缓冲区所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)