Toggle interactions

Enable or disable UI handlers on a map.

NPM module setup


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

config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const map = new Map({
    container: 'map',
    style: MapStyle.STREETS, 
    center: [103.8382, 1.3565],
    zoom: 10.71
});

document
    .getElementById('listing-group')
    .addEventListener('change', function (e) {
        const handler = e.target.id;
        if (e.target.checked) {
            map[handler].enable();
        } else {
            map[handler].disable();
        }
    });
Disable scroll zoom

Disable scroll zoom

Examples

Prevent scroll actions from zooming your interactive map.

Disable map rotation

Disable map rotation

Examples

Prevent users from rotating your interactive map.

Was this helpful?