arcgis api for silverlight自己寫個圖層,實現對google map的訪問

來源:互聯網
上載者:User

arcgis api for silverlight 中的ArcGISTiledMapServiceLayer圖層,繼承自TiledMapServiceLayer。如果想實現自己的緩衝地圖圖層,繼承它並重載GetTileUrl方法就可以。arcgis api for silverlight 內部會計算當前訪問的縮放等級level,切片二維編號row,col。這些參數暴露給GetTileUrl方法,在這個方法裡面設定訪問google靜態地圖的Url地址。

public class GoogleMapLayer : TiledMapServiceLayer
    {
        private const double cornerCoordinate = 20037508.3427892;
        public override void Initialize()
        {
            this.FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892)
            {
                SpatialReference = new SpatialReference(102100)
            };
            // This layer's spatial reference
            this.SpatialReference = new SpatialReference(102100);
            // 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(102100) },
                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)
        {
            string baseUrl = "http://mt2.google.cn/vt/v=w2.116&hl=zh-CN&gl=cn&x={0}&y={1}&z={2}&s=G";

            return string.Format(baseUrl, col, row, level);
        }
    }

 

 也可下載http://download.csdn.net/detail/leesmn/3634647試試效果

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.