-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
733 lines (655 loc) · 23.6 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
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="https://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="東日本大震災発生後24時間以内につぶやかれたジオタグ付きツイートのデジタルアーカイブ" />
<!-- 新規設置の際はURLの変更が必要 -->
<meta property="og:image" content="https://tweet.mapping.jp/data/screen.jpg" />
<meta property="og:description" content="東日本大震災発生後24時間以内につぶやかれたジオタグ付きツイートのデジタルアーカイブ" />
<meta name="twitter:card" content="summary_large_image" />
<!-- 新規設置の際はIDの変更が必要 -->
<meta name="twitter:site" content="@hwtnv" />
<meta name="twitter:creator" content="@hwtnv" />
<meta name="twitter:title" content="東日本大震災ツイートマッピング" />
<meta name="twitter:description" content="東日本大震災発生後24時間以内につぶやかれたジオタグ付きツイートのデジタルアーカイブ" />
<!-- 新規設置の際はURLの変更が必要 -->
<meta name="twitter:image" content="https://tweet.mapping.jp/data/screen.jpg" />
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>東日本大震災ツイートマッピング</title>
<link rel="SHORTCUT ICON" href="https://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="Cesium/Cesium.js"></script>
<script src="https://www.google.com/jsapi"></script>
<!-- 新規設置の際はGoogle Analytics IDの変更が必要 -->
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-93496169-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="geocode" class="functions">
<form action="javascript:geocode()" class="textbox" />
<input id="inputtext" class="textbox" type="text" value="" placeholder="地名で検索" />
</form>
</div>
<div id="textSearch" class="functions">
<form action="javascript:textSearch()" class="textbox" />
<input id="searchQuery" class="textbox" type="text" value="" placeholder="テキスト検索" />
</form>
</div>
<div class="titleScreen">
<p>
<img class="titleImage" src="data/logo.png">
</p>
</div>
<div id="blackOut">
<img class="loading" src="data/loading.gif">
</div>
<div id="cesiumContainer"></div>
<div id="baseLayerPickerContainer" class="functions"></div>
<div id="tweetMessage"></div>
<div id="buttonAbout" class="general-button" onclick="about();">
<div class="button-content">
<span class="icon-font">help</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="twCounter" class="twCounter">
<p>Loading...</p>
</div>
<script>
//Google Maps API(新規設置の際はKeyの変更が必要)
const script = document.createElement('script');
script.src = 'https://maps.googleapis.com/maps/api/js?key=AIzaSyDmPXZNocuhvv3T6zJe9gQZF0oVrU7TuCA&callback=initMap';
script.async = true;
window.initMap = function () {
};
document.head.appendChild(script);
//新規設置の際はTokenの変更が必要
Cesium.Ion.defaultAccessToken =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI2MWQxZDNlZC0xNzY1LTRmYzctYmY2Zi05YjZlYmI2YjI2ZGUiLCJpZCI6ODM3NDEsImlhdCI6MTY4MzkzMjEzNn0.scryF4Q6q6deO3pjfPmCnZ9986voN5H89uXQqGCSPuo';
//新規設置の際はKeyの変更が必要
Cesium.GoogleMaps.defaultApiKey = "AIzaSyDmPXZNocuhvv3T6zJe9gQZF0oVrU7TuCA";
//視点配列
const viewPointsArray = [];
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;
}
viewPointsArray[0] = new viewPoints("日本全体", 34.009340, 135.843524, -47, -50,
2000000);
viewPointsArray[1] = new viewPoints("東京都", 35.67623749668245, 139.75142329682316, 0, -60,
30000);
viewPointsArray[2] = new viewPoints("皇居", 35.6835836, 139.7508397, 0, -55, 2000);
//画面サイズ判別
function getDevice() {
const ua = navigator.userAgent;
if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPod') > 0 || ua.indexOf('Android') > 0 && ua.indexOf(
'Mobile') > 0) {
mobile = 1;
} else if (ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0) {
mobile = 2;
} else {
mobile = 0;
}
return mobile;
};
//画面サイズ調整
let screenAdjust = (function () {
const mobile = getDevice();
if (mobile != 1) {
setTimeout('resizeWindow()', 0);
} else {
$('.titleImage').css('width', '100%');
setTimeout('resizeWindow()', 1000);
}
})();
function resizeWindow() {
$(function () {
$(cesiumContainerDiv).css('height', '100%');
$(cesiumContainerDiv).css('width', '100%');
$(blackOutDiv).css('height', '100%');
$(blackOutDiv).css('height', '100%');
});
setTimeout('loadCesium()', 100);
}
//各種DIV
const cesiumContainerDiv = document.getElementById("cesiumContainer");
const blackOutDiv = document.getElementById("blackOut");
const loadingDiv = document.getElementById("twCounter");
//ビューア初期化
let viewer;
//Cesiumロード
function loadCesium() {
viewer = new Cesium.Viewer(cesiumContainerDiv, {
navigationHelpButton: false,
navigationInstructionsInitiallyVisible: false,
geocoder: false,
timeline: false,
animation: false,
sceneModePicker: false,
scene3DOnly: true,
baseLayerPicker: false,
requestRenderMode: true,
maximumRenderTimeChange: Infinity,
useBrowserRecommendedResolution: true
});
viewer.imageryLayers._layers[0].brightness = 0.5;
//画角を80度に
viewer.camera.frustum.fov = Cesium.Math.toRadians(80);
//スワイプによるスクロール禁止
const cesiumDiv = document.getElementById("cesiumContainer");
function preventScroll(event) {
event.preventDefault();
}
cesiumDiv.addEventListener("gesturestart", preventScroll, false);
cesiumDiv.addEventListener("gesturechange",
preventScroll, false);
cesiumDiv.addEventListener("gestureend", preventScroll, false);
//起動シークエンス呼び出し
openingSequence();
}
//起動シークエンス
function openingSequence() {
fadeInOut(blackOutDiv, 0);
fadeInOut(loadingDiv, 0);
const sequences = Promise.resolve()
.then(function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
$(function () {
$('.titleScreen').fadeOut(1000);
setTimeout(function () {
$('.titleScreen').remove();
}, 1000);
});
changeViewPoint(0, 3);
resolve();
}, 2000);
});
})
.then(function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
changeViewPoint(1, 3);
resolve();
}, 3000);
});
})
.then(function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
fadeInOut(blackOutDiv, 1);
fadeInOut(loadingDiv, 1);
resolve();
}, 3000);
});
})
.then(function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
loadTweets();
loadPhotogrammetry();
resolve();
}, 1000);
});
})
.then(function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
viewer.scene.globe.show = false;
resolve();
}, 500);
});
});
}
//3D Tiles
function loadPhotogrammetry() {
//デフォルトのglobeを黒に
const globe = viewer.scene.globe;
globe.baseColor = Cesium.Color.fromCssColorString('#000000');
//3D Tiles読み込み
(async () => {
try {
const tileset = viewer.scene.primitives.add(
await Cesium.Cesium3DTileset.fromIonAssetId(2275207)
);
tileset.style = new Cesium.Cesium3DTileStyle({
color: "rgba(110, 110, 110, 1)",
});
tileset.dynamicScreenSpaceError = true;
tileset.dynamicScreenSpaceErrorFactor = 12;
} catch (error) {
console.log(error);
}
})();
}
//BaseLayerPicker追加
/*
function baseLayerPickerAdd() {
//デフォルトタイル削除,色を黒に
let globe = viewer.scene.globe;
globe.imageryLayers.removeAll();
globe.baseColor = Cesium.Color.fromCssColorString('#000000');
let layers = viewer.imageryLayers;
//baseLayer配列を用意
var imageryViewModels = [];
//ArcGIS Maps
var satelliteMap = new Cesium.createWorldImageryAsync({
style: Cesium.IonWorldImageryStyle.AERIAL,
});
//GSI淡色地図
var roadMap = new Cesium.OpenStreetMapImageryProvider({
url: 'https://cyberjapandata.gsi.go.jp/xyz/pale/',
credit: '国土地理院',
minimumLevel: 5,
maximumLevel: 18
});
//GSI標高地図
var terrainMap = new Cesium.OpenStreetMapImageryProvider({
url: 'https://cyberjapandata.gsi.go.jp/xyz/relief/',
credit: '国土地理院',
minimumLevel: 5,
maximumLevel: 15
});
imageryViewModels.push(new Cesium.ProviderViewModel({
name: '航空写真',
iconUrl: Cesium.buildModuleUrl('Widgets/Images/ImageryProviders/bingAerial.png'),
creationFunction: function () {
setTimeout(function () {
layers._layers[0].brightness = 0.5;
shinsai2011PhotoLayer.alpha = 1;
}, 1);
return satelliteMap;
}
}));
//GSI淡色地図
imageryViewModels.push(new Cesium.ProviderViewModel({
name: '詳細地図',
iconUrl: Cesium.buildModuleUrl('Widgets/Images/ImageryProviders/gsiGray.png'),
creationFunction: function () {
setTimeout(function () {
layers._layers[0].brightness = 0.25;
layers._layers[0].saturation = 0.2;
shinsai2011PhotoLayer.alpha = 0;
}, 1);
return roadMap;
}
}));
//標高地図
imageryViewModels.push(new Cesium.ProviderViewModel({
name: '標高地図',
iconUrl: Cesium.buildModuleUrl('Widgets/Images/ImageryProviders/japanRelief.png'),
tooltip: '海域部は海上保安庁海洋情報部の資料を使用して作成',
creationFunction: function () {
setTimeout(function () {
layers._layers[0].brightness = 0.4;
layers._layers[0].saturation = 1.0;
shinsai2011PhotoLayer.alpha = 0;
}, 1);
return terrainMap;
}
}));
//baseLayerPickerボタンを追加
const baseLayerPicker = new Cesium.BaseLayerPicker('baseLayerPickerContainer', {
globe: viewer.scene.globe,
imageryProviderViewModels: imageryViewModels
});
//被災直後の空中写真
const shinsai2011Photo = new Cesium.OpenStreetMapImageryProvider({
url: 'https://cyberjapandata.gsi.go.jp/xyz/toho1/',
fileExtension: 'jpg',
credit: '国土地理院',
maximumLevel: 17,
brightness: 0.6
});
const shinsai2011PhotoLayer = new Cesium.ImageryLayer(shinsai2011Photo, {
minimumTerrainLevel: 15,
maximumTerrainLevel: 17,
brightness: 0.6
});
layers.add(shinsai2011PhotoLayer);
}
*/
//視点移動関数
function changeViewPoint(num, delay) {
//カメラパラメータ
let newLat = viewPointsArray[num].lat;
let newLng = viewPointsArray[num].lng;
let newHeading = Cesium.Math.toRadians(viewPointsArray[num].heading);
let newPitch = Cesium.Math.toRadians(viewPointsArray[num].pitch);
let newRange = viewPointsArray[num].range;
let center = Cesium.Cartesian3.fromDegrees(newLng, newLat);
let boundingSphere = new Cesium.BoundingSphere(center, newRange);
let headingPitchRange = new Cesium.HeadingPitchRange(newHeading, newPitch, newRange);
//Z軸固定
viewer.camera.constrainedAxis = Cesium.Cartesian3.UNIT_Z;
//FLYTO
viewer.camera.flyToBoundingSphere(boundingSphere, {
duration: delay,
offset: headingPitchRange,
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT
});
}
/* ここからJsonロード・ビルボード&ラベル追加 */
// 検索用配列
let jsonArray = [];
// translucencyByDistanceのパラメータ(暫定)
let translucencyByDistance;
// 一個目のbillboard, label
let billboard1st;
let label1st;
function loadTweets() {
//ビルボード・ラベル用オブジェクト
let billboardCollection = new Cesium.BillboardCollection();
let labelCollection = new Cesium.LabelCollection();
let billboards = viewer.scene.primitives.add(billboardCollection);
let labels = viewer.scene.primitives.add(labelCollection);
let pixelOffset = new Cesium.Cartesian2(20.0, 0);
let scaleByDistance = new Cesium.NearFarScalar(0.0, 1.4, 7500, 0.7);
translucencyByDistance = new Cesium.NearFarScalar(500.0, 1.0, 3000000, 0.0);
let verticalOrigin = Cesium.VerticalOrigin.CENTER;
let jsonNum = 0;
//JSON読み込み,ビルボード・ラベル追加
let timer = setInterval(function () {
//スマホとその他でスライス文字数を変える
if (getDevice == 1) {
let sliceText = 10;
} else {
sliceText = 20;
}
let jsonFile = "data/czml/tweets.json";
$.getJSON(jsonFile, function (json) {
for (let i = 0; i < 50; i++) {
if (jsonNum >= json.length) {
clearInterval(timer);
delete jsonFile;
finishLoading();
break;
} else {
let id = json[jsonNum].id;
let text = json[jsonNum].text;
if (text.length > sliceText) {
let name = text.slice(0, sliceText) + "...";
} else {
name = text;
}
let iconUrl = json[jsonNum].billboard.image;
let positions = json[jsonNum].position.cartographicDegrees;
positions[2] = 200 + 500 * Math.random();
let positionsCartesian3 = Cesium.Cartesian3.fromDegreesArrayHeights(
positions)[0];
//ビルボード・ラベル追加
if (i == 0) {
billboardsAdd = billboards.add({
id: id,
position: positionsCartesian3,
image: "data/icon/flags/" + iconUrl,
scale: 0.25,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
translucencyByDistance: translucencyByDistance,
});
labelAdd = labels.add({
id: id,
position: positionsCartesian3,
font: "11pt Sans-Serif",
style: Cesium.LabelStyle.FILL,
fillColor: Cesium.Color.WHITE,
pixelOffset: pixelOffset,
text: name,
scaleByDistance: scaleByDistance,
verticalOrigin: verticalOrigin,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
translucencyByDistance: translucencyByDistance
});
} else {
//2個め以降は1個目のオブジェクトのプロパティを流用する
billboard1st = viewer.scene.primitives._primitives[0]._billboards[0];
label1st = viewer.scene.primitives._primitives[1]._labels[0];
billboardsAdd = billboards.add({
id: id,
position: positionsCartesian3,
image: billboard1st.image,
scale: billboard1st.scale,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
translucencyByDistance: billboard1st.translucencyByDistance
});
labelAdd = labels.add({
id: id,
position: positionsCartesian3,
font: label1st.font,
style: label1st.style,
fillColor: label1st.fillColor,
pixelOffset: label1st.pixelOffset,
text: name,
scaleByDistance: label1st.scaleByDistance,
verticalOrigin: label1st.verticalOrigin,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
translucencyByDistance: label1st.translucencyByDistance
});
}
//検索用配列に追加
jsonArray.push({
id: id,
text: text
});
//読み込み件数表示
jsonNum++;
loadingDiv.innerHTML = "<p>" + jsonNum + "/" + json.length + "</p>";
}
}
});
viewer.scene.requestRender();
}, 10);
}
//ロード完了
function finishLoading() {
setTimeout(function () {
fadeInOut(blackOutDiv, 0);
fadeInOut(loadingDiv, 0);
changeViewPoint(2, 3);
}, 1000);
delete timer;
descriptionBalloon();
loadingDiv.innerHTML = "<p class='twCounter'>Completed.</p>";
}
//コンテンツバルーン表示
function descriptionBalloon() {
window.removeEventListener;
//入力フォーム,ボタンクリック時にバルーンを隠す
$('.functions,.general-button').click(function () {
$(tweetMessage).hide();
});
//カメラ移動時にバルーンを隠す
viewer.camera.changed.addEventListener(function () {
$(tweetMessage).fadeOut(100);
});
viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
// カメラ位置(経度)取得
let cameraPosRadians = viewer.camera.positionCartographic;
let cameraPosLongitude = Cesium.Math.toDegrees(cameraPosRadians.longitude);
let pickedObject = viewer.scene.pick(movement.position);
if (pickedObject === undefined) {
$(tweetMessage).hide();
} else {
let pikedObjectPos = pickedObject.primitive._position;
if (pikedObjectPos !== undefined) {
// オブジェクト位置(経度)取得
let objectPosCartesian = pickedObject.primitive._position;
let objectPosCartographic = Cesium.Cartographic.fromCartesian(objectPosCartesian);
let objectPosLongitude = Cesium.Math.toDegrees(objectPosCartographic.longitude);
// カメラとオブジェクトの経度差(絶対値)
let distanceLongitude = Math.abs(cameraPosLongitude - objectPosLongitude);
// カメラとオブジェクトの経度差が90度以内のときコンテンツバルーンを表示
if (distanceLongitude < 90) {
let pickedObjectId = pickedObject.id.toString();
$(tweetMessage).fadeIn(200);
adjustDivPosition();
let targetObject = jsonArray.find((n) => n.id === pickedObjectId);
text = targetObject.text;
let windowWidth = $(window).width();
$(function () {
$(window).click(function (e) {
$(window).off("click");
let rightMargin = windowWidth - e.pageX;
$(tweetMessage).html(text);
if (getDevice() != 1) {
if (rightMargin < 320) {
$(tweetMessage).offset({
top: e.pageY + 8,
left: e.pageX - 312
});
} else {
$(tweetMessage).offset({
top: e.pageY + 8,
left: e.pageX + 8
});
}
} else {
$(tweetMessage).offset({
top: e.pageY + 8,
left: windowWidth * 0.5 - 160
});
}
});
});
}
} else {
$(tweetMessage).hide();
}
}
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
}
//コンテンツバルーンの位置調整
function adjustDivPosition() {
setTimeout(function () {
let windowHeight = $(window).height();
var
pos = $(tweetMessage).offset().top;
let height = $(tweetMessage).height();
if ((windowHeight - (pos + height)) < 0) {
$(tweetMessage).offset({
top: windowHeight - height - 12
});
}
}, 200);
}
/* ここまでJsonロード・ビルボード&ラベル追加 */
//ジオコード
function geocode() {
let geocoder = new google.maps.Geocoder();
let input = document.getElementById('inputtext').value;
geocoder.geocode({
address: input
},
function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
let viewportObj = results[0].geometry.viewport;
let southNorth = viewportObj[Object.keys(viewportObj)[0]];
let westEast = viewportObj[Object.keys(viewportObj)[1]];
let south = southNorth[Object.keys(southNorth)[0]];
let north = southNorth[Object.keys(southNorth)[1]];
let west = westEast[Object.keys(westEast)[0]];
let east = westEast[Object.keys(westEast)[1]];
let rectangle = Cesium.Rectangle.fromDegrees(west, south, east, north);
viewer.camera.flyTo({
destination: rectangle,
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT
});
} else {
alert('見つかりません');
}
}
);
}
//現在地へ移動
function flyToMyLocation() {
function fly(position) {
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(position.coords.longitude, position.coords
.latitude,
3000.0),
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT
});
}
navigator.geolocation.getCurrentPosition(fly);
}
//テキスト検索
function textSearch() {
$(tweetMessage).hide();
let searchQuery = String(document.getElementById('searchQuery').value);
let targetObject = jsonArray.filter(function (obj) {
return obj.text.match(searchQuery);
});
let billboardsObject = viewer.scene.primitives._primitives[0]._billboards;
let labelsObject = viewer.scene.primitives._primitives[1]._labels;
for (let i = 0; i < billboardsObject.length; i++) {
// カラ検索で初期化
if (searchQuery == "") {
billboardsObject[i].show = true;
labelsObject[i].show = true;
billboardsObject[i].translucencyByDistance = translucencyByDistance;
labelsObject[i].translucencyByDistance = translucencyByDistance;
} else {
// 文字列が含まれるビルボードのみアクティブにする
if (targetObject.find((v) => v.id === billboardsObject[i]._id)) {
billboardsObject[i].show = true;
labelsObject[i].show = true;
billboardsObject[i].translucencyByDistance = undefined;
labelsObject[i].translucencyByDistance = undefined;
} else {
billboardsObject[i].show = false;
labelsObject[i].show = false;
}
}
}
viewer.scene.requestRender();
}
//DIVのフェードイン・アウト
function fadeInOut(layer, param) {
if (param == 0) {
$(function () {
$(layer).fadeOut("slow");
});
viewer.trackedEntity = undefined;
} else {
$(function () {
$(layer).fadeIn("slow");
});
}
}
//ヘルプ
function about() {
window.open(
'https://github.com/wtnv-lab/tweetMapping'
);
}
</script>
</body>
</html>