block by ThomasG77 5a122812635a85af7f762858ecf052a3

Make maplibre GL JS sample for IGN plan. Live demo at https://gist.githack.com/ThomasG77/5a122812635a85af7f762858ecf052a3/raw/b315d7ff1a9d9c49ece0ab0207687205263c549b/index.html

Full Screen

index.html

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Display a map</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <script type="text/javascript" src="https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.js"></script>
  <link rel="stylesheet" type="text/css" href="https://unpkg.com/maplibre-gl@1.15.2/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">
    const url_style = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json";
    fetch(url_style).then(res => res.json()).then(style => {
      // Patch tms scheme to xyz to make it compatible for Maplibre GL JS / Mapbox GL JS
      style.sources.plan_ign.scheme = 'xyz';
      style.sources.plan_ign.attribution = 'Données cartographiques : © IGN';
      const map = new maplibregl.Map({
        container: 'map', // container id
        style: style, // style URL
        center: [3.389162, 46.852644], // starting position [lng, lat]
        zoom: 5, // starting zoom
        attributionControl: false
      });
      map.addControl(new maplibregl.AttributionControl({compact: true}));
    })
  </script>
</body>
</html>

index-isohypse.html

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Display a map</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <script type="text/javascript" src="https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.js"></script>
  <link rel="stylesheet" type="text/css" href="https://unpkg.com/maplibre-gl@1.15.2/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">
    window.debugStyleMaplibre = null;
    // const url_style = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/ISOHYPSE/isohypse_multicolore.json"
    // const url_style = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/ISOHYPSE/isohypse_monochrome_marron.json"
    const url_style = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/ISOHYPSE/isohypse_monochrome_orange.json"
    fetch(url_style).then(res => res.json()).then(style => {
      window.debugStyleMaplibre = style;
      style.sources.isohypse.attribution = 'Données cartographiques : © IGN';
      style.layers = style.layers.filter(el => el['source-layer'] != 'frontiere_france')
      const map = new maplibregl.Map({
        container: 'map', // container id
        style: style, // style URL
        center: [6.018308, 45.390043], // starting position [lng, lat]
        zoom: 15, // starting zoom
        attributionControl: false,
        hash: true
      });
      map.addControl(new maplibregl.AttributionControl({compact: false}));
    })
  </script>
</body>
</html>