Getting started with AR maps: Display an AR control on your maps

The Augmented reality (AR) control adds a button on your map that enables you to generate a 3D model of the visible area, including 3D terrain and any additional layer you have put on top. This functionality is compatible with WebXR or Apple Quick Look, providing users with seamless integration and immersive experiences.

With just a click of a button, you can unlock a whole new dimension to map exploration, allowing for enhanced visualization and interaction. Whether you’re navigating unfamiliar terrain or simply curious about the world around you, AR maps offer a unique way to discover and engage with your surroundings.

The control’s activateAR option allows you to automatically activate the AR model as soon as the data is available. Currently only on iOS (Quick Look).

NPM module setup


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

config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';

// Creating a map
const map = new Map({
  container: 'map',
  style: MapStyle.OUTDOOR,
  zoom: 12,
  center: [-116.22335, 51.4117],
});

// Waiting for the map to be ready
map.on("load", (e) => {
  const arControl = new MaptilerARControl({
    activateAR: true //When the platform allows automatically activates the AR mode as soon as the data is ready
  });

  arControl.on("computeStart", (e) => {
    overlay.style.display = "inherit";
  })

  arControl.on("computeEnd", (e) => {
    overlay.style.display = "none";
  })

  map.addControl(arControl, "top-left");
})
Customize the AR experience.

Custom AR experience

Examples

Customize the appearance of the augmented reality map control.

Add GeoJSON to AR maps

Add GeoJSON to AR maps

Examples

Display GeoJSON biking or hiking routes in AR maps.

How to trigger actions in the AR control

Trigger AR control actions

Examples

Trigger AR map control actions using keyboard input.

Include a QR code to access your augmented reality (AR) maps on a mobile device

QR code to access AR maps

Examples

Provide a QR code to access mobile AR maps.

Was this helpful?