Create a non-interactive map

The MapTiler SDK JS is a mapping library designed for creating interactive maps, but you can also disable the interactivity and simulate a static map.

To get a simple non-interactive map, it’s typically much easier and more lightweight to generate a static map image via our Static maps API. However, you may prefer to use the SDK JS in these cases:

  • You already have a complex interactive map implemented and just want a simple way to switch it to non-interactive.
  • You need to add special features and custom data to your map, so the markers and lines that a static map allows aren’t sufficient.

To make your map non-interactive with MapTiler SDK JS, build your map as usual and then add the parameter interactive: false. See the result and code below.

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: [-74.5, 40],
    zoom: 9,
    // causes pan & zoom handlers not to be applied, similar to
    // .dragging.disable() and other handler .disable() funtions in Leaflet.
    interactive: false,
    navigationControl: false,
    geolocateControl: false
});
Disable map rotation

Disable map rotation

Examples

Prevent users from rotating your interactive map.

Fly to a location

Fly to a location

Examples

Smoothly interpolate between locations using the flyTo animation.

Hide map navigation controls

Hide map navigation controls

Tutorials

Hide the map navigation and zoom controls.

Disable scroll zoom

Disable scroll zoom

Examples

Prevent scroll actions from zooming your interactive map.

Was this helpful?