1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
/**
* Property: iViewer
* {<Geoportal.InterfaceViewer>} The Geoportal API viewer interface.
*/
iViewer= null;
/**
* Function: init
* Load the map. Called when "onload" event is fired.
*/
function init() {
iViewer= Geoportal.load(
// map's div id - identifiant de la div de la carte :
"viewerContainer",
// API's keys - clefs API :
["ma clé A JOUR de license gratuite pour l'API Geoportail"],
{
// center in WGS84G - centre en WGS84G
lon:6.800681349904434,
lat:45.521178078454874
},
// zoom level (0-20) - niveau de zooms (0 à 20) :
14,
{ // various options :
loadTheme: function() {
Geoportal.Util.setTheme("geoportal3");
Geoportal.Util.loadCSS("http://api.ign.fr/geoportail/api/js/2.0.3/theme/geoportal3/style.css","__GeoportalBlackCss__","");
if (OpenLayers.Util.alphaHack()) {
Geoportal.Util.loadCSS("http://api.ign.fr/geoportail/api/js/2.0.3/theme/geoportal3/ie6-style.css","__IE6GeoportalBlackCss__","");
}
},
// viewer default controls options overloads :
componentsOptions:{},
// Geoportal's layers to load (when none, all contracts' layers are loaded) :
layers:["GEOGRAPHICALGRIDSYSTEMS.MAPS:WMTS","CADASTRALPARCELS.PARCELS:WMTS","ORTHOIMAGERY.ORTHOPHOTOS:WMTS"],
// Geoportal's layers options :
layersOptions:{"GEOGRAPHICALGRIDSYSTEMS.MAPS:WMTS":{"opacity":0.3,"visibility":true},"CADASTRALPARCELS.PARCELS:WMTS":{"opacity":1,"visibility":false},"ORTHOIMAGERY.ORTHOPHOTOS:WMTS":{"opacity":1,"visibility":true}},
overlays:{},
// callback to use before returning (after centering) :
onView:function() {viewer=iViewer.getViewer();
//Ajout du contrôle d'impression
var nv= viewer.getMap().getControlsByClass("Geoportal.Control.NavToolbar")[0];
nv.addControls([new Geoportal.Control.PrintMap()]);
var measurebar= new Geoportal.Control.MeasureToolbar({
div: OpenLayers.Util.getElement(tbx.id+"_measure"),
displaySystemviewer.getMap().getProjection().getProjName()=="longlat"?"geographic":"metric"),
targetElement: OpenLayers.Util.getElement(tbx.id+"_meares")
});
viewer.getMap().addControl(measurebar);
viewer.getMap().getControlsByClass("Geoportal.Control.MeasureToolbar")[0].controls[2].deactivate;
viewer.getMap().getControlsByClass("Geoportal.Control.MeasureToolbar")[0].controls[2].div.style.display="none";
},
// class of viewer to use :
viewerClass:"Geoportal.Viewer.Default"
}
);
}
window.onload= init; |
Partager