-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path106_!_SingleImageWMSwithProj4js.html
98 lines (89 loc) · 3.58 KB
/
106_!_SingleImageWMSwithProj4js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="ol.js"></script>
<link rel="stylesheet" href="ol.css">
<script
src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL">
</script>
</head>
<script>
// :
//기본 : Map View Source Layer
//추가 :
</script>
<body>
<!-- 기본틀로 사용하는 양식 -->
<div id="map" class="map"></div>
<script>
// Transparent Proj4js support:
//
// EPSG:21781 is known to Proj4js because its definition is registered by
// calling proj4.defs(). Now when we create an ol/proj/Projection instance with
// the 'EPSG:21781' code, OpenLayers will pick up the transform functions from
// Proj4js. To get the registered ol/proj/Projection instance with other
// parameters like units and axis orientation applied from Proj4js, use
// `ol/proj#get('EPSG:21781')`.
//
// Note that we are setting the projection's extent here, which is used to
// determine the view resolution for zoom level 0. Recommended values for a
// projection's validity extent can be found at https://epsg.io/.
proj4.defs('EPSG:21781',
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 ' +
'+x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=660.077,13.551,369.344,2.484,1.783,2.939,5.66 +units=m +no_defs');
ol.proj.proj4.register(proj4);
var projection = new ol.proj.Projection({
code: 'EPSG:21781',
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864]
});
var extent = [420000, 30000, 900000, 350000];
var layers = [
new ol.layer.Image({
extent: extent,
source: new ol.source.ImageWMS({
url: 'https://wms.geo.admin.ch/',
crossOrigin: 'anonymous',
attributions: '© <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'
},
serverType: 'mapserver'
})
}),
new ol.layer.Image({
extent: extent,
source: new ol.source.ImageWMS({
url: 'https://wms.geo.admin.ch/',
crossOrigin: 'anonymous',
attributions: '© <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'
},
serverType: 'mapserver'
})
})
];
var map = new ol.Map({
controls: defaultControls().extend([
new ol.controls.ScaleLine()
]),
layers: layers,
target: 'map',
view: new ol.View({
projection: projection,
center: fromLonLat([8.23, 46.86], projection),
extent: extent,
zoom: 2
})
});
</script>
</body>
</html>