-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharrowStyle.html
More file actions
166 lines (156 loc) · 5.23 KB
/
Copy patharrowStyle.html
File metadata and controls
166 lines (156 loc) · 5.23 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
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">
<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">
유형 :
<select class="selectCustom" id="arrowType" onChange="setStyle()">
<option value="ALL_POINT">모든 포인트</option>
<option value="START_AND_END_POINT" selected="true">처음과 끝</option>
</select>
시작점 모양 :
<select class="selectCustom" id="startIcon" onChange="setStyle()">
<option value="blackTriangle" selected="true">◀</option>
<option value="whiteTriangle">◁</option>
<option value="bracket"><</option>
<option value="blackEquilateralArrow">⮜</option>
<option value="blackCircle">●</option>
<option value="whiteCircle">○</option>
<option value="none">없음</option>
</select>
종료점 모양 :
<select class="selectCustom" id="endIcon" onChange="setStyle()">
<option value="blackTriangle">▶</option>
<option value="whiteTriangle">▷</option>
<option value="bracket">></option>
<option value="blackEquilateralArrow">⮞</option>
<option value="blackCircle" selected="true">●</option>
<option value="whiteCircle">○</option>
<option value="none">없음</option>
</select>
</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 lineLayer = odf.LayerFactory.produce('geoserver', {
method : 'get',
server : 'https://geoserver.geon.kr/geoserver',
layer : 'geonpaas:L100000255', // 발행된 레이어 명칭 (ex. 저장소명:레이어명)
crtfckey : '',
service : 'wfs',
});
lineLayer.setMap(map);
lineLayer.fit();
map.setZoom(19);
/*startEndStyle 생성*/
function setArrow(startCoord, endCoord,{startIcon,endIcon}) {
styleArr = [];
var rotation = Math.atan2(endCoord[1] - startCoord[1], endCoord[0] - startCoord[0]);
if(startIcon!=='none'){
styleArr.push(odf.StyleFactory.produce({
geometry: odf.GeometryFactory.produce({
geometryType: 'point',
coordinates: startCoord,
}),
image: {
icon : {
crossOrigin : 'Anonymous',
src : `/js/oui/images/widget/arrowIcon/${startIcon}.png`,
scale : 0.4,
opacity :1,
rotation: -rotation + Math.PI,
color: [0, 255, 252, 0.95]
},
}
}));
}
/*end*/
if(endIcon!=='none'){
styleArr.push(odf.StyleFactory.produce({
geometry: odf.GeometryFactory.produce({
geometryType: 'point',
coordinates: endCoord,
}),
image: {
icon: {
crossOrigin : 'Anonymous',
src: `/js/oui/images/widget/arrowIcon/${endIcon}.png`,
scale: 0.4,
opacity :1,
rotation: -rotation,
color: [255, 0, 252, 0.95]
},
}
}));
}
return styleArr;
}
/*스타일 생성*/
function setStyle(){
var arrowType = document.getElementById('arrowType').value;
var startIcon = document.getElementById('startIcon').value;
var endIcon = document.getElementById('endIcon').value;
var styleOption = [
{
seperatorFunc : 'default',
style : {
stroke : {
color:[255,0,252,0.95],
lineCap : 'round',//선의 끝부분 모양('butt'(네모지게-선이 원래 길이보다 조금 일찍 끝남) / 'round' (둥글게) / 'square'(네모지게))
lineJoin : 'round',//('bevel' (꺾이는 부분을 지붕모양으로 )/ 'round' (둥글게)/ 'miter'(뾰족하게))
//lineDash : [10],//점선의 간격 크기
width:2
}
},
callbackFunc : function(style, feature, resolution) {
var styleArr = [style];
var geometries=[feature.getGeometry()];
if(feature.getGeometry().getType()==='MultiLineString'){
geometries = geometries[0].getLineStrings();
}
geometries.forEach((geometry,gIdx)=>{
if(arrowType==='ALL_POINT'){
geometry.forEachSegment((start, end)=>{
styleArr=styleArr.concat(setArrow(start, end,{startIcon,endIcon}));
});
}else{
var coordinates = geometry.getCoordinates();
var start = coordinates[0];
var end = coordinates[coordinates.length-1];
if(start[0]===end[0]&&start[1]===end[1]){
end = coordinates[coordinates.length-2];
}
styleArr = styleArr.concat(setArrow(coordinates[0],coordinates[1],{startIcon,endIcon : 'none'}));
styleArr = styleArr.concat(setArrow(coordinates[coordinates.length-2],coordinates[coordinates.length-1],{startIcon : 'none',endIcon}));
}
});
return styleArr;
},
}
];
var style = odf.StyleFactory.produceFunction(styleOption);
lineLayer.setStyle(style);
}
setStyle();
</script>
</html>