---
title: "MapboxRain"
description: "为地图添加降雨效果，options 透传 mapbox rain 规格。"
seo_title: "MapboxRain Component"
seo_description: "Add a rain effect via setRain, forwarding a Mapbox rain specification."
canonical_url: "https://mapbox.mhaibaraai.cn/docs/environment/rain"
---
# MapboxRain

> 为地图添加降雨效果，options 透传 mapbox rain 规格。

## 简介

`MapboxRain` 调用 `setRain` 为地图添加降雨效果，`options` 透传 mapbox rain 规格（`density`/`intensity`/`color` 等），省略用默认雨效。

> \[\!NOTE\]
> 
> setRain
> 
>  为 mapbox 实验性 API，需 v3 样式（如 
> 
> standard
> 
> ），未来版本可能变更。

## 用法

倾斜视角下叠加降雨：

```vue [RainExample.vue]
<template>
  <div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
    <MapboxMap
      :options="{
        style: 'mapbox://styles/mapbox/standard',
        center: [116.391, 39.908],
        zoom: 16,
        pitch: 60
      }"
    >
      <MapboxRain :options="{ density: 0.5, intensity: 1, color: '#a8b3c4' }" />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxRain component
 */
interface MapboxRainProps {
  /**
   * 降雨效果选项；缺省 {} 使用默认雨效
   */
  options?: mapboxgl.RainSpecification | undefined;
}
```

## Changelog

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


## Sitemap

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