64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
goog.require('ol.Attribution');
|
|
goog.require('ol.Coordinate');
|
|
goog.require('ol.Extent');
|
|
goog.require('ol.Map');
|
|
goog.require('ol.RendererHints');
|
|
goog.require('ol.View2D');
|
|
goog.require('ol.control.ScaleLine');
|
|
goog.require('ol.control.ScaleLineUnits');
|
|
goog.require('ol.control.defaults');
|
|
goog.require('ol.layer.TileLayer');
|
|
goog.require('ol.projection');
|
|
goog.require('ol.source.TiledWMS');
|
|
|
|
|
|
var projection = ol.projection.configureProj4jsProjection({
|
|
code: 'EPSG:21781',
|
|
extent: new ol.Extent(485869.5728, 76443.1884, 837076.5648, 299941.7864)
|
|
});
|
|
|
|
var extent = new ol.Extent(420000, 30000, 900000, 350000);
|
|
var layers = [
|
|
new ol.layer.TileLayer({
|
|
source: new ol.source.TiledWMS({
|
|
url: 'http://wms.geo.admin.ch/',
|
|
attributions: [new ol.Attribution(
|
|
'© ' +
|
|
'<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.TileLayer({
|
|
source: new ol.source.TiledWMS({
|
|
url: 'http://wms.geo.admin.ch/',
|
|
attributions: [new ol.Attribution(
|
|
'© ' +
|
|
'<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({
|
|
controls: ol.control.defaults({}, [
|
|
new ol.control.ScaleLine({
|
|
units: ol.control.ScaleLineUnits.METRIC
|
|
})
|
|
]),
|
|
layers: layers,
|
|
renderers: ol.RendererHints.createFromQueryData(),
|
|
target: 'map',
|
|
view: new ol.View2D({
|
|
projection: projection,
|
|
center: new ol.Coordinate(660000, 190000),
|
|
zoom: 2
|
|
})
|
|
});
|