-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
executable file
·583 lines (506 loc) · 17.5 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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="description" content="Cesiumを使った日野市オープンデータ可視化のサンプルです" />
<meta property="og:image" content="data/hinoshi.png"
/>
<meta property="og:description" content="Cesiumを使った日野市オープンデータ可視化のサンプルです" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>日野市オープンデータ可視化</title>
<link rel="alternate" href="http://hiroshima.archiving.jp/index_en.html" hreflang="en" />
<link rel="SHORTCUT ICON" href="http://shinsai.mapping.jp/favicon.ico">
<style>
@import url(Cesium/Widgets/widgets.css);
</style>
<link rel="stylesheet" type="text/css" media="all" href="./css/style.css" />
<link rel="stylesheet" type="text/css" media="all" href="./css/menubutton.css" />
<script src="js/jquery-2.1.3.min.js"></script>
<script src="js/slidein.js"></script>
<script src="js/slidein2.js"></script>
<script src="Cesium/Cesium.js"></script>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js"></script>
</head>
<body>
<div class="geocode">
<form action="javascript:geocode()" class="textbox" />
<input id="inputtext" class="textbox" type="text" value="" placeholder="地名で検索"/>
</form>
</div>
<div id="svNotAvailable" onclick="fadeInOut(svNotAvailable,0)"></div>
<div id="blackOut">
<img class="loading" src="data/loading.gif">
</div>
<div id="cesiumContainer"></div>
<div id="button" class="general-button">
<div class="button-content">
<span class="icon-font">menu</span>
</div>
</div>
<div id="button2" class="general-button" onclick="help();">
<div class="button-content">
<span class="icon-font">help</span>
</div>
</div>
<div id="button3" class="general-button">
<div class="button-content">
<span class="icon-font">paramater</span>
</div>
</div>
<div id="button4" class="general-button" onclick="streetView();">
<div class="button-content">
<span class="icon-font">car</span>
</div>
</div>
<div id="buttonGeo" class="general-button" onclick="flyToMyLocation();">
<div class="button-content">
<span class="icon-font">geo</span>
</div>
</div>
<div id="slide_menu"></div>
<div id="slide_menu2"></div>
<div id="streetView_wrapper">
<div id="streetView"></div>
<button class="btn" onclick="fadeInOut(streetView_wrapper,0)">×</button>
</div>
<script>
//スワイプによるスクロール禁止
var cesiumDiv = document.getElementById("cesiumContainer");
function preventScroll(event) {
event.preventDefault();
}
cesiumDiv.addEventListener("gesturestart", preventScroll, false);
cesiumDiv.addEventListener("gesturechange", preventScroll, false);
cesiumDiv.addEventListener("gestureend", preventScroll, false);
//各種DIV
var blackOutDiv = document.getElementById("blackOut");
var streetViewWrapper = document.getElementById("streetView_wrapper");
var svNotAvailable = document.getElementById("svNotAvailable");
//SVエラーメッセージレイヤを隠す
$(function() {
$(svNotAvailable).hide();
$('#button4').hide();
});
//視点作成配列
function viewPoints(_label, _lat, _lng, _heading, _pitch, _range) {
this.label = _label;
this.lat = _lat;
this.lng = _lng;
this.heading = _heading;
this.pitch = _pitch;
this.range = _range;
}
var viewPointsArray=[];
viewPointsArray[0]=new viewPoints("首都大",35.661,139.3657347,0,-45,1000);
viewPointsArray[1]=new viewPoints("日野市",35.654,139.394,0,-89,15000);
viewPointsArray[2]=new viewPoints("初期視点",35.654,139.394,0,-35,5000);
//視点メニュー作成
var viewPointChangeMenu = document.getElementById('slide_menu');
var dropDownList = "";
for (var i=0; i<viewPointsArray.length; i++) {
dropDownList = dropDownList + '<li><a href="#" onclick = "changeViewPoint(' + i + ',' + '3.0);return false;">' + viewPointsArray[i].label + '</a></li>';
}
var viewPointChangeMenuHtml = '<ul class="viewpoint">' + dropDownList + '</ul>';
viewPointChangeMenu.innerHTML = viewPointChangeMenuHtml;
//KML配列作成
function kmlData(_label, _url) {
this.label = _label;
this.url = _url;
}
var kmlDataArray=[];
kmlDataArray[0]=new kmlData("第1週",'data/kml/dec1.kml');
kmlDataArray[1]=new kmlData("第2週",'data/kml/dec2.kml');
kmlDataArray[2]=new kmlData("第3週",'data/kml/dec3.kml');
kmlDataArray[3]=new kmlData("第4週",'data/kml/dec4.kml');
//オーバレイ配列を用意
var overlayDataArray=[];
var openStreetMap = [];
//ビューア初期化
var viewer = new Cesium.Viewer('cesiumContainer',{
imageryProvider : new Cesium.ArcGisMapServerImageryProvider({
url : '//server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer',
enablePickFeatures : false
}),
navigationHelpButton : false,
navigationInstructionsInitiallyVisible : false,
geocoder:false,
timeline: false,
animation: false,
sceneModePicker:false,
baseLayerPicker:false,
scene3DOnly : true,
terrainExaggeration : 0
});
//地形メッシュを設定
var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
url : '//assets.agi.com/stk-terrain/world',
requestWaterMask : true,
requestVertexNormals : true
});
viewer.terrainProvider = cesiumTerrainProviderMeshes;
//フォグ
var fog = new Cesium.Fog();
fog.density = 0.0005;
fog.screenSpaceErrorFactor = 100.0;
//起動シークエンス
$(function() {
$('.cesium-widget-credits').css('display', 'none');
});
fadeInOut(blackOutDiv,0);
var layers = viewer.scene.imageryLayers;
setTimeout('groundZero()',1000);
function groundZero(){
changeViewPoint(1,3);
openStreetMapLayer();
setTimeout('landing()',4000);
}
function landing(){
changeViewPoint(2,3);
setTimeout('fadeInOut(blackOutDiv,1)',3000);
setTimeout('loadKml()',3000);
}
//KMLロード関数
function loadKml(){
var i = 0;
var load = setInterval(function(){
var kmlDataSource = new Cesium.KmlDataSource;
var promise = kmlDataSource.load(kmlDataArray[i].url);
promise.then(function(dataSource) {
viewer.dataSources.add(dataSource);
}).otherwise(function(error){
alert('KMLデータが読み込めません');
});
i++;
if (i == kmlDataArray.length){
console.log (kmlDataSource.entities._entities._array);
//createModel('http://localhost/cesium/data/kml/circle.gltf',0,35.656298,139.38229);
clearInterval(load);
setClickEvent();
setTimeout('fadeInOut(blackOutDiv,0)',3000);
}
}, 200);
}
//地図オーバレイ関数
function openStreetMapLayer (){
openStreetMap = layers.addImageryProvider(new Cesium.createOpenStreetMapImageryProvider());
//OSMの明度を下げる
openStreetMap.brightness = 0.7;
openStreetMap.saturation = 0.2;
//OSMの不透明度をデフォルト0に
openStreetMap.alpha = 1;
//オーバーレイ配列作成関数
function overlayData(_label, _value, _overlayObj, _id) {
this.label = _label;
this.value = _value;
this.overlayObj = _overlayObj;
this.id = _id;
}
overlayDataArray[0]=new overlayData("現在の地図",100,openStreetMap,"range01");
var overlayList = "";
for (var i=0; i<overlayDataArray.length; i++) {
overlayList = overlayList + '<p class="slide_label">' + overlayDataArray[i].label + '</p><input id="' + overlayDataArray[i].id + '" type="range" min="0" max="33" value="' + overlayDataArray[i].value * 0.33 + '" step="1" oninput="transParent(' + i + ');"/>';
}
var overlayListMenu = document.getElementById('slide_menu2');
overlayListMenu.innerHTML = overlayList;
}
//OSM透明度を変更する関数
function transParent (layer){
var id = overlayDataArray[layer].id;
var overlay = overlayDataArray[layer].overlayObj;
var slider = document.getElementById(id);
if (slider.value == 0){
overlay.show = false;
} else{
overlay.show = true;
overlay.alpha = slider.value * 0.03;
}
}
//視点移動する関数
function changeViewPoint(num, delay) {
var newLat = viewPointsArray[num].lat;
var newLng = viewPointsArray[num].lng;
var newHeading = Cesium.Math.toRadians(viewPointsArray[num].heading);
var newPitch = Cesium.Math.toRadians(viewPointsArray[num].pitch);
var newRange = viewPointsArray[num].range;
var center = Cesium.Cartesian3.fromDegrees(newLng, newLat);
var boundingSphere = new Cesium.BoundingSphere(center, newRange);
var headingPitchRange = new Cesium.HeadingPitchRange(newHeading, newPitch, newRange);
viewer.camera.constrainedAxis = Cesium.Cartesian3.UNIT_Z;
viewer.camera.flyToBoundingSphere(boundingSphere,{
duration : delay,
offset : headingPitchRange,
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT
});
}
//ジオコード関数
function geocode() {
var geocoder = new google.maps.Geocoder();
var input = document.getElementById('inputtext').value;
geocoder.geocode(
{ address:input },
function( results, status ) {
if( status == google.maps.GeocoderStatus.OK ) {
var viewportObj = results[0].geometry.viewport;
var southNorth = viewportObj[Object.keys(viewportObj)[0]];
var westEast = viewportObj[Object.keys(viewportObj)[1]];
var south = southNorth[Object.keys(southNorth)[0]];
var north = southNorth[Object.keys(southNorth)[1]];
var west = westEast[Object.keys(westEast)[0]];
var east = westEast[Object.keys(westEast)[1]];
var rectangle = Cesium.Rectangle.fromDegrees(west, south, east, north);
viewer.camera.flyTo({
destination : rectangle,
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT
});
} else {
alert('見つかりません');
}
}
);
}
//ダブルクリックでストビューを表示する関数
function setClickEvent(){
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(click) {
var pickedObject = viewer.scene.pick(click.position);
if (Cesium.defined(pickedObject) && (pickedObject != "")) {
var position = pickedObject.primitive._position;
console.log (position);
var cart = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
var latlng = new google.maps.LatLng(Cesium.Math.toDegrees(cart.latitude), Cesium.Math.toDegrees(cart.longitude));
var sv = new google.maps.StreetViewService();
sv.getPanoramaByLocation(latlng, 50,
function (data, status) {
//ストリートビュー未対応エリアの場合
if (status != google.maps.StreetViewStatus.OK) {
svNotAvailable.innerHTML = '<p class="errorMessage">この場所のストリートビューは利用できません</p>';
fadeInOut(svNotAvailable,1);
setTimeout('fadeInOut(svNotAvailable,0)',1500);
}
else{
streetViewWrapper.style.display = "block";
fadeInOut(streetViewWrapper,1);
var svp = new google.maps.StreetViewPanorama(
document.getElementById("streetView"),{
position : latlng
});
}
var newHeading = Cesium.Math.toRadians(0);
var newPitch = Cesium.Math.toRadians(-85);
var newRange = 500;
var center = position;
var boundingSphere = new Cesium.BoundingSphere(center, 1000);
var headingPitchRange = new Cesium.HeadingPitchRange(newHeading, newPitch, newRange);
viewer.camera.flyToBoundingSphere(boundingSphere,{
duration : 1,
offset : headingPitchRange,
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT
});
});
}
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
}
//現在地へ移動する関数
function flyToMyLocation() {
function fly(position) {
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(position.coords.longitude, position.coords.latitude, 750.0),
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT
});
}
navigator.geolocation.getCurrentPosition(fly);
}
//ヘルプ
function help(){
window.open('http://labo.wtnv.jp/');
}
//DIVのフェードイン・アウト 関数
function fadeInOut(layer,param) {
if (param == 0){
$(function() {
$(layer).fadeOut("slow");
});
viewer.trackedEntity = undefined;
} else {
$(function() {
$(layer).fadeIn("slow");
});
}
}
function createModel(url, height, latitude, longitude) {
viewer.entities.removeAll();
var position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
var heading = Cesium.Math.toRadians(135);
var pitch = 0;
var roll = 0;
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, heading, pitch, roll);
var entity = viewer.entities.add({
name : url,
position : position,
orientation : orientation,
model : {
uri : url,
minimumPixelSize : 128,
maximumScale : 20000
}
});
}
//createModel('http://localhost/cesium/data/kml/circle.glb',100,35.656298,139.38229);
var options = [{},
{ text : '日野台幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.656298,
longitude : 139.38229
},{
text : '欣浄寺みのり幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6806894,
longitude : 139.3975367
},{
text : '日野ふたば幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6608301,
longitude : 139.3884801
},{
text : '光塩女子学院日野幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6428853,
longitude : 139.3997301
},{
text : '日野わかくさ幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6562653,
longitude : 139.4323905
},{
text : '百草台幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6718788,
longitude : 139.3832883
},{
text : '日野ひかり幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6718788,
longitude : 139.3832883
},{
text : '杉野幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6474355,
longitude : 139.4221806
},{
text : '日野しらゆり幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6800309,
longitude : 139.3887209
},{
text : 'あらい保育園',
url : 'data/kml/circle.glb',
latitude : 35.6657915,
longitude : 139.4176438
},{
text : 'みさわ保育園',
url : 'data/kml/circle.glb',
latitude : 35.6613311,
longitude : 139.4247713
},{
text : 'たかはた台保育園',
url : 'data/kml/circle.glb',
latitude : 35.6530845,
longitude : 139.4126423
},{
text : 'みなみだいら保育園',
url : 'data/kml/circle.glb',
latitude : 35.6522943,
longitude : 139.3873516
},{
text : 'あさひがおか保育園',
url : 'data/kml/circle.glb',
latitude : 35.6626437,
longitude : 139.3683594
},{
text : 'もぐさ台保育園',
url : 'data/kml/circle.glb',
latitude : 35.6490186,
longitude : 139.4203446
},{
text : 'おおくぼ保育園',
url : 'data/kml/circle.glb',
latitude : 35.6709567,
longitude : 139.386538
},{
text : 'しんさかした保育園',
url : 'data/kml/circle.glb',
latitude : 35.6807363,
longitude : 139.386696
},{
text : '栄光保育園',
url : 'data/kml/circle.glb',
latitude : 35.6480983,
longitude : 139.3830173
},{
text : '至誠第二保育園',
url : 'data/kml/circle.glb',
latitude : 35.6803092,
longitude : 139.4076275
},{
text : '日野市立第二幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6497786,
longitude : 139.3860643
},{
text : '日野市立第三幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6768593,
longitude : 139.3996755
},{
text : '日野市立第四幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6778429,
longitude : 139.4176533
},{
text : '日野市立第五幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6608644,
longitude : 139.4225881
},{
text : '日野市立第七幼稚園',
url : 'data/kml/circle.glb',
latitude : 35.6622327,
longitude : 139.3689927
},{
text : 'とよだ保育園',
url : 'data/kml/circle.glb',
latitude : 35.6582859,
longitude : 139.384625
},{
text : 'たまだいら保育園',
url : 'data/kml/circle.glb',
latitude : 35.6666794,
longitude : 139.3807137
},
];
var optionNumber;
//Sandcastle.addToolbarMenu(options);
function SetPullDown(value) {
var selectedModel = options[value];
createModel(selectedModel["url"],100, selectedModel["latitude"],selectedModel["longitude"]);
deleteModel(value);
}
function deleteModel(value) {
var idName = "option" + optionNumber;
$(idName).remove();
optionNumber = value;
}
function addOptions() {
$("body").append('<select name="kindergarden" class="pulldown" onchange="SetPullDown(value);"><option value="">幼稚園を選択してください</option></select>');
for(var num=1; num<options.length; num++) {
var text = '<option value="' + num + '" id="option'+num+'">' + options[num]["text"] + '</option>';
$(".pulldown").append(text);
console.log(text);
}
}
addOptions();
</script>
</body>
</html>