Arcgis for Sliverlight 加载百度地图

来源:互联网 发布:测绘数据数据转换工具 编辑:程序博客网 时间:2024/06/05 03:38

加载百度地图类

using System;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.Shapes;using ESRI.ArcGIS.Client;using ESRI.ArcGIS.Client.Geometry;public class baidumap : TiledMapServiceLayer{    private const double cornerCoordinate = 20037508.3427892;    private string _baseURL = "Image"; //百度影像    public override void Initialize()    {        ESRI.ArcGIS.Client.Projection.WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();        this.FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892)        {            SpatialReference = new SpatialReference(102100)        };        //this.FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(9001735.65795624, 2919532.04645186, 19020489.8293508, 8346937.81802098)        //{        //    SpatialReference = new SpatialReference(102100)        //};        //图层的空间坐标系        this.SpatialReference = new SpatialReference(102100);        // 建立切片信息,每个切片大小256*256px,共16级.        this.TileInfo = new TileInfo()        {            Height = 256,            Width = 256,            Origin = new MapPoint(-cornerCoordinate, cornerCoordinate) { SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100) },            Lods = new Lod[32]        };        //为每级建立方案,每一级是前一级别的一半.        double resolution = cornerCoordinate * 2 / 256;        for (int i = 0; i < TileInfo.Lods.Length; i++)        {            TileInfo.Lods[i] = new Lod() { Resolution = resolution };            resolution /= 2;        }        // 调用初始化函数        base.Initialize();    }    string _mapType = "";    public override string GetTileUrl(int level, int row, int col)    {        int zoom = level - 1;        int offsetX = Convert.ToInt32(Math.Pow(2, zoom));        int offsetY = offsetX - 1;        int numX = col - offsetX;        int numY = (-row) + offsetY;        zoom = level + 1;        int num = (col + row) % 8 + 1;        String url = null;        if (MapType == "Map")        {            url = "http://online" + num + ".map.bdimg.com/tile/?qt=tile&x=" + numX + "&y=" + numY + "&z=" + zoom + "&styles=pl";        }        else if (MapType == "Image")        {            url = " http://shangetu"+num+".map.bdimg.com/it/u=x=" + numX + ";y=" + numY + ";z=" + zoom + ";v=009;type=sate&fm=46";        }        else if (MapType == "POI")        {            url = "http://online"+num+".map.bdimg.com/tile/?qt=tile&x=" + numX + "&y=" + numY + "&z=" + zoom + "&styles=sl&v=020";        }        return string.Format(url);    }    public string MapType    {        get        {            return _mapType;        }        set        {            _mapType = value;        }    }}
影像+标注

 

private void button2_Click(object sender, RoutedEventArgs e)        {            this.MyMap.Layers.Clear();            baidumap Alayer = new baidumap();            Alayer.MapType = "Image";            Alayer.Visible = true;            this.MyMap.Layers.Add(Alayer);            baidumap APOIlayer = new baidumap();            APOIlayer.MapType = "POI";            APOIlayer.Visible = true;            this.MyMap.Layers.Add(APOIlayer);            //中国范围            Envelope FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(9001735.65795624, 2919532.04645186, 19020489.8293508, 8346937.81802098)            {                SpatialReference = new SpatialReference(102100)            };            this.MyMap.ZoomTo(FullExtent);        }

矢量地图

    
   private void buttonMap_Click(object sender, RoutedEventArgs e)        {            this.MyMap.Layers.Clear();            baidumap Alayer = new baidumap();            Alayer.MapType = "Map";            Alayer.Visible = true;            this.MyMap.Layers.Add(Alayer);            //中国范围            Envelope FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(9001735.65795624, 2919532.04645186, 19020489.8293508, 8346937.81802098)            {                SpatialReference = new SpatialReference(102100)            };            this.MyMap.ZoomTo(FullExtent);        }
 

0 0
原创粉丝点击