---
title: "MaplibreScaleControl"
description: "比例尺控件，随缩放显示当前地图比例，支持公制、英制与海里单位。"
canonical_url: "https://maplibre.mhaibaraai.cn/docs/controls/scale"
---
# MaplibreScaleControl

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

## 简介

`MaplibreScaleControl` 显示当前地图比例尺并随缩放更新。`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">
    <MaplibreMap :options="{ style: 'https://tiles.openfreemap.org/styles/positron', center: [116.39, 39.91], zoom: 10 }">
      <MaplibreScaleControl position="bottom-left" :options="{ unit, maxWidth: 120 }" />
    </MaplibreMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MaplibreScaleControl component
 */
interface MaplibreScaleControlProps {
  /**
   * 控件停靠位置；省略用地图默认位置
   */
  position?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | undefined;
  /**
   * ScaleControl 构造选项
   */
  options?: ScaleControlOptions | undefined;
}
```

## Changelog

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


## Sitemap

See the full [sitemap](https://maplibre.mhaibaraai.cn/sitemap.md) for all pages.
