Skip to content

Commit 2efd1c0

Browse files
committed
edito: offlineMaps tweaks
1 parent ee9d8ae commit 2efd1c0

File tree

8 files changed

+40
-14
lines changed

8 files changed

+40
-14
lines changed

src/css/offline-maps.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#whiteScreen.downloadOverlay {
2-
background-color: rgba(0,0,0,.7);
2+
background-color: rgba(0,0,0,.5);
33
/* Carré de 200px de côté au centre */
44
clip-path: polygon(
55
0% 0%, 0% 100%, calc(50% - 100px) 100%, calc(50% - 100px) calc(50% - 100px),

src/html/tabs/offlineMapsWindow.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ <h3>Téléchargement de votre carte...</h3>
3333
</div>
3434
<div id="offlineMapsWindowName" class="d-none">
3535
<h3>Succès du téléchargement !</h3>
36-
Dernière étape, donner un nom à votre carte.
36+
Dernière étape : nommer la carte.
3737
<div class="dsign-form-element">
38-
<input type="text" id="offlineMaps-title" name="offlineMaps-title" class="landmark-input-text" placeholder=" " title="Nommer votre carte">
39-
<label class="dsign-form-label">Nommer votre carte</label>
38+
<input type="text" id="offlineMaps-title" name="offlineMaps-title" class="landmark-input-text" placeholder=" " title="Titre">
39+
<label class="dsign-form-label">Titre</label>
4040
</div>
4141
<div id="offlineMapsSave" class="form-submit">Enregistrer</div>
4242
</div>

src/js/event-listeners.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ function addListeners() {
197197
return;
198198
}
199199
Globals.online = newStatus;
200+
const planIgnLayerBtn = document.getElementById("PLAN.IGN.INTERACTIF$TMS");
200201
if (newStatus) {
201202
PopupUtils.showOnlinePopup(`
202203
<div id="onlinePopup">
@@ -207,6 +208,9 @@ function addListeners() {
207208
</div>
208209
</div>
209210
`, map);
211+
if (Capacitor.isNativePlatform()) {
212+
this.map.setGlyphs("https://data.geopf.fr/annexes/ressources/vectorTiles/fonts/{fontstack}/{range}.pbf");
213+
}
210214
} else {
211215
PopupUtils.showOnlinePopup(`
212216
<div id="onlinePopup">
@@ -217,6 +221,13 @@ function addListeners() {
217221
</div>
218222
</div>
219223
`, map);
224+
if (Capacitor.isNativePlatform()) {
225+
this.map.setGlyphs("data/fallback_glyphs/{fontstack}/{range}.pbf");
226+
}
227+
// Active Plan IGN
228+
if (!planIgnLayerBtn.classList.contains("selectedLayer")) {
229+
planIgnLayerBtn.click();
230+
}
220231
}
221232
});
222233

src/js/layer-manager/layer-catalogue.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ class LayerCatalogue extends EventTarget {
302302
});
303303
return;
304304
}
305+
// Si on est hors ligne : impossible d'enlever Plan IGN
306+
if (!Globals.online && layerName === "PLAN.IGN.INTERACTIF$TMS") {
307+
Toast.show({
308+
text: "Impossible d'enlever le Plan IGN en mode hors-ligne",
309+
duration: "short",
310+
position: "bottom"
311+
});
312+
return;
313+
}
305314
var element = document.getElementById(layerName);
306315
element.classList.remove("selectedLayer");
307316

src/js/layer-manager/layer-switcher.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import ImageNotFound from "../../html/img/image-not-found.png";
1616
import DomUtils from "../utils/dom-utils";
1717

1818
import { Toast } from "@capacitor/toast";
19+
import { Capacitor } from "@capacitor/core";
1920

