图片图层分两种,一种是动态图层,一种就是缓存图层。缓存图层就是已经切好图片,这种方式出图速度快,通常用作底图。关于图层相关概念请参考帮助文档《地图与图层》章节。
自定义缓存图层时,用户需要继承 TiledCachedLayer 类,Resolutions 和 Bounds 属性是必须设置的。如果是 SuperMap 切的图片,已知 Scales ,那么也要将 Scales 转成 Resolutions。最主要的是重写父类的 GetTileUrl 方法和 Initialize 方法,要在 Initialize 中获取必要的参数,在 GetTileUrl 中组织好对应缓存图片的 URL 。
下面是一个扩展 iServer2 缓存图片的例子。
- 代码实现:
C# | 拷贝代码 | ||
public class CustomCachedLayer : TiledCachedLayer |
- 定义 CustomCachedLayer 类之后,下面介绍一下使用方法。以下数据必须已知,可以从 Deskpro 中或调用 GetMapStatus 获取:
C# | 拷贝代码 | ||
string cachedurl="http://localhost:7080/output"; |