Skip to content
SDK mapx-gl

SDK mapx-gl

mapx-gl is a small add-on (ESM, TypeScript) for MapLibre GL JS. It sets the style URLs, registers the pmtiles:// protocol, wraps the APIs in typed functions and adds ready-made controls. Peer dependencies: maplibre-gl@{V.maplibre} and pmtiles@{V.pmtiles}.

Install

Load the bundle from https://map.mapx.at/sdk/v1/ (CORS is open) or download the files and serve them with your page:

FileUse
mapx-gl.bundle.jsEverything included, load as <script type="module">
mapx-gl.jsWithout peers, for projects with their own build
mapx-gl.cssStyles for the controls, load after maplibre-gl.css
mapx-gl.d.tsTypeScript types
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css">
<link rel="stylesheet" href="https://map.mapx.at/sdk/v1/mapx-gl.css">
<div id="map" style="height:100vh"></div>
<script type="module">
  import mapx from "https://map.mapx.at/sdk/v1/mapx-gl.bundle.js";
  const map = mapx.map({ accessToken: "YOUR_TOKEN", container: "map", style: "streets", center: [15.33, 48.23], zoom: 12 });
  map.addControl(new mapx.SearchControl(), "top-left");
  map.addControl(new mapx.RouteControl(), "top-right");
  map.addControl(new mapx.LayerControl(), "top-right");
</script>

A complete example is at map.mapx.at/sdk/v1/example.html.

Map

mapx.map(options) returns a MapLibre map. accessToken is your public token (Access and limits); it applies to the map and to all helpers. Without a map, call mapx.setAccessToken("YOUR_TOKEN") once. style is a short name (streets, streets-dawn, streets-dusk, streets-night, satellite, outdoors) that becomes https://api.mapx.at/v1/styles/{id}, or any style URL or object. terrain: true turns on 3D terrain.

What is in the box

PartContentPage
Helpersgeocode, reverse, searchSuggest, searchRetrieve, directions, transitDirections, isochrone, matrix, optimization, parcel, parcelDossier, tilequery, elevation, elevationProfile, trafficIncidents, stops, departures, weatherCurrent, weatherForecast, staticImageUrlSDK helpers
ControlsSearchControl, StyleSwitcherControl, MeasureControl, ElevationProfileControl, Terrain3DControl, RouteControl, LayerControlControls and popups
PopupsParcelPopup, DeparturesPopupControls and popups
ErrorsMapxError with code, param, allowed, retryAfterErrors and retries
TypesEvery option and response typeSDK reference
const r = await mapx.directions("driving-truck", [[16.3725, 48.2085], [15.3294, 48.2272]], { truck: { weight: 40, height: 4 } });
const h = await mapx.elevation([12.694, 47.074]); // 3726.3

Next