---
title: "MapboxRasterLayer"
description: "栅格瓦片图层，叠加 XYZ/TMS 模板的外部瓦片服务。"
seo_title: "MapboxRasterLayer Component"
seo_description: "MapboxRasterLayer adds an external XYZ/TMS raster tile service to the map with configurable tile size, scheme, zoom range and opacity."
canonical_url: "https://mapbox.mhaibaraai.cn/docs/layers/raster"
---
# MapboxRasterLayer

> 栅格瓦片图层，叠加 XYZ/TMS 模板的外部瓦片服务。

## 简介

`MapboxRasterLayer` 叠加外部栅格瓦片服务（`{z}/{x}/{y}` 模板 URL），支持 `tileSize` / `scheme` / `minzoom` / `maxzoom` / `attribution` / `opacity`。天地图等国内底图见 [扩展能力](/docs/extensions/tianditu)。

## 用法

在空样式底图上叠加 OpenStreetMap 瓦片：

```vue [RasterLayerExample.vue]
<script setup lang="ts">
const tiles = ['https://tile.openstreetmap.org/{z}/{x}/{y}.png']
</script>

<template>
  <div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
    <!-- 空样式底图，仅叠加外部栅格瓦片 -->
    <MapboxMap :options="{ style: 'mapbox://styles/mapbox/empty-v9', center: [116.4, 39.9], zoom: 9 }">
      <MapboxRasterLayer
        :tiles="tiles"
        :tile-size="256"
        attribution="© OpenStreetMap contributors"
      />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxRasterLayer component
 */
interface MapboxRasterLayerProps {
  /**
   * URL 模板瓦片地址（{z}/{x}/{y} 占位）
   */
  tiles: string[];
  /**
   * 图层 id；省略时自动生成
   */
  layerId?: string | undefined;
  /**
   * 瓦片尺寸
   * @default "256"
   */
  tileSize?: number | undefined;
  /**
   * 瓦片坐标方案
   */
  scheme?: "xyz" | "tms" | undefined;
  /**
   * 数据源最小缩放级别
   */
  minzoom?: number | undefined;
  /**
   * 数据源最大缩放级别
   */
  maxzoom?: number | undefined;
  /**
   * 版权信息
   */
  attribution?: string | undefined;
  /**
   * 不透明度
   * @default "1"
   */
  opacity?: number | undefined;
  /**
   * 插入到该图层之前
   */
  beforeId?: string | undefined;
}
```

## Changelog

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


## Sitemap

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