-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimplePointStyle.html
More file actions
109 lines (104 loc) · 3.67 KB
/
simplePointStyle.html
File metadata and controls
109 lines (104 loc) · 3.67 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
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
<!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>
<div class="btnDiv">
<input type="button" onclick="changeStyle(false)" class="onoffBtn" value="테두리 스타일 1">
<input type="button" onclick="changeStyle(true)" class="onoffBtn" value="테두리 스타일 2">
</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);
/*포인트 레이어 추가*/
var pointLayer = odf.LayerFactory.produce('geoserver', {
method : 'get',
server : 'https://geoserver.geon.kr/geoserver',
layer : 'geonpaas:L100000256', // 발행된 레이어 명칭 (ex. 저장소명:레이어명)
crtfckey : '',
service : 'wfs',
});
pointLayer.setMap(map);
pointLayer.fit();
/*점 스타일 생성*/
var pointStyle = odf.StyleFactory.produce({
image : {
circle : {
radius : 25,//크기
fill : {
color : [ 0, 0, 0, 0.2 ]
//채우기 색
},//채우기
stroke : {//윤곽선
color : [ 132, 229, 252, 0.95 ],//테두리 색
width : 10,//굵기
//lineDash:[4, 1]//점선 설정
},
//축척
scale :1,
// snapToPixel : true //true : sharp, false : blur
/*
//타원 스타일
//원래 크기의 n배 [가로 축척, 세로 축척]
scale : [1, 0.2],
//회전
rotation : (Math.PI*30/180),
//지도 회전시 같이 회전할지 여부
rotateWithView : true,
*/
}
},
text : {
text : '포인트스타일',//텍스트 내용
//offsetX : 0,//기준점으로부터 텍스트 x좌표 위치 이동
//offsetY : 0,//기준점으로부터 텍스트 Y좌표 위치 이동
//rotation : (Math.PI*270/180), //회전
//textAlign : 'left',//텍스트 수평정렬
//textBaseline : 'middle',//텍스트 수직정렬
font : 'bold 14px Courier New',//폰트 크기(필수) 및 글씨체(필수), 두께(옵션)
fill : {
color : [ 0, 0, 0, 0.95 ]
},
stroke : {//text 안의 stroke는 lineCap/lineJoin/lineDash/lineDashOffset/miterLimit 옵션 적용 x
color : [ 255, 255, 255, 0.8 ],
},
padding : [ 0.5, 0.5, 0.5, 0.5 ],//text와 background영역 사이의 여백 //placement :'line' 일 경우 미적용
backgroundStroke : {
color : 'black'
},//placement :'line' 일경우 미적용
backgroundFill : {
color : 'white'
},//placement :'line' 일경우 미적용
//maxAngle : 90*Math.PI/180,//placement :'line' 일경우 적용
//overflow : false,//placement :'line' 일경우 적용//텍스트를 나열한 길이보다 선이 짧을 경우, 넘치는 글자를 쭉 나열할지 여부
scale : 1, //텍스트 크기를 정해진 값의 n배로 셋팅
rotateWithView : true
//지도가 회전할때 텍스트도 적절하게 회전할지 여부
}
});
pointLayer.setStyle(pointStyle);
//스타일 변경
function changeStyle(styleFlag){
var chagedStyle = pointStyle.modify('image.circle.stroke.color', styleFlag?'pink':[ 132, 229, 252, 0.95 ]);
pointLayer.setStyle(chagedStyle);
}
</script>
</html>