// WMTS Layer Geoportail (http://ol3js.org/en/master/examples/wmts.html)
/**
* @constructor IGN's Geoportail WMTS layer definition
* @extends {ol.source.WMTS}
* @param {String=} key API key.
* @param {String=} layer Layer name.
* @param {olx.source.OSMOptions=} options WMTS options.
* @todo
*/
ol.source.Geoportail = function(key, layer, options)
{ if (!options) options={};
var matrixIds = new Array();
var resolutions = new Array();
var size = ol.extent.getWidth(ol.proj.get('EPSG:3857').getExtent()) / 256;
for (var z=0; z <= (options.maxZoom ? options.maxZoom:18) ; z++)
{ matrixIds[z] = z ;
resolutions[z] = size / Math.pow(2, z)
}
var attr = [ ol.source.Geoportail.prototype.attribution ];
if (options.attributions) attr.push(options.attributions);
ol.source.WMTS.call (this,
{ url: "http://wxs.ign.fr/" + key + "/wmts",
layer: layer,
matrixSet: "PM",
format: options.format ? options.format:"image/jpeg",
projection: "EPSG:3857",
tileGrid: new ol.tilegrid.WMTS
({ origin: [-20037508, 20037508],
resolutions: resolutions,
matrixIds: matrixIds
}),
style: options.style ? options.style:"normal",
attributions: attr
});
};
ol.inherits (ol.source.Geoportail, ol.source.WMTS);
// Attribution standard
ol.source.Geoportail.prototype.attribution = new ol.Attribution
({ html: 'GĂ©oportail © IGN-France'
});
/** */
// La carte
var map = new ol.Map
({ target: 'map',
renderer: ["canvas"], /* ["webgl", "canvas", "dom"] */
view: new ol.View
({ zoom: 7,
center: [288074, 6247982]
}),
controls: ol.control.defaults().extend
([ new ol.control.FullScreen()
]),
layers: [new ol.layer.Tile(
{ source: new ol.source.Geoportail(MA_CLE, "GEOGRAPHICALGRIDSYSTEMS.MAPS")
})]
});