-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
166 lines (141 loc) · 4.86 KB
/
index.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
160
161
162
163
164
165
166
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Layer Groups</title>
<link rel="stylesheet" type="text/css" href="drlee_v3-demo.css">
<link rel="stylesheet" href="css/ol.css" type="text/css">
<script src="drlee_v3-demo.js"></script>
<script src="build/ol.js"></script>
<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
</head>
<body>
<div id="leftsidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a href="#">About</a>
<a href="#">Service</a>
<a href="#">Clients</a>
<a href="#">부가기능</a>
<a href="#">설정</a>
</div>
<!-- 사이드 내비 -->
<span id=leftmenubtn style="color:#ffffff; font-size:30px; cursor:pointer" onclick="openNav()">☰</span>
<div id="map" class="map"></div>
<!-- 좌표 입력 후 엔터를 치면 이동 -->
<div id="pantool" class="tools">
<h4>이동</h4> <h6>ex) 127 37</h6> <br />
<input type="text" id=coordedit name="posXY">
</div>
<div id="layertree" class="tools">
<h4>레이어 설정</h4> <h6>Click a Layer name</h6>
<button id="btnaddlayer" type="button">레이어 추가</button>
<table id="layertable"> </table>
</div>
<!-- 하단 정보 출력-->
<div id="footer">
<div id="location"></div>
</div>
<!-- 레이어 추가 창 -->
<div id="dlgaddlayer" class="modal">
<div class="modal-inner">
<div class="modal-content">
<div class="control-header">
<p>레이어 추가</p>
</div>
<div id="form-addlayer">
<label><b>Title</b></label>
<input type="text" id="addlayer-title" placeholder="제목을 입력하세요." name="name" required>
<label><b>URL</b></label>
<input type="text" id="addlayer-url" placeholder="경로를 입력하세요." name="path" required>
<label><b>Name</b></label>
<input type="text" id="addlayer-name" placeholder="WMS 레이어 이름을 입력하세요." name="path" required>
<button id="ok" onclick="btnaddlayer()">Confirm</button>
</div>
<span class="close">x</span>
</div>
</div>
</div>
<script type="text/javascript">
var map;
window.onload = function() {
var osmLayer = new ol.layer.Tile({
source: new ol.source.OSM(),
name: 'OSM layer'
});
var worldBorderLayer = new ol.layer.Tile({
source: new ol.source.TileJSON({
url: 'http://api.tiles.mapbox.com/v3/' +
'mapbox.world-borders-light.json',
crossOrigin: 'anonymous'
}),
name: 'World borders layer'
});
var wmslayers = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://192.168.1.48:8080/geoserver/nurc/wms',
params: {'LAYERS': 'nurc:Arc_Sample', 'TILED': true},
serverType: 'geoserver'
}),
name: 'wms - arc sample'
});
var layers = [ osmLayer ,
new ol.layer.Group({
name : 'my group',
layers: [
worldBorderLayer,
wmslayers
]
})
];
// 마우스 드래그
var mousePositionControl = new ol.control.MousePosition({
projection: 'EPSG:4326',
className: 'custom-mouse-position',
target: document.getElementById('location'),
coordinateFormat: ol.coordinate.createStringXY(5),
undefinedHTML: ' '
});
map = new ol.Map({
layers: layers,
controls: ol.control.defaults().extend([
mousePositionControl,
new ol.control.FullScreen()
]),
target: 'map',
view: new ol.View({
center: ol.proj.fromLonLat([127.40570, 37.81566]),
zoom: 7
}),
// the renderer property can be set to 'canvas', 'dom' or 'webgl'
renderer: 'canvas'
});
setLayerList(map.getLayers());
/* 좌표 입력 엔터 이벤트 추가 */
$("#coordedit").keyup(function(event){
if(event.keyCode == 13){
var str = $("#coordedit").val().split(" ").map(Number);
var loc = ol.proj.transform(str, 'EPSG:4326', 'EPSG:3857');
panTo(loc);
}
});
initModal();
};
function initModal() {
var modal = document.getElementById('dlgaddlayer');
var btn = document.getElementById('btnaddlayer');
var span = document.getElementsByClassName('close')[0];
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
}
</script>
</body>
</html>