ArcGIS WebAPI接入google瓦片服务

0
分享 2012-11-25
当前电子地图大行其道,其中大部分是以瓦片的形式和rest接口来对地图内容进行访问的,那么我们能否在需要底图数据的时候借用下这些丰富而详细的数据内容呢?
接下来我们利用ArcGIS强大的API实现了集中常见类型瓦片服务的接入,其中的关键就是对于TiledMapServiceLayer类的理解和使用了。
public class Googlemap:TiledMapServiceLayer
{
//public bool chn;
publicstring _mapType = null;
publicoverridevoid Initialize()
{
//this.Opacity = 0.5;
this.FullExtent = new
ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787);//(-180,-85.0511287798066,180, 85.0511287798066)
{
SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100);
};
this.SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100);
//this.InitialExtent = this.FullExtent;
this.TileInfo = new TileInfo()
{
Height = 256,
Width = 256,
Origin = new ESRI.ArcGIS.Client.Geometry.MapPoint(-20037508.342787,20037508.342787)//Origin = new ESRI.ArcGIS.Geometry.MapPoint(-180,90)
{
SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100)
},
Lods = new Lod[20]
};
double resolution = 156543.033928;
for (int i = 0; i <TileInfo.Lods.Length; i++)
{
TileInfo.Lods = new Lod() { Resolution = resolution };
resolution /= 2;
}
base.Initialize();
}

publicoverridestring GetTileUrl(int level, int row, int col)
{
string url = null;
if (_mapType == “poi”)
{
string baseUrl = “http://mt1.google.cn/vt/imgtp% ... Bx%3D”;
url = baseUrl + col.ToString() + “&amp;y=” +row.ToString() + “&amp;z=” + level.ToString() + “&amp;s=Ga”;

}
elseif (_mapType == “image”)
{
string baseUrl = “http://mt3.google.cn/vt/lyrs%3 ... Bx%3D”;
url = baseUrl + col.ToString() + “&amp;y=” +row.ToString() + “&amp;z=” + level.ToString() + “&amp;s=”;
}
elseif (_mapType == “map”)
{
string baseUrl = “http://mt0.google.cn/vt/lyrs%3 ... Bx%3D”;
url = baseUrl + col.ToString() + “&amp;y=” +row.ToString() + “&amp;z=” + level.ToString() + “&amp;s=Ga”;
}
return url;
}
}

文章来源:http://blog.csdn.net/sydbc/article/details/17258167

0 个评论

要回复文章请先登录注册