| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | import BaseContextMenu from './baseContextMenu/BaseContextMenu.js'; |
| 26 | import MenuItem from './baseContextMenu/MenuItem.js'; |
| 27 | import theWayPointEditor from '../core/WayPointEditor.js'; |
| 28 | import theTranslator from '../core/uiLib/Translator.js'; |
| 29 | import theTravelNotesData from '../data/TravelNotesData.js'; |
| 30 | import theNoteEditor from '../core/NoteEditor.js'; |
| 31 | import theRouteEditor from '../core/RouteEditor.js'; |
| 32 | import Zoomer from '../core/Zoomer.js'; |
| 33 | |
| 34 | import { LAT, LNG, LAT_LNG, INVALID_OBJ_ID } from '../main/Constants.js'; |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | class MapContextMenu extends BaseContextMenu { |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | constructor ( contextMenuEvent, parentNode ) { |
| 51 | super ( contextMenuEvent, parentNode ); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | get menuItems ( ) { |
| 60 | return [ |
| 61 | new MenuItem ( |
| 62 | theTranslator.getText ( 'MapContextMenu - Select this point as start point' ), |
| 63 | ( INVALID_OBJ_ID !== theTravelNotesData.editedRouteObjId ) |
| 64 | && |
| 65 | ( LAT_LNG.defaultValue === theTravelNotesData.travel.editedRoute.wayPoints.first.lat ), |
| 66 | ( ) => theWayPointEditor.setStartPoint ( this.latLng ) |
| 67 | ), |
| 68 | new MenuItem ( |
| 69 | theTranslator.getText ( 'MapContextMenu - Select this point as way point' ), |
| 70 | ( INVALID_OBJ_ID !== theTravelNotesData.editedRouteObjId ), |
| 71 | ( ) => theWayPointEditor.addWayPoint ( this.latLng ) |
| 72 | ), |
| 73 | new MenuItem ( |
| 74 | theTranslator.getText ( 'MapContextMenu - Select this point as end point' ), |
| 75 | ( INVALID_OBJ_ID !== theTravelNotesData.editedRouteObjId ) |
| 76 | && |
| 77 | ( LAT_LNG.defaultValue === theTravelNotesData.travel.editedRoute.wayPoints.last.lat ), |
| 78 | ( ) => theWayPointEditor.setEndPoint ( this.latLng ) |
| 79 | ), |
| 80 | new MenuItem ( |
| 81 | theTranslator.getText ( 'MapContextMenu - Select this point as start and end point' ), |
| 82 | ( INVALID_OBJ_ID !== theTravelNotesData.editedRouteObjId ) |
| 83 | && |
| 84 | ( LAT_LNG.defaultValue === theTravelNotesData.travel.editedRoute.wayPoints.first.lat ) |
| 85 | && |
| 86 | ( LAT_LNG.defaultValue === theTravelNotesData.travel.editedRoute.wayPoints.last.lat ), |
| 87 | ( ) => theWayPointEditor.setStartAndEndPoint ( this.latLng ) |
| 88 | ), |
| 89 | new MenuItem ( theTranslator.getText ( 'MapContextMenu - Add a route' ), |
| 90 | true, |
| 91 | ( ) => theRouteEditor.addRoute ( ) |
| 92 | ), |
| 93 | new MenuItem ( |
| 94 | theTranslator.getText ( 'MapContextMenu - Hide all routes' ), |
| 95 | true, |
| 96 | ( ) => theRouteEditor.hideRoutes ( ) |
| 97 | ), |
| 98 | new MenuItem ( |
| 99 | theTranslator.getText ( 'MapContextMenu - Show all routes' ), |
| 100 | true, |
| 101 | ( ) => theRouteEditor.showRoutes ( ) |
| 102 | ), |
| 103 | new MenuItem ( |
| 104 | theTranslator.getText ( 'MapContextMenu - New travel note' ), |
| 105 | true, |
| 106 | ( ) => theNoteEditor.newTravelNote ( this.latLng ) |
| 107 | ), |
| 108 | new MenuItem ( |
| 109 | theTranslator.getText ( 'MapContextMenu - Hide all notes' ), |
| 110 | true, |
| 111 | ( ) => theNoteEditor.hideNotes ( ) |
| 112 | ), |
| 113 | new MenuItem ( |
| 114 | theTranslator.getText ( 'MapContextMenu - Show all notes' ), |
| 115 | true, |
| 116 | ( ) => theNoteEditor.showNotes ( ) |
| 117 | ), |
| 118 | new MenuItem ( |
| 119 | theTranslator.getText ( 'MapContextMenu - Zoom to travel' ), |
| 120 | true, |
| 121 | ( ) => new Zoomer ( ).zoomToTravel ( ) |
| 122 | ), |
| 123 | new MenuItem ( |
| 124 | 'What the fuck?', |
| 125 | true, |
| 126 | ( ) => { |
| 127 | const linkElement = document.createElement ( 'a' ); |
| 128 | linkElement.href = |
| 129 | 'https://www.openstreetmap.org/query?lat=' + |
| 130 | this.latLng [ LAT ].toFixed ( LAT_LNG.fixed ) + |
| 131 | '&lon=' + |
| 132 | this.latLng [ LNG ].toFixed ( LAT_LNG.fixed ) + |
| 133 | '#map=' + |
| 134 | theTravelNotesData.map.getZoom ( ) + |
| 135 | '/' + |
| 136 | this.latLng [ LAT ].toFixed ( LAT_LNG.fixed ) + |
| 137 | '/' + |
| 138 | this.latLng [ LNG ].toFixed ( LAT_LNG.fixed ); |
| 139 | linkElement.target = '_blank'; |
| 140 | linkElement.click ( ); |
| 141 | } |
| 142 | ) |
| 143 | ]; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | export default MapContextMenu; |
| 148 | |
| 149 | |
| 150 | |