diff --git a/demo/images/emptydirectory/unique_wpt.gpx b/demo/images/emptydirectory/unique_wpt.gpx new file mode 100644 index 000000000..6f0955683 --- /dev/null +++ b/demo/images/emptydirectory/unique_wpt.gpx @@ -0,0 +1,15 @@ + + + + favourites + + + + Location name + + special_star + circle + #eecc22 + + + diff --git "a/demo/images/its a along directory name. with special caracters(_.-.,-.,) 1234 56789 \305\261\303\241\303\251\303\272 \305\221\303\263\303\274\303\266/subdirectory/gpx_3locations.gpx" "b/demo/images/its a along directory name. with special caracters(_.-.,-.,) 1234 56789 \305\261\303\241\303\251\303\272 \305\221\303\263\303\274\303\266/subdirectory/gpx_3locations.gpx" new file mode 100644 index 000000000..e2b78c61f --- /dev/null +++ "b/demo/images/its a along directory name. with special caracters(_.-.,-.,) 1234 56789 \305\261\303\241\303\251\303\272 \305\221\303\263\303\274\303\266/subdirectory/gpx_3locations.gpx" @@ -0,0 +1,35 @@ + + + + favourites + + + + Location 1 + + special_star + circle + #eecc22 + + + + + Location 2 + + Street 1, Town + special_star + circle + #eecc22 + + + + + Location 3 + + Street 2, Town + special_star + circle + #eecc22 + + + 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 e207860d6..0b983a5f3 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 @@ -386,15 +386,23 @@ export class GalleryMapLightboxComponent implements OnChanges { // tslint:disable-next-line:prefer-for-of for (let i = 0; i < this.gpxFiles.length; i++) { const file = this.gpxFiles[i]; - const path = await this.mapService.getMapPath(file); + // get items into path[] and items into wpoints[] + const [path,wpoints] = await this.mapService.getMapCoordinates(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[])); + } + if (wpoints.length !== 0) { + wpoints_loop: for (let wpt_i = 0; i < wpoints.length; wpt_i++) { + if (wpoints[wpt_i] === undefined) { + continue wpoints_loop; + } + this.mapLayersControlOption.overlays.Paths.addLayer(marker(wpoints[wpt_i] as LatLng)); + } } - this.mapLayersControlOption.overlays.Paths.addLayer(marker(path[0] as LatLng)); - this.mapLayersControlOption.overlays.Paths.addLayer(polyline(path as LatLng[])); } } } diff --git a/src/frontend/app/ui/gallery/map/map.service.ts b/src/frontend/app/ui/gallery/map/map.service.ts index 4e98aba2e..476cc5c19 100644 --- a/src/frontend/app/ui/gallery/map/map.service.ts +++ b/src/frontend/app/ui/gallery/map/map.service.ts @@ -70,25 +70,29 @@ export class MapService { } - public async getMapPath(file: FileDTO): Promise { + public async getMapCoordinates(file: FileDTO): Promise { const filePath = Utils.concatUrls(file.directory.path, file.directory.name, file.name); const gpx = await this.networkService.getXML('/gallery/content/' + filePath); - const elements = gpx.getElementsByTagName('trkpt'); - const points: MapPath[] = []; - // tslint:disable-next-line:prefer-for-of - for (let i = 0; i < elements.length; i++) { - points.push({ - lat: parseFloat(elements[i].getAttribute('lat')), - lng: parseFloat(elements[i].getAttribute('lon')) - }); - } - return points; + const tagnames=['trkpt','wpt']; + var coordinates: MapCoordinates[][]=[]; + tagnames.forEach(function (item, index) { + const elements=gpx.getElementsByTagName(item); + const points: MapCoordinates[] = []; + // tslint:disable-next-line:prefer-for-of + for (let i = 0; i < elements.length; i++) { + points.push({ + lat: parseFloat(elements[i].getAttribute('lat')), + lng: parseFloat(elements[i].getAttribute('lon')) + }); + } + coordinates[index]=points; + }) + return coordinates; } - } -export interface MapPath { +export interface MapCoordinates { lat: number; lng: number; }