arcgis api for silverlight 中的ArcGISTiledMapServiceLayer图层,继承自TiledMapServiceLayer。如果想实现自己的缓存地图图层,继承它并重载GetTileUrl方法就可以。arcgis api for silverlight 内部会计算当前访问的缩放等级level,切片二维编号row,col。这些参数暴露给GetTileUrl方法,在这个方法里面设置访问google静态地图的URL地址。
public class GoogleMapLayer : TiledMapServiceLayer
{
private const double cornerCoordinate = 20037508.3427892;
public override void Initialize()
{
this.FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892)
{
SpatialReference = new SpatialReference(102100)
};
// This layer's spatial reference
this.SpatialReference = new SpatialReference(102100);
// Set up tile @R_992_4045@ion. Each tile is 256x256px,19 levels.
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]
};
// Set the resolutions for each level. Each level is half the resolution of the prevIoUs one.
double resolution = cornerCoordinate * 2 / 256;
for (int i = 0; i < TileInfo.Lods.Length; i++)
{
TileInfo.Lods[i] = new Lod() { Resolution = resolution };
resolution /= 2;
}
// Call base initialize to raise the initialization event
base.Initialize();
}
public override string GetTileUrl(int level,int row,int col)
{
string baseUrl = "http://mt2.google.cn/vt/v=w2.116&hl=zh-CN&gl=cn&x={0}&y={1}&z={2}&s=G";
return string.Format(baseUrl,col,row,level);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。