主要参考网址
http://www.cnblogs.com/luxiaoxun/p/3802559.html
http://www.cnblogs.com/luxiaoxun/p/3463250.html
http://blog.csdn.net/onepiecehuiyu/article/details/19159565
GMap官方网址
http://greatmaps.codeplex.com/
WGS84,GCJ02,BD09坐标转换
http://blog.csdn.net/ma969070578/article/details/41013547
GMap总结
http://wenku.baidu.com/link?url=0JOy2cyTf8RUokKbfDelzSs29pvPnuzRNLqcT5VM451bnfKZ-gBmCg3QOFyuFut2zep_qBfp2bqqsQnaAHNGBdG5kVZoIvt8Rhgdg3raOdy
http://wenku.baidu.com/link?url=OKVBEUV5ekfPEcSRRdUyBAG6PN4Lh330gUZogBv30L92pgJECvvDPZ4hcz7h8XAt4SBw-9sTxDddeleYHvbYtDe2Y9vKtlvY2d_Pd-n4V9C
下面介绍如何在GMap.net官方控件的基础上添加国内高德地图以及添加墨卡托mercator坐标系在中国的翻版GCJ02转换投影
因为基本所有的gps芯片获取的都是wgs84坐标系数据,但是google中国,高德地图都是用的wgs84经过gcj02转换的投影,所以gmap.net获取gps数据后再地图上显示时,需要使用gcj的投影,而官方的GMap.net控件中只是标准的mercator投影
从官网下载GMap.net控件,里面是没有高德地图的所以需要添加,并且原来官方控件中是没有MercatorProjectionGCJ投影换算的。

1,http://greatmaps.codeplex.com/ 官网下载GMap.net控件

2,在GMap.NET.MapProviders文件夹下,建立AMap文件夹,在该文件夹下新建AMapProvider.cs AMapSateliteProvider.cs文件,如图所示

AMapProvider.cs文件

