-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmaptastic.html
142 lines (122 loc) · 5.09 KB
/
maptastic.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
<!DOCTYPE html>
<html>
<head>
<title>maptastic</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./assets/css/examples.css" />
<link rel="stylesheet" href="./assets/css/loading_screen.css" />
</head>
<body>
<script src="./assets/js/libs/numeric_solve.min.js"></script>
<script src="./assets/js/libs/maptastic.js"></script>
<script src="../dist/RUN_MODE/bundle.js"></script>
<script src="./assets/js/loadingScreen.js"></script>
<script type="text/javascript">
const udviz = window.udviz;
udviz
.loadMultipleJSON([
'./assets/config/extents.json',
'./assets/config/crs.json',
'./assets/config/widget/slide_show.json',
])
.then((configs) => {
udviz.proj4.default.defs(
configs['crs'][0].name,
configs['crs'][0].transform
);
const extent = new udviz.itowns.Extent(
configs['extents'][0].name,
parseInt(configs['extents'][0].west),
parseInt(configs['extents'][0].east),
parseInt(configs['extents'][0].south),
parseInt(configs['extents'][0].north)
);
// create a itowns planar view
const viewDomElement = document.createElement('div');
viewDomElement.classList.add('full_screen');
document.body.appendChild(viewDomElement);
const view = new udviz.itowns.PlanarView(viewDomElement, extent);
// eslint-disable-next-line no-constant-condition
if ('RUN_MODE' == 'production')
loadingScreen(view, ['UD-VIZ', 'UDVIZ_VERSION']);
// init scene 3D
udviz.initScene(
view.camera.camera3D,
view.mainLoop.gfxEngine.renderer,
view.scene
);
const fitExtent = () => {
udviz.cameraFitRectangle(
view.camera.camera3D,
new udviz.THREE.Vector2(extent.west, extent.south),
new udviz.THREE.Vector2(extent.east, extent.north)
);
view.notifyChange(view.camera.camera3D);
};
fitExtent();
view.camera.camera3D.rotation.set(0, 0, 0);
// /// SLIDESHOW MODULE
// 3D Setup
const slideShow = new udviz.widgetSlideShow.SlideShow(
view,
configs['slide_show'],
extent
);
slideShow.addListeners();
view.scene.add(slideShow.plane);
// Add UI
document.body.appendChild(slideShow.domElement);
slideShow.domElement.id = 'idSlideShow';
const maptasticClass = new Maptastic({
showLabelsNames: false,
autoLoad: false,
autoSave: false,
});
maptasticClass.addListeners();
maptasticClass.addLayers([slideShow.domElement, viewDomElement]);
const maptasticControlsUI = document.createElement('pre');
maptasticControlsUI.style.zIndex =
Number(maptasticClass.canvas.style.zIndex) + 1;
maptasticControlsUI.style.position = 'fixed';
maptasticControlsUI.style.background = '#ffffffa6';
maptasticControlsUI.style.top = '0';
maptasticControlsUI.style.right = '0';
maptasticControlsUI.style.margin = '0';
const toggleEditMode = document.createElement('div');
toggleEditMode.innerText = 'Toggle Edit Mode';
toggleEditMode.style.cursor = 'pointer';
toggleEditMode.style.fontWeight = 'bold';
const divTextControls = document.createElement('div');
divTextControls.innerText = `
click / drag: select and move quads/corner points
SHIFT + drag: move selcted quad/corner point with 10x precision
ALT + drag: rotate/scale selected quad
Arrow keys: move selected quad/corner point
SHIFT + Arrow keys: move selected quad/corner point by 10 pixels
ALT + Arrow keys: rotate/scale selected quad
's': Solo/unsolo selected quad
'c': Toggle mouse cursor crosshairs
'r': Rotate selected layer 90 degrees clock-wise
'h': Flip selected layer horizontally
'v': Flip selected layer vertically
'b': Show/Hide projector bounds
`;
toggleEditMode.onclick = () => {
if (maptasticClass.configActive) {
maptasticClass.setConfigEnabled(false);
divTextControls.remove();
slideShow.addListeners();
} else {
maptasticClass.setConfigEnabled(true);
maptasticControlsUI.appendChild(divTextControls);
slideShow.removeListeners();
}
};
maptasticControlsUI.appendChild(toggleEditMode);
document.body.appendChild(maptasticControlsUI);
});
</script>
SCRIPT_TAG_RELOAD
</body>
</html>