原文: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 for Silverlight加载google地图(后续篇)的更多相关文章

  1. ArcGIS API for Silverlight 加载google地图

    原文:ArcGIS API for Silverlight 加载google地图 using System; using System.Net; using System.Windows; using ...

  2. Arcgis api For silverlight 加载QQ地图

    原文 http://www.cnblogs.com/thinkaspx/archive/2012/11/07/2759079.html //本篇博客仅在技术上探讨可行性   //如果要使用Q 地图,请 ...

  3. Arcgis api For silverlight 加载高德地图

    原文 http://www.cnblogs.com/thinkaspx/archive/2012/11/13/2767752.html 地图仅供演示,研究使用.如要商用 请联系厂商. public c ...

  4. 解决ArcGIS API for Silverlight 加载地图的内外网访问问题

    原文:解决ArcGIS API for Silverlight 加载地图的内外网访问问题 先上一个类,如下: public class BaseClass { public static string ...

  5. ARCGIS FLEX API加载google地图、百度地图、天地图(转)

    http://www.cnblogs.com/chenyuming507950417/ Flex加载google地图.百度地图以及天地图作底图 一  Flex加载Google地图作底图 (1)帮助类G ...

  6. 《ArcGIS Runtime SDK for Android开发笔记》——(13)、图层扩展方式加载Google地图

    1.前言 http://mt2.google.cn/vt/lyrs=m@225000000&hl=zh-CN&gl=cn&x=420&y=193&z=9& ...

  7. ArcGIS api for javascript——加载查询结果,悬停显示信息窗口

    转自原文 ArcGIS api for javascript——加载查询结果,悬停显示信息窗口 描述 本例在开始和地图交互前执行一个查询任务并加在查询结果.这允许用户鼠标悬停在任意郡县时立即见到Inf ...

  8. Flex加载google地图、百度地图以及天地图作底图

    一  Flex加载Google地图作底图 (1)帮助类GoogleLayer.as /* * 根据输入的地图类型加载Google地图(by chenyuming) */ package Layers ...

  9. ArcGIS API for Javascript 加载天地图(经纬度投影)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

随机推荐

  1. BZOJ3276 : 磁力

    按距离建立线段树,维护区间重量最小值 然后跑一遍拓扑,每次将所有能取的加入队尾 #include<cstdio> #include<algorithm> #define N 2 ...

  2. 4.1 avd

    6.接着我们回到文件夹界面,运行 AVD Manager.exe. 7.打开 AVD Manager.exe后,点击“New"创建新的模拟器: 8.创建一个新的 Android Virtua ...

  3. 开学后,板刷usaco!

    我要开权限我要开权限我要开权限我要开权限我要开权限我要开权限我要开权限我要开权限 他们刷rank的太可恶了 没有usaco银组金组分类的oj太可恶了 没有usaco翻译的太可恶了 没有usaco数据的 ...

  4. Linux压力测试工具

    1 http_load:http://www.oschina.net/p/http_load 命令行输入man http_load 或者 http_load -h可以看到工具的使用方式: 参数说明: ...

  5. [开源框架推荐]Icepdf:纯java的pdf文档的提取和转换库

    ICEpdf 是一个轻量级的开源 Java 语言的 PDF 类库.通过 ICEpdf 可以用来浏览.内容提取和转换 PDF 文档,而无须一些本地PDF库的支持. 可以用来做什么? 1.从pdf文件中提 ...

  6. winform学习之----打开文件对话框并将文件内容放入文本框

    OpenFileDialog ofg = new OpenFileDialog(); ofg.Title = "ddd";//设置对话框标题 ofg.Multiselect = t ...

  7. MySQL 日期和时间戳互相转换

    ① 时间戳转换成日期 FROM_UNIXTIME 例如: 数据表中 invest_time 存储的是时间戳,如 1429063399 使用 FROM_UNIXTIME 可以把时间戳转换为日期: sel ...

  8. 使用国内镜像源来加速python pypi包的安装

    pipy国内镜像目前有: http://pypi.douban.com/  豆瓣 http://pypi.mirrors.ustc.edu.cn/  中国科学技术大学 安装时,使用-i参数 pip i ...

  9. win7系统安装FAQ

    安装失败: 直接重启后进入原系统 蓝屏 提示失败 开机F1进入BIOS-〉config-〉Serial ATA-〉将硬盘模式从AHCI改为Compatibility.这项很重要的.可以解决以上问题:

  10. 数据库中MyISAM与InnoDB区别

    数据库中MyISAM与InnoDB区别 首页 » DIY技术区 » 数据库中MyISAM与InnoDB区别 09:57:40   MyISAM:这个是默认类型,它是基于传统的ISAM类型,ISAM是I ...