---
title: "MaplibreNavigationControl"
description: "Navigation control that provides zoom buttons and a compass. Use position to set the dock corner and options to pass through to maplibre-gl."
canonical_url: "https://maplibre.mhaibaraai.cn/en/docs/controls/navigation"
---
# MaplibreNavigationControl

> Navigation control that provides zoom buttons and a compass. Use position to set the dock corner and options to pass through to maplibre-gl.

## Introduction

`MaplibreNavigationControl` mounts zoom buttons and a compass on the map. `position` sets the dock corner (omit to use the map's default), and `options` is forwarded directly to the maplibre-gl `NavigationControl` constructor (`showZoom` / `showCompass` / `visualizePitch`). The control is mounted when the map is ready and automatically removed when the component unmounts.

## Usage

Adjust `position` to change the dock corner:

```vue [NavigationControlExample.vue]
<script setup lang="ts">
import type { ControlPosition } from 'maplibre-gl'

withDefaults(defineProps<{ position?: ControlPosition }>(), {
  position: 'top-right'
})
</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 }">
      <MaplibreNavigationControl :position="position" />
    </MaplibreMap>
  </div>
</template>
```

## Examples

### Visualize Pitch

Tilt the map and enable `visualizePitch` — the compass tilts along with the pitch angle to indicate the current view:

```vue [NavigationControlPitchExample.vue]
<template>
  <div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
    <MaplibreMap
      :options="{
        style: 'https://tiles.openfreemap.org/styles/liberty',
        center: [116.39, 39.91],
        zoom: 11,
        pitch: 55,
        bearing: -25
      }"
    >
      <!-- visualizePitch 让罗盘随俯仰角倾斜，showZoom 保留缩放按钮 -->
      <MaplibreNavigationControl
        position="top-right"
        :options="{ visualizePitch: true, showCompass: true, showZoom: true }"
      />
    </MaplibreMap>
  </div>
</template>
```

## API

### Props

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

## Changelog

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


## Sitemap

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