-
Notifications
You must be signed in to change notification settings - Fork 6
/
scene-view.js
62 lines (57 loc) · 1.99 KB
/
scene-view.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
/* eslint-disable ember/no-classic-classes */
/* eslint-disable ember/no-classic-components */
/* eslint-disable ember/require-tagless-components */
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import layout from '../templates/components/scene-view';
export default Component.extend({
layout,
classNames: ['scene-view'],
esriLoader: service('esri-loader'),
// once we have a DOM node to attach the map to...
didInsertElement () { /* eslint-disable-line ember/no-component-lifecycle-hooks */
this._super(...arguments);
// load the esri modules
this.esriLoader.loadModules(['esri/views/SceneView', 'esri/Map']).then(modules => {
if (this.isDestroyed || this.isDestroying) {
return;
}
const [SceneView, Map] = modules;
// create a new scene view
this._view = new SceneView({
// An instance of Map or WebScene
map: new Map({
basemap: 'hybrid',
ground: 'world-elevation',
}),
// The id of a DOM element (may also be an actual DOM element)
container: this.elementId,
camera: {
position: [7.654, 45.919, 5184],
tilt: 80
}
});
this._view.when(() => {
// TOOD: wire up elevation checkbox
// this._view.map.ground.layers.forEach(layer => {
// layer.visible = false;
// });
})
.catch((err) => {
// A rejected view indicates a fatal error making it unable to display,
// this usually means that WebGL is not available, or too old.
/* eslint-disable no-console */
console.error("SceneView rejected:", err);
/* eslint-enable no-console */
});
});
},
// destroy the map before this component is removed from the DOM
willDestroyElement () { /* eslint-disable-line ember/no-component-lifecycle-hooks */
this._super(...arguments);
if (this._view) {
this._view.container = null;
delete this._view;
}
}
});