之前在博客中(http://blog.csdn.net/taomanman/article/details/8019687)提到的加载google地图方案,因为google地址问题,看不到图了,发现是URL地址变换造成的。
现将如下三个类公布出来,源码如下:
using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Geometry; namespace MapClient.CommonClass { public class GoogleMapLayer : TiledMapServiceLayer { private const double cornerCoordinate = 20037508.3427892; public string _baseURL = "t@131"; //google地形图 public override void Initialize() { ESRI.ArcGIS.Client.Projection.WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator(); this.FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892) { SpatialReference = new SpatialReference(102100) }; //图层的空间坐标系 this.SpatialReference = new SpatialReference(102100); // 建立切片信息,每个切片大小256*256px,共16级. this.TileInfo = new TileInfo() { Height = 256,Width = 256,Origin = new MapPoint(-cornerCoordinate,cornerCoordinate) { SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100) },Lods = new Lod[18] }; //为每级建立方案,每一级是前一级别的一半. double resolution = cornerCoordinate * 2 / 256; for (int i = 0; i < TileInfo.Lods.Length; i++) { TileInfo.Lods[i] = new Lod() { Resolution = resolution }; resolution /= 2; } // 调用初始化函数 base.Initialize(); } public override string GetTileUrl(int level,int row,int col) { string url = "http://mt1.google.cn/vt/lyrs=" + _baseURL + ",r@225000000&&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Ga"; if (_baseURL == "t@131") { //地形图 url = "http://mt1.google.cn/vt/lyrs=" + _baseURL + ",r@225000000&&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Ga"; } if (_baseURL == "s@132") { //卫星图 url = "http://mt3.google.cn/vt/lyrs=" + _baseURL + "&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=G"; } if (_baseURL == "m@225000000") { //街道图 url = "http://mt1.google.cn/vt/lyrs=" + _baseURL + "&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Ga"; } return string.Format(url); } } }
using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Geometry; namespace MapClient.CommonClass { public class GoogleMapRoadLayer : TiledMapServiceLayer { private const double cornerCoordinate = 20037508.3427892; private string _baseURL = "m@225000000"; //google交通图 public override void Initialize() { ESRI.ArcGIS.Client.Projection.WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator(); this.FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.3427892,Lods = new Lod[19] }; //为每级建立方案,每一级是前一级别的一半. double resolution = cornerCoordinate * 2 / 256; for (int i = 0; i < TileInfo.Lods.Length; i++) { TileInfo.Lods[i] = new Lod() { Resolution = resolution }; resolution /= 2; } // 调用初始化函数 base.Initialize(); } public override string GetTileUrl(int level,r@225000000&&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Ga"; } if (_baseURL == "s@132") { //卫星图 url = "http://mt3.google.cn/vt/lyrs=" + _baseURL + "&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=G"; } if (_baseURL == "m@225000000") { //街道图 url = "http://mt1.google.cn/vt/lyrs=" + _baseURL + "&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Ga"; } return string.Format(url); } } }
using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Geometry; namespace MapClient.CommonClass { public class GoogleMapSateliateLayer : TiledMapServiceLayer { private const double cornerCoordinate = 20037508.3427892; private string _baseURL = "s@132"; //google卫星图 public override void Initialize() { ESRI.ArcGIS.Client.Projection.WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator(); this.FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.3427892,Lods = new Lod[20] }; //为每级建立方案,每一级是前一级别的一半. double resolution = cornerCoordinate * 2 / 256; for (int i = 0; i < TileInfo.Lods.Length; i++) { TileInfo.Lods[i] = new Lod() { Resolution = resolution }; resolution /= 2; } // 调用初始化函数 base.Initialize(); } public override string GetTileUrl(int level,r@225000000&&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Ga"; } if (_baseURL == "s@132") { //卫星图 url = "http://mt3.google.cn/vt/lyrs=" + _baseURL + "&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=G"; } if (_baseURL == "m@225000000") { //街道图 url = "http://mt1.google.cn/vt/lyrs=" + _baseURL + "&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=Ga"; } return string.Format(url); } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。