# new WebMapTileServiceLayer(url, options)
WMTS图层(Leaflet)
参数:
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
url |
String | 服务基地址 |
|
options |
Object | 额外构造参数 |
|
visible |
Boolean | true | 图层显隐 |
opacity |
Number | 1 | 图层透明度 |
tilematrixSet |
String | 图层裁图方案的id |
|
layer |
String | 图层名称 |
|
style |
String | 图层样式Id |
|
version |
String | 1.0.0 | WMTS版本号 |
tileSize |
Number | 256 | 瓦片大小 |
bounds |
L.latLngBounds | 图层显示范围 |
|
clippingArea |
Object | 图层几何裁剪对象 |
|
crsOptions |
Object | 相同坐标系的图层,但裁图方案不同时,设置此参数,可让图层进行叠加 |
|
zoomOffset |
Number | 0 | 偏移级数 |
minZoom |
Number | 0 | 最小显示级数 |
maxZoom |
Number | 18 | 最大显示级数 |
tokenKey |
String | token名 |
|
tokenValue |
String | token值 |
示例
// ES5引入方式
const { WMTSLayer } = zondy.Layer
const { initializeCRS, initializeOptions } = zondy.leaflet
// ES6引入方式
import { WMTSLayer } from "@mapgis/webclient-common"
import "@mapgis/webclient-leaflet-plugin"
const { initializeCRS, initializeOptions } = zondy.leaflet
// 构造一个WMTSLayer图层对象
const layer = new WMTSLayer({
// 服务基地址
url: "http://{ip}:{port}/igs/rest/services/{服务名}/WMTSServer"
});
// 加载图层元数据
layer.load().then(function () {
// 构造地图视图的初始化参数
const crs = initializeCRS(layer)
const mapViewOptions = {
// 地图视图参考系
crs: crs,
// 初始化中心点
center: [31.147781205532336,112.21905099757561],
// 初始化级数
zoom: 6
}
// 构造Leaflet地图视图对象
const map = L.map('地图视图容器ID', mapViewOptions)
// 构造图层的初始化参数
const layerOptions = initializeOptions(layer)
// 添加图层到地图视图中
new zondy.leaflet.WebMapTileServiceLayer(layer.url, layerOptions).addTo(map)
})