From 7008bc9246e8dca9b36d59abdedf0c7c0ca2d57b Mon Sep 17 00:00:00 2001 From: zigmhount <58641590+zigmhount@users.noreply.github.com> Date: Sun, 6 Mar 2022 22:16:23 +0100 Subject: [PATCH] Plot markers for wpoints from MapPoints In addition to path from getMapPath(), get wpoints from getMapPoints() and plot them on the marker layer. Somehow the for loop `wpoints_loop` tends to continue infinitely, forcing stop with `break wpoints_loop` for now. --- .../lightbox.map.gallery.component.ts | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.ts b/src/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.ts index e207860d..5d599fc5 100644 --- a/src/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.ts +++ b/src/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.ts @@ -387,14 +387,32 @@ export class GalleryMapLightboxComponent implements OnChanges { for (let i = 0; i < this.gpxFiles.length; i++) { const file = this.gpxFiles[i]; const path = await this.mapService.getMapPath(file); + const wpoints = await this.mapService.getMapPoints(file); if (file !== this.gpxFiles[i]) { // check race condition return; } - if (path.length === 0) { - continue; + if (path.length !== 0) { + this.mapLayersControlOption.overlays.Paths.addLayer(marker(path[0] as LatLng)); + this.mapLayersControlOption.overlays.Paths.addLayer(polyline(path as LatLng[])); + // console.log('Trk path is not empty, in file ' + i + ', path[0]=' + JSON.stringify(path[0])); + // continue; + } else { + // console.log('No trk path in file ' + i); + // continue; + } + if (wpoints.length !== 0) { + // console.log('Wpt exist in file ' + i + ', wpoints[0]=' + JSON.stringify(wpoints[0]) +', wpoints.length=' + wpoints.length); + wpoints_loop: for (let wpt_i = 0; i < wpoints.length; wpt_i++) { + // console.log('item number ' + wpt_i + ' out of ' + wpoints.length + ', coord=' + JSON.stringify(wpoints[wpt_i])); + if (wpoints[wpt_i] === undefined) { + break wpoints_loop; + } + this.mapLayersControlOption.overlays.Paths.addLayer(marker(wpoints[wpt_i] as LatLng)); + } + // console.log('Wpoints plotted.'); + } else { + // console.log('No wpt points in file ' + i); } - this.mapLayersControlOption.overlays.Paths.addLayer(marker(path[0] as LatLng)); - this.mapLayersControlOption.overlays.Paths.addLayer(polyline(path as LatLng[])); } } }