Compass rose control

Add a compass rose as a visual indicator of the map’s bearing (rotation) using Custom Controls.

This example demonstrates how to effectively use declarative custom controls to implement a control that follows the state of the map without requiring any JavaScript to create it.

NPM module setup


npm install --save @maptiler/sdk
import { Map, MapStyle, config } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';

// Initialize MapTiler SDK
config.apiKey = "YOUR_MAPTILER_API_KEY_HERE";

// Initialize the map
const map = new Map({
  container: 'map', // The ID of the HTML element where the map will be rendered
  style: MapStyle.DATAVIZ,
  zoom: 7,
  bearing: 42,
  center: [-104.986605, 39.760618],
  customControls: true,
});
Add custom zoom control

Add custom zoom control

Examples

Add custom zoom level control to your map interface.

Add a custom control declarative way

Custom control declarative

Examples

Add interactive custom controls to maps using declarative HTML.

Add a custom control programmatically

Custom control programmatically

Examples

Programmatically add custom controls for dynamic map logic integration.

How to display a minimap or overview map control to aid the map navigation

Minimap control

Tutorials

Display an overview minimap control to aid map navigation.

Was this helpful?