ArcGIS API for Silverlight載入google地圖(後續篇)
之前在部落格中(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, -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[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, 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 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, -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[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, 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);
}
}
}
相關文章
- ArcGis api配合vue開發入門系列(一)引入arcgis api以及載入地圖APIVue地圖
- vue地圖視覺化 ArcGIS篇(3)Vue地圖視覺化
- ArcGIS API for JavaScript根據兩個點座標在地圖上畫線APIJavaScript地圖
- 使用Adobe Illustrator + ArcGIS繪製地圖 | Map Design Using ArcGIS + Adobe Illustrator地圖
- ArcGis API JS 4.X本地化部署與地圖的基礎使用APIJS地圖
- 不偏移的天地圖地圖服務-ArcGIS版地圖
- 高德地圖和google地圖適配地圖Go
- arcgis api for js入門開發系列十九圖層線上編輯APIJS
- ArcGIS Pro釋出地圖服務(影像、向量)地圖
- 前端 – 百度地圖 API 基礎入門前端地圖API
- ArcGIS地圖投影與座標系轉換的方法地圖
- 地圖採集車的那些事 | 載車篇地圖
- 從零開始釋出一個ArcGIS Server地圖服務Server地圖
- google books api 獲取圖書資訊GoAPI
- android基礎知識:Google提供的高效載入大圖方案AndroidGo
- MapBox載入GeoServer釋出的WMS地圖服務Server地圖
- 對接百度地圖API地圖API
- 基於Echarts的百度地圖疊加arcgis server的WMS圖層服務Echarts地圖Server
- JS腦圖--後續完善JS
- 百度地圖API基本使用(一)地圖API
- java接入高德地圖常用WEB APIJava地圖WebAPI
- 百度地圖API功能演示地圖API
- 30億次下載後,《地鐵跑酷》怎樣繼續提升影響力?
- [API 寫法] QQ 登入、微信登入、Facebook、google、蘋果登入APIGo蘋果
- 百度地圖API : 自定義標註圖示地圖API
- vue地圖視覺化 Cesium篇Vue地圖視覺化
- 百度地圖API圖示、文字、圖例與連線地圖API
- Silverlight實用竅門系列:4.Silverlight 4.0新增滑鼠右鍵選單和Silverlight全屏模式的進入退出。【附帶原始碼例項】...模式原始碼
- ArcGIS Pro 專題圖製作
- react中使用高德地圖的原生APIReact地圖API
- 淺談百度地圖API的坑地圖API
- 對接高德地圖API的總結地圖API
- Cesium載入ArcGIS Server4490且orgin -400 400的切片服務Server
- 某應用上架AG谷歌地圖載入失敗解決方案谷歌地圖
- ArcGISAPIforJavaScript4.x之載入2D、3D地圖APIJavaScript3D地圖
- AI已進入谷歌地圖AI谷歌地圖
- ArcGis api配合vue開發入門系列(二)距離以及面積的測量APIVue
- 部落格園去google廣告載入方法Go
- vue 地圖視覺化 mapbox篇(2)Vue地圖視覺化