Skip to content

Commit 06ffcb7

Browse files
committed
fix: offline issues
1 parent 4d6fbda commit 06ffcb7

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

src/js/data-layer/immersvie-position-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{
1313
"id": "BDTOPO_V3:parc_ou_reserve",
1414
"layer": "BDTOPO_V3:parc_ou_reserve",
15-
"attributes": ["nature", "toponyme"],
15+
"attributes": ["nature", "toponyme", "nature_detaillee"],
1616
"geom_name": "geometrie"
1717
},
1818
{

src/js/event-listeners.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function addListeners() {
209209
</div>
210210
`, map);
211211
if (Capacitor.isNativePlatform()) {
212-
this.map.setGlyphs("https://data.geopf.fr/annexes/ressources/vectorTiles/fonts/{fontstack}/{range}.pbf");
212+
Globals.map.setGlyphs("https://data.geopf.fr/annexes/ressources/vectorTiles/fonts/{fontstack}/{range}.pbf");
213213
}
214214
} else {
215215
PopupUtils.showOnlinePopup(`
@@ -222,7 +222,7 @@ function addListeners() {
222222
</div>
223223
`, map);
224224
if (Capacitor.isNativePlatform()) {
225-
this.map.setGlyphs("data/fallback_glyphs/{fontstack}/{range}.pbf");
225+
Globals.map.setGlyphs("data/fallback_glyphs/{fontstack}/{range}.pbf");
226226
}
227227
// Active Plan IGN
228228
if (!planIgnLayerBtn.classList.contains("selectedLayer")) {

src/js/globals.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ let offlineMaps = null;
105105
// Global flag: is the device connected to the internet?
106106
let online = (await Network.getStatus()).connected;
107107

108+
if (!online) {
109+
let hasPlanIGN = false;
110+
for (let i = 0; i < layersDisplayed.length; i++) {
111+
const layer = layersDisplayed[i];
112+
if (layer.id === "PLAN.IGN.INTERACTIF$TMS") {
113+
hasPlanIGN = true;
114+
break;
115+
}
116+
}
117+
if (!hasPlanIGN) {
118+
layersDisplayed.unshift(
119+
{
120+
id: "PLAN.IGN.INTERACTIF$TMS",
121+
opacity: 100,
122+
visible: true,
123+
gray: false,
124+
}
125+
);
126+
}
127+
}
128+
108129
// Scroll
109130
let maxScroll = (document.scrollingElement.scrollHeight - document.scrollingElement.clientHeight);
110131
let anchors = [0, maxScroll / 2.5, maxScroll];

src/js/immersive-position.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ImmersivePosion extends EventTarget {
4444
*/
4545
computeHtml() {
4646
let htmlTemplate = `
47-
<p>&#x1F3D8;&#xFE0F; Vous êtes sur la commune de ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"][0][0] : "chargement..."}, qui compte ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"][0][1] : "chargement..."} habitants, située dans le département de ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:departement"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:departement"][0] : "chargement..."}</p>
47+
<p>&#x1F3E0; Vous êtes sur la commune de ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"][0][0] : "chargement..."}, qui compte ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:commune"][0][1] : "chargement..."} habitants, située dans le département de ${this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:departement"] ? this.data["LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:departement"][0] : "chargement..."}</p>
4848
`;
4949

5050
if (this.data["BDTOPO_V3:parc_ou_reserve"] && this.data["BDTOPO_V3:parc_ou_reserve"].length) {
@@ -230,6 +230,9 @@ class ImmersivePosion extends EventTarget {
230230
if ( !(["Site Natura 2000", "Parc naturel régional", "Parc national", "Réserve naturelle"].includes(parc[0])) ) {
231231
return false;
232232
}
233+
if (["Périmètre de protection d'une réserve naturelle nationale", "Périmètre de protection d'une réserve naturelle régionale"].includes(parc[2])) {
234+
return false;
235+
}
233236
if (parc[0] === "Site Natura 2000") {
234237
if (this.hasNatural2000) {
235238
return false;

0 commit comments

Comments
 (0)