本文主要是介绍ArcGIS Web API 接入天地图瓦片,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
接入天地图的瓦片完全类似google的瓦片服务,但是空间参考不一致,想叠加其他的数据的话需要注意空间参考的设置,以上三篇博客的目的为简单的技术研究,如果想将这些内容用于商业用途,大家还是要联系厂家啊!
publicclasstianditu :TiledMapServiceLayer
{
publicstring _mapType = null;
privatestring[] _hosts = new
string[] { “tile0″,
“tile1″, “tile2″,
“tile3″, “tile4″,
“tile5″, “tile6″,
“tile6″, “tile7″
};
publicoverridevoid
Initialize()
{
this.FullExtent
= new
ESRI.ArcGIS.Client.Geometry.Envelope(180,-90,-180,90); {
SpatialReference = newESRI.ArcGIS.Client.Geometry.SpatialReference(4326);
};
this.SpatialReference
= new
ESRI.ArcGIS.Client.Geometry.SpatialReference(4326);
this.TileInfo
= new TileInfo()
{
Height = 256,
Width = 256,
Origin = new
ESRI.ArcGIS.Client.Geometry.MapPoint(-90d,45d) {
SpatialReference = new
ESRI.ArcGIS.Client.Geometry.SpatialReference(4326)
},
Lods = new
Lod[18]
};
double
resolution = 0.3515625;
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)
{
int
index = Math.Abs(col % 7);
string
host = _hosts[index];
string
url=“”;
if(_mapType==
“map”)
{
if
(level < 10)
{
url=string.Format(“http://{0}.tianditu.com/DataServer?T=A0512_EMap&X={1}&Y={2}&L={3}”,
host, col, row, level+1);
}
else
if (level < 12)
{
url=string.Format(“http://{0}.tianditu.com/DataServer?T=B0627_EMap1112&X={1}&Y={2}&L={3}”,
host, col, row, level+1);
}
else
{
url=string.Format(“http://{0}.tianditu.com/DataServer?T=siwei0608&X={1}&Y={2}&L={3}”,
host, col, row, level+1);
}
}
if
(_mapType == “Vanno”)
{
if
(level < 10)
{
url = string.Format(“http://{0}.tianditu.com/DataServer?T=AB0512_Anno&X={1}&Y={2}&L={3}”,
host, col, row, level + 1);
}
}
if
(_mapType == “img”)
{
if
(level < 10)
{
url = string.Format(“http://{0}.tianditu.com/DataServer?T=sbsm0210&X={1}&Y={2}&L={3}”,
host, col, row, level + 1);
}
else
if (level == 10)
{
url = string.Format(“http://{0}.tianditu.com/DataServer?T=e11&X={1}&Y={2}&L={3}”,
host, col, row, level + 1);
}
else
if (level == 11)
{
url = string.Format(“http://{0}.tianditu.com/DataServer?T=e12&X={1}&Y={2}&L={3}”,
host, col, row, level + 1);
}
else
if (level == 12)
{
url = string.Format(“http://{0}.tianditu.com/DataServer?T=e13&X={1}&Y={2}&L={3}”,
host, col, row, level + 1);
}
else
if (level == 13)
{
url = string.Format(“http://{0}.tianditu.com/DataServer?T=eastdawnall&X={1}&Y={2}&L={3}”,
host, col, row, level + 1);
}
else
{
url = string.Format(“http://{0}.tianditu.com/DataServer?T=sbsm1518&X={1}&Y={2}&L={3}”,
host, col, row, level + 1);
}
}
return
url;
}
}
这篇关于ArcGIS Web API 接入天地图瓦片的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!