上一节学习了silverlight加载GeoServer发布的WMS地图,这一节学习一下加载GraphicsLayer

一、加载.png或jpg文件图标

1、在MainPage.xaml中添加资源配置

<Grid.Resources>
            <esri:SimpleMarkerSymbol x:Key="RedMarkerSymbol" Color="Red" Size="12" Style="Circle" />
            <esri:SimpleMarkerSymbol x:Key="BlackMarkerSymbol" Color="Black" Size="14" Style="Diamond" />
            <esri:PictureMarkerSymbol x:Key="GlobePictureSymbol" OffsetX="8" OffsetY="8"
                Source="images/ttt.png" />
            <esri:SimpleLineSymbol x:Key="DefaultLineSymbol" Color="Green" Style="DashDot" Width="4" />
            <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="Green" BorderBrush="Blue"
                BorderThickness="3" />
        </Grid.Resources>

2、在cs文件中添加实现函数(以添加图片图标为例,添加其它请参考api官网)

private static ESRI.ArcGIS.Client.Projection.WebMercator mercator =
            new ESRI.ArcGIS.Client.Projection.WebMercator();

private void AddPictureMarkerAndTextGraphics()
        {

    GraphicsLayer g = new ESRI.ArcGIS.Client.GraphicsLayer();
            for (int i = 0; i < 2; i++)
            {
                Graphic graphic = new Graphic()
                {
                    Geometry = mercator.FromGeographic(new MapPoint(107.2 + i, 38.1 + i)),
                    Symbol = LayoutRoot.Resources["GlobePictureSymbol"] as Symbol
                };

g.Graphics.Add(graphic);
                
            }
            this.myMap.Layers.Add(g);
        }

添加System.Runtime.Serialization引用

3、调用AddPictureMarkerAndTextGraphics()

二、加载Graphic点并高亮、闪烁显示

1、实现鼠标触发高亮显示

1.1 在MainPage.xaml中添加资源配置

<esri:MarkerSymbol x:Key="StrobeMarkerSymbol">
<esri:MarkerSymbol.ControlTemplate>
<ControlTemplate>
<Canvas>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="MouseOver">
<Storyboard RepeatBehavior="ForEver">

<DoubleAnimation BeginTime="0"
Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"
From="1" To="10" Duration="00:00:01" />

<DoubleAnimation BeginTime="0"
Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)"
From="1" To="10" Duration="00:00:01" />

<DoubleAnimation BeginTime="0"
Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)"
From="1" To="0" Duration="00:00:01" />
</Storyboard>
</VisualState>
<!--If normal state is not specified, the animation will
keep going until a mouse out. Keep it empty to transition back to original symbol. -->
<VisualState x:Name="Normal" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<!--Strobe ellipse-->
<!--Note that IsHitTestVisible="False" on the strobe symbol,
so only the static ellipse will trigger mouse over/mouse out-->
<Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5"
RenderTransformOrigin="0.5,0.5" x:Name="ellipse"
IsHitTestVisible="False"
>
<Ellipse.RenderTransform>
<ScaleTransform />
</Ellipse.RenderTransform>
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Color="#00FF0000" />
<GradientStop Color="#FFFF0000" Offset="0.25"/>
<GradientStop Color="#00FF0000" Offset="0.5"/>
<GradientStop Color="#FFFF0000" Offset="0.75"/>
<GradientStop Color="#00FF0000" Offset="1"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<!--Static symbol on top-->
<Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5"
Fill="#FFFF0000" x:Name="ellipse1"/>
</Canvas>
</ControlTemplate>
</esri:MarkerSymbol.ControlTemplate>
</esri:MarkerSymbol>

1.2 后台代码

Graphic g = new Graphic()
{
Geometry = mercator.FromGeographic(new MapPoint(107.2 , 36.1)),
Symbol = LayoutRoot.Resources["StrobeMarkerSymbol"] as Symbol
};
GraphicsLayer glayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
glayer.Graphics.Add(g);

this.myMap.Layers.Add(g);

2、实现直接高亮、闪烁显示

2.1 修改<VisualState x:Name="MouseOver">为: <VisualState x:Name="Normal">

2.1注释<VisualState x:Name="Normal" />为<!--<VisualState x:Name="Normal" />-->

