源自:http://blog.163.com/zwx_gis/blog/static/32434435201122193611576/ (主页:http://blog.163.com/zwx_gis/

一、安装

1、Visual Studio:

(1)Visual Studio 2010或Visual Web Developer Express 2010

(2)Silverlight 4 Tools for Visual Studio (add-on) :仅Silverlight 4支持

(3)Expression Blend 4 SDK for Silverlight (also included with Expression Blend 4)

(Necessary for behavior and Silverlight support)

2、Expression Blend:

(1)Expression Blend 4:Included with Expression Studio editions

3、其它附加(非必须安装)

(1)Deep Zoom Composer

(2)Silverlight Toolkit

二、开始

1、VS2010,新建“Silverlight应用程序”

2、勾选“在新网站中承载Silverlight应用程序”(ASP.NET Web应用程序项目)

3、添加引用:.NET\ESRI.ArcGIS.Client

4、xaml文件中:添加命名空间指向ArcGIS Silverlight/WPF;添加Map控件,并指定其MapServiceLayer。

<UserControl x:Class="SilverlightApplication.MainPage" xmlns="…" …

xmlns:esri="http://schemas.esri.com/arcgis/client/2009">

<Grid x:Name="LayoutRoot">

<esri:Map x:Name="MyMap" >

<esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"

Url="http://hostName/ArcGIS/rest/services/mapservName/MapServer"/>

</esri:Map>

</Grid>

</UserControl>

注意:为了能跨域访问(MapServer在不同域),需要将clientaccesspolicy.xml或 crossdomain.xml文件拷贝到网站根目录(如IIS的C:\inetpub\wwwroot\)。

三、ArcGIS API for Microsoft Silverlight/WPF 2.1的ODM:

1、OMD(Object model diagrams对象模型图表)总览:参见附件一

2、OMD(Object model diagrams对象模型图表)详表:参见附件二

四、地图和图层(Maps and Layers)

1、创建地图(map)

exent属性:地图的左下角和右上角坐标值,即地图的显示范围

默认:所有地图图层的范围

spatial reference(空间参考)属性:如果空间参考不一致,地图将不显示

默认:采用第一个图层的空间参考值

<esri:Map x:Name="MyMap">

<esri:Map.Extent>

<esriGeometry:Envelope XMin="." YMin="." XMax="." YMax="." >

<esriGeometry:Envelope.SpatialReference>

<esriGeometry:SpatialReference WKID="26777"/>

</esriGeometry:Envelope.SpatialReference>

</esriGeometry:Envelope>

</esri:Map.Extent>

</esri:Map>

也可后台指定:

ESRI.ArcGIS.Client.Geometry.Envelope initialExtent = new ESRI.ArcGIS.Client.Geometry.

Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator( new ESRI.

ArcGIS.Client.Geometry.MapPoint(-130, 20)),ESRI.ArcGIS.Client.Bing.Transform.

GeographicToWebMercator(new ESRI.ArcGIS.Client.Geometry.MapPoint(-65, 55)));

initialExtent.SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100);

MyMap.Extent = initialExtent;

注:WKID-Well Know ID:EPSG发布的代表特定椭球体、单位、地理坐标系或投影坐标系的ID,例如 "EPSG:4326" 指的就是WGS 84地理坐标系,其中WKID=4326

2、新增图层(layer)

第一加载图层的空间参考决定了整个地图的空间参考

先加载的图层在地图下边,如下图:

Map Service Layers

两种类型:

tiled Service:瓦片,地图服务器上预先定义好的Image

Dyanmic Service:动态,动态生成的Image

Service host

Map Service Layer Type

描述

ArcGIS Service

ArcGISTiledMapServiceLayer

地图服务器的缓存地图服务已经存在所有地图image瓦片

ArcGISDynamicMapServiceLayer

地图服务器的无缓存地图服务动态生成地图images,可动态访问矢量(vector)和(栅格)raster数据

ArcGISImageServiceLayer

地图服务器的image服务动态生成地图images,可动态访问栅格数据

