From f1d53b02564b3f5672d8b421ea8bb723d8e93b04 Mon Sep 17 00:00:00 2001 From: "amaury.zarzelli" Date: Thu, 8 Feb 2024 17:38:29 +0100 Subject: [PATCH] feat(myaccount): enregistrement des landmarks et actions sur les landmarks --- .github/workflows/android-deploy.yml | 1 + .github/workflows/ios-deploy.yml | 1 + .github/workflows/web-deploy.yml | 1 + src/css/assets/landmark-favourite-map.png | Bin 0 -> 716 bytes src/css/assets/landmark-saved-map.png | Bin 0 -> 775 bytes src/css/assets/landmark-tovisit-map.png | Bin 0 -> 980 bytes src/css/layer-switcher.css | 18 +++ src/css/my-account.css | 4 + src/js/controls.js | 1 + src/js/event-listeners.js | 4 +- src/js/landmark.js | 29 ++++ src/js/map-buttons-listeners.js | 3 + src/js/my-account/my-account-dom.js | 134 ++++++++++++++- src/js/my-account/my-account-styles.js | 59 +++++++ src/js/my-account/my-account.js | 152 +++++++++++++++++- src/js/nav.js | 2 + src/js/search.js | 2 +- src/js/state.js | 3 + utils/README.md | 2 + utils/compare_style.py | 4 +- utils/convertOLZoomsToMapblireZooms.py | 4 +- utils/convertStopsToStep.py | 2 +- .../poi_rlt_csv_to_geojson.py | 0 23 files changed, 411 insertions(+), 15 deletions(-) create mode 100644 src/css/assets/landmark-favourite-map.png create mode 100644 src/css/assets/landmark-saved-map.png create mode 100644 src/css/assets/landmark-tovisit-map.png create mode 100644 utils/README.md rename poi_rlt_csv_to_geojson.py => utils/poi_rlt_csv_to_geojson.py (100%) diff --git a/.github/workflows/android-deploy.yml b/.github/workflows/android-deploy.yml index 30715c8b..fdbd9441 100644 --- a/.github/workflows/android-deploy.yml +++ b/.github/workflows/android-deploy.yml @@ -17,6 +17,7 @@ jobs: - name: Make envfile run: | echo "GPF_key=${{ secrets.GPF_key }}" > .env + echo "signalement_url=${{ secrets.SIGNALEMENT_URL }}" >> .env - name: Setup Node.js uses: actions/setup-node@v3 diff --git a/.github/workflows/ios-deploy.yml b/.github/workflows/ios-deploy.yml index 5c4641c7..c7691826 100644 --- a/.github/workflows/ios-deploy.yml +++ b/.github/workflows/ios-deploy.yml @@ -17,6 +17,7 @@ jobs: - name: Make envfile run: | echo "GPF_key=${{ secrets.GPF_key }}" > .env + echo "signalement_url=${{ secrets.SIGNALEMENT_URL }}" >> .env - name: Setup Node.js uses: actions/setup-node@v3 diff --git a/.github/workflows/web-deploy.yml b/.github/workflows/web-deploy.yml index 89f3e480..52a7579b 100644 --- a/.github/workflows/web-deploy.yml +++ b/.github/workflows/web-deploy.yml @@ -30,6 +30,7 @@ jobs: - name: Make envfile run: | echo "GPF_key=${{ secrets.GPF_key }}" > .env + echo "signalement_url=${{ secrets.SIGNALEMENT_URL }}" >> .env - name: Setup Node.js uses: actions/setup-node@v3 diff --git a/src/css/assets/landmark-favourite-map.png b/src/css/assets/landmark-favourite-map.png new file mode 100644 index 0000000000000000000000000000000000000000..201254797fb2b7c0b45d44c1d48ab5bf58a606f5 GIT binary patch literal 716 zcmV;-0yF)IP)C=)Ik`>zx!g*i8+#zXHDX^fN|6Gs;3Zeu^N{&W}m-HdLZeuq~ns#NjhO;?<5r@4cPN1 zNehy`SyLC`6T-qd2Rg}&-_LV)oEwK*T^I52UIy~Lm5%+c%JuC@Z9WW z;G=EMb>OI{jx6`9X?*}nojkP!3{m@?cnoxTXmnXFrghr4o)9Afrl@fTC}zklT27Uz zkXk~Glz>I2n3)W@Gfv(jo=Yk(BLWTqFP)+$+sK)8;$N6XP#t*~5tR+Q>J)c{#>=c| zV^vlOJ1BBDBH#${+$r)de;)uP;D$540vyY0{ydEcI0!s(id_H>0Q-T5&iBi};XLQg z+lYXDz+7F?%g*zh#pF8gUKpt^qwDPCHaqVlQ5zAJYpZ)7nI_;W+p2|Jb=zgs`b&E` yNhgeSg!I2wY$PMGk&MJfG7=lfNNgk{vGE68)>jWifhMT{0000C=6;T+6A0_%QO0lTGOp3Bdmm$%rAS~z~XcH}hK#D93goHjU`VU&PiFQG> zhzg=zOQD6BT2^G5wJQvazL1_4GZ#;GvFn`~8e)EMn3==-p7;06xifRltx@?ORQs((UL>ed3yz_y^Z0_{Lc9Mb_j3346*oxnF> z5O@i^n%6#8<)#Yy^Xjnr)rEDxOzs}_=U?*P8~qGhvz(DSV21K9iFd(W9RqFx(`Dj1 zfqncwlPk)^^#d0wc2>oVTnX;pjCxS5t74o|t5KWPJHfb3w2`x5Y*ma zya{#7V#i3U_?v2qml5Aw&6R002ovPDHLk FV1h;OS;znY literal 0 HcmV?d00001 diff --git a/src/css/assets/landmark-tovisit-map.png b/src/css/assets/landmark-tovisit-map.png new file mode 100644 index 0000000000000000000000000000000000000000..119b298c879e1dadc65c74d88a2381c2538c754a GIT binary patch literal 980 zcmV;_11tQAP)c}80QO@-+6w| z^PK1Rx%aux?{`j}Bo=}e&36E4DF?}#a*(Vk2g#Zi3`qSvt@{M<9MA#$1$+LRuK4YNs|@6JCgQi8Kg(jvV^0zUiJ|+#&~T3ViE>u`k3~ zH|XlU>ZBUMu5kB-q*8TI4MX2uo-9zeC@!e ze$R32SOs{h8%lG%$?hxiZMUgrbfu-i^7V6d�-W&}+TH&Mw)Fshh!a#2 zkZ4O>#(||G2X+HnFz`+8f7N5U1ssnRRf1FLJwH{(V$Au_=S<78 zd!eGgAZfLv8$Rw(+_-90G;YC8s9taP0l#D4_E(g*Qlv)U2)5<^2HuIiVhw(gJt~(S z<8~j3ix=v`?S?sn{ zrGJ^*Pk>jjWOx908v~0TxMC}9kP)}tKwU*&Gw>a-&D;H0^6T^VQ@|iGOOr@xgM8_B z18@*4XTX9R09FAfut!{gU)?qXr$`6^>4WrRl`L46E@8#uWngD8W};$V0cf4e!fAv2 zj|F_p+YbOMvEuY5@B#2<%4-6(d5iK7@I0^-ItH51fV?X1ISW)k(46i9LxuD-@C}cn@8{a>>-a239Hw2*5^QFLO99XV699BjC3r zlaqpEP7CHGb`Fv? { }); // Poi RLT Globals.comparePoi = new ComparePoi(map, {}); + Globals.myaccount.addLandmarksLayers(); }); }); }; diff --git a/src/js/event-listeners.js b/src/js/event-listeners.js index d4b20123..64610fb4 100644 --- a/src/js/event-listeners.js +++ b/src/js/event-listeners.js @@ -83,6 +83,7 @@ function addListeners() { localStorage.setItem("lastMapZoom", map.getZoom()); localStorage.setItem("lastLayersDisplayed", JSON.stringify(Globals.layersDisplayed)); localStorage.setItem("savedRoutes", JSON.stringify(Globals.myaccount.routes)); + localStorage.setItem("savedLandmarks", JSON.stringify(Globals.myaccount.landmarks)); }); window.addEventListener("beforeunload", () => { @@ -91,6 +92,7 @@ function addListeners() { localStorage.setItem("lastMapZoom", map.getZoom()); localStorage.setItem("lastLayersDisplayed", JSON.stringify(Globals.layersDisplayed)); localStorage.setItem("savedRoutes", JSON.stringify(Globals.myaccount.routes)); + localStorage.setItem("savedLandmarks", JSON.stringify(Globals.myaccount.landmarks)); }); // Screen dimentions change @@ -130,7 +132,7 @@ function addListeners() { } } } - if (["selectOnMapDirections", "selectOnMapIsochrone", "compare"].includes(Globals.backButtonState)) { + if (["selectOnMapDirections", "selectOnMapIsochrone", "selectOnMapLandmark", "compare"].includes(Globals.backButtonState)) { Globals.currentScrollIndex = 0; } if (Globals.backButtonState === "compareLayers2") { diff --git a/src/js/landmark.js b/src/js/landmark.js index 2e8060dc..f7d295d3 100644 --- a/src/js/landmark.js +++ b/src/js/landmark.js @@ -5,6 +5,7 @@ import { Toast } from "@capacitor/toast"; // dependance : abonnement au event du module import Geocode from "./services/geocode"; import Location from "./services/location"; +import Reverse from "./services/reverse"; /** * Interface sur le contrôle point de repère @@ -147,6 +148,34 @@ class Landmark { }; } + /** + * listener sur la carte pour recuperer les coordonnées du point + * @param {*} e + */ + onAddWayPoint(e) { + console.debug(e); + var coordinates = e.lngLat; + Reverse.compute({ + lon : coordinates.lng, + lat : coordinates.lat + }) + .then(() => {}) + .catch(() => {}) + .finally(() => { + var coords = Reverse.getCoordinates() || {lon : coordinates.lng, lat : coordinates.lat}; + var address = Reverse.getAddress() || coords.lon.toFixed(6) + ", " + coords.lat.toFixed(6); + var strAddress = address; + if (typeof address !== "string") { + strAddress = ""; + strAddress += (address.number !== "") ? address.number + " " : ""; + strAddress += (address.street !== "") ? address.street + ", " : ""; + strAddress += address.city + ", " + address.postcode; + } + this.dom.location.dataset.coordinates = "[" + coords.lon + "," + coords.lat + "]"; + this.dom.location.value = strAddress; + }); + } + /** * listener issu du dom sur l'interface du menu 'search' * @param {*} e diff --git a/src/js/map-buttons-listeners.js b/src/js/map-buttons-listeners.js index fcd9ed07..1ca14c80 100644 --- a/src/js/map-buttons-listeners.js +++ b/src/js/map-buttons-listeners.js @@ -76,6 +76,9 @@ const addListeners = () => { lat: Globals.map.getCenter().lat, }); Globals.menu.close("selectOnMapDirections"); + } else if (Globals.backButtonState === "selectOnMapLandmark") { + Globals.landmark.onAddWayPoint({lngLat: Globals.map.getCenter()}); + Globals.menu.close("selectOnMapLandmark"); } }); }; diff --git a/src/js/my-account/my-account-dom.js b/src/js/my-account/my-account-dom.js index e6619e25..dd3096a3 100644 --- a/src/js/my-account/my-account-dom.js +++ b/src/js/my-account/my-account-dom.js @@ -12,11 +12,12 @@ import Sortable from "sortablejs"; let MyAccountDOM = { dom: { container: null, - routeTab: null, routeNumber: null, + routeTab: null, + routeList: null, landmarkNumber: null, landmarkTab: null, - routeList: null, + landmarkList: null, }, /** @@ -26,7 +27,7 @@ let MyAccountDOM = { * @returns {DOMElement} * @public */ - getContainer(accountName, routes) { + getContainer(accountName, routes, landmarks) { // nettoyage if (this.dom.container) { this.dom.container.remove(); @@ -36,6 +37,8 @@ let MyAccountDOM = { container.appendChild(this.__addTabsContainerDOMElement()); // ajout des itinéraires this.dom.routeList = this.__addAccountRoutesContainerDOMElement(routes); + // ajout des points de repèrez + this.dom.landmarkList = this.__addAccountLandmarksContainerDOMElement(landmarks); // dragn'drop ! Sortable.create(this.dom.routeList, { handle: ".handle-draggable-layer", @@ -47,6 +50,17 @@ let MyAccountDOM = { } }); this.dom.routeTab.appendChild(this.dom.routeList); + // dragn'drop ! + Sortable.create(this.dom.landmarkList, { + handle: ".handle-draggable-layer", + draggable: ".draggable-layer", + animation: 200, + forceFallback: true, + onEnd : (evt) => { + this.setLandmarkPosition(evt.oldDraggableIndex, evt.newDraggableIndex); + } + }); + this.dom.landmarkTab.appendChild(this.dom.landmarkList); return container; }, @@ -125,7 +139,7 @@ let MyAccountDOM = { * @private */ __addAccountRoutesContainerDOMElement(routes) { - var divList = this.dom.container = document.createElement("div"); + var divList = document.createElement("div"); divList.id = "myaccountRouteList"; for (let i = 0; i < routes.length; i++) { divList.appendChild(this.__addRouteContainer(routes[i], i)); @@ -147,6 +161,35 @@ let MyAccountDOM = { this.dom.routeNumber.innerText = routes.length; }, + /** + * ajoute le container sur les points de repère + * @param {*} landmarks + * @returns {DOMElement} + * @private + */ + __addAccountLandmarksContainerDOMElement(landmarks) { + var divList = this.dom.container = document.createElement("div"); + divList.id = "myaccountLandmarksList"; + for (let i = 0; i < landmarks.length; i++) { + divList.appendChild(this.__addLandmarkContainer(landmarks[i], i)); + } + this.dom.landmarkNumber.innerText = landmarks.length; + return divList; + }, + + /** + * met à jour le container sur les points de repère + * @param {*} landmarks + * @private + */ + __updateAccountLandmarksContainerDOMElement(landmarks) { + this.dom.landmarkList.innerHTML = ""; + for (let i = 0; i < landmarks.length; i++) { + this.dom.landmarkList.appendChild(this.__addLandmarkContainer(landmarks[i], i)); + } + this.dom.landmarkNumber.innerText = landmarks.length; + }, + /** * Ajout d'une entrée pour une route (DOM) * @param {*} route @@ -232,6 +275,89 @@ let MyAccountDOM = { } }); + if (!container) { + console.warn(); + return; + } + return container; + }, + + /** + * Ajout d'une entrée pour un point de repère (DOM) + * @param {*} landmark + * @private + */ + __addLandmarkContainer(landmark) { + console.log(landmark); + var title = landmark.properties.title; + var landmarkId = landmark.properties.id; + var checked = landmark.properties.visible ? "checked" : ""; + + // Template d'une route + var tplContainer = ` +
+
+
+ +
+ ${title} +
+
+ +
+
Partager
+ + +
Exporter
+
Supprimer
+
+
+ `; + + // transformation du container : String -> DOM + var container = DomUtils.stringToHTML(tplContainer.trim()); + + container.querySelector(`#landmark-share_ID_${landmarkId}`).addEventListener("click", () => { + this.shareLandmark(landmark); + }); + + container.querySelector(`#landmark-export_ID_${landmarkId}`).addEventListener("click", () => { + this.exportLandmark(landmark); + }); + + container.querySelector(`#landmark-basic-tools_ID_${landmarkId}`).addEventListener("click", () => { + const buttonToClick = container.querySelector(`#landmark-visibility_ID_${landmarkId}`); + if (buttonToClick.checked) { + buttonToClick.click(); + } + buttonToClick.click(); + }); + + container.querySelector(`#landmark-visibility_ID_${landmarkId}`).addEventListener("click", () => { + this.toggleShowLandmark(landmark); + }); + + let deleteLandmark = () => { + this.deleteLandmark(landmarkId); + }; + + let handleDeleteLandmark = deleteLandmark.bind(this); + + container.querySelector(`#landmark-remove_ID_${landmarkId}`).addEventListener("click", () => { + Toast.show({ + text: "Confirmez la suppression du point de repère", + duration: "short", + position: "bottom" + }); + container.querySelector(`#landmark-remove_ID_${landmarkId}`).addEventListener("click", handleDeleteLandmark); + }); + + document.addEventListener("click", (event) => { + if (!event.target.closest(`#landmark-remove_ID_${landmarkId}`)) { + container.querySelector(`#landmark-remove_ID_${landmarkId}`).removeEventListener("click", handleDeleteLandmark); + } + }); + if (!container) { console.warn(); return; diff --git a/src/js/my-account/my-account-styles.js b/src/js/my-account/my-account-styles.js index 1c5e3f27..7d721adf 100644 --- a/src/js/my-account/my-account-styles.js +++ b/src/js/my-account/my-account-styles.js @@ -161,6 +161,65 @@ const layers = { }, filter: ["==", ["get", "order"], "destination"], }, + "landmark-casing": { + id: "my-account-landmarks-casing", + type: "circle", + source: "", + paint: { + "circle-radius": [ + "interpolate", + ["exponential", 1.5], + ["zoom"], + 0, + 6, + 5, + 6, + 18, + 17 + ], + "circle-color": "white", + "circle-opacity": ["case", ["boolean", ["get", "visible"], false], 1, 0], + } + }, + "landmark": { + id: "my-account-landmarks", + type: "circle", + source: "", + paint: { + "circle-radius": [ + "interpolate", + ["exponential", 1.5], + ["zoom"], + 0, + 5, + 5, + 5, + 18, + 15 + ], + "circle-color": ["get", "color"], + "circle-opacity": ["case", ["boolean", ["get", "visible"], false], 1, 0], + } + }, + "landmark-icon": { + id: "my-account-landmark-icon", + type: "symbol", + source: "", + layout: { + "icon-image": ["get", "icon"], + "icon-size": [ + "interpolate", + ["exponential", 1.5], + ["zoom"], + 0, + 10/50, + 5, + 10/50, + 18, + 30/50 + ], + }, + }, }; export default layers; diff --git a/src/js/my-account/my-account.js b/src/js/my-account/my-account.js index 0697157b..2aad2de7 100644 --- a/src/js/my-account/my-account.js +++ b/src/js/my-account/my-account.js @@ -8,6 +8,10 @@ import { Toast } from "@capacitor/toast"; import { Filesystem, Directory, Encoding } from "@capacitor/filesystem"; import maplibregl from "maplibre-gl"; +import LandmarkIconSaved from "../../css/assets/landmark-saved-map.png"; +import LandmarkIconFavourite from "../../css/assets/landmark-favourite-map.png"; +import LandmarkIconTovisit from "../../css/assets/landmark-tovisit-map.png"; + /** * Interface sur la fenêtre du compte * @module MyAccount @@ -31,6 +35,7 @@ class MyAccount { this.configuration = this.options.configuration || { linesource: "my-account-line", pointsource: "my-account-point", + landmarksource: "my-account-landmark", }; // target @@ -61,6 +66,24 @@ class MyAccount { this.routes = this.routes.concat(localRoutes); } + // récupération des points de repère enregistrés en local + if (!localStorage.getItem("savedLandmarks")) { + localStorage.setItem("savedLandmarks", "[]"); + } else { + var localLandmarks = JSON.parse(localStorage.getItem("savedLandmarks")); + this.landmarks = this.landmarks.concat(localLandmarks); + } + + this.map.loadImage(LandmarkIconSaved, (_, image) => { + this.map.addImage("landmark-icon-saved", image); + }); + this.map.loadImage(LandmarkIconFavourite, (_, image) => { + this.map.addImage("landmark-icon-favourite", image); + }); + this.map.loadImage(LandmarkIconTovisit, (_, image) => { + this.map.addImage("landmark-icon-tovisit", image); + }); + // récupération des infos et rendu graphique this.compute().then(() => { // Ajout d'identifiant unique aux routes @@ -68,6 +91,11 @@ class MyAccount { route.id = this.lastRouteId; this.lastRouteId++; }); + // Ajout d'identifiant unique aux landmarks + this.landmarks.forEach((landmark) => { + landmark.id = this.lastLandmarkId; + this.lastLandmarkId++; + }); this.render(); this.#updateSources(); }); @@ -86,7 +114,7 @@ class MyAccount { return; } - var container = this.getContainer(this.accountName, this.routes); + var container = this.getContainer(this.accountName, this.routes, this.landmarks); if (!container) { console.warn(); return; @@ -132,7 +160,13 @@ class MyAccount { * @param {*} landmarkGeojson */ addLandmark(landmarkGeojson) { - console.log(landmarkGeojson); + const newlandmark = JSON.parse(JSON.stringify(landmarkGeojson)); + newlandmark.properties.id = this.lastLandmarkId; + this.lastLandmarkId++; + this.landmarks.unshift(newlandmark); + this.__updateAccountLandmarksContainerDOMElement(this.landmarks); + localStorage.setItem("savedLandmarks", JSON.stringify(this.landmarks)); + this.#updateSources(); } /** @@ -151,6 +185,22 @@ class MyAccount { } } + /** + * Supprime un point de repère de l'epace utilisateur + */ + deleteLandmark(landmarkId) { + for (let i = 0; i < this.landmarks.length; i++) { + let landmark = this.landmarks[i]; + if (landmark.properties.id !== landmarkId) { + continue; + } + this.landmarks.splice(i, 1); + this.__updateAccountLandmarksContainerDOMElement(this.landmarks); + this.#updateSources(); + break; + } + } + /** * Change l'ordre des routes dans l'objet * @param {*} oldIndex @@ -162,6 +212,17 @@ class MyAccount { this.routes.splice(newIndex, 0, route); } + /** + * Change l'ordre des points de repère dans l'objet + * @param {*} oldIndex + * @param {*} newIndex + */ + setLandmarkPosition(oldIndex, newIndex) { + const landmark = this.landmarks[oldIndex]; + this.landmarks.splice(oldIndex, 1); + this.landmarks.splice(newIndex, 0, landmark); + } + /** * Ouvre l'outil de tracé d'itinéraire pour modifier un itinéraire * @param {*} route @@ -190,7 +251,7 @@ class MyAccount { } /** - * Partage le résumé d'un itinéraire + * Partage l'itinéraire sous forme de fichier * @param {*} route */ shareRoute(route) { @@ -224,6 +285,23 @@ Dénivelé positif : ${route.data.elevationData.dplus} m, Dénivelé négatif : }); } + /** + * Partage le point de repère + * @param {*} landmark + */ + shareLandmark(landmark) { + Share.share({ + title: `${landmark.properties.title}`, + text: `${landmark.properties.title} +${landmark.properties.locationName} +Latitude : ${landmark.geometry.coordinates[1]} +Longitude : ${landmark.geometry.coordinates[0]} +${landmark.properties.description} +`, + dialogTitle: "Partager mon point de repère", + }); + } + /** * Exporte l'itinéraire sous forme d'un ficheir geojson * @param {*} route @@ -250,9 +328,34 @@ Dénivelé positif : ${route.data.elevationData.dplus} m, Dénivelé négatif : }); } + /** + * Exporte le point de repère sous forme d'un ficheir geojson + * @param {*} route + */ + exportLandmark(landmark) { + Filesystem.writeFile({ + path: `${landmark.properties.title}.geojson`, + data: JSON.stringify(landmark), + directory: Directory.Documents, + encoding: Encoding.UTF8, + }).then(() => { + Toast.show({ + text: "Fichier enregistré dans Documents.", + duration: "long", + position: "bottom" + }); + }).catch( () => { + Toast.show({ + text: "Le point de repère n'a pas pu être savegardé.", + duration: "long", + position: "bottom" + }); + }); + } + /** * Affiche l'itinéraire s'il est caché, ou le cache s'il est affiché - * @param {*} routes + * @param {*} route */ toggleShowRoute(route) { if (route.visible) { @@ -274,6 +377,21 @@ Dénivelé positif : ${route.data.elevationData.dplus} m, Dénivelé négatif : this.#updateSources(); } + /** + * Affiche le point de repère s'il est caché, ou le cache s'il est affiché + * @param {*} landmark + */ + toggleShowLandmark(landmark) { + if (landmark.properties.visible) { + landmark.properties.visible = false; + } else { + landmark.properties.visible = true; + this.hide(); + this.map.flyTo({center: landmark.geometry.coordinates}); + } + this.#updateSources(); + } + /** * Convertit une route telle qu'enregistrée dans le compte en geojson valide * @param {*} route @@ -357,6 +475,12 @@ Dénivelé positif : ${route.data.elevationData.dplus} m, Dénivelé négatif : type: "FeatureCollection", features: this.#getRoutePoints(), }); + + var landmarksource = this.map.getSource(this.configuration.landmarksource); + landmarksource.setData({ + type: "FeatureCollection", + features: this.landmarks, + }); } /** @@ -392,6 +516,26 @@ Dénivelé positif : ${route.data.elevationData.dplus} m, Dénivelé négatif : this.map.addLayer(MyAccountLayers["point"]); this.map.addLayer(MyAccountLayers["point-departure"]); this.map.addLayer(MyAccountLayers["point-destination"]); + + this.map.addSource(this.configuration.landmarksource, { + "type": "geojson", + "data": { + type: "FeatureCollection", + features: [], + } + }); + MyAccountLayers["landmark-casing"].source = this.configuration.landmarksource; + MyAccountLayers["landmark"].source = this.configuration.landmarksource; + MyAccountLayers["landmark-icon"].source = this.configuration.landmarksource; + } + + /** + * ajoute le layer landmarks à la carte. Séparé pour pouvoir les ajouter en dernier, au-dessus des POI OSM + */ + addLandmarksLayers() { + this.map.addLayer(MyAccountLayers["landmark-casing"]); + this.map.addLayer(MyAccountLayers["landmark"]); + this.map.addLayer(MyAccountLayers["landmark-icon"]); } /** diff --git a/src/js/nav.js b/src/js/nav.js index 21b67ef7..c822a6de 100644 --- a/src/js/nav.js +++ b/src/js/nav.js @@ -128,6 +128,7 @@ class MenuNavigation { break; case "selectOnMapDirections": case "selectOnMapIsochrone": + case "selectOnMapLandmark": DOM.$filterPoiBtn.classList.add("d-none"); DOM.$layerManagerBtn.classList.add("d-none"); DOM.$mapCenter.classList.remove("d-none"); @@ -365,6 +366,7 @@ class MenuNavigation { DOM.$filterPoiBtn.classList.remove("d-none"); // falls through case "selectOnMapIsochrone": + case "selectOnMapLandmark": DOM.$layerManagerBtn.classList.remove("d-none"); DOM.$mapCenter.classList.add("d-none"); DOM.$mapCenterMenu.classList.add("d-none"); diff --git a/src/js/search.js b/src/js/search.js index 0779e783..cc51c098 100644 --- a/src/js/search.js +++ b/src/js/search.js @@ -98,7 +98,7 @@ class Search { } else if (Globals.backButtonState === "searchLandmark") { e.target.classList.add("autocompresultselected"); setTimeout(() => { - Globals.menu.open("selectOnMapIsochrone"); + Globals.menu.open("selectOnMapLandmark"); }, 250); } }, true); diff --git a/src/js/state.js b/src/js/state.js index 6db5df0a..6c9fc42f 100644 --- a/src/js/state.js +++ b/src/js/state.js @@ -100,6 +100,9 @@ const onBackKeyDown = () => { if (Globals.backButtonState === "selectOnMapIsochrone") { Globals.menu.close("selectOnMapIsochrone"); } + if (Globals.backButtonState === "selectOnMapLandmark") { + Globals.menu.close("selectOnMapLandmark"); + } if (Globals.backButtonState === "comparePoi") { Globals.menu.close("comparePoi"); } diff --git a/utils/README.md b/utils/README.md new file mode 100644 index 00000000..cefb113e --- /dev/null +++ b/utils/README.md @@ -0,0 +1,2 @@ +À lancer depuis le dossier racine : +`python utils/convertOLZoomsToMapblireZooms.py` diff --git a/utils/compare_style.py b/utils/compare_style.py index 8b782b93..ed19cead 100644 --- a/utils/compare_style.py +++ b/utils/compare_style.py @@ -1,6 +1,6 @@ import json -with open("plan-ign-interactif-style.json") as file: +with open("www/data/plan-ign-interactif-style.json") as file: style1 = json.load(file) with open("PlanIGNetPOI-Test11-Geoplateforme.json") as file: @@ -24,4 +24,4 @@ if layerid not in style1_ids: differences.append("only in newfile: " + layerid) -print(differences) \ No newline at end of file +print(differences) diff --git a/utils/convertOLZoomsToMapblireZooms.py b/utils/convertOLZoomsToMapblireZooms.py index a2617764..0e202c15 100644 --- a/utils/convertOLZoomsToMapblireZooms.py +++ b/utils/convertOLZoomsToMapblireZooms.py @@ -23,7 +23,7 @@ def convertFileZooms(path): style = json.load(file) converZoomsLayers(style) with open(path, "w", encoding="utf-8", newline="") as file: - json.dump(style, file, indent='2', ensure_ascii=False) + json.dump(style, file, indent=2, ensure_ascii=False) if __name__ == "__main__": - convertFileZooms("plan-ign-interactif-style.json") \ No newline at end of file + convertFileZooms("www/data/plan-ign-interactif-style.json") diff --git a/utils/convertStopsToStep.py b/utils/convertStopsToStep.py index c24e74c3..9e5e770e 100644 --- a/utils/convertStopsToStep.py +++ b/utils/convertStopsToStep.py @@ -30,4 +30,4 @@ def convertFileStopsToStep(path): json.dump(style, file, indent=2, ensure_ascii=False) if __name__ == "__main__": - convertFileStopsToStep("plan-ign-interactif-style.json") \ No newline at end of file + convertFileStopsToStep("www/data/plan-ign-interactif-style.json") diff --git a/poi_rlt_csv_to_geojson.py b/utils/poi_rlt_csv_to_geojson.py similarity index 100% rename from poi_rlt_csv_to_geojson.py rename to utils/poi_rlt_csv_to_geojson.py