arcgis api for silverlight自己写个图层,实现对OpenStreetMap的访问

来源:互联网 发布:阿里云 pop3 编辑:程序博客网 时间:2024/04/27 14:07

 继承TiledMapServiceLayer,实现GetTileUrl方法。

   public class OpenStreetMapLayer : TiledMapServiceLayer
    {
        private static string[] subDomains = { "a", "b", "c" };
        private const string baseUrl = "http://{0}.tile.openstreetmap.org/{1}/{2}/{3}.png";
        public override void Initialize()
        {
            this.FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892)
            {
                SpatialReference = new SpatialReference(102113)
            };

            double cornerCoordinate = 20037508.3427892;//from wkid 3857/102100

            // This layer's spatial reference
            this.SpatialReference = new SpatialReference(102113);
            // Set up tile information. Each tile is 256x256px, 19 levels.
            this.TileInfo = new TileInfo()
            {
                Height = 256,
                Width = 256,
                Origin = new MapPoint(-cornerCoordinate, cornerCoordinate) { SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102113) },
                Lods = new Lod[19]
            };
            // Set the resolutions for each level. Each level is half the resolution of the previous one.
            double resolution = cornerCoordinate * 2 / 256;
            for (int i = 0; i < TileInfo.Lods.Length; i++)
            {
                TileInfo.Lods[i] = new Lod() { Resolution = resolution };
                resolution /= 2;
            }
            // Call base initialize to raise the initialization event
            base.Initialize();
        }

        public override string GetTileUrl(int level, int row, int col)
        {
            // Select a subdomain based on level/row/column so that it will always
            // be the same for a specific tile. Multiple subdomains allows the user
            // to load more tiles simultanously. To take advantage of the browser cache
            // the following expression also makes sure that a specific tile will always
            // hit the same subdomain.
            string subdomain = subDomains[(level + col + row) % subDomains.Length];
            return string.Format(baseUrl, subdomain, level, col, row);
        }
    }

可下载http://download.csdn.net/detail/leesmn/3634647试试效果

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 戴牙冠前临时补牙材料掉了怎么办 设备间在业主家里每次上锁怎么办 成都安全员证原件丢了并过期怎么办 记不施工员证书号了怎么办 优易学车学员版登录不了怎么办 先科移动dvd主板坏了怎么办 离职单位不出劳动解除书怎么办 离职后一级建造师注册证怎么办 京牌货车报废挂靠公司不给办怎么办 二建挂靠注册证书到期了怎么办 二建证书挂靠公司不给钱怎么办 二建拿到证书原单位不解锁怎么办 凯云软件清单锁定只读了怎么办 苹果笔记本鼠标触摸板没反应怎么办 苹果笔记本键盘和触摸板失灵怎么办 苹果手机输入密码显示已停用怎么办 苹果7p手机刷机黑屏了怎么办 苹果5s来电接听屏幕卡顿怎么办? 手机摔了一下触屏失灵怎么办 小米手机摔了一下触屏失灵怎么办 苹果6sp触摸ic坏了怎么办 苹果4s屏幕摔裂了怎么办 新换的手机内屏颜色太亮怎么办 苹果手机摔了一下屏幕失灵怎么办 苹果手机6s屏幕坏了怎么办 苹果6s屏幕摔坏了怎么办 苹果手机屏幕进油了屏幕变暗怎么办 苹果手机不小心屏幕进油了怎么办 苹果6充电插口螺丝口坏了怎么办 苹果5s手机安装屏幕翘边怎么办 苹果手机摔了一下触摸屏失灵怎么办 苹果手机摔了下触摸屏失灵怎么办 苹果6老是屏幕失灵或者闪屏怎么办 华为荣耀8手触摸屏乱跳失灵怎么办 苹果5s屏幕有半边竖纹怎么办 苹果5s电源键坏了怎么办 苹果6s手机触屏失灵怎么办 不能取电池的手机触屏不灵怎么办? 7p主板触摸ic坏了怎么办 小米六手机摔了一下屏幕失灵怎么办 魅蓝5s触屏失灵怎么办