Bing Maps

TileLayer

Feature layers

包含features,如geometry(几何学)和attribute(属性)

不支持多图层缓存

ArcGISDynamicMapServiceLayer的背景颜色通常为透明

opacity属性用于定义图层的透明度(0-1)

地图不显示的原因有:

url不正确;

Map Service不可用

Map Service网站或主机没有跨域认证文件(clientaccesspolicy.xml或 crossdomain.xml)

Map Service要求token或credentials

3、导航地图(Navigation)

(1)map的ZoomDuration属性和PanDuration 属性:用于指定缩放和平移动作的持续时间。

如<esri:Map ZoomDuration="00:00:00" PanDuration ="00:00:00” …>

(2)map的SnapToLevels属性:用于指定level of detail(LOD),地图在该级别是否显示。

如<esri:Map SnapToLevels=”ture” …>

(3)map的ZoomFactor属性:键盘+/-进行缩放时,缩放的级数

(4)系统已封装的键盘和鼠标导航地图快捷键:

键盘

鼠标

结果

上、下、左、右

地图平移

拖动

地图平移

+、-

地图缩放,缩放比例为map的ZoomFactor属性指定的值

双击

地图放大,放大比例为map的ZoomFactor属性指定的值

Shift

拉框

拉框放大

Shift+Ctrl

拉框

拉框缩小

滚轮

地图缩放

(5)系统已封装的导航地图的方式和接口:

map的属性|方法

描述

Extent属性

map.Extent=envelope

Zoom()

map.Zoom(n) ,n为缩放比率,n>1为zoomin,n<1为zoomout

Zoomto()

map.Zoomto(envelope)

ZoomToResolution()

map.ZoomToResolution(lod.Resolution);

Resolution指每pixel包含的map unit数,如

Lod lod=tiledMapServiceLayer.TileInfo.Lods[5];

map.ZoomToResolution(lod.Resolution);

Panto()

Panto(point),point为地图窗口的中心点

、Time-aware layers(此知识点不懂,有待继续研究)

ArcGIS10开始支持Time-aware layers,存储了随时间变化的信息,可用于:

(1)飓风路径及其它气象学事件;

(2)人口和土地利用的历史变化;

(3)监测生产现状的变化;

(4)火灾或洪水的行进;

(5)疾病的蔓延。

Time-aware layers的使用:

(1)使用Tookit里的TimeSlider控件

(2)使用API自己建立应用程序

Time-aware layers的建立:

在ArcMap中,右键图层\属性\Time,勾选Enable time on this layer

地图发布后,可以使用time-aware map或feature Service(ArcGISDynamicMapServiceLayer 或FeatureLayer classes)来随时间变化的查询和展示。

对于Image Services,栅格地图必须提供Mosaic Dateset,如下图:

访问TimeExtent类:通过time-aware layers的TimeExtent属性访问

TimeExtent timeExtent = (MyMap.Layers["MyFeatureLayer"] as FeatureLayer)

.TimeExtent;

//TimeExtent timeExtent = new ESRI.ArcGIS.Client.TimeExtent();

timeExtent.Start = DateTime.Parse("2002-01-01T17:33:46.0000000",

CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal);

5、Behaviors和actions

BehaviorAPI位于Esri.ArcGIS.Client.Behaviors集(内藏在Expression Blend4中),用于定义用户与地图的交互。使用时必须添加System.Windows.Interactivity集。

xaml文件中必须添加命名空间如下:

xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors"    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

BehaviorAPI包括三个核心类:

(1)Behavior:由trigger(地图上的事件)和action(产生结果)组成

Behavior

Description

Code Example

ConstrainExtentBehavior

Limit the map extent to an envelope. The user cannot navigate outside of the envelope defined on the behavior.

<esri:Map x:Name="MyMap" Extent="-120,30,-60,60">

. . .

<i:Interaction.Behaviors>

<esriBehaviors:ConstrainExtentBehavior

ConstrainedExtent="-120,30,-60,60"/>

</i:Interaction.Behaviors>

