---
title: "MapboxScaleControl"
description: "Scale bar control that displays the current map scale and updates on zoom, supporting metric, imperial, and nautical units."
canonical_url: "https://mapbox.mhaibaraai.cn/en/docs/controls/scale"
---
# MapboxScaleControl

> Scale bar control that displays the current map scale and updates on zoom, supporting metric, imperial, and nautical units.

## Introduction

`MapboxScaleControl` displays the current map scale and updates as you zoom. `options.unit` selects the unit (`metric` / `imperial` / `nautical`), and `options.maxWidth` limits the maximum pixel width of the scale bar.

## Usage

Switch `unit` to see the scale bar in different units:

```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](https://mapbox.mhaibaraai.cn/sitemap.md) for all pages.
