-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectFeatureOnClick.html
More file actions
80 lines (71 loc) · 2.27 KB
/
selectFeatureOnClick.html
File metadata and controls
80 lines (71 loc) · 2.27 KB
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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<link href="https://developer.geon.kr/js/odf/odf.css" rel="stylesheet">
<script type="text/javascript" src="https://developer.geon.kr/js/odf/odf.min.js"></script>
</head>
<body>
<div id="map" class="odf-view" style="height:550px;"></div>
<p>지도에서 피처를 클릭해보세요</p>
<div class="infoArea" style="margin-top: 15px;">
<div id="featureInfo"></div>
</div>
</body>
<script>
/* 맵객체 생성 (외부에서 사용할 때는 proxyURL, proxyParam 옵션이 필요합니다.) */
var mapContainer = document.getElementById('map');
var coord = new odf.Coordinate(199312.9996,551784.6924);
var mapOption = {
center : coord,
zoom : 11,
projection : 'EPSG:5186',
//proxyURL: 'proxyUrl.jsp',
//proxyParam: 'url',
vWorldURL : 'https://gsapi.geon.kr/map/api/vworld/wmts',
basemap : {
vWorld : ['vWorldBase', 'vWorldWhite', 'vWorldMidnight', 'vWorldHybrid', 'vWorldSatellite'],
},
};
var map = new odf.Map(mapContainer, mapOption);
/*wfs 레이어 생성*/
var wfsLayer = odf.LayerFactory.produce('geoserver', {
method : 'get',
server : 'https://geoserver.geon.kr/geoserver',
layer : 'geonpaas:L100000254',
service : 'wfs',
});
wfsLayer.setMap(map);
wfsLayer.fit();
// wfs 레이어 스타일 생성
var wfsstyle = odf.StyleFactory.produce({
fill : {
color : [ 255, 255, 255, 0 ],
},
stroke : {
color : 'red',
width : 3,
},
});
wfsLayer.setStyle(wfsstyle);
//지도 클릭시 클릭한 위치에 있는 feature 정보 조회
odf.event.addListener(map, 'click', function(evt) {
//클릭한 위치의 feature 정보 조회
var featureObject = map.selectFeatureOnClick(evt);
if(featureObject.length===0){
return;
}
if (document.getElementById('creDiv')) {
var creDiv = document.getElementById('creDiv');
creDiv.innerText = 'DGM_NM = ' + featureObject[0].feature.getProperties().DGM_NM;
} else {
var creDiv = document.createElement('div');
creDiv.setAttribute('id', 'creDiv');
creDiv.innerText = 'DGM_NM = ' + featureObject[0].feature.getProperties().DGM_NM;
}
document.getElementById('featureInfo').append(creDiv);
//iframe 크기 조절
if (parent.window.containerResize) parent.window.containerResize();
}.bind(this));
</script>
</html>