---
title: "MapboxScaleControl"
description: "比例尺控件，随缩放显示当前地图比例，支持公制、英制与海里单位。"
seo_title: "MapboxScaleControl Component"
seo_description: "MapboxScaleControl shows the current map scale and updates with zoom, supporting metric, imperial and nautical units via options."
canonical_url: "https://mapbox.mhaibaraai.cn/docs/controls/scale"
---
# MapboxScaleControl

> 比例尺控件，随缩放显示当前地图比例，支持公制、英制与海里单位。

## 简介

`MapboxScaleControl` 显示当前地图比例尺并随缩放更新。`options.unit` 选择单位（`metric` / `imperial` / `nautical`），`options.maxWidth` 限制比例尺最大像素宽度。

## 用法

切换 `unit` 查看不同单位下的比例尺：

```vue [ScaleControlExample.vue]
<script setup lang="ts">
withDefaults(defineProps<{ unit?: 'metric' | 'imperial' | 'nautical' }>(), {
  unit: 'metric'
})
</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.39, 39.91], zoom: 10 }">
      <MapboxScaleControl position="bottom-left" :options="{ unit, maxWidth: 120 }" />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxScaleControl component
 */
interface MapboxScaleControlProps {
  /**
   * 控件停靠位置；省略用地图默认位置
   */
  position?: mapboxgl.ControlPosition | undefined;
  /**
   * ScaleControl 构造选项
   */
  options?: mapboxgl.ScaleControlOptions | undefined;
}
```

## Changelog

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


## Sitemap

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