ArcGIS api fo silverlight学习二(silverlight加载GraphicsLayer)的更多相关文章

  1. ArcGIS API for JavaScript 4.4 版本加载谷歌地图

    ArcGIS API for JavaScript 4.X 版本升级后,API发生了很大的变化. 其中就支持了WebEarth展示,主要是通过 esri/views/SceneView 实现的. 在新 ...

  2. ArcGIS api fo silverlight学习一(silverlight加载GeoServer发布的WMS地图)

    最好的学习资料ArcGIS api fo silverlight官网:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm 一. ...

  3. ArcGIS api fo silverlight学习三(利用ElementLayer实现鼠标悬浮弹出自定义窗体)

    接着上一节继续学习,本节主要是利用ElementLayer实现鼠标悬浮弹出自定义窗体 参考博文:http://www.cnblogs.com/luxiaoxun/p/3322218.html 一.新建 ...

  4. ArcGIS API for Silverlight 调用GP服务加载等值线图层

    原文:ArcGIS API for Silverlight 调用GP服务加载等值线图层 第二篇.Silverlight客户端调用GP服务 利用ArcGIS API for Silverlight实现G ...

  5. arcgis api for javascript 学习(七) 调用发布地图信息,并将地图属性信息输出到Excel表格---进阶版

    我们在arcgis api for javascript 学习(三)已经学习到了关于调用地图信息进行属性输出的问题,不过通过代码我们实现后会发现还是有一些小瑕疵的,比如我们只能单个数据属性的输出,如果 ...

  6. 深入java虚拟机学习 -- 类的加载机制(续)

    昨晚写 深入java虚拟机学习 -- 类的加载机制 都到1点半了,由于第二天还要工作,没有将上篇文章中的demo讲解写出来,今天抽时间补上昨晚的例子讲解. 这里我先把昨天的两份代码贴过来,重新看下: ...

  7. 轻松搞定 easyui datagrid 二次加载的问题(转)

    对于使用url方式的初学者,经常碰到重复请求的问题,这个问题的根源是因为一旦设置了url参数,Datagrid组件在实例化的时候就会做请求,如何避免二次加载这样问题呢,个人觉得注意以下两点基本就可以防 ...

  8. 【Java Web开发学习】Spring加载外部properties配置文件

    [Java Web开发学习]Spring加载外部properties配置文件 转载:https://www.cnblogs.com/yangchongxing/p/9136505.html 1.声明属 ...

  9. ArcGis API for JavaScript学习——加载地图

    ArcGis API for JavaScript开发笔记——加载地图 在这个例子中使用的离线部署的API(请参见 http://note.youdao.com/noteshare?id=f42865 ...

随机推荐

  1. Back-propagation, an introduction

    About Contact Subscribe   Back-propagation, an introduction Sanjeev Arora and Tengyu Ma  •  Dec 20, ...

  2. undefined reference to `dlopen'

    g++ -O0 -g3 -I. -Ithird/json -Ithird/core/include -Ithird/vite/include -Ithird/openfst-1.2.10/src/in ...

  3. jQuery 常用方法经典总结

    1.关于页面元素的引用通过jquery的$()引用元素包括通过id.class.元素名以及元素的层级关系及dom或者xpath条件等方法,且返回的对象为jquery对象(集合对象),不能直接调用dom ...

  4. Reed-Solomon码,QR

    原文: Reed–Solomon codes for coders参考: AN2407.pdfWIKI: 里德-所罗门码实现:Pypi ReedSolo #译注:最近看到了RS码,发现还挺有意思的,找 ...

  5. jdbc/DAO模式

    DAO设计模式: 1.DAO:      DAO设计模式是属于J2EE数据层的操作,使用DAO设计模式可以简化大量代码,增强程序的可移植性. 2.DAO各部分详解:DAO设计模式包括以下4个主要部分: ...

  6. Javascript中数组与字典(即map)的使用

    简述: 简单记录一下数据结构Map和数组, 其实在Javascript这种弱类型的脚本语言中,数组同时也就是字典,下面主要就是字典数组的简易使用   代码: 1. 数组中添加map <!DOCT ...

  7. 在实现和使用上与select和poll有很大差异

    在看此课程的读者,希望先阅读关于函数基础内容 函数定义与函数作用域 的章节,因为此课程或多或少会涉及函数基础的内容,而基础内容,本人放在 函数定义函数作用域 章节. 本文直接赘述函数参数与闭包,若涉及 ...

  8. iis 7.5 0x80004005 静态文件 html、js、css 500错误

    环境:iis 7.5 win7 64位 vs2012 问题:本地环境F5直接运行,没有任何问题,发布到IIS,静态文件不能访问,出现500错误,网上找了一堆解决办法,排除路径不正确,iis全部功能勾了 ...

  9. WPF嵌入Unity3D代码下载

    这不是大家想找的资源,这是给我的一个帖子用的.当然可以使用u3d自带编译器打开.这是给wpf 嵌入u3d的例子贴用http://bbs.csdn.net/topics/391853486?page=1 ...

  10. javascript序列化和反序列化

    一. JavaScript中的对象序列化(Serialize)和反序列化(Deserialize),简单实例: var obj = {id: 1, name: 'yoyo', age: undefin ...