Leaflet Géoportail Ext : couches WMTS

Utilisation de L.GeoportalLayer.WMTS

by Géoportail IGNF

HTML

<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css">
<script src="https://ignf.github.io/geoportal-extensions/leaflet-latest/dist/GpPluginLeaflet.js"></script>
<link rel="stylesheet" href="https://ignf.github.io/geoportal-extensions/leaflet-latest/dist/GpPluginLeaflet.css">
<div id="map"></div>
<div id="info"></div>

CSS

#map {
    padding: 5px;
    width: 100%;
    height: 500px;
    box-shadow: 0 0 10px #999;
}

#info {
    padding: 5px;
    width: 100%;
    height: 20px;
    font-family: monospace;
}

JavaScript

function go() {
    map = L.map("map").setView([48.845, 2.424], 10);
    var lyr = L.geoportalLayer.WMTS({
        // layer: "ORTHOIMAGERY.ORTHOPHOTOS",
        layer: "GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2",
    }, { // leafletParams
        opacity: 0.8
    });
    lyr.addTo(map); // ou map.addLayer(lyr);
}

Gp.Services.getConfig({
    apiKey : "essentiels",
    onSuccess : go,
    onFailure: (e) => {console.log(e)}
}) ;

var infoDiv= document.getElementById("info") ;
infoDiv.innerHTML= "<p> Extension Leaflet version "+Gp.leafletExtVersion+" ("+Gp.leafletExtDate+") - Leaflet version : "+ L.version +"</p>" ;