zoukankan      html  css  js  c++  java
  • 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); //百度地图中心位置:郑州
  • 相关阅读:
    python等缩进语言的词法分析实现
    收集Android程序测试代码覆盖率
    对语言之争的看法
    关于asmlinkage
    洛谷 P4171 [JSOI2010] 满汉全席(2sat)
    Codeforces Round #748 (Div. 3)解题报告
    洛谷 P1712 [NOI2016] 区间(尺取法、线段树)
    洛谷 P4782 【模板】2SAT 问题
    洛谷 P3513 [POI2011]KONConspiracy(2sat方案数)
    梦见和深爱的女孩牵着手,竟然从梦中幸福惊醒,醒后一片悲伤~~
  • 原文地址:https://www.cnblogs.com/xinzheng/p/5421414.html
Copyright © 2011-2022 走看看