silverlight   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了silverlight调用GP服务实现缓冲区大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

  启发来源于http://blog.csdn.net/qq364981997/article/details/8769388 http://www.cnblogs.com/potential/archive/2012/11/03/2752289.html   写代码之前制作模型,这里使用的是ArcTutor\GP service Examples\BufferPoints。 也可以根据http:

 

启发来源于http://blog.csdn.net/qq364981997/article/details/8769388

http://www.cnblogs.com/potential/archive/2012/11/03/2752289.html

 

代码之前制作模型,这里使用的是ArcTutor\GP service Examples\BufferPoints。

silverlight调用GP服务实现缓冲区

也可以根据http://help.arcgis.com/zh-cn/arcgisdesktop/10.0/help/index.html#//002v00000014000000自己做数据。做完之后测试一下。

前端代码

<UserControl x:Class="GPBuffer.MainPage"
    xmlns="http://scheR_119_11845@as.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://scheR_119_11845@as.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://scheR_119_11845@as.microsoft.com/expression/blend/2008"
    xmlns:esri="http://scheR_119_11845@as.esri.com/arcgis/client/2009"
    xmlns:mc="http://scheR_119_11845@as.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 x:Name="Mymap" BACkground="White"
            MouseClick="Mymap_MouseClick" >
            <esri:ArcGISDynamicMapserviceLayer ID="buffer"
                                               Url="http://localhost/arcgis/rest/services/bufferpoint/MapServer"/>
            <esri:GraphicsLayer ID="MyGraphicsLayer">
            </esri:GraphicsLayer>
        </esri:Map>

        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,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,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>

@H_262_42@  

后台代码

using System;@H_262_42@ using System.Collections.Generic;@H_262_42@ using System.Linq;@H_262_42@ using System.Net;@H_262_42@ using System.Windows;@H_262_42@ using System.Windows.Controls;@H_262_42@ using System.Windows.Documents;@H_262_42@ using System.Windows.Input;@H_262_42@ using System.Windows.Media;@H_262_42@ using System.Windows.Media.Animation;@H_262_42@ using System.Windows.Shapes;

using ESRI.ArcGIs.CLIENt;@H_262_42@ using ESRI.ArcGIs.CLIENt.Tasks;@H_262_42@ using ESRI.ArcGIs.CLIENt.Symbols;

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

        void _geoprocessorTask_Failed(object sender,TaskFailedEventArgs E)@H_262_42@         {@H_262_42@             messageBox.Show("请求服务失败:" + e.Error.ToString());@H_262_42@         }

        void _geoprocessorTask_GetResultDataCompleted(object sender,GPParameterEventArgs E)@H_262_42@         {@H_262_42@             GraphicsLayer graphicsLayer = new GraphicsLayer();@H_262_42@             GPFeatureRecordSetLayer featureSetLayer = e.Parameter as GPFeatureRecordSetLayer;@H_262_42@             foreach (Graphic graphic in featureSetLayer.FeatureSet.Features)@H_262_42@             {@H_262_42@                 graphic.Symbol = LayoutRoot.resources["DefaultBufferSymbol"] as Symbol;@H_262_42@                 graphicsLayer.Graphics.Add(graphic);@H_262_42@             }@H_262_42@             Mymap.Layers.Add(graphicsLayer);@H_262_42@             messageBox.Show("********************");@H_262_42@         }

        void _geoprocessorTask_JobCompleted(object sender,JobInfoEventArgs E)@H_262_42@         {@H_262_42@             if (e.JobInfo.JobStatus == esriJobStatus.esriJobFailed)@H_262_42@             {@H_262_42@                 messageBox.Show("请求服务失败:"+e.JobInfo.messages.ToString());@H_262_42@                 return;@H_262_42@             }@H_262_42@             httpWebrequest.RegisterPrefix("http://",System.Net.Browser.WebRequestCreator.ClientHttp);@H_262_42@             _geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId,"Output_Polygons");@H_262_42@         }@H_262_42@         @H_262_42@         private void Mymap_MouseClick(object sender,ESRI.ArcGIs.CLIENt.Map.MouseEventArgs E)@H_262_42@         {@H_262_42@             GraphicsLayer graphicsLayer = Mymap.Layers["MyGraphicsLayer"] as GraphicsLayer;@H_262_42@             graphicsLayer.ClearGraphics();

            e.MapPoint.SpatialReference = Mymap.SpatialReference;@H_262_42@             Graphic graphic = new Graphic() { @H_262_42@                 Geometry=e.MapPoint,@H_262_42@                 Symbol=LayoutRoot.resources["DefaultClickSymbol"] as Symbol@H_262_42@             };@H_262_42@             @H_262_42@             graphic.SetZIndex(1);@H_262_42@             graphicsLayer.Graphics.Add(graphic);

            List<GPParameter> parameters = new List<GPParameter>();@H_262_42@             parameters.Add(new GPFeatureRecordSetLayer("Input_Points",e.MapPoint));@H_262_42@             parameters.Add(new GPLinearUnit("Distance",esriUnits.esriMeters,1000));

            _geoprocessorTask.SubmitJobAsync(parameters);@H_262_42@         }

        //void _geoprocessorTask_Failed(object sender,TaskFailedEventArgs E)@H_262_42@         //{@H_262_42@         //    messageBox.Show("Geoprocessing service Failed: " + e.Error);@H_262_42@         //}

        //void _geoprocessorTask_ExecuteCompleted(object sender,GPExecuteCompleteEventArgs E)@H_262_42@         //{@H_262_42@         //    GraphicsLayer graphicsLayer = Mymap.Layers["MyGraphicsLayer"] as GraphicsLayer;

        //    foreach (GPParameter parameter in e.Results.OutParameters)@H_262_42@         //    {@H_262_42@         //        if (parameter is GPFeatureRecordSetLayer)@H_262_42@         //        {@H_262_42@         //            GPFeatureRecordSetLayer gpLayer = parameter as GPFeatureRecordSetLayer;

        //            foreach (Graphic graphic in gpLayer.FeatureSet.Features)@H_262_42@         //            {@H_262_42@         //                graphic.Symbol = LayoutRoot.resources["DefaultBufferSymbol"] as Symbol;@H_262_42@         //                graphicsLayer.Graphics.Add(graphic);@H_262_42@         //            }@H_262_42@         //        }@H_262_42@         //    }@H_262_42@         //}@H_262_42@     }@H_262_42@ }@H_262_42@

 

注释掉的是同步执行的方法,但是好像不管用

下图是Buffer  GP服务的详细信息。

silverlight调用GP服务实现缓冲区

结果:

silverlight调用GP服务实现缓冲区

大佬总结

以上是大佬教程为你收集整理的silverlight调用GP服务实现缓冲区全部内容,希望文章能够帮你解决silverlight调用GP服务实现缓冲区所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。