diff --git a/examples/wms-single-image-custom-proj.html b/examples/wms-single-image-custom-proj.html new file mode 100644 index 0000000000..b833cdf7a3 --- /dev/null +++ b/examples/wms-single-image-custom-proj.html @@ -0,0 +1,52 @@ + + + + + + + + + + Tiled WMS with custom projection example + + + + + +
+ +
+
+
+
+
+ +
+ +
+

Single image WMS with custom projection example

+

Example of two single image WMS layers (Pixelmap 1:1'000'000 and national parks) using the projection EPSG:21781.

+
+

See the wms-single-image-custom-proj.js source to see how this is done.

+
+
wms, single, projection
+
+ +
+ +
+ + + + + diff --git a/examples/wms-single-image-custom-proj.js b/examples/wms-single-image-custom-proj.js new file mode 100644 index 0000000000..617b9c78b5 --- /dev/null +++ b/examples/wms-single-image-custom-proj.js @@ -0,0 +1,60 @@ +goog.require('ol.Attribution'); +goog.require('ol.Coordinate'); +goog.require('ol.Extent'); +goog.require('ol.Map'); +goog.require('ol.Projection'); +goog.require('ol.ProjectionUnits'); +goog.require('ol.RendererHints'); +goog.require('ol.View2D'); +goog.require('ol.layer.ImageLayer'); +goog.require('ol.projection'); +goog.require('ol.source.SingleImageWMS'); + + +var epsg21781 = new ol.Projection({ + code: 'EPSG:21781', + units: ol.ProjectionUnits.METERS, + // Validity extent from http://spatialreference.org + extent: new ol.Extent(485869.5728, 76443.1884, 837076.5648, 299941.7864) +}); +ol.projection.addProjection(epsg21781); + +var extent = new ol.Extent(420000, 30000, 900000, 350000); +var layers = [ + new ol.layer.ImageLayer({ + source: new ol.source.SingleImageWMS({ + url: 'http://wms.geo.admin.ch/', + attributions: [new ol.Attribution( + '© ' + + '' + + 'Pixelmap 1:1000000 / geo.admin.ch')], + params: { + 'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale', + 'FORMAT': 'image/jpeg' + }, + extent: extent + }) + }), + new ol.layer.ImageLayer({ + source: new ol.source.SingleImageWMS({ + url: 'http://wms.geo.admin.ch/', + attributions: [new ol.Attribution( + '© ' + + '' + + 'National parks / geo.admin.ch')], + params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'}, + extent: extent + }) + }) +]; + +var map = new ol.Map({ + layers: layers, + renderers: ol.RendererHints.createFromQueryData(), + target: 'map', + view: new ol.View2D({ + projection: epsg21781, + center: new ol.Coordinate(660000, 190000), + zoom: 2 + }) +});