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試試效果