</esri:Map>

MaintainExtentBehavior

Maintain the current extent when the map is resized.

<esri:Map x:Name="MyMap">

. . .

<i:Interaction.Behaviors>

<esriBehaviors:MaintainExtentBehavior />

</i:Interaction.Behaviors>

</esri:Map>

ShowCoordinatesBehavior

Show map coordinates next to the mouse cursor when hovering over the map.

<esri:Map x:Name="MyMap">

. . .

<i:Interaction.Behaviors>

<esriBehaviors:ShowCoordinatesBehavior

FormatString="{}{0:0.00} , {1:0.00}"/>

</i:Interaction.Behaviors>

</esri:Map>

(2)Action:由trigger(地图上的事件)和目标结果

Action

Description

Code Example

ClearGraphicsAction

Clears all graphics in a graphics layer.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:ClearGraphicsAction

GraphicsLayerID="MyGraphicsLayer"

TargetName="MyMap" />

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

MeasureAction

Shows measure distance, radius, and area.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:MeasureAction

AreaUnit="SquareMiles"

DisplayTotals="True"

DistanceUnit="Miles"

MapUnits="DecimalDegrees"

MeasureMode="Polygon"

FillSymbol="{StaticResource DefaultFillSymbol}"

TargetName="MyMap"/>

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

PanToAction

Pans to a specified geometry.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:PanToAction

TargetName="MyMap">

<esriBehaviors:PanToAction.Geometry>

<esriGeometry:MapPoint X="-120" Y="43" />

</esriBehaviors:PanToAction.Geometry>

</esriBehaviors:PanToAction>

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

RedlineAction

Draw graphics on the map and add it to a graphics layer.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:RedlineAction

Color="#FF32FF00"

DrawMode="Freehand"

GraphicsLayerID="MyGraphicsLayer"

TargetName="MyMap"/>

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

SpatialQueryAction

Draw geometry on the map to query features in a feature layer. Draw the results in a graphics layer.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:SpatialQueryAction

DrawMode="Rectangle"

LayerID="MyGraphicsLayer"

Url="http://myserver/ArcGIS/rest/myservice/MapServer/2"

Symbol="{StaticResource GraphicsLayerFillSymbol}"

TargetName="MyMap" />

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

ToggleLayerAction

Toggle the visibility of a layer.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:ToggleLayerAction

LayerID="MyDynamicLayer"

TargetName="MyMap"/>

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

UpdateFeatureLayerAcvtion

Refresh the contents of a feature layer.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:UpdateFeatureLayerAction

FeatureLayerID="MyFeatureLayer"

TargetName="MyMap" />

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

ZoomToAction

Zoom to a specified geometry. If the geometry is a point, the map will pan.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:ZoomToAction

TargetName="MyMap">

<esriBehaviors:ZoomToAction.Geometry>

<esriGeometry:Envelope

XMin="-110" YMin="40" XMax="-100" YMax="50" />

</esriBehaviors:ZoomToAction.Geometry>

</esriBehaviors:ZoomToAction>

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

ZoomToFullExtentAction

Zoom to the full extent of all layers.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:ZoomToFullExtentAction

TargetName="MyMap"/>

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

ZoomToLayerAction

Zoom the extent of a specified layer.

<Button>

<i:Interaction.Triggers>

<i:EventTrigger EventName="Click">

<esriBehaviors:ZoomToLayerAction

LayerID="MyTileLayer"

TargetName="MyMap"/>

</i:EventTrigger>

</i:Interaction.Triggers>

</Button>

(3)Trigger(略)

