iTowns Géoportail Ext : MousePosition - coord systemes
utilisation de : itowns.control.MousePosition
by Géoportail IGNF
January 18, 2022
HTML
<script src="https://github.com/iTowns/itowns/releases/download/v2.28.0/itowns.js"></script>
<script src="https://ignf.github.io/geoportal-extensions/itowns-latest/dist/GpPluginItowns.js"></script>
<link rel="stylesheet" href="https://ignf.github.io/geoportal-extensions/itowns-latest/dist/GpPluginItowns.css">
<body>
<div id="viewerDiv">
<button id="tiltButton">
jsFiddle bug - click on this text to activate tilt (ctrl + left click)
<br>
Do not integrate this button to your own non-jsFiddle pages
</button>
</div>
<div id="info"></div>
</body>
CSS
html {
height: 100%;
}
body {
margin: 0;
overflow: hidden;
height: 100%;
}
#viewerDiv {
margin: auto auto;
width: 100%;
height: 400px;
padding: 0;
}
#tiltButton {
background-color: white;
position: absolute;
top: 20px;
left: 50px;
}
#info {
padding: 5px;
width: 100%;
height: 20px;
font-family: "monospace";
font-size: 10px;
}
JavaScript
var createMap = function() {
/* global itowns,document,GuiTools*/
const positionOnGlobe = {
longitude: 2.3465,
latitude: 48.88,
altitude: 25000000
};
// iTowns namespace defined here
const viewerDiv = document.getElementById('viewerDiv');
const globeView = new itowns.GlobeViewExtended(viewerDiv, positionOnGlobe);
globeView.listen(itowns.GlobeViewExtended.EVENTS.GLOBE_INITIALIZED, () => {
// adds control
mousePosition = new itowns.control.MousePosition({
collapsed: false,
displayCoordinates: true,
displayAltitude: true,
systems: [{
crs: 'EPSG:2154',
label: "RGF93",
type: "Metric"
},
{
crs: "EPSG:4326",
label: "Géographiques",
type: "Geographical"
}
],
units: ["M"]
});
globeView.addWidget(mousePosition);
});
// adds layers
var orthoLayer = new itowns.layer.GeoportalWMTS({
layer: "ORTHOIMAGERY.ORTHOPHOTOS"
});
var mntLayer = new itowns.layer.GeoportalElevation({
layer: "ELEVATION.ELEVATIONGRIDCOVERAGE"
});
globeView.addLayer(orthoLayer);
globeView.addLayer(mntLayer);
}
Gp.Services.getConfig({
apiKey: "ortho,altimetrie,calcul",
timeOut: 20000,
onSuccess: createMap
});
var infoDiv = document.getElementById("info");
infoDiv.innerHTML = "<p> Extension iTowns version " + Gp.itownsExtVersion + " (" + Gp.itownsExtDate + ")</p>";