From e04e9520e7313089d8c6015f54b1ff0c4998552f Mon Sep 17 00:00:00 2001 From: Aubrey Li Date: Thu, 18 Nov 2021 15:50:05 -0500 Subject: mapbox latest --- src/client/documents/Documents.ts | 5 ++- src/client/views/nodes/MapBox/MapBox.tsx | 63 +++++++++++++++++--------------- 2 files changed, 36 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 44f661df1..fc386f81a 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -158,6 +158,7 @@ export class DocumentOptions { z?: number; // whether document is in overlay (1) or not (0 or undefined) lat?: number; lng?: number; + infoWindowOpen?: boolean; author?: string; _layoutKey?: string; unrendered?: boolean; // denotes an annotation that is not rendered with a DocumentView (e.g, rtf/pdf text selections and links to scroll locations in web/pdf) @@ -785,8 +786,8 @@ export namespace Docs { return InstanceFromProto(Prototypes.get(DocumentType.MAP), new List(documents), options); } - export function MapMarkerDocument(lat: number, lng: number, documents: Array, options: DocumentOptions, id?: string) { - return InstanceFromProto(Prototypes.get(DocumentType.MARKER), new List(documents), { lat, lng, ...options }, id); + export function MapMarkerDocument(lat: number, lng: number, infoWindowOpen: boolean, documents: Array, options: DocumentOptions, id?: string) { + return InstanceFromProto(Prototypes.get(DocumentType.MARKER), new List(documents), { lat, lng, infoWindowOpen, ...options }, id); } export function KVPDocument(document: Doc, options: DocumentOptions = {}) { diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx index 418309219..9cee7f2a2 100644 --- a/src/client/views/nodes/MapBox/MapBox.tsx +++ b/src/client/views/nodes/MapBox/MapBox.tsx @@ -14,7 +14,9 @@ import { emptyFunction, OmitKeys, returnEmptyFilter, returnFalse, returnOne, ret import { Docs } from '../../../documents/Documents'; import { CurrentUserUtils } from '../../../util/CurrentUserUtils'; import { DragManager } from '../../../util/DragManager'; +import { SelectionManager } from '../../../util/SelectionManager'; import { SnappingManager } from '../../../util/SnappingManager'; +import { undoBatch } from '../../../util/UndoManager'; import { CollectionFreeFormView, MarqueeOptionsMenu } from '../../collections/collectionFreeForm'; import { CollectionStackingView } from '../../collections/CollectionStackingView'; import { CollectionViewType } from '../../collections/CollectionView'; @@ -91,7 +93,7 @@ export class MapBox extends ViewBoxAnnotatableComponent { place[Id] ? this.markerMap[place[Id]] = marker : null; - place[Id] ? this.markerIdToMapMarker[place[Id]] = place : null; + // place[Id] ? this.markerIdToMapMarker[place[Id]] = place : null; console.log("the following is a markerMap from id to Marker:") console.log(this.markerMap); @@ -259,17 +261,12 @@ export class MapBox extends ViewBoxAnnotatableComponent { if (doc.lat !== undefined && doc.lng !== undefined) { const existingMarker = this.allMapMarkers.find(marker => marker.lat === doc.lat && marker.lng == doc.lng); + doc.onClickBehavior = "enterPortal"; if (existingMarker) { Doc.AddDocToList(existingMarker, "data", doc); } else { - const marker = Docs.Create.MapMarkerDocument(NumCast(doc.lat), NumCast(doc.lng), [doc], {}); + const marker = Docs.Create.MapMarkerDocument(NumCast(doc.lat), NumCast(doc.lng), false, [doc], {}); this.addDocument(marker, this.annotationKey); } } @@ -381,12 +379,11 @@ export class MapBox extends ViewBoxAnnotatableComponent { - if (this.infoWindowOpen) { - this.infoWindowOpen = false; + private handleInfoWindowClose = (place: Doc) => { + if (place.infoWindowOpen) { + place.infoWindowOpen = false; } - this.infoWindowOpen = false; - this.selectedPlace = undefined; + place.infoWindowOpen = false; } @computed get sidebarHandle() { @@ -496,7 +493,7 @@ export class MapBox extends ViewBoxAnnotatableComponent; } @@ -523,21 +521,16 @@ export class MapBox extends ViewBoxAnnotatableComponent { - return this.infoWindowOpen && this.selectedPlace && ( + private renderInfoWindow = (place: Doc) => { + + return place.infoWindowOpen && ( this.handleInfoWindowClose(place)} >
-
-
-
-
- -
-
- {this.renderChildDocs(this.selectedPlace)} + {this.renderChildDocs(place)}
@@ -547,6 +540,13 @@ export class MapBox extends ViewBoxAnnotatableComponent { + console.log("print the selected views in selectionManager:") + if (SelectionManager.Views().lastElement()) { + console.log(SelectionManager.Views().lastElement()); + } + } + panelWidth = () => this.props.PanelWidth() / (this.props.scaling?.() || 1) - this.sidebarWidth(); // (this.Document.scrollHeight || Doc.NativeHeight(this.Document) || 0); panelHeight = () => this.props.PanelHeight() / (this.props.scaling?.() || 1); // () => this._pageSizes.length && this._pageSizes[0] ? this._pageSizes[0].width : Doc.NativeWidth(this.Document); scrollXf = () => this.props.ScreenToLocalTransform().translate(0, NumCast(this.layoutDoc._scrollTop)); @@ -610,7 +610,10 @@ export class MapBox extends ViewBoxAnnotatableComponent {this.renderMarkers()} - {this.renderInfoWindow()} + {this.allMapMarkers.map(place => ( + this.renderInfoWindow(place) + ))} + {this.handleMapCenter(this._map)} {!this._marqueeing || !this._mainCont.current || !this._annotationLayer.current ? (null) :