研究了下ArcGIS的Silverlight接口可以继承ObservableCollection实现特殊效果。下面的程序就是随机的在地图上显示图片
using System;
using System.Collections.ObjectModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using ESRI.ArcGIS.Client.Symbols;
namespace ArcGISEditorTest
{
public class Customers : ObservableCollection<Graphic>
{
Random random;
private static ESRI.ArcGIS.Client.Projection.WebMercator mercator =
new ESRI.ArcGIS.Client.Projection.WebMercator();
public Customers()
{
Load();
}
private void Load()
{
random = new Random();
PictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbol();
pictureMarkerSymbol.Source = new BitmapImage(new Uri("1.png", UriKind.Relative));
for (int i = 0; i < 3; i++)
{
Graphic g = new Graphic()
{
Geometry = mercator.FromGeographic(new MapPoint(random.Next(-180, 180), random.Next(-90, 90)))
};
g.Symbol = pictureMarkerSymbol;
Add(g);
}
}
void timer_Tick(object sender, EventArgs e)
{
ClearItems();
random = new Random();
PictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbol();
pictureMarkerSymbol.Source = new BitmapImage(new Uri("1.png",UriKind.Relative));
for (int i = 0; i < 10; i++)
{
Graphic g = new Graphic()
{
Geometry = mercator.FromGeographic(new MapPoint(random.Next(-180, 180), random.Next(-90, 90)))
};
g.Symbol = pictureMarkerSymbol;
Add(g);
}
}
}
}
本文介绍如何使用ArcGIS的Silverlight接口实现地图上的随机图片显示。通过继承ObservableCollection并利用定时器不断更新地图上的标记位置,演示了一种动态展示效果。程序实现了随机地理位置的图片放置,并展示了具体代码实现。
3821

被折叠的 条评论
为什么被折叠?



