摘要:Silverlight 結合 ArcGis 在地圖上畫線
先來看看完成後的畫面,我從桃園畫到高雄,再由高雄畫到香港
Silverlight這邊如下
我們在畫面上新增一個線型的Symbol
程式碼內如下
'Create by maggiore 2012/5/10 for dotblog
Public Sub New()
InitializeComponent()
Dim g_graphic_airport As GraphicsLayer '宣告一個圖層物件變數
'將畫面上的圖層丟給圖層物件
g_graphic_airport = TryCast(MyMap.Layers("graphic_airport"), GraphicsLayer)
Dim pGraphic As Graphic = New Graphic() 'Imports ESRI.ArcGIS.Client
Dim Point As New MapPoint 'Imports ESRI.ArcGIS.Client.Geometry
'桃園機場經緯度
Point.X = 121.23 '經度
Point.Y = 25.08 '緯度
Dim Point2 As New MapPoint 'Imports ESRI.ArcGIS.Client.Geometry
'高雄經緯度
Point2.X = 120.35 '經度
Point2.Y = 22.58 '緯度
Dim Point3 As New MapPoint 'Imports ESRI.ArcGIS.Client.Geometry
'香港經緯度
Point3.X = 113.92 '經度
Point3.Y = 22.31 '緯度
Dim pPolyline1 As ESRI.ArcGIS.Client.Geometry.Polyline = New ESRI.ArcGIS.Client.Geometry.Polyline()
Dim pPointCollection1 As ESRI.ArcGIS.Client.Geometry.PointCollection = New ESRI.ArcGIS.Client.Geometry.PointCollection()
pPointCollection1.Add(Point)
pPointCollection1.Add(Point2)
pPointCollection1.Add(Point3)
pPolyline1.Paths.Add(pPointCollection1)
pGraphic.Geometry = pPolyline1
pGraphic.Symbol = Line_black
g_graphic_airport.Graphics.Add(pGraphic)
End Sub
上述三個地點,小馬在專案中是用for 迴圈去撈資料庫的資料,上面是為了讓讀者清楚簡單了解,
才一個點一個點的示範喔!。
到這,讀者應該可以明白之前小馬是怎麼耍白癡學食神在畫面畫個"贏"字了吧!(點或線皆可)