ArcGIS Web API 接入天地图瓦片

来源:互联网 发布:sql注入布尔型攻击 编辑:程序博客网 时间:2024/05/18 09:09

接入天地图的瓦片完全类似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;

    }

}

0 0
原创粉丝点击