UNPKG

1.63 kBJavaScriptView Raw
1goog.require('ol.Map');
2goog.require('ol.View');
3goog.require('ol.layer.Image');
4goog.require('ol.layer.Tile');
5goog.require('ol.proj.Projection');
6goog.require('ol.source.ImageWMS');
7goog.require('ol.source.TileWMS');
8
9
10var layers = [
11 new ol.layer.Tile({
12 source: new ol.source.TileWMS({
13 attributions: '© <a href="http://www.geo.admin.ch/internet/geoportal/' +
14 'en/home.html">Pixelmap 1:1000000 / geo.admin.ch</a>',
15 crossOrigin: 'anonymous',
16 params: {
17 'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
18 'FORMAT': 'image/jpeg'
19 },
20 url: 'https://wms.geo.admin.ch/'
21 })
22 }),
23 new ol.layer.Image({
24 source: new ol.source.ImageWMS({
25 attributions: '© <a href="http://www.geo.admin.ch/internet/geoportal/' +
26 'en/home.html">National parks / geo.admin.ch</a>',
27 crossOrigin: 'anonymous',
28 params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
29 serverType: 'mapserver',
30 url: 'https://wms.geo.admin.ch/'
31 })
32 })
33];
34
35// A minimal projection object is configured with only the SRS code and the map
36// units. No client-side coordinate transforms are possible with such a
37// projection object. Requesting tiles only needs the code together with a
38// tile grid of Cartesian coordinates; it does not matter how those
39// coordinates relate to latitude or longitude.
40var projection = new ol.proj.Projection({
41 code: 'EPSG:21781',
42 units: 'm'
43});
44
45var map = new ol.Map({
46 layers: layers,
47 target: 'map',
48 view: new ol.View({
49 center: [660000, 190000],
50 projection: projection,
51 zoom: 9
52 })
53});