refactorisation +touch-ups
davvalent

davvalent commited on 2023-03-23 15:21:03
Showing 1 changed files, with 21 additions and 18 deletions.

... ...
@@ -6,14 +6,16 @@
6 6
  * intégration du plan d’expropriation du Fabourg à m’lasse
7 7
  *
8 8
  * @author David Valentine <d@ntnlv.ca>
9
- * @todo loading messages (chargement)
9
+ * @todo rdfa
10
+ * @todo loading messages for body tag (chargement)
10 11
  * @todo cache
11 12
  * @todo error handling
12 13
  * @todo build process and cp in dist folder for deployment
13 14
  * @todo get rid of warnings liens source (map)
14 15
  * @todo voir https://geojson.org/geojson-ld/
15 16
  * @todo voir linked places format
16
- * @todo protocole de geolocalisation : si geojson.io,, charger buildings.json
17
+ * @todo geolocalisation : si geojson.io, charger buildings.json
18
+ * @todo geolocalisation : voir placemark @placemarkio
17 19
  */
18 20
 
19 21
 (async function main() {
... ...
@@ -109,20 +111,17 @@
109 111
         pane: 'fixed',
110 112
         className: 'popup-fixed',
111 113
         autoPan: false,
112
-        maxWidth: 2000, // must be larger than 50% of the viewport
113
-        content: "Chargement"
114
+        maxWidth: 2000 // must be larger than 50% of the viewport
114 115
       });
115 116
 
116 117
       layer.bindPopup(popup);
117 118
 
118
-      layer.on("click", () => {
119
+      /** Event passé automatiquement au callback */
120
+      layer.on("click", (e) => {
119 121
 
120 122
         let URI = feature.properties.URI;
121 123
 
122 124
         if (dev()) {
123
-
124
-          console.log("Dev: Message fired when clicking the geoJSON feature (the marker).");
125
-
126 125
           if (sessionStorage.getItem("onLineTripleStore") !== "true") {
127 126
             URI = feature.properties.URI.replace("http://data.qdmtl.ca", sessionStorage.getItem("devTripleStoreUrl"));
128 127
           }
... ...
@@ -142,7 +141,7 @@
142 141
         .then((jsonLD) => {
143 142
 
144 143
           if (dev) {
145
-            console.log("Dev: Response from local server:", jsonLD);
144
+            console.log("Dev: Response from RDF store: ", jsonLD);
146 145
           }
147 146
           
148 147
           const popUpInformation = `
... ...
@@ -157,7 +156,10 @@
157 156
               <div class="glide__track" data-glide-el="track">
158 157
                 <ul class="glide__slides">
159 158
                   <li class="glide__slide">
160
-                    <img src="https://archivesdemontreal.ica-atom.org/uploads/r/ville-de-montreal-section-des-archives/1/7/178126/VM94C196-0132.jpg">
159
+                    <img
160
+                      src="https://archivesdemontreal.ica-atom.org/uploads/r/ville-de-montreal-section-des-archives/1/7/178126/VM94C196-0132.jpg"
161
+                      alt="foo"
162
+                      title="bar">
161 163
                     <div class="overlay"></div>
162 164
                   </li>
163 165
                   <li class="glide__slide">
... ...
@@ -195,6 +197,10 @@
195 197
 
196 198
           popup.setContent(popUpInformation);
197 199
 
200
+          if (dev()) {
201
+            console.log("Dev popup:", popup);
202
+          }  
203
+
198 204
           /**
199 205
            * Déplacement et centrage de la punaise
200 206
            */
... ...
@@ -231,10 +237,6 @@
231 237
         (reason) => {
232 238
             /* rejection handler */
233 239
         }).catch(err => console.log(err));
234
-
235
-        if (dev()) {
236
-          console.log("Dev popup:", popup);
237
-        }
238 240
       });
239 241
     }
240 242
   }),
... ...
@@ -259,7 +261,7 @@
259 261
     /** Instanciation du plan */
260 262
     pifm = L.map("map", {
261 263
       center: [45.51823567357893, -73.55085910368373],
262
-      zoom: 17.5,
264
+      zoom: 18, // https://github.com/Leaflet/Leaflet/issues/3575
263 265
       minZoom: 15,
264 266
       zoomDelta: 0.5,
265 267
       zoomSnap: 0.5,
... ...
@@ -298,11 +300,12 @@
298 300
 
299 301
   if (dev()) {
300 302
     pifm.on("popupopen", () => {
301
-      console.log("Dev: Message fired on pop-up opening");
303
+      console.log("Dev: Message fired on POPUP OPENING");
302 304
     });
303
-    pifm.on("popupclose", () => {
304
-      console.log("Dev CLOSE: Message fired on pop-up closing");
305
+    pifm.on("popupclose", (e) => {
306
+      console.log("Dev CLOSE: Message fired on pop-up closing", e);
305 307
     });
308
+    pifm.on('click', (e) => console.log("EVENT: click on map", e));
306 309
   };
307 310
 
308 311
 })();
309 312