Simple Map
Estimated reading time: 1 minuteDisplay a simple map with maplibre-gl-js.
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<link href="https://unpkg.com/[email protected]/dist/maplibre-gl.css" rel="stylesheet" />
<script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script>
<style>
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
#map {
min-height: 500px;
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
// Don't forget to replace <YOUR_GIS_ACCESS_TOKEN> by your own access token
const accessToken = "<YOUR_GIS_ACCESS_TOKEN>";
const mapId = "<YOUR_GIS_MAP_ID>";
const map = new maplibregl.Map({
container: "map",
style: `https://api.jawg.io/gis/maps/${mapId}/versions/latest/style?access-token=${accessToken}`,
zoom: 12,
center: [2.35071554, 48.85826376],
}).addControl(new maplibregl.NavigationControl(), "top-right");
// This plugin is used for right to left languages
maplibregl.setRTLTextPlugin("https://unpkg.com/@mapbox/[email protected]/mapbox-gl-rtl-text.min.js");
</script>
</body>
</html>