ArcGIS API for Silverlight动态标绘的实现

简介: 原文:ArcGIS API for Silverlight动态标绘的实现 1、下载2个dll文件,分别是:ArcGISPlotSilverlightAPI.dll 和 Matrix.dll其下载地址为:http://download.
原文: ArcGIS API for Silverlight动态标绘的实现


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

ArcGISPlotSilverlightAPI.dll 和 Matrix.dll

其下载地址为:http://download.csdn.net/detail/taomanman/9212163


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



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

<UserControl x:Class="SLPlotMap.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    xmlns:layer="clr-namespace:MapClient.CommonClass"
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid x:Name="LayoutRoot" Background="White">
        <esri:Map Background="White" Name="myMap" WrapAround="True">
            <esri:Map.Layers>
                <esri:LayerCollection>
                    <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
                </esri:LayerCollection>
            </esri:Map.Layers>
        </esri:Map>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="40" />
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal" Margin="2">
                <Button Click="simpleArrow_Click">
                    简单箭头
                </Button>
                <Button Click="TailedArrow_Click">
                    尾箭头
                </Button>
                <Button Click="StraightArrow_Click">
                    直箭头
                </Button>
                <Button Click="CustomArrow_Click">
                    自定义箭头
                </Button>
                <Button Click="CustomTailedArrow_Click">
                    自定义尾箭头
                </Button>
                <Button Click="DoubleArrow_Click">
                    双箭头
                </Button>
                <Button Click="AssemblyArea_Click">
                    装配区
                </Button>
                <Button Click="CurveFlag_Click">
                    曲线旗
                </Button>
                <Button Click="RectFlag_Click">
                    矩形旗
                </Button>
                <Button Click="TriangleFlag_Click">
                    三角旗
                </Button>
                <Button Click="Circle_Click">
                    圆
                </Button>
                <Button Click="Finish_Click">
                    结束
                </Button>
                <Button Click="StartEdit_Click">
                    开始编辑
                </Button>
                <Button Click="StopEdit_Click">
                    停止编辑
                </Button>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>

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<Matrix.EventArgs>(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);
        }
    }
}


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

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


目录
相关文章
|
人工智能 数据可视化 API
ArcGIS API for Python
ArcGIS API for Python
72 0
|
JavaScript 前端开发 应用服务中间件
Arcgis api for javascript 详细部署
Arcgis api for javascript 详细部署
|
XML JSON 前端开发
软件测试|Spring Boot 的 RESTful API 设计与实现
软件测试|Spring Boot 的 RESTful API 设计与实现
软件测试|Spring Boot 的 RESTful API 设计与实现
|
人工智能 数据可视化 数据管理
ArcGIS API for Python
ArcGIS API for Python
118 0
|
数据可视化 数据管理 API
​​​​​​​ARCGIS API for Python进行城市区域提取
​​​​​​​ARCGIS API for Python进行城市区域提取
​​​​​​​ARCGIS API for Python进行城市区域提取
arcgis api 3.X 修改自带弹窗样式 2022年6月12日
自带的弹窗介绍: arcgis api 3.X 修改自带弹窗样式插图 /*修改原有弹窗的css样式*/ /* 弹窗整体 */ .esriPopup { font-size: 16px; box-shadow: 10px 10px 5px #888888; } .esriPopup .sizer { position: relative; width: 400px; /* 弹窗宽度 */ z-index: 1; } /* 标题部分 */ .esriPopup .titlePane { background-color: rgba(7
|
SQL 安全 Java
微服务API开放授权平台的设计与实现
微服务API开放授权平台的设计与实现
509 0
微服务API开放授权平台的设计与实现
|
人工智能 数据可视化 API
【超简单API实现分割】PaddleSeg 分割之API
【超简单API实现分割】PaddleSeg 分割之API
395 0
【超简单API实现分割】PaddleSeg 分割之API
|
前端开发 JavaScript API
借助 Web Animations API 实现一个鼠标跟随偏移动画
借助 Web Animations API 实现一个鼠标跟随偏移动画
320 0
借助 Web Animations API 实现一个鼠标跟随偏移动画
|
SQL Java 数据库连接
Apache-DBUtils实现CRUD操作,已封装的API实现jdbc对数据库进行操作
Apache-DBUtils实现CRUD操作,已封装的API实现jdbc对数据库进行操作
203 0
Apache-DBUtils实现CRUD操作,已封装的API实现jdbc对数据库进行操作

热门文章

最新文章