-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenlayers_ringmap.html
263 lines (217 loc) · 8.03 KB
/
openlayers_ringmap.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE>
<html>
<head>
<title>OpenLayers Examples</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Bootstrap 3.0.3 -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" type="text/css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<!-- OpenLayers 2.13.1 -->
<link rel="stylesheet" href="http://www.openlayers.org/api/theme/default/style.css" type="text/css">
<script type="text/javascript" src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script>
<script type="text/javascript" src="./CreateRingMap.js"></script>
<!-- Geostats -->
<script type="text/javascript" src="http://www.empreinte-urbaine.eu/mapping/geostats/lib/geostats.js"></script>
<style type="text/css">
html, body {
width: 100%; height: 100%; padding: 0; margin: 0;
}
#wrap {
min-height: 100%; height: auto; margin: 0 auto -40px; padding: 0 0 40px;
}
#content {
padding-top: 60px; padding-bottom: 40px;
width: 100%;
}
#map {
width: 100%; height: 500px; background-color: #fff; border: 1px solid #ddd;
}
#footer {
height: 40px; line-height: 30px; background-color: #f5f5f5;
}
dt, dd {
height: 30px;
}
.dl-horizontal dt {
width: 120px;
}
.dl-horizontal dd {
margin-left: 130px;
}
.ringMapLegend{
position: absolute;
top: 130px;
left: 30px;
}
</style>
</head>
<body>
<div id="wrap">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">RingMap for OpenLayers (Version 2.13.1)</a>
</div>
</div>
</div>
<!-- Content Layout Start-->
<div id="content" class="container">
<div id="map"></div>
<br>
<div class="row">
<div class="col-xs-6">
<div id="toolbox" class="panel panel-default">
<div class="panel-body text-right">
<button class="btn btn-default" type="button" onclick="createRingMap();">Draw RingMap</button>
</div>
<div class="panel-footer">
<dl class="dl-horizontal">
<dt>Mandatory</dt><dd></dd>
<dt>*** sourceLayer : </dt>
<dd>
<select name="inputsourceLayer"></select>
</dd>
<dt>*** fieldNames : </dt>
<dd><input type="input" name="inputfieldNames" style="width:100%;" value="['a3_2000', 'a3_2001', 'a3_2002', 'a3_2003', 'a3_2004', 'a3_2004']"/></dd>
<hr>
<dt>Optional</dt><dd></dd>
<dt>labelDisplay : </dt>
<dd><input type="checkbox" name="inputlabelDisplay" checked/></dd>
<dt>labelField : </dt>
<dd><input type="input" name="inputlabelField" style="width:100%;" value="sgg_nm"/></dd>
<dt>valueDisplay : </dt>
<dd><input type="checkbox" name="inputvalueDisplay"/></dd>
<dt>anchorDisplay : </dt>
<dd><input type="checkbox" name="inputanchorDisplay" checked/></dd>
<dt>colors : </dt>
<dd><input type="input" name="inputcolors" style="width:100%;" value="['#8ec1dd', '#5aa2cf', '#3181bd', '#105ca4', '#08306b']"/></dd>
</dl>
</div>
</div>
</div>
<div class="col-xs-6">
<pre style="height:416px; overflow:auto;">
//샘플 예제
var map = new OpenLayers.Map('map', { ... });
var sourceLayer = new OpenLayers.Layer.Vector(
'Source Layer', { ... }
);
map.addLayer(sourceLayer);
var ringLayer = new OpenLayers.Layer.CreateRingMap(
'RingMap Layer', //레이어명
sourceLayer, //참조(소스) 벡터 데이터
fieldNames, //데이터 필드
{
//라벨 보기설정 (default false)
labelDisplay: false,
//라벨 필드설정
labelField: 'sgg_nm',
//링 피처에 값 표시 (default false)
valueDisplay: false,
//원본데이터 연결선 생성 (default false)
anchorDisplay: true,
//색상표시
colors: ['#8ec1dd', '#5aa2cf', '#3181bd']
}
);
map.addLayer(ringLayer);
</pre>
</div>
</div>
</div>
<!-- Content Layout Start-->
</div>
<div id="footer">
<div class="container">
<p class="text-muted text-center">(C)2014 by Hanjin Lee ([email protected])</p>
</div>
</div>
<script type="text/javascript">
var map = new OpenLayers.Map('map', {
projection: new OpenLayers.Projection("EPSG:900913")
});
var googleMap = [
new OpenLayers.Layer.Google("Google Roadmap", {
type: google.maps.MapTypeId.ROADMAP,
sphericalMercator: true
}),
new OpenLayers.Layer.Google("Google Satellite", {
//type: google.maps.MapTypeId.G_SKY_VISIBLE_MAP,
type: google.maps.MapTypeId.SATELLITE,
sphericalMercator: true, numZoomLevels: 20
}),
new OpenLayers.Layer.Google("Google Hybrid", {
type: google.maps.MapTypeId.HYBRID,
sphericalMercator: true
}),
new OpenLayers.Layer.Google("Google Terrain", {
type: google.maps.MapTypeId.TERRAIN,
sphericalMercator: true
})
]
map.addLayers(googleMap);
var sggGML = new OpenLayers.Layer.Vector('SGG GML', {
protocol: new OpenLayers.Protocol.HTTP({
url: './seoul_series.gml',
format: new OpenLayers.Format.GML()
}),
strategies: [new OpenLayers.Strategy.Fixed()]
});
map.addLayer(sggGML);
/*
var sggJSON = new OpenLayers.Layer.Vector('SGG GeoJSON', {
protocol: new OpenLayers.Protocol.HTTP({
url: './data/seoul_series.geojson',
format: new OpenLayers.Format.GeoJSON()
}),
strategies: [new OpenLayers.Strategy.Fixed()]
});
map.addLayer(sggJSON);
*/
map.zoomToExtent( new OpenLayers.Bounds(14052985.866789, 4480432.8493403, 14226956.543141, 4556564.1295017) );
//Add to Controls
map.addControl( new OpenLayers.Control.LayerSwitcher() );
map.addControl( new OpenLayers.Control.MousePosition() );
map.addControl( new OpenLayers.Control.Scale() );
map.addControl( new OpenLayers.Control.ScaleLine() );
$.each(map.getLayersByClass('OpenLayers.Layer.Vector'), function(index, item) {
$('select[name=inputsourceLayer]').html('<option value="'+ item.name +'">'+ item.name +'</option>');
});
function createRingMap() {
var crm = map.getLayersByClass('OpenLayers.Layer.CreateRingMap')[0];
if (crm != undefined) {
map.removeLayer(crm);
$('.ringMapLegend').remove();
}
var sourceLayer = map.getLayersByName($('select[name=inputsourceLayer]').val())[0];
var fieldNames = eval($('input[name=inputfieldNames]').val().trim());
var labelDisplay = $('input[name=inputlabelDisplay]').is(':checked');
var labelField = $('input[name=inputlabelField]').val().trim() != "" ? $('input[name=inputlabelField]').val() : null;
var valueDisplay = $('input[name=inputvalueDisplay]').is(':checked');
var anchorDisplay = $('input[name=inputanchorDisplay]').is(':checked');
var colors = $('input[name=inputcolors]').val().trim() != "" ? eval($('input[name=inputcolors]').val()) : null;
var ringLayer = new OpenLayers.Layer.CreateRingMap(
'RingMap Layer_' + map.getLayersByClass('OpenLayers.Layer.CreateRingMap').length,
sourceLayer, fieldNames,
{
labelDisplay: labelDisplay,
labelField: labelField,
valueDisplay: valueDisplay,
anchorDisplay: anchorDisplay,
colors: colors
}
);
map.addLayer(ringLayer);
var legendHtml = '<div class="ringMapLegend"><ul class="list-unstyled">';
for (var i=0; i<ringLayer.colors.length; i++) {
//alert( ringLayer.classify[i].toFixed(4) + ' ~ ' + ringLayer.classify[i].toFixed(4) + '/' + ringLayer.colors[i] );
legendHtml += '<li style="background-color:'+ ringLayer.colors[i] +'">'+ ringLayer.classify[i].toFixed(4) + ' ~ ' + ringLayer.classify[i+1].toFixed(4) +'</li>';
};
legendHtml += "</ul></div>";
$('#map').append(legendHtml);
}
</script>
</body>
</html>