• GMap.Net中使用百度地图


    public abstract class BaiduMapProviderBase : GMapProvider
        { 
            public BaiduMapProviderBase()
            {
                MaxZoom = null;
                RefererUrl = "http://map.baidu.com";
                Copyright = string.Format("©{0} Baidu Corporation, ©{0} NAVTEQ, ©{0} Image courtesy of NASA", DateTime.Today.Year);
            }
    
            public override GMap.NET.PureProjection Projection
            {
                get { return MercatorProjection.Instance; }
            }
    
            GMapProvider[] overlays;
            public override GMapProvider[] Overlays
            {
                get
                {
                    if (overlays == null)
                    {
                        overlays = new GMapProvider[] { this };
                    }
                    return overlays;
                }
            }
        }
    public class BaiduMapProvider : BaiduMapProviderBase
        {
            static BaiduMapProvider()
            {
                Instance = new BaiduMapProvider();
            }
            public static readonly BaiduMapProvider Instance;
            readonly Guid id = new Guid("47C1561B-C785-4EBF-9EC3-2CF0E416E219");
            public override GMap.NET.PureImage GetTileImage(GMap.NET.GPoint pos, int zoom)
            {
                try
                {
                    string url = MakeTileImageUrl(pos, zoom, LanguageStr);
                    return GetTileImageUsingHttp(url);
                }
                catch 
                {
                    return null;
                }
            }
            string MakeTileImageUrl(GPoint pos, int zoom, string language)
            {
                zoom = zoom - 1; 
                var offsetX = Math.Pow(2, zoom); 
                var offsetY = offsetX - 1; 
                var numX = pos.X - offsetX;
                var numY = -pos.Y + offsetY; 
                zoom = zoom + 1; 
                var num = (pos.X + pos.Y) % 8 + 1;
                var x = numX.ToString().Replace("-", "M");
                var y = numY.ToString().Replace("-", "M");
                //原来:http://q3.baidu.com/it/u=x=721;y=209;z=12;v=014;type=web&fm=44
                //更新:http://online1.map.bdimg.com/tile/?qt=tile&x=23144&y=6686&z=17&styles=pl
                //string url = string.Format(UrlFormat, num, x, y, zoom, "014", "web", "44"); 
                string url = string.Format(UrlFormat, x, y, zoom);
                return url;
            }
            //static readonly string UrlFormat = "http://q{0}.baidu.com/it/u=x={1};y={2};z={3};v={4};type={5}&fm={6}";
            static readonly string UrlFormat = "http://online1.map.bdimg.com/tile/?qt=tile&x={0}&y={1}&z={2}&styles=pl";
            public override Guid Id
            {
                get { return id; }
            }
            readonly string name = "BaiduMap";
            public override string Name
            {
                get
                {
                    return name;
                }
            }
        }
    mapControl.Position = new PointLatLng(21.5053134635657, 67.8822576999664); //百度地图中心位置:郑州
  • 相关阅读:
    [转载] <深入理解.NET> 导读
    32bit Assembler is Easy, why and how to develop using the assembler; start learning to program in Assembly now!
    一致代码段,非一致代码段
    Data Mining、Data Warehousing、OLAP三者关系 [收藏]
    对比Windows和Linux两系统的动态库
    Win32汇编开发环境介绍和RadAsm简明教程
    How to make a 32 bit protected mode boot sector.
    龙芯CPU 参数
    并发编程第一章简单介绍和环境准备
    并发编程第三章线程创建、原理、常用线程方法
  • 原文地址:https://www.cnblogs.com/xinzheng/p/5421414.html
Copyright © 2020-2023  润新知