function go() { var osmLyr = new ol.layer.Tile({ source: new ol.source.OSM() }); var map = new ol.Map({ target: 'map', layers: [ osmLyr, new ol.layer.GeoportalWMTS({ layer: "GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2", olParams: { minResolution: 1222.9924523925781 } }), new ol.layer.GeoportalWMTS({ layer: "ORTHOIMAGERY.ORTHOPHOTOS", olParams: { opacity: 0.7 } }) ], view: new ol.View({ center: [288074.8449901076, 6247982.515792289], zoom: 12 }) }); var lsControl = new ol.control.LayerSwitcher({ layers : [{ layer: osmLyr, config: { title: "OSM", description: "Couche OpenStreet Map", } }], options : { collapsed: true } }); map.addControl(lsControl); var layers = map.getLayers().getArray(); var layersNb = layers.length; for (var i=0;i<layersNb;i++) { var minRes = layers[i].getMinResolution(); var clientMinRes = minRes/Math.pow(2,5) // Client zoom up to 3 more zoom levels if (clientMinRes < 0.074) { clientMinRes = 0.074; } layers[i].setMinResolution(clientMinRes); } //console.log(map.getLayers().getArray()); } Gp.Services.getConfig({ apiKey: "essentiels", onSuccess: go }); var infoDiv = document.getElementById("info"); infoDiv.innerHTML = "<p> Extension OL version " + Gp.olExtVersion + " (" + Gp.olExtDate + ")</p>";
<div id="map"></div> <div id="info"></div>
#map { padding: 5px; width: 100%; height: 300px; box-shadow: 0 0 10px #999; } #info { padding: 5px; width: 100%; height: 20px; font-family: "monospace"; font-size: 10px; }