SDK 3D : démarrage rapide
Utilisation de Gp.Map.load
by Géoportail IGNF
May 31, 2022
HTML
<script src="https://ignf.github.io/geoportal-sdk/latest/dist/3d/GpSDK3D.js"></script>
<link rel="stylesheet" href="https://ignf.github.io/geoportal-sdk/latest/dist/3d/GpSDK3D.css">
<div id="map">
<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>
CSS
html {
height: 100%;
}
body {
margin: 0;
overflow:hidden;
height:100%;
}
#map {
margin : auto auto;
width: 100%;
height: 300px;
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 map = Gp.Map.load(
"map", // html div
{
// Geoportal access key obtained here : http://professionnels.ign.fr/ign/contrats
apiKey: "cartes,altimetrie",
// load the map in 3D (with itowns)
viewMode : "3d",
// map center
center : {
x : 2.27,
y : 48.86
},
// map zoom level
zoom : 17,
// layers to display
layersOptions : {
"GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2" : {
},
"ELEVATION.ELEVATIONGRIDCOVERAGE" : {
type : "elevation"
},
},
// additional tools to display on the map
controlsOptions : {
"search" : {
maximised : true
}
},
// markers to put in the map
markersOptions : [{
content : "<h1>Pôle Géosciences</h1><br/><p>73 avenue de Paris, Saint-Mandé</p><br/><p><a href='http://www.pôle-géosciences.fr/index.htm' target='_blank'>Site Web</a></p>"
}]
}
) ;
var infoDiv = document.getElementById("info");
infoDiv.innerHTML = "<p> SDK version " + Gp.sdkVersion + " (" + Gp.sdkDate + ")</p>";