diff options
| -rw-r--r-- | chimere/static/chimere/js/jquery.chimere.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js index 39b1abd..4e9e89b 100644 --- a/chimere/static/chimere/js/jquery.chimere.js +++ b/chimere/static/chimere/js/jquery.chimere.js @@ -74,6 +74,49 @@ var LayerSwitcher = function(options){ }; // LayerSwitcher + +// Géoportail (IGN) +// example: geoportail_layer('2mqbg0z6cx7ube8gsou10nrt', 'GEOGRAPHICALGRIDSYSTEMS.MAPS', 'Géoportail - Plan IGN', 18, 'image/jpeg') +// geoportail_layer('2mqbg0z6cx7ube8gsou10nrt', 'CADASTRALPARCELS.PARCELS', 'Géoportail - Cadastre', 20, 'image/png') +function geoportail_layer(key, layer, name, max_zoom, image_format){ + var resolutions = []; + var matrixIds = []; + var proj3857 = ol.proj.get('EPSG:3857'); + var maxResolution = ol.extent.getWidth(proj3857.getExtent()) / 256; + for (var i = 0; i < max_zoom; i++) { + matrixIds[i] = i.toString(); + resolutions[i] = maxResolution / Math.pow(2, i); + } + + var plan_tileGrid = new ol.tilegrid.WMTS({ + origin: [-20037508, 20037508], + resolutions: resolutions, + matrixIds: matrixIds + }); + + var plan_ign_source = new ol.source.WMTS({ + url: 'http://wxs.ign.fr/' + key + '/wmts', + layer: layer, + matrixSet: 'PM', + format: image_format, + projection: 'EPSG:3857', + tileGrid: plan_tileGrid, + style: 'normal', + attributions: [new ol.Attribution({ + html: '<a href="http://www.geoportail.fr/" target="_blank">' + + '<img src="http://api.ign.fr/geoportail/api/js/latest/' + + 'theme/geoportal/img/logo_gp.gif"></a>' + })] + }); + + return new ol.layer.Tile({ + baselayer: true, + name: name, + source: plan_ign_source + }); +} + + function transformExtent(extent) { return ol.proj.transformExtent( extent, EPSG_DISPLAY_PROJECTION, EPSG_PROJECTION); |
