博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ArcGIS API for Silverlight动态标绘的实现
阅读量:6612 次
发布时间:2019-06-24

本文共 7886 字,大约阅读时间需要 26 分钟。

原文:

1、下载2个dll文件,分别是:

ArcGISPlotSilverlightAPI.dll 和 Matrix.dll

其下载地址为:

2、在Silverlight项目中添加上面2个dll引用,如下图所示:

3、核心及调用代码如下所示:

using System;using System.Collections.Generic;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 ArcGISPlotSilverlightAPI;using Matrix.Xmpp.Client;using ESRI.ArcGIS.Client.Geometry;using ESRI.ArcGIS.Client.Symbols;using ESRI.ArcGIS.Client.Geometry;using ESRI.ArcGIS.Client.Symbols;using Matrix.Xmpp;using Matrix.Net;using MapClient.CommonClass;using System.Windows.Media.Imaging;using System.IO;using SLPlotMap.CommonClass;namespace SLPlotMap{    public partial class MainPage : UserControl    {        private AssemblyArea _aArrow;        private SimpleArrow _arraw;        private CustomArrow _cArrow;        private CurveFlag _cFlag;        private Circle _circle;        private CustomTailedArrow _ctArrow;        private DoubleArrow _dArrow;        private EditGeometry _editGeometry;        private GraphicsLayer _gGraphicsLayer1;        private bool _isEdit;        private bool _isFinish;        private PlotDraw _plotDraw;        private long _pointCount;        private RectFlag _rFlag;        private StraightArrow _sArrow;        private TailedArrow _tArraw;        private TriangleFlag _tFlag;        private XmppClient _xmppClient;        private Graphic selectedPointGraphic;        public MainPage()        {            InitializeComponent();            this.Init();        }        private void _gGraphicsLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e)        {            if (this._isEdit)            {                e.Handled = true;                if (e.Graphic.Geometry is MapPoint)                {                    e.Graphic.Selected = true;                    this.selectedPointGraphic = e.Graphic;                }                else                {                    this._editGeometry.StartEdit(e.Graphic);                }            }        }        private void _plotDraw_DrawEnd(ESRI.ArcGIS.Client.Geometry.Polygon polygon)        {            SimpleFillSymbol symbol = new SimpleFillSymbol            {                Fill = new SolidColorBrush(Color.FromArgb(0x9b, 0xff, 0, 0))            };            Graphic item = new Graphic            {                Geometry = polygon,                Symbol = symbol            };            this._gGraphicsLayer1.Graphics.Add(item);            Message el = new Message            {                To = "lei@192.168.200.117",                Type = MessageType.chat,                Body = polygon.ToString()            };            this._xmppClient.Send(el);        }        private void _xmppClient_OnRosterEnd(object sender, EventArgs e)        {        }        private void AssemblyArea_Click(object sender, RoutedEventArgs e)        {            this._plotDraw.setPlotDrawMode(PlotDrawMode.AssemblyArea);        }        private void Circle_Click(object sender, RoutedEventArgs e)        {            this._plotDraw.setPlotDrawMode(PlotDrawMode.Circle);        }        private void CloseSession()        {            this._xmppClient.SendUnavailablePresence("Gone home from the office");            this._xmppClient.Close();        }        private void Connect()        {            this._xmppClient.SetUsername("zbc");            this._xmppClient.SetXmppDomain("192.168.200.117");            this._xmppClient.Password = "zbc";            this._xmppClient.OnRosterEnd += new EventHandler
(this._xmppClient_OnRosterEnd); this._xmppClient.Port = 0x1466; this._xmppClient.Transport = Transport.BOSH; this._xmppClient.Uri = new Uri("http://192.168.200.117:8080/http-bind/"); } private void CurveFlag_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.CurveFlag); } private void CustomArrow_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.CustomArrow); } private void CustomTailedArrow_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.CustomTailedArrow); } private void DoubleArrow_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.DoubleArrow); } private void Finish_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.None); } public void Init() { this._pointCount = 0L; this._gGraphicsLayer1 = new GraphicsLayer(); this._isFinish = true; this._xmppClient = new XmppClient(); this.Connect(); this._plotDraw = new PlotDraw(this.myMap); this._plotDraw.DrawEnd += new PlotDraw.DrawEndEventHandler(this._plotDraw_DrawEnd); EditGeometry geometry = new EditGeometry { Map = this.myMap, IsEnabled = true, EditVerticesEnabled = false }; this._editGeometry = geometry; this.myMap.Layers.Add(this._gGraphicsLayer1); this._gGraphicsLayer1.MouseLeftButtonDown += new GraphicsLayer.MouseButtonEventHandler(this._gGraphicsLayer_MouseLeftButtonDown); this._isEdit = false; } private void RectFlag_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.RectFlag); } private void simpleArrow_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.SimpleArrow); } private void StartEdit_Click(object sender, RoutedEventArgs e) { this._isEdit = true; this._plotDraw.setPlotDrawMode(PlotDrawMode.None); } private void StopEdit_Click(object sender, RoutedEventArgs e) { this._isEdit = false; } private void StraightArrow_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.StraightArrow); } private void TailedArrow_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.TailedArrow); } private void TriangleFlag_Click(object sender, RoutedEventArgs e) { this._plotDraw.setPlotDrawMode(PlotDrawMode.TriangleFlag); } }}

===========================================================================

如果觉得对您有帮助,微信扫一扫支持一下:

你可能感兴趣的文章
springboot docker笔记
查看>>
Modbus RTU 通信工具设计
查看>>
服务化改造实践 | 如何在 Dubbo 中支持 REST
查看>>
【第8章】JVM内存管理
查看>>
在绿色的河流上
查看>>
ovirt官方安装文档 附录G
查看>>
磁盘故障小案例
查看>>
了解相关.NET Framework不同组件区别及安装知识
查看>>
ToughRADIUS快速指南
查看>>
HTML
查看>>
【转】左手坐标系和右手坐标系
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
POJ 3335 Rotating Scoreboard 半平面交
查看>>
《Gamestorming》读书笔记
查看>>
域名和网址链接被微信浏览器拦截怎么办 微信屏蔽网址打开如何解决
查看>>
使用SQL Server Analysis Services数据挖掘的关联规则实现商品推荐功能(二)
查看>>
ubuntu下安装jdk
查看>>
C/S与B/S架构比较
查看>>
XML学习总结(2)——XML简单介绍
查看>>