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

继承TiledMapServiceLayer,实现GetTileUrl方法。

public class OpenStreetMapLayer : TiledMapServiceLayer
{
private static string[] subDomains = { "a", "b", "c" };
private const string baseUrl = "http://{0}.tile.openstreetmap.org/{1}/{2}/{3}.png";
public override void Initialize()
{
this.FullExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892)
{
SpatialReference = new SpatialReference(102113)
};

double cornerCoordinate = 20037508.3427892;//from wkid 3857/102100

// This layer's spatial reference
this.SpatialReference = new SpatialReference(102113);
// 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(102113) },
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)
{
// Select a subdomain based on level/row/column so that it will always
// be the same for a specific tile. Multiple subdomains allows the user
// to load more tiles simultanously. To take advantage of the browser cache
// the following expression also makes sure that a specific tile will always
// hit the same subdomain.
string subdomain = subDomains[(level + col + row) % subDomains.Length];
return string.Format(baseUrl, subdomain, level, col, row);
}
}

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值