Arcgis for Sliverlight 加载百度地图

加载百度地图类

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);

        }
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zkcharge

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值