using System;
using GMap.NET;
using GMap.NET.MapProviders;
using GMap.NET.Projections;namespace GMap.NET.MapProviders
{public abstract class AMapProviderBase : GMapProvider{private GMapProvider[] overlays;public AMapProviderBase(){this.MaxZoom = null;base.RefererUrl = "http://www.amap.com/";base.Copyright = string.Format("©{0} 高德软件 Image© DigitalGlobe & chinasiwei | AIRBUS & EastDawn", DateTime.Today.Year);}public override GMapProvider[] Overlays{get{if (this.overlays == null){this.overlays = new GMapProvider[] { this };}return this.overlays;}}public override PureProjection Projection{get{return MercatorProjectionGCJ.Instance;}}}public class AMapProvider : AMapProviderBase{private readonly Guid id = new Guid("EF3DD303-3F74-4938-BF40-232D0595EE88");public static readonly AMapProvider Instance = new AMapProvider();//private readonly string name = Resources.Strings.AMap;private readonly string name = "AMap";private static readonly string UrlFormat = "http://webrd04.is.autonavi.com/appmaptile?x={0}&y={1}&z={2}&lang=zh_cn&size=1&scale=1&style=7";public override PureImage GetTileImage(GPoint pos, int zoom){string url = this.MakeTileImageUrl(pos, zoom, GMapProvider.LanguageStr);return base.GetTileImageUsingHttp(url);}private string MakeTileImageUrl(GPoint pos, int zoom, string language){string str = string.Format(UrlFormat, pos.X, pos.Y, zoom);Console.WriteLine("url:" + str);return str;}public override Guid Id{get{return this.id;}}public override string Name{get{return this.name;}}}}

AMapSateliteProvider.cs文件如下

namespace GMap.NET.MapProviders
{using GMap.NET;using System;public class AMapSateliteProvider : AMapProviderBase{private readonly Guid id = new Guid("FCA94AF4-3467-47c6-BDA2-6F52E4A145BC");public static readonly AMapSateliteProvider Instance = new AMapSateliteProvider();//private readonly string name = Resources.Strings.AMapSatellite;private readonly string name = "AMapSatellite";private static readonly string UrlFormat = "http://webst04.is.autonavi.com/appmaptile?x={0}&y={1}&z={2}&lang=zh_cn&size=1&scale=1&style=6";public override PureImage GetTileImage(GPoint pos, int zoom){string url = this.MakeTileImageUrl(pos, zoom, GMapProvider.LanguageStr);return base.GetTileImageUsingHttp(url);}private string MakeTileImageUrl(GPoint pos, int zoom, string language){string str = string.Format(UrlFormat, pos.X, pos.Y, zoom);Console.WriteLine("url:" + str);return str;}public override Guid Id{get{return this.id;}}public override string Name{get{return this.name;}}}
}

3,在GMap.NET.Projections文件夹下添加MercatorProjectionGCJ.cs文件如下

namespace GMap.NET.Projections
{using GMap.NET;using System;public class MercatorProjectionGCJ : PureProjection{internal double a = 6378245.0;internal double ee = 0.0066934216229659433;public static readonly MercatorProjectionGCJ Instance = new MercatorProjectionGCJ();private static readonly double MaxLatitude = 85.05112878;private static readonly double MaxLongitude = 180.0;private static readonly double MinLatitude = -85.05112878;private static readonly double MinLongitude = -180.0;private readonly GSize tileSize = new GSize(0x100L, 0x100L);public override GPoint FromLatLngToPixel(double lat, double lng, int zoom){double[] latlng = new double[2];this.transform(lat, lng, latlng);lat = latlng[0];lng = latlng[1];GPoint empty = GPoint.Empty;lat = PureProjection.Clip(lat, MinLatitude, MaxLatitude);lng = PureProjection.Clip(lng, MinLongitude, MaxLongitude);double num = (lng + 180.0) / 360.0;double num2 = Math.Sin((lat * 3.1415926535897931) / 180.0);double num3 = 0.5 - (Math.Log((1.0 + num2) / (1.0 - num2)) / 12.566370614359172);GSize tileMatrixSizePixel = this.GetTileMatrixSizePixel(zoom);long width = tileMatrixSizePixel.Width;long height = tileMatrixSizePixel.Height;empty.X = (long)PureProjection.Clip((num * width) + 0.5, 0.0, (double)(width - 1L));empty.Y = (long)PureProjection.Clip((num3 * height) + 0.5, 0.0, (double)(height - 1L));return empty;}public override PointLatLng FromPixelToLatLng(long x, long y, int zoom){PointLatLng empty = PointLatLng.Empty;GSize tileMatrixSizePixel = this.GetTileMatrixSizePixel(zoom);double width = tileMatrixSizePixel.Width;double height = tileMatrixSizePixel.Height;double num3 = (PureProjection.Clip((double)x, 0.0, width - 1.0) / width) - 0.5;double num4 = 0.5 - (PureProjection.Clip((double)y, 0.0, height - 1.0) / height);empty.Lat = 90.0 - ((360.0 * Math.Atan(Math.Exp((-num4 * 2.0) * 3.1415926535897931))) / 3.1415926535897931);empty.Lng = 360.0 * num3;PointLatLng lng2 = new PointLatLng();double[] latlng = new double[2];this.transform(empty.Lat, empty.Lng, latlng);lng2.Lat = latlng[0];lng2.Lng = latlng[1];empty.Lat -= lng2.Lat - empty.Lat;empty.Lng -= lng2.Lng - empty.Lng;return empty;}public override GSize GetTileMatrixMaxXY(int zoom){long num = ((int)1) << zoom;return new GSize(num - 1L, num - 1L);}public override GSize GetTileMatrixMinXY(int zoom){return new GSize(0L, 0L);}private static bool outOfChina(double lat, double lon){if (((lon >= 72.004) && (lon <= 137.8347)) && ((lat >= 0.8293) && (lat <= 55.8271))){return false;}return true;}private void transform(double wgLat, double wgLon, double[] latlng){if (outOfChina(wgLat, wgLon)){latlng[0] = wgLat;latlng[1] = wgLon;}else{double num = this.transformLat(wgLon - 105.0, wgLat - 35.0);double num2 = this.transformLon(wgLon - 105.0, wgLat - 35.0);double a = (wgLat / 180.0) * 3.1415926535897931;double d = Math.Sin(a);d = 1.0 - ((this.ee * d) * d);double num5 = Math.Sqrt(d);num = (num * 180.0) / (((this.a * (1.0 - this.ee)) / (d * num5)) * 3.1415926535897931);num2 = (num2 * 180.0) / (((this.a / num5) * Math.Cos(a)) * 3.1415926535897931);latlng[0] = wgLat + num;latlng[1] = wgLon + num2;}}private double transformLat(double x, double y){double num = ((((-100.0 + (2.0 * x)) + (3.0 * y)) + ((0.2 * y) * y)) + ((0.1 * x) * y)) + (0.2 * Math.Sqrt(Math.Abs(x)));num += (((20.0 * Math.Sin((6.0 * x) * 3.1415926535897931)) + (20.0 * Math.Sin((2.0 * x) * 3.1415926535897931))) * 2.0) / 3.0;num += (((20.0 * Math.Sin(y * 3.1415926535897931)) + (40.0 * Math.Sin((y / 3.0) * 3.1415926535897931))) * 2.0) / 3.0;return (num + ((((160.0 * Math.Sin((y / 12.0) * 3.1415926535897931)) + (320.0 * Math.Sin((y * 3.1415926535897931) / 30.0))) * 2.0) / 3.0));}private double transformLon(double x, double y){double num = ((((300.0 + x) + (2.0 * y)) + ((0.1 * x) * x)) + ((0.1 * x) * y)) + (0.1 * Math.Sqrt(Math.Abs(x)));num += (((20.0 * Math.Sin((6.0 * x) * 3.1415926535897931)) + (20.0 * Math.Sin((2.0 * x) * 3.1415926535897931))) * 2.0) / 3.0;num += (((20.0 * Math.Sin(x * 3.1415926535897931)) + (40.0 * Math.Sin((x / 3.0) * 3.1415926535897931))) * 2.0) / 3.0;return (num + ((((150.0 * Math.Sin((x / 12.0) * 3.1415926535897931)) + (300.0 * Math.Sin((x / 30.0) * 3.1415926535897931))) * 2.0) / 3.0));}public override double Axis{get{return 6378137.0;}}public override RectLatLng Bounds{get{return RectLatLng.FromLTRB(MinLongitude, MaxLatitude, MaxLongitude, MinLatitude);}}public override double Flattening{get{return 0.0033528106647474805;}}public override GSize TileSize{get{return this.tileSize;}}}
}

4,编译,在bin/Debug文件夹下生成GMap.NET.Core.dll文件,然后在工程中引用这个dll文件,即可出现高德地图

GMap.net控件学习记录相关推荐

  1. xml 硕正报表_硕正控件学习记录

    最近做项目接触到了很强大的Web套件工具:硕正富文本应用套件,特此记录下学习插件的点滴: ********************* TreeList/FreeForm *************** ...

  2. 【Autojs教程】03-Autojs 控件学习 | 淘宝关注店铺取消实战

    [Autojs教程]03-Autojs 控件学习 | 淘宝关注店铺取消实战 写在前面 本篇教程构思良久,笔者希望通过一个实际的例子,将枯燥无味的函数放到程序中进行讲解,前面一部分是理论教程(还是更加希 ...

  3. CGRidCtrl控件 学习心得

    wuqinxiang0我的:收件箱资源博客空间设置|帮助|退出 首页 业界 移动 云计算 研发 论坛 博客 下载 更多 狂想盼盼 积累点点滴滴 目录视图 摘要视图 订阅 新版论坛系列介绍之二--功能介 ...

  4. winform控件学习(2)—HScrollBar控件和MaskedTextBox控件

    好几天没系统的总结了,感觉忘得很快,还是记录下来比较好.废话不说了,接着介绍几个使用频率比较高的控件. 1.HScrollBar控件:在窗体实现一个水平滚动的滚动条,以便在较长的项列表中或大量信息中转 ...

  5. IOS学习笔记(四)之UITextField和UITextView控件学习

    IOS学习笔记(四)之UITextField和UITextView控件学习(博客地址:http://blog.csdn.net/developer_jiangqq) Author:hmjiangqq ...

  6. ListView控件学习系列2-编辑ListView(Edit,Update,Insert,Delete)

    目录: ListView控件学习系列1-了解ListView控件 ListView控件学习系列2-编辑ListView ListView控件学习系列3-ListView选择,排序,分页 ListVie ...

  7. 实现Repeater控件的记录单选(二)

    前一篇<实现Repeater控件的记录单选>http://www.cnblogs.com/insus/p/7426334.html 虽然可以实现对Repeater控件的记录进行单选,但是, ...

  8. AJAX Control Toolkit 控件学习(转自csdn山巅)

    AJAX Control Toolkit 控件学习 2006-1-16 ToggleButton 关联ASP.NET CheckBox控件 RoundedCorder 造就圆角框 PasswordSt ...

  9. wxpython制作表格界面_[Python] wxPython 菜单栏控件学习总结(原创)

    1.总结 1.大体创建过程 1.创建一个 菜单栏 : menuBar = wx.MenuBar() 相当于这个白色地方,没有File这个菜单 2.创建 菜单 : fileMenu = wx.Menu( ...

最新文章

  1. 怎么给html页面添加网格线,html – 如何使用css制作网格(如图纸网格)?
  2. 黑色星期五Friday the Thirteenth
  3. Python 三十大实践、建议和技巧
  4. java类接口实验_实验3_Java类的继承和接口的定义和使用
  5. SparkStreaming从Kafka读取数据两种方式
  6. 分布式入门:常用的分布式基础算法
  7. 获取其他线程的数据用 queue, 多进程Q
  8. 【SSH高速进阶】——struts2简单的实例
  9. leetcode 231. 2的幂
  10. CSharpThinking---C# 要点(附加三)
  11. 从零基础入门Tensorflow2.0 ----一、3.2 实战深度神经网络(批归一化)
  12. 伯克利的云计算报告(中)
  13. Linux间共享文件夹
  14. 【原理图和PCB】基于单片机的超声波测距仪设计
  15. 【NVMe2.0b 8】NVMe 队列仲裁机制
  16. PS 一键生成Android各个尺寸的图标
  17. android 动态贴纸,萌拍动态贴纸相机软件下载
  18. cancase vector_vector CANcase 1630
  19. deeplearning4j的官网
  20. 【软件工程】 软件设计阶段

热门文章

  1. 漫画,开学季来临,用Python告诉你,女朋友应该从全国的哪个城市找
  2. Qt使用C++封装qml自定义图形控件(QQuickPaintedItem)
  3. 场强测试软件,无线场强测试系统的软件结构设计与实现
  4. Oracle创建存储过程语法
  5. Unity 开发总结之onValueChanged事件
  6. root后怎么刷回官方,recovery刷入root
  7. 王道论坛机试指南学习笔记(四)图论
  8. 计算机上的音乐怎么找,得到APP里面的音频怎样可以在电脑上面听呢? 谢谢了...
  9. 2008年汽车电子的9大应用开发和改进亮点
  10. UE4 高频 Fatal Error: exiting due to D3D device being lost解决方法: