Files
openlayers/examples/wms-image-custom-proj.js
2013-09-14 21:14:55 -06:00

60 lines
1.6 KiB
JavaScript

goog.require('ol.Attribution');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.layer.Image');
goog.require('ol.proj');
goog.require('ol.source.ImageWMS');
var projection = ol.proj.configureProj4jsProjection({
code: 'EPSG:21781',
extent: [[485869.5728, 76443.1884], [837076.5648, 299941.7864]]
});
var extent = [[420000, 30000], [900000, 350000]];
var layers = [
new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous',
attributions: [new ol.Attribution({
html: '© ' +
'<a href="http://www.geo.admin.ch/internet/geoportal/' +
'en/home.html">' +
'Pixelmap 1:1000000 / geo.admin.ch</a>'
})],
params: {
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
'FORMAT': 'image/jpeg'
},
extent: extent
})
}),
new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous',
attributions: [new ol.Attribution({
html: '&copy; ' +
'<a href="http://www.geo.admin.ch/internet/geoportal/' +
'en/home.html">' +
'National parks / geo.admin.ch</a>'
})],
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: projection,
center: [660000, 190000],
zoom: 2
})
});