-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathglobals.js
More file actions
205 lines (170 loc) · 4.18 KB
/
globals.js
File metadata and controls
205 lines (170 loc) · 4.18 KB
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
/**
* Copyright (c) Institut national de l'information géographique et forestière
*
* This program and the accompanying materials are made available under the terms of the GPL License, Version 3.0.
*/
import { Network } from "@capacitor/network";
/** global: map */
let map = null;
let mapRLT1 = null;
let mapRLT2 = null;
/**
* global: layer display state
*/
let layersDisplayed;
if (!localStorage.getItem("lastLayersDisplayed")) {
layersDisplayed = [
{
id: "PLAN.IGN.INTERACTIF$TMS",
opacity: 100,
visible: true,
gray: false,
}
];
} else {
layersDisplayed = JSON.parse(localStorage.getItem("lastLayersDisplayed"));
}
/**
* global: back button state
* is one of: 'default' 'search' 'params' 'legal' 'privacy' 'infos' 'layerManagerWindow' 'route' ...
*/
let backButtonState = "default";
/** global: last text in search bar */
let lastTextInSearch = "";
let myPositionMarker = null;
let searchResultMarker = null;
let myPositionIcon;
let myPositionIconGrey;
let searchResultIcon;
// Pour l'annulation de fetch
let searchAbortController = new AbortController();
let searchAbortSignal = searchAbortController.signal;
// Global Search plugin
let search = null;
// Global Route plugin
let directions = null;
// Global Isochrone plugin
let isochrone = null;
// Global Position plugin
let position = null;
// Global Compare Plugin
let compare = null;
let comparedLayers = ["ORTHOIMAGERY.ORTHOPHOTOS.1950-1965$WMTS", "ORTHOIMAGERY.ORTHOPHOTOS$WMTS"];
// Global Menu navigation
let menu = null;
// Global Layer Manager
let manager = null;
// Global POI filters
let poi = null;
// Global route draw
let routeDraw = null;
// Global interactivity
let interactivityIndicator = null;
// Global control mapInteractivity
let mapInteractivity = null;
// Global control my account
let myaccount = null;
// Global control compare Poi
let comparePoi = null;
// Global control osm poi accessibility
let osmPoiAccessibility = null;
// Global control signalement
let signalement = null;
let signalementOSM = null;
// Global control landmark and RTL landmark
let landmark = null;
let compareLandmark = null;
// Global control offline maps
let offlineMaps = null;
// Global control track record
let trackRecord = null;
// Global control immersive notifications
let immersiveNotifications = null;
// Global control 3d
let threeD = null;
// Global flag: is the device connected to the internet?
let online = (await Network.getStatus()).connected;
if (!online) {
let hasPlanIGN = false;
for (let i = 0; i < layersDisplayed.length; i++) {
const layer = layersDisplayed[i];
if (layer.id === "PLAN.IGN.INTERACTIF$TMS") {
hasPlanIGN = true;
break;
}
}
if (!hasPlanIGN) {
layersDisplayed.push(
{
id: "PLAN.IGN.INTERACTIF$TMS",
opacity: 100,
visible: true,
gray: false,
}
);
}
}
// Scroll
let maxScroll = (document.scrollingElement.scrollHeight - document.scrollingElement.clientHeight);
let anchors = [0, maxScroll / 2.5, maxScroll];
let currentScrollIndex = 0;
let mapLoaded = false;
// Walking speed for time calculation
let walkingSpeed;
if (!localStorage.getItem("walkingSpeed")) {
walkingSpeed = 4 / 3.6;
} else {
walkingSpeed = parseFloat(localStorage.getItem("walkingSpeed")) / 3.6;
}
// Are new place notifications enabled?
let newPlaceNotifEnabled;
if (!localStorage.getItem("newPlaceNotifEnabled")) {
newPlaceNotifEnabled = 1;
} else {
newPlaceNotifEnabled = parseFloat(localStorage.getItem("newPlaceNotifEnabled"));
}
export default {
map,
mapRLT1,
mapRLT2,
layersDisplayed,
backButtonState,
lastTextInSearch,
myPositionMarker,
searchResultMarker,
myPositionIcon,
myPositionIconGrey,
searchResultIcon,
searchAbortController,
searchAbortSignal,
currentScrollIndex,
maxScroll,
anchors,
directions,
isochrone,
position,
search,
compare,
comparedLayers,
menu,
manager,
poi,
routeDraw,
interactivityIndicator,
mapInteractivity,
myaccount,
comparePoi,
signalement,
signalementOSM,
online,
mapLoaded,
walkingSpeed,
osmPoiAccessibility,
landmark,
compareLandmark,
offlineMaps,
immersiveNotifications,
newPlaceNotifEnabled,
threeD,
trackRecord,
};