MapboxWmtsLayer
接入标准 WMTS(KVP)服务为栅格图层,支持子域名展开与自定义鉴权参数。
简介
MapboxWmtsLayer 把标准 WMTS(KVP GetTile)服务接入为栅格图层:url 与 layer 必填,tileMatrixSet / style / format 透传,url 含 {s} 时配合 subdomains 展开多 host,params 追加鉴权参数(如 tk)。MapboxTiandituLayer 即基于它封装。
用法
以天地图影像为例演示 WMTS 接入(tk 取自运行时配置):
<script setup lang="ts">
// 以天地图影像为例演示通用 WMTS(KVP)接入;tk 取自运行时配置,不硬编码
const tk = (useRuntimeConfig().public.mapbox as { tiandituToken?: string }).tiandituToken
const subdomains = ['0', '1', '2', '3', '4', '5', '6', '7']
</script>
<template>
<div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
<MapboxMap
:options="{ style: 'mapbox://styles/mapbox/light-v11', center: [116.397, 39.908], zoom: 10 }"
>
<MapboxWmtsLayer
url="https://t{s}.tianditu.gov.cn/img_w/wmts"
layer="img"
:subdomains="subdomains"
:params="{ tk }"
attribution="© 天地图"
/>
</MapboxMap>
</div>
</template>
API
Props
| Prop | Default | Type |
|---|---|---|
url | stringWMTS 服务基础地址;含 {s} 时配合 subdomains 展开 | |
layer | string图层标识 LAYER | |
layerId | `wmts-${layer}` | stringsource/layer id |
tileMatrixSet | 'w' | string瓦片矩阵集 |
format | 'tiles' | string瓦片格式 |
subdomains | string[]子域名列表,替换 url 中的 {s} | |
tileSize | 256 | number瓦片尺寸 |
attribution | string版权信息 | |
params | Record<string, string>透传查询参数(如 { tk }) | |
beforeId | string插入到该图层之前 |
Changelog
No recent changes