Silverlight載入第一個Map

來源:互聯網
上載者:User

標籤:

1、Map

  Map 是 ArcGIS API for Silverlight 中的核心組件,主要用於呈現地圖服務、影像服務中的空間資料,此外還可以展示 WMS 服務、熱點圖(HeatMap)、Bing 地圖、OpenStreetMap、GeoRSS、KML 資料等,並且 Map 可以與使用者互動,接受使用者輸入。

屬性:

Extent:地圖外包矩形的範圍,即四個角點座標範圍。

IsLogoVisible:是否顯示esri的logo。

Layers:地圖中的圖層集合,先加入的圖層在底部,最後加入的圖層在最上層顯示。

PanDuration/ZoomDuration:平移/縮放時動畫期間。

SpatialReference:空間參考,通過WKID(空間參考編號)或WKT(空間參考名稱)指定,預設為加入地圖中的第一個具有空間參考的圖層的空間參考。

WrapAround:設定地圖是否經向迴圈,即通過平移工具,一直向左或向右移動地圖,類比球體旋轉。

方法:

MapToScreen/ScreenToMap:地圖與螢幕之間的座標轉換。

PanTo/ZoomTo:平移/縮放到指定範圍。

事件:

ExtentChanged:地圖範圍改變事件。

MouseClick:地圖上的單擊事件。

Progress:地圖資料載入進度事件。

PropertyChanged:地圖屬性變化事件。

2、載入地圖資料

<UserControl x:Class="HelloWorld.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"    xmlns:esri="http://schemas.esri.com/arcgis/client/2009"                       mc:Ignorable="d"    d:DesignHeight="300" d:DesignWidth="400">    <Grid x:Name="LayoutRoot" Background="White">        <esri:Map x:Name="myMap">            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"InitializationFailed="Layer_InitializationFailed"/>                   </esri:Map>            </Grid></UserControl>

添加後台代碼(C#):

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;namespace HelloWorld{    public partial class MainPage : UserControl    {        public MainPage()        {            InitializeComponent();        }        private void Layer_InitializationFailed(object sender,EventArgs e)        {            //擷取圖層對象            Layer layer = sender as Layer;            //顯示圖層載入失敗原因的提示            MessageBox.Show("載入圖層失敗:" + layer.InitializationFailure.Message);        }    }}

3、後台代碼方式  

  通過在後台代碼(如 C#)中建立 ArcGISDynamicMapServiceLayer 並將其添加到Map 對象中,實現向地圖中添加動態服務圖層的功能,代碼如下所示:

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;namespace HelloWorld{    public partial class MainPage : UserControl    {        public MainPage()        {            InitializeComponent();            // 建立動態服務圖層            ArcGISDynamicMapServiceLayer usaMapLayer = new ArcGISDynamicMapServiceLayer();            usaMapLayer.ID = "usaMap";// 指定圖層ID            // 指定圖層URL            usaMapLayer.Url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer";            // 將圖層添加到地圖中            myMap.Layers.Add(usaMapLayer);        }    }}

 

Silverlight載入第一個Map

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.