Add a map to a webpage
Create a map within an HTML element using MapTiler SDK JS. Additionally, it is possible to insert maps into websites with a simple iframe directly from MapTiler.
This is the most basic demonstration of utilizing the MapTiler SDK JS to effortlessly build a web mapping application. Feel free to explore various map styles, customizations, and functionalities to provide an exceptional mapping experience for your users. Take a look at the other examples available to discover the full potential of the SDK.
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', // container id
style: MapStyle.STREETS,
center: [16.62662018, 49.2125578], // starting position [lng, lat]
zoom: 10 // starting zoom
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Add a map to a webpage | 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%;}