研究了下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);
}
}
}
}