Skip to content
First map in 5 minutes

First map in 5 minutes

Save the code as index.html and open it in a browser. Replace YOUR_TOKEN with a public token from account.mapx.at (allowed origin: your site, or localhost while testing). No build step.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>First mapx map</title>
  <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css">
  <script src="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js"></script>
  <style>html, body, #map { margin: 0; height: 100%; }</style>
</head>
<body>
  <div id="map"></div>
  <script>
    const TOKEN = "YOUR_TOKEN"; // public token mx_pk_…
    new maplibregl.Map({
      container: "map",
      style: "https://api.mapx.at/v1/styles/streets",
      // adds the token to every request to mapx.at (style, tiles, fonts, sprites)
      transformRequest: (url) => ({ url: /^https:\/\/([\w-]+\.)?mapx\.at\//.test(url) ? url + (url.includes("?") ? "&" : "?") + "access_token=" + TOKEN : url }),
      center: [16.3725, 48.2085], // Vienna, lon,lat
      zoom: 13,
    });
  </script>
</body>
</html>

The style streets is a normal MapLibre style. Replace it with satellite or outdoors to change the look. All styles: Styles API.

MapLibre GL JS {V.maplibre} is the version these examples are tested with.

Next