2021
/**
2122
* Gestionnaire de couches
@@ -621,7 +622,7 @@ class LayerSwitcher extends EventTarget {
621622
this.map.setSprite(data_1.sprite);
622623
this.map.setGlyphs(data_1.glyphs);
623624
// Fallback for offline glyphs
624-
if (!Globals.online) {
625+
if (!Globals.online && Capacitor.isNativePlatform()) {
625626
this.map.setGlyphs("data/fallback_glyphs/{fontstack}/{range}.pbf");
626627
}
627628
const data_2 = data_1;

src/js/my-account/my-account-dom.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ let MyAccountDOM = {
680680
// Au clic sur la carte : zoomer sur l'emprise
681681

682682
container.querySelector(`#offline-map-basic-tools_ID_${offlineMapId}`).addEventListener("click", () => {
683+
// Place le plan IGN au dessus de la pile des couches
684+
const planIgnLayerBtn = document.getElementById("PLAN.IGN.INTERACTIF$TMS");
685+
do {
686+
planIgnLayerBtn.click();
687+
} while (!planIgnLayerBtn.classList.contains("selectedLayer"));
683688
this.hide();
684689
this.map.fitBounds([[offlineMap.boundingBox.minLng, offlineMap.boundingBox.minLat], [offlineMap.boundingBox.maxLng, offlineMap.boundingBox.maxLat]]);
685690
});

src/js/offline-maps.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ class OfflineMaps {
254254
PopupUtils.showPopup(
255255
`
256256
<div id="planIgnInfoPopup">
257-
<div class="divPositionTitle">Pourquoi uniquement plan IGN ?</div>
257+
<div class="divPositionTitle">Pourquoi uniquement Plan IGN ?</div>
258258
<div class="divPopupClose" onclick="onClosePlanIgnInfoPopup(event)"></div>
259259
<div class="divPopupContent">
260-
L'adresse affichée est obtenue grâce au service de géocodage inverse. Ce service retourne, à partir d'un point sur la carte, l'adresse de la Base Adresse Nationale (BAN) la plus proche. Selon ce principe, une adresse affichée peut différer de l'adresse connue d'un lieu.
260+
Certaines cartes SCAN - dont le SCAN 25 - ne sont pas libres de droits. Pour garantir la gratuité de l'application, le téléchargement pour une utilisation hors ligne est uniquement disponible à partir du Plan IGN.
261261
</div>
262262
</div>
263263
`,
@@ -284,6 +284,7 @@ class OfflineMaps {
284284
duration: "long",
285285
position: "bottom"
286286
});
287+
Globals.menu.open("myaccount");
287288
}
288289

289290
/**
@@ -332,6 +333,9 @@ class OfflineMaps {
332333
* Locks the map view before downloading
333334
*/
334335
#lockView() {
336+
if (this.map.getZoom() < 8) {
337+
return;
338+
}
335339
this.dom.selectOnMapScreen.classList.add("d-none");
336340
this.dom.failedWindow.classList.add("d-none");
337341
this.dom.startDownloadScreen.classList.remove("d-none");
@@ -457,9 +461,6 @@ class OfflineMaps {
457461
this.#setLayerSource(this.map, layer.id, "offline-plan-ign");
458462
}
459463
});
460-
if (Capacitor.isNativePlatform()) {
461-
this.map.setGlyphs("data/fallback_glyphs/{fontstack}/{range}.pbf");
462-
}
463464
}
464465

465466
/**
@@ -471,9 +472,6 @@ class OfflineMaps {
471472
this.#setLayerSource(this.map, layer.id, "plan_ign");
472473
}
473474
});
474-
if (Capacitor.isNativePlatform()) {
475-
this.map.setGlyphs("https://data.geopf.fr/annexes/ressources/vectorTiles/fonts/{fontstack}/{range}.pbf");
476-
}
477475
}
478476

479477
/**

src/js/poi.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* This program and the accompanying materials are made available under the terms of the GPL License, Version 3.0.
55
*/
66

7+
import { Capacitor } from "@capacitor/core";
8+
79
import LayersConfig from "./layer-manager/layer-config";
810
import LayersGroup from "./layer-manager/layer-group";
911

@@ -107,7 +109,7 @@ class POI {
107109
this.map.setSprite(data.sprite);
108110
this.map.setGlyphs(data.glyphs);
109111
// Fallback for offline glyphs
110-
if (!Globals.online) {
112+
if (!Globals.online && Capacitor.isNativePlatform()) {
111113
this.map.setGlyphs("data/fallback_glyphs/{fontstack}/{range}.pbf");
112114
}
113115
this.#loadSprite(data.sprite);

0 commit comments

Comments
 (0)