---
title: "MapboxWmsLayer"
description: "接入标准 WMS 服务为栅格图层，透传版本、格式、CRS 等参数。"
seo_title: "MapboxWmsLayer Component"
seo_description: "Add an OGC WMS service as a raster layer, forwarding version, format, CRS and custom query parameters."
canonical_url: "https://mapbox.mhaibaraai.cn/docs/extensions/wms"
---
# MapboxWmsLayer

> 接入标准 WMS 服务为栅格图层，透传版本、格式、CRS 等参数。

## 简介

`MapboxWmsLayer` 把标准 WMS（GetMap）服务接入为栅格图层：`url` 与 `layers` 必填，`version` / `format` / `crs` / `transparent` 等透传，`params` 追加自定义查询参数。瓦片按 `{bbox-epsg-3857}` 逐块请求。

## 用法

接入 terrestris 公开 OSM-WMS：

```vue [WmsLayerExample.vue]
<template>
  <div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
    <MapboxMap :options="{ style: 'mapbox://styles/mapbox/light-v11', center: [10.45, 51.16], zoom: 5 }">
      <!-- terrestris 公开 OSM-WMS（EPSG:3857） -->
      <MapboxWmsLayer
        url="https://ows.terrestris.de/osm/service"
        layers="OSM-WMS"
        attribution="© terrestris / OpenStreetMap"
      />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxWmsLayer component
 */
interface MapboxWmsLayerProps {
  /**
   * WMS 服务基础地址
   */
  url: string;
  /**
   * 图层 LAYERS（逗号分隔多层）
   */
  layers: string;
  /**
   * source/layer id
   */
  layerId?: string | undefined;
  /**
   * WMS 版本
   */
  version?: string | undefined;
  /**
   * 图片格式
   */
  format?: string | undefined;
  /**
   * 是否透明
   */
  transparent?: boolean | undefined;
  /**
   * 样式
   */
  styles?: string | undefined;
  /**
   * 坐标参考系
   */
  crs?: string | undefined;
  /**
   * 瓦片尺寸
   */
  tileSize?: number | undefined;
  /**
   * 版权信息
   */
  attribution?: string | undefined;
  /**
   * 透传查询参数
   */
  params?: Record<string, string | undefined> | undefined;
  /**
   * 插入到该图层之前
   */
  beforeId?: string | undefined;
}
```

## Changelog

See commit history for [src/runtime/components/extensions/WmsLayer.vue](https://github.com/mhaibaraai/movk-mapbox/commits/main/src/runtime/components/extensions/WmsLayer.vue).


## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
