Leaflet Géoportail Ext : MousePosition et CRS
Utilisation de L.geoportalControl.MousPosition avec paramétrage des CRSs
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: 300px;
box-shadow: 0 0 10px #999;
}
#info {
padding: 5px;
width: 100%;
height: 20px;
font-family: monospace;
}
JavaScript
function go() {
// Projection UTM 20N
var utm20 = new L.Proj.CRS('EPSG:4559',
'+proj=utm +zone=20 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
map = L.map("map").setView([16.239, -61.545], 12);
var lyrOrtho = L.geoportalLayer.WMTS({
layer: "ORTHOIMAGERY.ORTHOPHOTOS",
});
map.addLayer(lyrOrtho);
var mousePosition = L.geoportalControl.MousePosition({
displayAltitude : false,
systems : [
{
crs : utm20,
label : "UTM 20 Nord",
type : "Metric"
},
{
crs : L.CRS.Simple,
label : "Lon, Lat",
type : "Geographical"
},
],
units : ["DEC", "DMS", "M"]
});
map.addControl(mousePosition);
}
Gp.Services.getConfig({
apiKey: "essentiels",
onSuccess: go
});
var infoDiv = document.getElementById("info");
infoDiv.innerHTML = "<p> Extension Leaflet version " + Gp.leafletExtVersion + " (" + Gp.leafletExtDate + ")</p>";