---
title: "Add a map to a webpage | JavaScript maps SDK"
description: "Create maps in HTML elements using MapTiler SDK JS."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# 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](https://docs.maptiler.com/guides/using-map/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](https://docs.maptiler.com/sdk-js/examples/) available to discover the full potential of the SDK.

### NPM module setup

```bash
npm install --save @maptiler/sdk
```

#### main.js

```js
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
});
```

#### index.html

```html
<!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>
```

#### style.css

```css
body {margin: 0; padding: 0;}
#map {position: absolute; top: 0; bottom: 0; width: 100%;}
```

### Basic JavaScript setup

```html
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add a map to a webpage</title>
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.css" rel="stylesheet" />
<style>
  body {margin: 0; padding: 0;}
  #map {position: absolute; top: 0; bottom: 0; width: 100%;}
</style>
</head>
<body>
<div id="map"></div>
  <script>
    maptilersdk.config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
    const map = new maptilersdk.Map({
      container: 'map', // container id
      style: maptilersdk.MapStyle.STREETS, 
      center: [16.62662018, 49.2125578], // starting position [lng, lat]
      zoom: 10 // starting zoom
    });
  </script>
</body>
</html>
```
