arcgis silverlight自己写个图层,实现对google map的访问

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 information. 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);
}
}

也可下载http://download.csdn.net/detail/leesmn/3634647试试效果

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值