-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase_globe.js
142 lines (129 loc) · 3.84 KB
/
base_globe.js
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
require(
[
"esri/Map",
"esri/views/SceneView",
"esri/layers/TileLayer",
"esri/layers/GeoJSONLayer",
"esri/Basemap",
"utils/ExaggeratedElevationLayer",
"esri/Graphic",
"esri/core/promiseUtils",
"esri/geometry/Point",
"esri/rest/locator",
"esri/core/reactiveUtils"
],function (
Map, SceneView,
TileLayer, GeoJSONLayer,
Basemap, ExaggeratedElevationLayer,
Graphic, reactiveUtils, Point) {
const R = 6358137; // approx radius of Earth in m
const offset = 300000; // offset from the ground used for the clouds
const basemap = new Basemap({
baseLayers: [
new TileLayer({
//url: "https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/terrain_with_heavy_bathymetry/MapServer"
url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
})
]
});
const map = new Map({
//basemap: "topo-3d",
basemap: basemap,
ground: "world-elevation"
});
const view = new SceneView({
container: "viewDiv",
map: map,
alphaCompositingEnabled: true,
qualityProfile: "high",
camera: {
position: [-55.03975781, 14.94826384, 19921223.30821],
heading: 2.03,
tilt: 0.13
},
popup: {
dockEnabled: true,
dockOptions: {
position: "top-right",
breakpoint: false,
buttonEnabled: false
},
collapseEnabled: false
},
highlightOptions: {
color: [255, 255, 255],
haloOpacity: 0.5
}
});
map.ground.layers = [new ExaggeratedElevationLayer({
exaggerationBathymetry: 60,
exaggerationTopography: 40
})];
const origin = new Point({
x: 0, y: -90, z: -(2 * R)
});
const oceanSurface = new Graphic({
geometry: origin,
symbol: {
type: "point-3d",
symbolLayers: [{
type: "object",
resource: {
href: "./sphere/scene.gltf"
},
width: 2 * R
}]
}
});
view.graphics.add(oceanSurface);
const blob = new Blob([JSON.stringify()], {
type: "application/json"
});
// URL reference to the blob
const url = URL.createObjectURL(blob);
const dv_scale_Layer = new GeoJSONLayer({
url: "./data/pembroke_alumni.geojson",
elevationInfo: {
mode: "absolute-height",
offset: offset
},
popupEnabled: true,
popupTemplate: {
title: "{NAME}",
content: `
<div class="popupImage">
<img src="{imageUrl}"/>
</div>
<div class="popupDescription">
<p class="info">
{facts}
</p>
</div>
`
}
});
map.layers.add(dv_scale_Layer);
// rotate();
let clicked = false;
view.on("click", (event) => {
view.hitTest(event).then(({results}) => {
rotate();
console.log("clicked? ", clicked);
const camera = view.camera.clone();
console.log("current longitude: ", camera.position.longitude);
console.log("current latitude: ", camera.position.latitude);
}).catch((error) => {
console.error(error);
});
clicked = !clicked;
});
function rotate() {
console.log("In rotate, clicked: ", clicked);
if (!view.interacting && clicked) {
const camera = view.camera.clone();
camera.position.longitude -= 0.1;
view.goTo(camera, { animate: false });
requestAnimationFrame(rotate);
}
}
});