本文主要是介绍ArcGIS WebAPI接入google瓦片服务,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
当前电子地图大行其道,其中大部分是以瓦片的形式和rest接口来对地图内容进行访问的,那么我们能否在需要底图数据的时候借用下这些丰富而详细的数据内容呢?
接下来我们利用ArcGIS强大的API实现了集中常见类型瓦片服务的接入,其中的关键就是对于TiledMapServiceLayer类的理解和使用了。
publicclassGooglemap :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[i] = 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=png32&lyrs=h@169000000&hl=zh-CN&gl=cn&x=”;
url = baseUrl + col.ToString() + “&y=” +row.ToString() + “&z=” + level.ToString() + “&s=Ga”;
}
elseif (_mapType == “image”)
{
string
baseUrl = “http://mt3.google.cn/vt/lyrs=s@101&hl=zh-CN&gl=cn&x=”;
url = baseUrl + col.ToString() + “&y=” +row.ToString() + “&z=” + level.ToString() + “&s=”;
}
elseif (_mapType == “map”)
{
string
baseUrl = “http://mt0.google.cn/vt/lyrs=m@169000000&hl=zh-CN&gl=cn&x=”;
url = baseUrl + col.ToString() + “&y=” +row.ToString() + “&z=” + level.ToString() + “&s=Ga”;
}
return
url;
}
}
这篇关于ArcGIS WebAPI接入google瓦片服务的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!