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

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

## Introduction

`MaplibreScaleControl` 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">
    <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.
