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
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Create a non-interactive map | NPM example</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div id="map"></div>
<script type="module" src="./main.js"></script>
</body>
</html>
body {margin: 0; padding: 0;}
#map {position: absolute; top: 0; bottom: 0; width: 100%;}