最新silverlight调用google地形图包含矢量

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;
namespace sdhbgis.Dal
{




    public class GoogleMapLayerTerrain : TiledMapServiceLayer
    {
        private const double cornerCoordinate = 20037508.3427892;
        public override void Initialize()
        {
            //this.Opacity = 0.5;


            this.FullExtent = new


            ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787);//(-180,-85.0511287798066,180, 85.0511287798066)


            {


                SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100);


            };


            this.SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100);


            //this.InitialExtent = this.FullExtent;


            this.TileInfo = new TileInfo()


            {


                Height = 256,


                Width = 256,


                Origin = new ESRI.ArcGIS.Client.Geometry.MapPoint(-20037508.342787, 20037508.342787)//Origin = new ESRI.ArcGIS.Geometry.MapPoint(-180, 90)


                {


                    SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100)


                },


                Lods = new Lod[20]


            };


            double resolution = 156543.033928;


            for (int i = 0; i < TileInfo.Lods.Length; i++)
            {


                TileInfo.Lods[i] = new Lod() { Resolution = resolution };


                resolution /= 2;


            }


            base.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();
        }
        private string setType="3";


        public string SetType
        {
            get { return setType; }
            set { setType = value; }
        }


        public override string GetTileUrl(int level, int row, int col)
        {
            //    int num = (col + (2 * row)) % 4;
            //    string str = "&s=";
            //    string str2 = "Galileo";
            //    int length = ((col * 3) + row) % 8;
            //    str = str + str2.Substring(0, length);
            //    if (row >= 0x2710)
            //    {
            //    }
            //    string str3 = "http://khm" + num.ToString() + ".google.com/kh=49&x=";
            //    return (str3 + col.ToString() + "&y=" + row.ToString() + "&z=" + level.ToString() + str);


            //  string baseUrl = "http://mt2.google.cn/vt/lyrs=m@167000000&hl=zh-CN&gl=cn&s=Galil&x=";//矢量图
           // string baseUrl = "http://mt2.google.cn/vt/lyrs=s@167000000&hl=zh-CN&gl=cn&s=Galil&x=";//卫星图
            //string cbaseUrl = "http://mt2.google.cn/vt/lyrs=m@167000000&hl=zh-CN&gl=cn&x=0&y=0&z=0&s=Galil";//市区图
          //  string  baseUrl = "http://mt2.google.cn/vt/lyrs=t@128&hl=zh-CN&gl=cn&s=Galil&x=";//地形
            //if (SetType == "1")
            //{
            //    baseUrl = "http://mt2.google.cn/vt/lyrs=m@167000000&hl=zh-CN&gl=cn&s=Galil&x=";//矢量
            //}
            //else if (SetType == "2")
            //{
            //    baseUrl = "http://mt2.google.cn/vt/lyrs=s@167000000&hl=zh-CN&gl=cn&s=Galil&x=";//卫星
            //}
            //else
            //{
            //    baseUrl = "http://mt2.google.cn/vt/lyrs=t@128&hl=zh-CN&gl=cn&s=Galil&x=";//地形
            //}
            string url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=t@169000000,m@169000000&v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Galil";
           // string url = baseUrl + col.ToString() + "&y=" + row.ToString() + "&z=" + level.ToString() + "";
           // string url2 = "http://api.tiles.virtualearth.net/api/GetMap.ashx?c=" + row.ToString() + "," + col.ToString() + "&z=" + level.ToString() + "&b=h,mkt.en-US&z=4&token={token}";
            //string url3 = "http://mt{0}.google.cn/vt/lyrs=s@88&gl=cn&x=";
           // string ur4 = url3 + col.ToString() + "&y=" + row.ToString() + "&z=" + level.ToString() + "";
            return url;
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

奔跑的熊猫

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

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

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

打赏作者

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

抵扣说明:

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

余额充值