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);
}
}
}
===========================================================================
如果覺得對您有幫助,微信掃一掃支援一下:
相關文章
- ArcGIS API for Silverlight 繪製降雨路徑動畫API動畫
- ArcGIS API for Silverlight 滑鼠移動顯示地理座標API
- ArcGIS API for Silverlight實現地圖測距功能API地圖
- ArcGIS API for Silverlight 呼叫GP服務繪製等值面API
- ArcGIS API for Silverlight 實現修改地圖上的工程點位置API地圖
- ArcGIS API for Silverlight 動態圖層(ArcGISDynamicMapServiceLayer)的顯示與隱藏API
- ArcGIS API for Silverlight 學習筆記API筆記
- ArcGIS API for Silverlight 中根據座標點在地圖上打標記API地圖
- ArcGIS API for Silverlight 載入google地圖APIGo地圖
- ArcGIS API for Silverlight之ElementLayer使用注意點API
- ArcGIS API for Silverlight 動態新增點的同時,新增文字說明(利用TextSymbol新增多文字資訊 )APISymbol
- Flask SocketIO 實現動態繪圖Flask繪圖
- ArcGIS API for Silverlight程式碼中使用Template模板API
- ArcGIS API for Silverlight開發入門準備API
- 建立第一個ArcGIS API for Silverlight應用API
- ArcGIS API for Silverlight 之ElementLayer使用及TextSymbol的模板使用APISymbol
- ArcGIS API for Silverlight 查詢點閃爍顯示API
- ArcGIS API for Silverlight 查詢點聚焦的一個注意點API
- ArcGIS API for Silverlight 呼叫WebService出現跨域訪問報錯的解決方法APIWeb跨域
- ArcGIS API for Silverlight載入google地圖(後續篇)APIGo地圖
- ArcGIS API for Silverlight載入BingMap遙感地圖API地圖
- ArcGIS API for Silverlight開發中常用問題彙總API
- ArcGIS API for Silverlight中載入Google地形圖(瓦片圖)APIGo
- svg實現路徑自己動態繪製的功能SVG
- ArcGIS API for Silverlight 地圖元素點閃爍,線流動顯示的處理方式API地圖
- Silverlight4中實現Theme的動態切換
- 收集的一些關於ArcGIS API for Silverlight開發的連線API
- MyBatis標籤實現的動態SQL語句MyBatisSQL
- ArcGIS API for Silverlight 解決眾多密集點分層顯示API
- ArcGIS API for Silverlight 點選地圖彈出自定義窗體API地圖
- ArcGIS API for Silverlight 呼叫GP服務載入等值線圖層API
- Kitten 動態繪製 Y 軸方向立方體的實現方法
- ArcGIS 10 影像分析工具及ArcGIS Engine的實現
- ArcGIS API for Silverlight 地圖中解決點眾多的簇解決方法API地圖
- ArcGIS API for Silverlight 地圖載入進度條類之MapProgressBarAPI地圖APP
- 解決ArcGIS API for Silverlight 載入地圖的內外網訪問問題API地圖
- ArcGIS API for JS 中的styleAPIJS
- 【Gin-API系列】實現動態路由分組(七)API路由