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:
@H_197_18@ 

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

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

@H_197_18@ 

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

@H_197_18@

silverlight调用GP服务实现缓冲区

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

@H_197_18@前端代码

<UserControl x:Class="GPBuffer.MainPage"
    xmlns="http://scheR_363_11845@as.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://scheR_363_11845@as.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://scheR_363_11845@as.microsoft.com/expression/blend/2008"
    xmlns:esri="http://scheR_363_11845@as.esri.com/arcgis/client/2009"
    xmlns:mc="http://scheR_363_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_197_18@
 

@H_197_18@后台代码

@H_197_18@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;

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

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

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

@H_197_18@        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);
            messageBox.Show("********************");
        }

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

@H_197_18@            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);

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

@H_197_18@            _geoprocessorTask.SubmitJobAsync(parameters);
        }

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

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

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

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

@H_197_18@ 

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

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

@H_197_18@

silverlight调用GP服务实现缓冲区

@H_197_18@结果:

@H_197_18@

silverlight调用GP服务实现缓冲区

大佬总结

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

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

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