ArcGIS API for Silverlight 调用GP服务加载等值线图层

ArcGIS API for Silverlight 调用GP服务加载等值线图层,第1张

概述第二篇、Silverlight客户端调用GP服务          利用ArcGIS API for Silverlight实现GP服务调用,这里的雨量数据是通过一个WebService获取而来,主要信息是雨量站点的经纬度坐标值和某个时间段内的降雨量值三个主要字段。 以下是核心代码部分:   <UserControl xmlns="http://schemas.microsoft.co

第二篇、Silverlight客户端调用GP服务

         利用ArcGIS API for Silverlight实现GP服务调用,这里的雨量数据是通过一个WebService获取而来,主要信息是雨量站点的经纬度坐标值和某个时间段内的降雨量值三个主要字段。

以下是核心代码部分:

 

<UserControl      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"      xmlns:esri="http://schemas.esri.com/arcgis/clIEnt/2009"      xmlns:controlsToolkit="clr-namespace:System.windows.Controls;assembly=System.windows.Controls.Toolkit"      xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="TestDZX.MainPage2"      mc:Ignorable="d"      d:DesignHeight="300" d:DesignWIDth="400">      <controlsToolkit:BusyIndicator x:name="busyIndicator" BusyContent="正在加载,请稍等..." IsBusy="True">          <GrID x:name="LayoutRoot" Background="White">            <esri:Map x:name="myMap"  IslogoVisible="False" ZoomDuration="0:00:00" PanDuration="0:00:00"                    Extent="117.647738815324,29.4704217183843,118.446182957997,30.4124245048916">                  <esri:ArcGISTiledMapServiceLayer ID="BaseLayer" Url="http://localhost/arcgis/rest/services/HSDQ/MapServer/"/>                  <!--等值线和等直面图层-->                  <esri:Graphicslayer ID="GraphicsDZX"/>              </esri:Map>              <GrID x:name="grIDMain" HorizontalAlignment="left" WIDth="215" margin="1,0">                  <GrID.ColumnDeFinitions>                      <ColumnDeFinition WIDth="200" x:name="grIDSub2" />                      <ColumnDeFinition WIDth="15" x:name="grIDSub1"/>                  </GrID.ColumnDeFinitions>                  <GrID  GrID.Column="1" Background="#FFD2D4D1" WIDth="15" margin="-1,0" d:LayoutOverrIDes="Horizontalmargin">                      <border borderBrush="#FFA5C6E5" borderThickness="2" WIDth="15">                          <Image x:name="imgExpandOrCollapsed" margin="0,136,117" Source="Images/ss.png" Stretch="Fill" Height="45" MouseleftbuttonDown="imgExpandOrCollapsed_MouseleftbuttonDown" MouseleftbuttonUp="imgExpandOrCollapsed_MouseleftbuttonUp" Cursor="Hand" tooltipService.tooltip="收缩/展开"/>                      </border>                  </GrID>                  <GrID  WIDth="200" HorizontalAlignment="left" Background="#FFD2D4D1">                      <GrID.RowDeFinitions>                          <RowDeFinition Height="0.095*"/>                          <RowDeFinition Height="0.905*"/>                      </GrID.RowDeFinitions>                      <StackPanel margin="0" GrID.Row="1" VerticalAlignment="top">                          <GrID Height="40" d:LayoutOverrIDes="Height,Verticalmargin" VerticalAlignment="top">                              <sdk:DatePicker x:name="dpStart" margin="38,6,65,6"/>                              <ComboBox x:name="cbStart" HorizontalAlignment="Right" margin="0,16,6" WIDth="49"/>                              <TextBlock HorizontalAlignment="left" margin="3,0" textwrapPing="Wrap" Text="起始:" WIDth="40" FontSize="13.333" FontFamily="Microsoft YaHei" VerticalAlignment="Center"/>                              <TextBlock textwrapPing="Wrap" Text="时" FontSize="13.333" FontFamily="Microsoft YaHei" VerticalAlignment="Center" HorizontalAlignment="Right" WIDth="15" margin="0,1,0"/>                          </GrID>                          <GrID Height="40" d:LayoutOverrIDes="Height,Verticalmargin">                              <sdk:DatePicker x:name="dpEnd" margin="38,6"/>                              <ComboBox x:name="cbEnd" HorizontalAlignment="Right" margin="0,0" textwrapPing="Wrap" Text="截至:" WIDth="40" FontSize="13.333" FontFamily="Microsoft YaHei" VerticalAlignment="Center"/>                              <TextBlock textwrapPing="Wrap" Text="时" FontSize="13.333" FontFamily="Microsoft YaHei" VerticalAlignment="Center" HorizontalAlignment="Right" WIDth="15" margin="0,Verticalmargin">                              <ComboBox x:name="cbRainGrade" margin="68,6"/>                              <TextBlock HorizontalAlignment="left" margin="4,0" textwrapPing="Wrap" Text="雨量级别:" WIDth="69" FontSize="13.333" FontFamily="Microsoft YaHei" VerticalAlignment="Center"/>                          </GrID>                          <GrID Height="40" d:LayoutOverrIDes="Height,Verticalmargin">                              <Radiobutton x:name="rb1" Content="稀" margin="70,11,67,1" FontSize="13.333" FontFamily="Microsoft YaHei" Groupname="rbGroup" IsChecked="True" Cursor="Hand" Click="rb_Click"/>                              <TextBlock HorizontalAlignment="left" margin="4,0" textwrapPing="Wrap" Text="过滤级:" WIDth="55" FontSize="13.333" FontFamily="Microsoft YaHei" VerticalAlignment="Center"/>                              <Radiobutton x:name="rb2" Content="密" margin="0,12,8,0" FontSize="13.333" FontFamily="Microsoft YaHei" HorizontalAlignment="Right" WIDth="55" Groupname="rbGroup" Cursor="Hand" Click="rb_Click"/>                          </GrID>                          <GrID Height="40" d:LayoutOverrIDes="Height,Verticalmargin">                              <button x:name="btnAnalysis" Content="等值线分析" margin="64,63,0" VerticalAlignment="Center" Cursor="Hand" FontSize="13.333" FontFamily="Microsoft YaHei" d:LayoutOverrIDes="WIDth" Click="btnAnalysis_Click"/>                          </GrID>                      </StackPanel>                      <border borderBrush="#FF459BFB" borderThickness="2" Background="#FF449DFF" Height="30" VerticalAlignment="top">                          <TextBlock HorizontalAlignment="Center" margin="0" textwrapPing="Wrap" Text="专 题 分 析" WIDth="82" FontSize="16" FontFamily="Microsoft YaHei" VerticalAlignment="Center" Foreground="White"/>                      </border>                  </GrID>              </GrID>          </GrID>      </controlsToolkit:BusyIndicator>  </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;  using ESRI.ArcGIS.ClIEnt.Geometry;  using ESRI.ArcGIS.ClIEnt.Tasks;  using System.Net.browser;  using ESRI.ArcGIS.ClIEnt.Symbols;  using TestDZX.ServiceReference1;  using System.Collections.ObjectModel;  using System.Collections;  using System.windows.Media.Imaging;  using System.Threading;  using System.Globalization;  using Syit.CommonClass;namespace TestDZX  {      public partial class MainPage2 : UserControl      {          /******************GP参数* 2012-08-29***********************/        private Geoprocessor _ContourTask; //等值线GP          public struct EvaluationPointStruct          {              public double Latitute; //纬度              public double Longitute; //经度              public double YL; //雨量          };          public EvaluationPointStruct[] evaluatePoints;          private Featureset featureset;//作为GP输入参数的要素集        ESRI.ArcGIS.ClIEnt.Projection.WebMercator mercator = new ESRI.ArcGIS.ClIEnt.Projection.WebMercator();        public int Contour_interval = 5; //默认是5表示稀,1表示密          /*********************************************************/        public MainPage2()          {              InitializeComponent();              //设置日期格式              Thread.CurrentThread.CurrentCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();              Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd";              //加载日期              this.dpStart.SelectedDate = (DateTime?)DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"));              this.dpEnd.SelectedDate = (DateTime?)DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));              //加载小时及雨量级别              BindElement();              //初次加载前日八时到现在小时的数据              DrawContourUseGP();          }        #region 页面上数据绑定        public voID BindElement()          {              //起始小时绑定              this.cbStart.Items.Add("00");              this.cbStart.Items.Add("01");              this.cbStart.Items.Add("02");              this.cbStart.Items.Add("03");              this.cbStart.Items.Add("04");              this.cbStart.Items.Add("05");              this.cbStart.Items.Add("06");              this.cbStart.Items.Add("07");              this.cbStart.Items.Add("08");              this.cbStart.Items.Add("09");              this.cbStart.Items.Add("10");              this.cbStart.Items.Add("11");              this.cbStart.Items.Add("12");              this.cbStart.Items.Add("13");              this.cbStart.Items.Add("14");              this.cbStart.Items.Add("15");              this.cbStart.Items.Add("16");              this.cbStart.Items.Add("17");              this.cbStart.Items.Add("18");              this.cbStart.Items.Add("19");              this.cbStart.Items.Add("20");              this.cbStart.Items.Add("21");              this.cbStart.Items.Add("22");              this.cbStart.Items.Add("23");              this.cbStart.Selectedindex = 8;            //结束时间绑定              this.cbEnd.Items.Add("00");              this.cbEnd.Items.Add("01");              this.cbEnd.Items.Add("02");              this.cbEnd.Items.Add("03");              this.cbEnd.Items.Add("04");              this.cbEnd.Items.Add("05");              this.cbEnd.Items.Add("06");              this.cbEnd.Items.Add("07");              this.cbEnd.Items.Add("08");              this.cbEnd.Items.Add("09");              this.cbEnd.Items.Add("10");              this.cbEnd.Items.Add("11");              this.cbEnd.Items.Add("12");              this.cbEnd.Items.Add("13");              this.cbEnd.Items.Add("14");              this.cbEnd.Items.Add("15");              this.cbEnd.Items.Add("16");              this.cbEnd.Items.Add("17");              this.cbEnd.Items.Add("18");              this.cbEnd.Items.Add("19");              this.cbEnd.Items.Add("20");              this.cbEnd.Items.Add("21");              this.cbEnd.Items.Add("22");              this.cbEnd.Items.Add("23");              DateTime dt = DateTime.Now;              string hour = dt.Hour.ToString();              if (hour.Length == 1)              {                  hour = "0" + hour;              }              switch (hour)              {                  case "00":                      this.cbEnd.Selectedindex = 0;                      break;                  case "01":                      this.cbEnd.Selectedindex = 1;                      break;                  case "02":                      this.cbEnd.Selectedindex = 2;                      break;                  case "03":                      this.cbEnd.Selectedindex = 3;                      break;                  case "04":                      this.cbEnd.Selectedindex = 4;                      break;                  case "05":                      this.cbEnd.Selectedindex = 5;                      break;                  case "06":                      this.cbEnd.Selectedindex = 6;                      break;                  case "07":                      this.cbEnd.Selectedindex = 7;                      break;                  case "08":                      this.cbEnd.Selectedindex = 8;                      break;                  case "09":                      this.cbEnd.Selectedindex = 9;                      break;                  case "10":                      this.cbEnd.Selectedindex = 10;                      break;                  case "11":                      this.cbEnd.Selectedindex = 11;                      break;                  case "12":                      this.cbEnd.Selectedindex = 12;                      break;                  case "13":                      this.cbEnd.Selectedindex = 13;                      break;                  case "14":                      this.cbEnd.Selectedindex = 14;                      break;                  case "15":                      this.cbEnd.Selectedindex = 15;                      break;                  case "16":                      this.cbEnd.Selectedindex = 16;                      break;                  case "17":                      this.cbEnd.Selectedindex = 17;                      break;                  case "18":                      this.cbEnd.Selectedindex = 18;                      break;                  case "19":                      this.cbEnd.Selectedindex = 19;                      break;                  case "20":                      this.cbEnd.Selectedindex = 20;                      break;                  case "21":                      this.cbEnd.Selectedindex = 21;                      break;                  case "22":                      this.cbEnd.Selectedindex = 22;                      break;                  case "23":                      this.cbEnd.Selectedindex = 23;                      break;              }              //绑定雨量级别              this.cbRainGrade.Items.Add("A:5,10,25,50,100,200");              this.cbRainGrade.Items.Add("B:10,200,300");              this.cbRainGrade.Items.Add("C:50,300,400,500,600");              this.cbRainGrade.Items.Add("D:100,600,700");              this.cbRainGrade.Items.Add("E:10,20,30,40,60");              this.cbRainGrade.Selectedindex = 0;          }        #endregion        #region 调用GP服务绘制等值线        /// <summary>          /// 调用GP服务绘制等值线          /// </summary>          public voID DrawContourUseGP()          {              Thread.Sleep(1000);              //加载之前,显示等待              busyIndicator.IsBusy = true;            try              {                  getXQYJInfoSoapClIEnt clIEnt = new getXQYJInfoSoapClIEnt();                  //水位数据                  clIEnt.getSWRainByTimeSpanCompleted += new EventHandler<getSWRainByTimeSpanCompletedEventArgs>(clIEnt_getSWRainByTimeSpanCompleted);                  clIEnt.getSWRainByTimeSpanAsync(DateTime.Parse(this.dpStart.SelectedDate.ToString().Split(' ')[0] + " " + this.cbStart.SelectedItem.ToString() + ":00:00"),DateTime.Parse(this.dpEnd.SelectedDate.ToString().Split(' ')[0] + " " + this.cbEnd.SelectedItem.ToString() + ":00:00"));              }              catch (Exception)              {                                }            }         voID clIEnt_getSWRainByTimeSpanCompleted(object sender,getSWRainByTimeSpanCompletedEventArgs e)          {              try              {                  //获取到所有的水文局雨量点                  ObservableCollection<RainFall> Lists = e.Result;                  int PointsNum = Lists.Count;//点的个数                  evaluatePoints = new EvaluationPointStruct[PointsNum];                  int index = 0;                  foreach (RainFall item in Lists)                  {                      if (item.YL24 != 0)                      {                          evaluatePoints[index].Latitute = item.Latitute;                          evaluatePoints[index].Longitute = item.Longitute;                          evaluatePoints[index].YL = item.YL24;                          index++;                      }                  }                  Utility.AddPointToMapLayer(myMap,evaluatePoints,out featureset);                AccessGPService(featureset);              }              catch (Exception)              {                 }          }        private voID AccessGPService(Featureset featureset)          {              try              {                  httpWebRequest.RegisterPrefix("http://",System.Net.browser.WebRequestCreator.ClIEnthttp);                  _ContourTask = new Geoprocessor("http://localhost/arcgis/rest/services/ContourServicetool/GPServer/Contour");                  List<GPParameter> parameters = new List<GPParameter>();                  parameters.Add(new GPFeatureRecordSetLayer("input_point_features",featureset));                  parameters.Add(new GPDouble("Contour_interval",Contour_interval));                  _ContourTask.UpdateDelay = 5000; // 10s的更新时间                  _ContourTask.OutputSpatialReference = myMap.SpatialReference; //设置输出空间参考系                  _ContourTask.JobCompleted += new EventHandler<JobInfoEventArgs>(geoprocessorTask_JobCompleted);                  _ContourTask.Failed += new EventHandler<TaskFailedEventArgs>(geoprocessorTask_Failed);                  _ContourTask.submitJobAsync(parameters);              }              catch (Exception)              {                 }          }        /********************************事件处理程序段***************************************/        voID geoprocessorTask_JobCompleted(object sender,JobInfoEventArgs e)          {              Geoprocessor gp = sender as Geoprocessor;              //注册前缀              httpWebRequest.RegisterPrefix("http://",System.Net.browser.WebRequestCreator.ClIEnthttp);              gp.GetResultDataCompleted += new EventHandler<GPParameterEventArgs>(gp_GetResultDataCompleted);              gp.GetResultDataAsync(e.JobInfo.JobID,"Contour_IDw_11_Clip_Smoothli_shp");            //加载完成,隐藏              busyIndicator.IsBusy = false;          }        voID gp_GetResultDataCompleted(object sender,GPParameterEventArgs e)          {              //找到显示等值线图层并清空,然后再次加载              Graphicslayer layer = myMap.Layers["GraphicsDZX"] as Graphicslayer;              layer.Cleargraphics();              GPFeatureRecordSetLayer gplayer = e.Parameter as GPFeatureRecordSetLayer;              int index = 0;              foreach (Graphic graphic in gplayer.Featureset.Features)              {                  if (IsRainInGrade(graphic.Attributes["CONTOUR"].ToString()))                  {                      graphic.Symbol = new ESRI.ArcGIS.ClIEnt.Symbols.Simplelinesymbol()                      {                          Style = ESRI.ArcGIS.ClIEnt.Symbols.Simplelinesymbol.linestyle.solID,color = new SolIDcolorBrush(colors.Red),WIDth = 2                      };                    layer.Graphics.Add(graphic); //添加红色的等值线                      /****************************************************************************************/                    //标注数值                      TextSymbol textSymbol = new TextSymbol()                      {                          FontFamily = new System.windows.Media.FontFamily("Microsoft YaHei"),Foreground = new System.windows.Media.solIDcolorBrush(color.FromArgb(255,0)),FontSize = 12,Text = graphic.Attributes["CONTOUR"].ToString()                      };                      //寻找线段的中心点坐标位置                      Graphic graphicText; //封闭曲线在曲线中间显示数值                      Graphic graphicStart; //非封闭曲线的起始点                      Graphic graphicEnd; //非封闭曲线的终止点                      if (gplayer.Featureset.GeometryType == GeometryType.polyline)                      {                          ESRI.ArcGIS.ClIEnt.Geometry.polyline pl = gplayer.Featureset.Features[index].Geometry as ESRI.ArcGIS.ClIEnt.Geometry.polyline;                          MapPoint mp = pl.Extent.GetCenter();                          if (pl.Paths != null && pl.Paths.Count > 0)                          {                              ESRI.ArcGIS.ClIEnt.Geometry.PointCollection path = pl.Paths[0];                              if (path != null && path.Count > 0)                              {                                  int mID = path.Count / 2;                                  mp = path[mID];                                  if (path.Count == 2)                                  {                                      // path里面只有两个点的情况                                      double x1 = (path[0] as MapPoint).X;                                      double y1 = (path[0] as MapPoint).Y;                                      double x2 = (path[1] as MapPoint).X;                                      double y2 = (path[1] as MapPoint).Y;                                      mp.X = x2 + (x1 - x2) / 2;                                      mp.Y = y2 + (y1 - y2) / 2;                                      //封闭的曲线                                      graphicText = new Graphic()                                      {                                          Geometry = mercator.FromGeographic(mp),Symbol = textSymbol                                      };                                      //封闭的曲线在中间位置                                      layer.Graphics.Add(graphicText); //添加数值                                  }                                  else                                  {                                      //起始                                      graphicStart = new Graphic()                                      {                                          Geometry = mercator.FromGeographic(new MapPoint(path[0].X,path[0].Y)),Symbol = textSymbol                                      };                                      //结束                                      graphicEnd = new Graphic()                                      {                                          Geometry = mercator.FromGeographic(new MapPoint(path[path.Count - 1].X,path[path.Count - 1].Y)),Symbol = textSymbol                                      };                                      layer.Graphics.Add(graphicStart); //标注起始数值                                      layer.Graphics.Add(graphicEnd); //标注结束数值                                  }                              }                          }                      }                  }                  //索引自增字段                  index++;              }          }        /// <summary>          /// 地理处理失败,返回失败原因          /// </summary>          /// <param name="sender"></param>          /// <param name="e"></param>          voID geoprocessorTask_Failed(object sender,TaskFailedEventArgs e)          {              MessageBox.Show(e.Error.ToString());          }        /// <summary>          /// 等值线分析按钮          /// </summary>          /// <param name="sender"></param>          /// <param name="e"></param>          private voID btnAnalysis_Click(object sender,RoutedEventArgs e)          {              DrawContourUseGP();          }        #endregion        #region 菜单处理选项及事件        private voID imgExpandOrCollapsed_MouseleftbuttonDown(object sender,System.windows.input.MousebuttonEventArgs e)          {              e.Handled = true;          }        private voID imgExpandOrCollapsed_MouseleftbuttonUp(object sender,System.windows.input.MousebuttonEventArgs e)          {              if (this.grIDSub2.WIDth == new GrIDLength(200,GrIDUnitType.Pixel))              {                  //处于展开状态                  this.imgExpandOrCollapsed.Tag = "收缩面板";                  GrID.SetColumnSpan(grIDMain,1);                  this.grIDSub2.WIDth = new GrIDLength(0,GrIDUnitType.Pixel);                  Uri uri = new Uri("Images/zk.png",UriKind.relative);                  BitmAPImage image = new BitmAPImage(uri);                  this.imgExpandOrCollapsed.source = image;              }              else              {                  //处于收缩状态                  this.imgExpandOrCollapsed.Tag = "展开面板";                  GrID.SetColumnSpan(grIDMain,2);                  this.grIDSub2.WIDth = new GrIDLength(200,GrIDUnitType.Pixel);                  Uri uri = new Uri("Images/ss.png",UriKind.relative);                  BitmAPImage image = new BitmAPImage(uri);                  this.imgExpandOrCollapsed.source = image;              }          }        /// <summary>          /// 过滤级单选按钮的切换事件          /// </summary>          /// <param name="sender"></param>          /// <param name="e"></param>          private voID rb_Click(object sender,RoutedEventArgs e)          {              Radiobutton currRadiobutton;              currRadiobutton = sender as Radiobutton;              if (currRadiobutton != null && currRadiobutton.IsChecked.Value)              {                  if (currRadiobutton.name == "rb1")                  {                      //首先赋值Contour_interval                      Contour_interval = 5;                      //改变值后,重新加载等值线                      DrawContourUseGP();                  }                  else if (currRadiobutton.name == "rb2")                  {                      //首先赋值Contour_interval                      Contour_interval = 1;                      //改变值后,重新加载等值线                      DrawContourUseGP();                  }              }          }        #endregion        #region 根据雨量等级进行数据筛选        /// <summary>          /// 判断一个降雨值取整数后,是否在雨量级别的数值中          /// </summary>          /// <param name="value"></param>          /// <returns>在数值中的话,返回true,否则返回false</returns>          public bool IsRainInGrade(string value)          {              bool flag = false;              string[] List = this.cbRainGrade.SelectedItem.ToString().Trim().Split(':')[1].Split(',');              foreach (string s in List)              {                  if (value.Trim() == s)                  {                      flag = true;                  }              }              return flag;          }          #endregion      }  }                  使用到的另一个cs类文件如下Utility.cs文件如下    using System;  using System.Net;  using System.windows;  using System.windows.Controls;  using System.windows.documents;  using System.windows.Ink;  using System.windows.input;  using System.windows.Media;  using System.windows.Media.Animation;  using System.windows.Shapes;  using ESRI.ArcGIS.ClIEnt.Geometry;  using ESRI.ArcGIS.ClIEnt;  using ESRI.ArcGIS.ClIEnt.Tasks;  using ESRI.ArcGIS.ClIEnt.Symbols;namespace TestDZX  {      public class Utility      {          public static voID AddPointToMapLayer(ESRI.ArcGIS.ClIEnt.Map map,MainPage2.EvaluationPointStruct[] evaluatePoints,out  ESRI.ArcGIS.ClIEnt.Tasks.Featureset featureset)          {              ESRI.ArcGIS.ClIEnt.Projection.WebMercator mercator = new ESRI.ArcGIS.ClIEnt.Projection.WebMercator();            #region 动态添加预测点图层            if (map.Layers["YLPointsLayer"] != null)              {                  map.Layers.Remove(map.Layers["YLPointsLayer"]);              }              Graphicslayer graphicslayer = new Graphicslayer()              {                  ID = "YLPointsLayer",};              map.Layers.Add(graphicslayer);            #endregion            #region 将降雨量点添加到图层中            featureset = new Featureset();              if (evaluatePoints.Length != 0)              {                  foreach (MainPage2.EvaluationPointStruct evaluationpoint in evaluatePoints)                  {                      Graphic g = new Graphic()                      {                          Geometry = mercator.FromGeographic(new MapPoint(evaluationpoint.Latitute,evaluationpoint.Longitute)),Symbol = new ESRI.ArcGIS.ClIEnt.Symbols.SimpleMarkerSymbol()                          {                              Style = ESRI.ArcGIS.ClIEnt.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Circle,Size = 5,color = new SolIDcolorBrush(colors.Red)                          }                      };                      g.Attributes.Add("YL",evaluationpoint.YL);                      featureset.Features.Add(g);                      graphicslayer.Graphics.Add(g);                      //动态添加文本                      TextSymbol textSymbol = new TextSymbol()                      {                          FontFamily = new System.windows.Media.FontFamily("Microsoft YaHei"),117,99)),Text = evaluationpoint.YL.ToString(),OffsetX = 12,OffsetY = -5                      };                    Graphic graphicText = new Graphic()                      {                          Geometry = mercator.FromGeographic(new MapPoint(evaluationpoint.Latitute,Symbol = textSymbol                      };                      graphicslayer.Graphics.Add(graphicText);                  }              }              #endregion          }      }  }  

显示效果如下:

总结

以上是内存溢出为你收集整理的ArcGIS API for Silverlight 调用GP服务加载等值线图层全部内容,希望文章能够帮你解决ArcGIS API for Silverlight 调用GP服务加载等值线图层所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1015290.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存