Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Last active February 1, 2022 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasG77/2c0f884c209eebb2710648e316052382 to your computer and use it in GitHub Desktop.
Save ThomasG77/2c0f884c209eebb2710648e316052382 to your computer and use it in GitHub Desktop.
Demo maplibre GL JS pour le cadastre français. Lien"Live" https://bl.ocks.org/ThomasG77/2c0f884c209eebb2710648e316052382
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Display cadastre on Maplibre</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="https://unpkg.com/maplibre-gl@2.1.1/dist/maplibre-gl.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/maplibre-gl@2.1.1/dist/maplibre-gl.css">
<style type="text/css">
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
// Pas de garantie de la persistance des URLs dans le futur
const url_style = 'https://raw.githack.com/etalab/cadastre.data.gouv.fr/master/components/react-map-gl/styles/vector.json';
// Pour une vue ortho, commenter la ligne ci-dessus, décommenter la ligne ci-dessous
// const url_style = 'https://raw.githack.com/etalab/cadastre.data.gouv.fr/1ba6181976f7147f08335a6f0c638f2f8523d37c/components/react-map-gl/styles/ortho.json';
const map = new maplibregl.Map({
container: 'map', // container id
style: url_style, // style URL
center: [2.6, 46], // starting position [lng, lat]
zoom: 5 // starting zoom
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment