ArcGIS for Silverlight在地图上随机显示图片

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


    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值