博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# GMap下提供一个高德地图
阅读量:5162 次
发布时间:2019-06-13

本文共 2345 字,大约阅读时间需要 7 分钟。

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

 

转载于:https://www.cnblogs.com/wjshan0808/p/5940823.html

你可能感兴趣的文章
.NET CLR基本术语
查看>>
ubuntu的home目录下,Desktop等目录消失不见
查看>>
建立,查询二叉树 hdu 5444
查看>>
[Spring框架]Spring 事务管理基础入门总结.
查看>>
2017.3.24上午
查看>>
Python-常用模块及简单的案列
查看>>
LeetCode 159. Longest Substring with At Most Two Distinct Characters
查看>>
LeetCode Ones and Zeroes
查看>>
基本算法概论
查看>>
jquery动态移除/增加onclick属性详解
查看>>
JavaScript---Promise
查看>>
暖暖的感动
查看>>
Java中的日期和时间
查看>>
Django基于admin的stark组件创建(一)
查看>>
抛弃IIS,利用FastCGI让Asp.net与Nginx在一起
查看>>
C. Tanya and Toys_模拟
查看>>
springboot jar包运行中获取资源文件
查看>>
基于FPGA实现的高速串行交换模块实现方法研究
查看>>
Java Scala获取所有注解的类信息
查看>>
delphi ,安装插件
查看>>