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' });