Skip to content

Commit

Permalink
fix ctrl+click on gpx layer, relates to #91
Browse files Browse the repository at this point in the history
  • Loading branch information
vcoppe committed Sep 12, 2024
1 parent 1190a47 commit dc76c71
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions website/src/lib/components/gpx-layer/GPXLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class GPXLayer {
layerOnMouseEnterBinded: (e: any) => void = this.layerOnMouseEnter.bind(this);
layerOnMouseLeaveBinded: () => void = this.layerOnMouseLeave.bind(this);
layerOnClickBinded: (e: any) => void = this.layerOnClick.bind(this);
layerOnContextMenuBinded: (e: any) => void = this.layerOnContextMenu.bind(this);
maybeHideWaypointPopupBinded: (e: any) => void = this.maybeHideWaypointPopup.bind(this);

constructor(map: mapboxgl.Map, fileId: string, file: Readable<GPXFileWithStatistics | undefined>) {
Expand Down Expand Up @@ -153,6 +154,7 @@ export class GPXLayer {
});

this.map.on('click', this.fileId, this.layerOnClickBinded);
this.map.on('contextmenu', this.fileId, this.layerOnContextMenuBinded);
this.map.on('mouseenter', this.fileId, this.layerOnMouseEnterBinded);
this.map.on('mouseleave', this.fileId, this.layerOnMouseLeaveBinded);
}
Expand Down Expand Up @@ -302,6 +304,7 @@ export class GPXLayer {
remove() {
if (get(map)) {
this.map.off('click', this.fileId, this.layerOnClickBinded);
this.map.off('contextmenu', this.fileId, this.layerOnContextMenuBinded);
this.map.off('mouseenter', this.fileId, this.layerOnMouseEnterBinded);
this.map.off('mouseleave', this.fileId, this.layerOnMouseLeaveBinded);
this.map.off('style.import.load', this.updateBinded);
Expand Down Expand Up @@ -382,6 +385,12 @@ export class GPXLayer {
}
}

layerOnContextMenu(e: any) {
if (e.originalEvent.ctrlKey) {
this.layerOnClick(e);
}
}

showWaypointPopup(waypoint: Waypoint) {
if (get(currentPopupWaypoint) !== null) {
this.hideWaypointPopup();
Expand Down

0 comments on commit dc76c71

Please sign in to comment.