@@ -240,6 +240,7 @@ export default {
240
240
markedMarker: null ,
241
241
hamburger: false ,
242
242
finishedLoading: false ,
243
+ cabinetQuery: null ,
243
244
};
244
245
},
245
246
components: {
@@ -267,11 +268,13 @@ export default {
267
268
async mounted () {
268
269
this .isLoading = true ;
269
270
let ref = this ;
271
+
270
272
// add the map to a data object
271
273
this .$refs .mapRef .$mapPromise .then ((map ) => (this .map = map));
272
274
this .$root .$on (" hamburgerState" , (state ) => {
273
275
this .hamburger = state;
274
276
});
277
+
275
278
// DSLAM LOADING
276
279
let dslam = await axios
277
280
.get (" https://api.fttx.gr/api/v1/centers?limit=0&approved=true" )
@@ -311,6 +314,33 @@ export default {
311
314
this .paths .push (e[0 ]);
312
315
});
313
316
this .isLoading = false ;
317
+ // cabinet query start
318
+ const cabQuery = " cabinet?id=" ;
319
+ if (window .location .href .includes (cabQuery)) {
320
+ const cabId = window .location .href .split (cabQuery)[1 ];
321
+ console .log (cabId);
322
+ let c = await axios
323
+ .get (` https://api.fttx.gr/api/v1/cabinets/${ cabId} ` )
324
+ .then ((r ) => r);
325
+ c = c .data .data ;
326
+ const marker = new google.maps.Marker ({
327
+ position: c .position ,
328
+ map: this .map ,
329
+ icon: this .markerIcons [c .isp ],
330
+ });
331
+ marker .db = c;
332
+ ref .infoWindow (marker);
333
+ marker .addListener (" click" , function () {
334
+ ref .infoWindow (marker);
335
+ });
336
+ this .myCoordinates = {
337
+ lat: c .position .lat ,
338
+ lng: c .position .lng ,
339
+ };
340
+ this .zoom = 17 ;
341
+ this .cabinetQuery = cabId;
342
+ }
343
+ // cabinet query end
314
344
// POLYGON LOADING END -- LOAD EVERYTHING ELSE BUT INVISIBLE (NOTE: This part here is what causing the initial lag spike because there's just too much data. Working on it.)
315
345
const initialize = async (page ) => {
316
346
const results = await axios
@@ -321,6 +351,8 @@ export default {
321
351
const cabinets = results .data .data .filter ((d ) => d .type !== " DSLAM" );
322
352
this .numberOfCabinets += cabinets .length ;
323
353
cabinets .forEach ((d ) => {
354
+ // check if a cabinet is queried and if it's stored in cabinetQuery, exclude it from loading because it's already loaded.
355
+ if (this .cabinetQuery && d ._id === this .cabinetQuery ) return ;
324
356
const marker = new google.maps.Marker ({
325
357
position: d .position ,
326
358
map: this .map ,
@@ -432,7 +464,9 @@ export default {
432
464
marker .db ._id
433
465
} <br><a style="font-weight: bold; color: purple;" target="_blank" href="${
434
466
marker .db .img_url
435
- } ">Click Here for image</a>` ;
467
+ } ">Click Here for image</a><br><a style="font-weight: bold; color: purple;" target="_blank" href="https://fttx.gr/cabinet?id=${
468
+ marker .db ._id
469
+ } ">URL to this Cabinet</a>` ;
436
470
const infowindow = new google.maps.InfoWindow ({
437
471
content: text,
438
472
});
@@ -590,10 +624,8 @@ export default {
590
624
},
591
625
},
592
626
async created () {
593
- const cabQuery = " cabinet?id=" ;
594
- if (window .location .pathname .includes (cabQuery)) {
595
- const cabId = window .location .pathname .split (cabQuery)[1 ];
596
- }
627
+ const ref = this ;
628
+ //
597
629
},
598
630
};
599
631
</script >
0 commit comments