1 | goog.require('ol.Map');
|
2 | goog.require('ol.View');
|
3 | goog.require('ol.control');
|
4 | goog.require('ol.control.ScaleLine');
|
5 | goog.require('ol.layer.Image');
|
6 | goog.require('ol.proj');
|
7 | goog.require('ol.proj.Projection');
|
8 | goog.require('ol.source.ImageWMS');
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | var projection = new ol.proj.Projection({
|
27 | code: 'EPSG:21781',
|
28 | extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
|
29 | });
|
30 |
|
31 | var extent = [420000, 30000, 900000, 350000];
|
32 | var layers = [
|
33 | new ol.layer.Image({
|
34 | extent: extent,
|
35 | source: new ol.source.ImageWMS({
|
36 | url: 'https://wms.geo.admin.ch/',
|
37 | crossOrigin: 'anonymous',
|
38 | attributions: '© <a href="http://www.geo.admin.ch/internet/geoportal/' +
|
39 | 'en/home.html">Pixelmap 1:1000000 / geo.admin.ch</a>',
|
40 | params: {
|
41 | 'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
42 | 'FORMAT': 'image/jpeg'
|
43 | },
|
44 | serverType: 'mapserver'
|
45 | })
|
46 | }),
|
47 | new ol.layer.Image({
|
48 | extent: extent,
|
49 | source: new ol.source.ImageWMS({
|
50 | url: 'https://wms.geo.admin.ch/',
|
51 | crossOrigin: 'anonymous',
|
52 | attributions: '© <a href="http://www.geo.admin.ch/internet/geoportal/' +
|
53 | 'en/home.html">National parks / geo.admin.ch</a>',
|
54 | params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
55 | serverType: 'mapserver'
|
56 | })
|
57 | })
|
58 | ];
|
59 |
|
60 | var map = new ol.Map({
|
61 | controls: ol.control.defaults().extend([
|
62 | new ol.control.ScaleLine()
|
63 | ]),
|
64 | layers: layers,
|
65 | target: 'map',
|
66 | view: new ol.View({
|
67 | projection: projection,
|
68 | center: ol.proj.fromLonLat([8.23, 46.86], projection),
|
69 | extent: extent,
|
70 | zoom: 2
|
71 | })
|
72 | });
|