From b2d824b412e6bbf9b4867ed13f49a433af7c26c7 Mon Sep 17 00:00:00 2001 From: zaultavangar Date: Sun, 17 Dec 2023 22:33:08 -0500 Subject: fixing some bugs with MapBox and MapAnchorMenu --- src/client/views/nodes/MapBox/MapAnchorMenu.tsx | 236 ++++++++++++++++-------- src/client/views/nodes/MapBox/MapBox.scss | 7 +- src/client/views/nodes/MapBox/MapBox.tsx | 183 +++++------------- 3 files changed, 204 insertions(+), 222 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/MapBox/MapAnchorMenu.tsx b/src/client/views/nodes/MapBox/MapAnchorMenu.tsx index b1fb3368c..1b1b74e7c 100644 --- a/src/client/views/nodes/MapBox/MapAnchorMenu.tsx +++ b/src/client/views/nodes/MapBox/MapAnchorMenu.tsx @@ -20,6 +20,7 @@ import { List } from '../../../../fields/List'; import { MarkerIcons } from './MarkerIcons'; import { CirclePicker, ColorResult } from 'react-color'; import { Position } from 'geojson'; +import { CalendarManager } from '../../../util/CalendarManager'; type MapAnchorMenuType = 'standard' | 'routeCreation' | 'calendar' | 'customize' | 'route'; @@ -45,13 +46,15 @@ export class MapAnchorMenu extends AntimodeMenu { public IsTargetToggler: () => boolean = returnFalse; public DisplayRoute: (routeInfoMap: Record | undefined, type: TransportationType) => void = unimplementedFunction; - public HideRoute: () => void = unimplementedFunction; public AddNewRouteToMap: (coordinates: Position[], origin: string, destination: any, createPinForDestination: boolean) => void = unimplementedFunction; public CreatePin: (feature: any) => void = unimplementedFunction; public UpdateMarkerColor: (color: string) => void = unimplementedFunction; public UpdateMarkerIcon: (iconKey: string) => void = unimplementedFunction; + + public Hide: () => void = unimplementedFunction; + public OpenAnimationPanel: (routeDoc: Doc | undefined) => void = unimplementedFunction; @observable @@ -70,14 +73,31 @@ export class MapAnchorMenu extends AntimodeMenu { private title: string | undefined = undefined; - public setPinDoc(pinDoc: Doc) { - this.pinDoc = pinDoc; - this.title = StrCast(pinDoc.title ? pinDoc.title : `${NumCast(pinDoc.longitude)}, ${NumCast(pinDoc.latitude)}`); + public setPinDoc(pinDoc: Doc | undefined) { + if (pinDoc){ + this.pinDoc = pinDoc; + this.title = StrCast(pinDoc.title ? pinDoc.title : `${NumCast(pinDoc.longitude)}, ${NumCast(pinDoc.latitude)}`); + } + } - public setRouteDoc(routeDoc: Doc) { - this.routeDoc = routeDoc; - this.title = StrCast(routeDoc.title ?? 'Map route'); + public setRouteDoc(routeDoc: Doc | undefined) { + if (routeDoc){ + this.routeDoc = routeDoc; + this.title = StrCast(routeDoc.title ?? 'Map route'); + } + } + + @action + public Reset(){ + this.destinationSelected = false; + this.currentRouteInfoMap = undefined; + this.destinationFeatures = []; + this.selectedDestinationFeature = undefined; + this.allMapPinDocs = []; + this.title = undefined; + this.routeDoc = undefined; + this.pinDoc = undefined; } public setAllMapboxPins(pinDocs: Doc[]) { @@ -263,7 +283,6 @@ export class MapAnchorMenu extends AntimodeMenu { console.log(coordinates); console.log(this.selectedDestinationFeature); this.AddNewRouteToMap(coordinates, this.title ?? '', this.selectedDestinationFeature, this.createPinForDestination); - this.HideRoute(); } }; @@ -277,86 +296,155 @@ export class MapAnchorMenu extends AntimodeMenu { return undefined; }; + getDirectionsButton: JSX.Element = ( + } + color={SettingsManager.userColor} /> + ) + + getAddToCalendarButton = (docType: string): JSX.Element => { + return ( + { + CalendarManager.Instance.open(undefined, docType === 'pin' ? this.pinDoc : this.routeDoc) + }} + icon={} + color={SettingsManager.userColor} + /> + ) + + } + addToCalendarButton: JSX.Element = ( + CalendarManager.Instance.open(undefined, this.pinDoc)} + icon={} + color={SettingsManager.userColor} /> + ) + + getLinkNoteToDocButton = (docType: string): JSX.Element => { + return ( +
+ } + color={SettingsManager.userColor} + /> +
+ ) + } + + linkNoteToPinOrRoutenButton: JSX.Element = ( +
+ } + color={SettingsManager.userColor} + /> +
+ ) + + customizePinButton: JSX.Element = ( + } + color={SettingsManager.userColor} + /> + ) + + centerOnPinButton: JSX.Element = ( + } + color={SettingsManager.userColor} + /> + ) + + backButton: JSX.Element = ( + } + color={SettingsManager.userColor} + /> + ) + + addRouteButton: JSX.Element = ( + } + color={SettingsManager.userColor} + /> + ) + + getDeleteButton = (type: string) => { + return ( + } + color={SettingsManager.userColor} + /> + ) + } + + animateRouteButton: JSX.Element = ( + this.OpenAnimationPanel(this.routeDoc)} + icon={} + color={SettingsManager.userColor} + /> + ) + + revertToOriginalMarkerButton = ( + this.revertToOriginalMarker()} + icon={} + color={SettingsManager.userColor} + /> + ) + render() { const buttons = (
{this.menuType === 'standard' && ( <> - } - color={SettingsManager.userColor} - /> - } color={SettingsManager.userColor} /> - } color={SettingsManager.userColor} /> -
- } - color={SettingsManager.userColor} - /> -
- } color={SettingsManager.userColor} /> - } - color={SettingsManager.userColor} - /> + {this.getDeleteButton('pin')} + {this.getDirectionsButton} + {this.getAddToCalendarButton('pin')} + {this.getLinkNoteToDocButton('pin')} + {this.customizePinButton} + {this.centerOnPinButton} )} {this.menuType === 'routeCreation' && ( <> - } - color={SettingsManager.userColor} - /> - } - color={SettingsManager.userColor} - /> + {this.backButton} + {this.addRouteButton} )} {this.menuType === 'route' && ( <> - } - color={SettingsManager.userColor} - /> - this.OpenAnimationPanel(this.routeDoc)} /**TODO: fix */ icon={} color={SettingsManager.userColor} /> -
- } - color={SettingsManager.userColor} - /> -
- } color={SettingsManager.userColor} /> + {this.getDeleteButton('route')} + {this.animateRouteButton} + {this.getAddToCalendarButton('route')} + {this.getLinkNoteToDocButton('route')} )} {this.menuType === 'customize' && ( <> - } - color={SettingsManager.userColor} - /> - this.revertToOriginalMarker()} - icon={} - color={SettingsManager.userColor} - /> + {this.backButton} + {this.revertToOriginalMarkerButton} )} @@ -373,12 +461,6 @@ export class MapAnchorMenu extends AntimodeMenu { )} */}
); - // return ( - //
- // HELLO THIS IS ANCHOR MENU - // {this.getElement(buttons)} - //
- // ) return this.getElement(
diff --git a/src/client/views/nodes/MapBox/MapBox.scss b/src/client/views/nodes/MapBox/MapBox.scss index b3ce55786..25b4587a5 100644 --- a/src/client/views/nodes/MapBox/MapBox.scss +++ b/src/client/views/nodes/MapBox/MapBox.scss @@ -109,20 +109,15 @@ display: flex; justify-content: flex-start; align-items: center; - gap: 7px; + width: 100%; .animation-suboptions { display: flex; justify-content: flex-start; - flex-wrap: wrap; align-items: center; gap: 7px; width: 100%; - .first-person-label { - width: '130px' !important; - } - label { margin-bottom: 0; } diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx index 44afb8e7b..562cb63d1 100644 --- a/src/client/views/nodes/MapBox/MapBox.tsx +++ b/src/client/views/nodes/MapBox/MapBox.tsx @@ -650,6 +650,7 @@ export class MapBox extends ViewBoxAnnotatableComponent { + console.log('deleting') if (this.selectedPinOrRoute) { // Removes filter Doc.setDocFilter(this.Document, 'latitude', this.selectedPinOrRoute.latitude, 'remove'); @@ -672,9 +673,19 @@ export class MapBox extends ViewBoxAnnotatableComponent { + this.temporaryRouteSource = { + type: 'FeatureCollection', + features: [], + } + }) + + document.removeEventListener('pointerdown', this.tryHideMapAnchorMenu, true); }; + + @action centerOnSelectedPin = () => { if (this.selectedPinOrRoute) { @@ -869,6 +880,11 @@ export class MapBox extends ViewBoxAnnotatableComponent { this.featuresFromGeocodeResults = []; + this.settingsOpen = false; if (this._mapRef.current) { const features = this._mapRef.current.queryRenderedFeatures(e.point, { layers: ['map-routes-layer'], @@ -953,13 +970,14 @@ export class MapBox extends ViewBoxAnnotatableComponent !anno.layout_unrendered)); MapAnchorMenu.Instance.DisplayRoute = this.displayRoute; - MapAnchorMenu.Instance.HideRoute = this.hideRoute; MapAnchorMenu.Instance.AddNewRouteToMap = this.createMapRoute; MapAnchorMenu.Instance.CreatePin = this.addMarkerForFeature; MapAnchorMenu.Instance.OpenAnimationPanel = this.openAnimationPanel; @@ -976,6 +994,8 @@ export class MapBox extends ViewBoxAnnotatableComponent !anno.layout_unrendered)); MapAnchorMenu.Instance.DisplayRoute = this.displayRoute; - MapAnchorMenu.Instance.HideRoute = this.hideRoute; MapAnchorMenu.Instance.AddNewRouteToMap = this.createMapRoute; MapAnchorMenu.Instance.CreatePin = this.addMarkerForFeature; @@ -1367,8 +1388,6 @@ export class MapBox extends ViewBoxAnnotatableComponent {}; getRouteAnimationOptions = (): JSX.Element => { return ( @@ -1406,7 +1425,6 @@ export class MapBox extends ViewBoxAnnotatableComponent|
} @@ -1414,8 +1432,11 @@ export class MapBox extends ViewBoxAnnotatableComponent|
|
-
Select Line Color:
- this.setAnimationLineColor(color)} /> +
+
Select Line Color:
+ this.setAnimationLineColor(color)} /> +
+ @@ -1449,7 +1470,7 @@ export class MapBox extends ViewBoxAnnotatableComponent) => { - this.dataDoc.map_style = `mapbox://styles/mapbox/${e.target.value}`; + this.dataDoc.map_style = e.target.value; // this.mapStyle = `mapbox://styles/mapbox/${e.target.value}` }; @@ -1457,6 +1478,7 @@ export class MapBox extends ViewBoxAnnotatableComponent) => { const bearing = parseInt(e.target.value); if (!isNaN(bearing) && this._mapRef.current) { + console.log('bearing change') const fixedBearing = Math.max(0, Math.min(360, bearing)); this._mapRef.current.setBearing(fixedBearing); this.dataDoc.map_bearing = fixedBearing; @@ -1467,6 +1489,7 @@ export class MapBox extends ViewBoxAnnotatableComponent) => { const pitch = parseInt(e.target.value); if (!isNaN(pitch) && this._mapRef.current) { + console.log('pitch change') const fixedPitch = Math.max(0, Math.min(85, pitch)); this._mapRef.current.setPitch(fixedPitch); this.dataDoc.map_pitch = fixedPitch; @@ -1564,29 +1587,29 @@ export class MapBox extends ViewBoxAnnotatableComponent
Map Style:
- + + + + + + + +
Bearing:
- +
Pitch:
- +
Zoom:
- +
Show terrain:
@@ -1620,26 +1643,11 @@ export class MapBox extends ViewBoxAnnotatableComponent
)} - {/*
- this.onStepZoomChange(true)} - icon={} - size={Size.SMALL} - color={SettingsManager.userColor} - /> - this.onStepZoomChange(false)} - icon={} - size={Size.SMALL} - color={SettingsManager.userColor} - /> -
*/} - - {/* */} - {/*
- {!this._mapReady - ? null - : this.allAnnotations - .filter(anno => !anno.layout_unrendered) - .map((pushpin, i) => ( - - ))} -
*/} - {/* */} - {/* */}
this.handleSearchChange(searchText)} - onChange={(e, selectedOption) => { - this.handleSearchChange(""); // clear input - this.addMarkerForFeature(selectedOption); - }} - options={this.featuresFromGeocodeResults - .filter(feature => feature.place_name) - .map(feature => feature)} - getOptionLabel={(feature) => feature.place_name} - renderInput={(params) => ( - - )} - /> */ -} -{ - /* typeof newText === 'string' && this.handleSearchChange(newText)} - // onEnter={e => this.bingSearch()} - onEnter={e => {}} - height={32} - // placeholder={this.bingSearchBarContents || 'Enter a location'} - placeholder='Enter a location' - textAlign="center" - /> */ -} -{ - /*