【转】ArcGIS API for Silverlight/WPF 2.1学习笔记(一)的更多相关文章

  1. ArcGIS API for Silverlight/WPF 2.1学习笔记(一)——精简版

    一.安装 1.Visual Studio: (1)Visual Studio 2010或Visual Web Developer Express 2010 (2)Silverlight 4 Tools ...

  2. 【转】ArcGIS API for Silverlight/WPF 2.1学习笔记(四)

      七.Editing ArcGIS Server 10提供了: 通过feature service,在Web上编辑Feature layers的geographic data的功能. 通过geome ...

  3. 【转】ArcGIS API for Silverlight/WPF 2.1学习笔记(二)

      五.Graphics layer 1.新增Graphics layer Graphics layer用于显示用户自定义绘制的点.线.面图形.使用时确保xaml文件中Graphics layer定义 ...

  4. 【转】ArcGIS API for Silverlight/WPF 2.1学习笔记(五)

    2.Find示例代码 (1)xaml文件: //添加Symbol命名空间 xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbol ...

  5. 【转】ArcGIS API for Silverlight/WPF 2.1学习笔记(三)

    六.Feature Layer Feature Layer是一种特殊的Graphics layer(继承自Graphics layer),除了像Graphics layer一样包含和显示Graphic ...

  6. 扩展ArcGIS API for Silverlight/WPF 中的TextSymbol支持角度标注

    原文 http://blog.csdn.net/esricd/article/details/7587136 在ArcGIS API for Silverlight/WPF中原版的TextSymbol ...

  7. ArcGIS API for Silverlight学习笔记

    ArcGIS API for Silverlight学习笔记(一):为什么要用Silverlight API(转) 你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我都 ...

  8. ArcGIS API for Silverlight开发入门

    你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我 都没关系.但你不能否认3G是一种趋势,最终我们每个人都会被包裹在3G网络中.1100也不是一成不变,没准哪天为了打击 ...

  9. ArcGIS API For Silverlight使用在线地图的多种方法总结

    引自:http://www.cnblogs.com/meimao5211/p/3283969.html ArcGIS API For Silverlight使用在线地图的多种方法总结 本人也正在学习A ...

随机推荐

  1. codeforces E - Anya and Cubes 分块处理 暴力搜索

    说的是给了n个立方体,立方体从1标号到n,每个立方体上有一个数字, 你有 k 个机会 使得其中 k个数位他们自己的阶乘,(自然使用可以少于k次机会,每个立方体最多被使用1次) ,那么求出你从这n个立方 ...

  2. Pointofix 1.7 Portable试用

    Pointofix 1.7 Portable简体中文单文件便携版 软件大小:347K软件语言:简体中文软件类别:国外软件/桌面工具/教育教学运行环境:windows XP/Vista/Win7开 发 ...

  3. 常用linux命令:locate 命令

    locate 让使用者可以很快速的搜寻档案系统内是否有指定的档案.其方法是先建立一个包括系统内所有档案名称及路径的数据库,之后当寻找时就只需查询这个数据库,而不必实际深入档案系统之中了.在一般的 di ...

  4. 解析分布式锁之Redis实现(二)

    摘要:在前文中提及了实现分布式锁目前有三种流行方案,分别为基于数据库.Redis.Zookeeper的方案,本文主要阐述基于Redis的分布式锁,分布式架构设计如今在企业中被大量的应用,而在不同的分布 ...

  5. nginx反向代理-后端服务器组设置

    nginx服务器的反向代理时其最常用的重要功能之一,在实际工作中应用广泛,涉及的配置指令也比较多.下面会尽量详细地介绍对应的指令,及其使用状态. 反向代理一般是互联网需要向内网拉取资源,比如访问一个w ...

  6. Jquery 数组与字符串之间的转换

    var auth_list = []; $("input[name='auth_list']:checkbox").each(function () { if ($(this).a ...

  7. 20145122《Java面向对象程序设计》实验二实验报告

    实验名称: Java面向对象程序设计 实验内容: 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设计模式 PSP时间 步骤 ...

  8. linux内核分析 第18章读书笔记

    十八章 调试 一.内核调试概述 1.需要面对的 一个确定的bug 一个藏匿bug的内核版本 相关的内核代码的知识和运气 2.艰难的调试工作 重现bug很困难:大部分bug通常都不是行为可靠而且定义明确 ...

  9. Python3基础 list 推导式 生成与已知列表等长度+元素为0的列表

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  10. Python3基础 list str转成list

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...