-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathol3_daum_5181.html
159 lines (146 loc) · 6.34 KB
/
ol3_daum_5181.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>OpenLayers3 Tile Map Test - ESPG 5181</title>
<style>
body {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
width: 100%;
}
.map {
width: 100%;
height: 100%;
z-index: 0;
}
</style>
<!-- OpenLayers 3 & Proj4js -->
<link rel="stylesheet" type="text/css" href="javascript/ol.css" />
<script type="text/javascript" src="javascript/ol.js"></script>
<link rel="stylesheet" type="text/css" href="javascript/ol3-layerswitcher.css" />
<script type="text/javascript" src="javascript/ol3-layerswitcher.js"></script>
<script type="text/javascript" src="javascript/proj4.js"></script>
<script type="text/javascript">
// define epsg:5181 projection
proj4.defs("EPSG:5181","+proj=tmerc +lat_0=38 +lon_0=127 +k=1 +x_0=200000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
ol.proj.setProj4 = proj4;
var resolutions = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25];
var extent = [-30000, -60000, 494288, 988576];
var projection = new ol.proj.Projection({
code: 'EPSG:5181',
extent: extent,
units: 'm'
});
// define tile layer
var tileLayer = new ol.layer.Tile({
title : 'Daum Street Map',
visible : true,
type : 'base',
source : new ol.source.XYZ({
projection: projection,
tileSize: 256,
minZoom: 0,
maxZoom: resolutions.length - 1,
tileGrid: new ol.tilegrid.TileGrid({
origin: [extent[0], extent[1]],
resolutions: resolutions
}),
tileUrlFunction: function (tileCoord, pixelRatio, projection) {
if (tileCoord == null) return undefined;
var s = Math.floor(Math.random() * 4); // 0 ~ 3
var z = resolutions.length - tileCoord[0];
var x = tileCoord[1];
var y = tileCoord[2];
return 'http://map' + s + '.daumcdn.net/map_2d/2fso49/L' + z + '/' + y + '/' + x + '.png';
},
attributions: [
new ol.Attribution({
html: ['<a href="http://map.daum.net"><img src="http://i1.daumcdn.net/localimg/localimages/07/mapjsapi/m_bi.png"></a>']
})
]
})
});
function init() {
// set map
var map = new ol.Map({
controls : [
new ol.control.Attribution({
collapsible: true
}),
new ol.control.Zoom(),
new ol.control.FullScreen(),
new ol.control.MousePosition({
projection: 'EPSG:4326',
coordinateFormat: ol.coordinate.createStringXY(2)
}),
new ol.control.ZoomToExtent({
extent: extent
}),
new ol.control.ScaleLine(),
new ol.control.LayerSwitcher()
],
layers : [
new ol.layer.Group({
title : 'Base Maps',
layers : [
tileLayer
]
}),
new ol.layer.Group({
title: 'Tiled WMS',
layers: [
]
})
],
target : 'map',
renderer: 'canvas',
interactions : ol.interaction.defaults({
shiftDragZoom : true
}),
view : new ol.View({
projection: projection,
extent: extent,
resolutions: resolutions,
maxResolution: resolutions[0],
zoomFactor: 1,
center : [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2],
zoom : 0
})
});
// add gwc layer to map
var layer = 'foss:korea_sgg';
map.addLayer(createGWCLayer(layer, layer, '', false, false));
};
/**
* Helper method for gwc layer.
*/
var createGWCLayer = function(layer, title, styles, isBaseLayer, isVisible) {
var gwcLayer = new ol.layer.Tile({
title : title,
type: isBaseLayer ? 'base' : '',
visible : isVisible,
source: new ol.source.TileWMS({
url: 'http://localhost:8080/geoserver/gwc/service/wms',
serverType: 'geoserver',
params: {
'TILED': true,
'VERSION': '1.1.0', // must be 1.1.0, not 1.3.0
'STYLES': styles,
'LAYERS': layer,
'FORMAT': 'image/png',
'TRANSPARENT': 'true'
}
})
});
return gwcLayer;
};
</script>
</head>
<body onload="init()">
<div id="map" class="map"></div>
</body>
</html>