码迷,mamicode.com
首页 > Windows程序 > 详细

C# GMap下提供一个高德地图

时间:2016-10-09 09:07:07      阅读:1190      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using GMap.NET.Internals;
using GMap.NET.Projections;

namespace GMap.NET.MapProviders
{
    public class AMapProvider : AMapProviderBase
    {
        private readonly string name = "AMap";
        private readonly string language = "zh_cn";
        private readonly Guid id = new Guid("F81F5FB4-0902-4686-BF5B-B2B1E4D47922");
        public static readonly AMapProvider Instance;
        private Random ran = new Random();
        private static string UrlFormat = "http://webrd0{0}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={1}&y={2}&z={3}&scale=1&ltype=3";
        public string Caption
        {
            get
            {
                return "高德地图";
            }
        }
        public override Guid Id
        {
            get { return this.id; }
        }

        public override string Name
        {
            get { return this.name; }
        }

        static AMapProvider()
        {
            Instance = new AMapProvider();
        }
        public AMapProvider()
        {

        }

        public override PureImage GetTileImage(GPoint pos, int zoom)
        {
            string url = MakeTileImageUrl(pos, zoom, language);
            return GetTileImageUsingHttp(url);
        }
        //http://wprd0{0}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={1}&y={2}&z={3}&scl=2&ltype=3
        private string MakeTileImageUrl(GPoint pos, int zoom, string language)
        {
            int serverID = ran.Next(1, 5);//1-4 
            return string.Format(UrlFormat, 4, pos.X, pos.Y, zoom);
        }
    }


    public abstract class AMapProviderBase : GMapProvider
    {
        protected GMapProvider[] overlays;
        public AMapProviderBase()
        {
            RefererUrl = "http://www.amap.com/";
            Copyright = string.Format("©{0} 高德地图 GPRS(@{0})", DateTime.Today.Year);
            MinZoom = 1;
            MaxZoom = 20;
        }

        public override GMapProvider[] Overlays
        {
            get
            {
                if (overlays == null)
                {
                    overlays = new GMapProvider[] { this };
                }
                return overlays;
            }
        }

        public override PureProjection Projection
        {
            get
            {
                return MercatorProjection.Instance;
            }
        }
    }
}

 

C# GMap下提供一个高德地图

标签:

原文地址:http://www.cnblogs.com/wjshan0808/p/5940823.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!