diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/documents/Documents.ts | 5 | ||||
-rw-r--r-- | src/client/views/nodes/MapBox/MapBox.tsx | 63 |
2 files changed, 36 insertions, 32 deletions
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<Doc>, 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<Doc>, 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<ViewBoxAnnotatableProps @observable private _map: google.maps.Map = null as unknown as google.maps.Map; @observable private selectedPlace: Doc | undefined; @observable private markerMap: { [id: string]: google.maps.Marker } = {}; - @observable private markerIdToMapMarker: { [id: string]: Doc | MapMarker | undefined } = {}; + // @observable private markerIdToMapMarker: { [id: string]: Doc | MapMarker | undefined } = {}; @observable private center = navigator.geolocation ? navigator.geolocation.getCurrentPosition : defaultCenter; @observable private zoom = 2.5; @observable private infoWindowOpen = false; @@ -195,7 +197,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps map: map }); map.panTo(position); - const mapMarker = Docs.Create.MapMarkerDocument(NumCast(position.lat()), NumCast(position.lng()), [], {}); + const mapMarker = Docs.Create.MapMarkerDocument(NumCast(position.lat()), NumCast(position.lng()), false, [], {}); this.addDocument(mapMarker, this.annotationKey); } @@ -245,7 +247,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps @action private markerLoadHandler = (marker: google.maps.Marker, place: Doc) => { 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<ViewBoxAnnotatableProps console.log("you have selected this location:"); console.log(this.selectedPlace); - // used so clicking a second marker works - if (this.infoWindowOpen) { - this.infoWindowOpen = false; - console.log("closeinfowindow") - } - this.infoWindowOpen = true; + place.infoWindowOpen = true; console.log("open infowindow") } /** - * Called when dragging documents into map sidebar + * Called when dragging documents into map sidebar or directly into infowindow * @param doc * @param sidebarKey * @returns @@ -282,10 +279,11 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps docs.forEach(doc => { 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<ViewBoxAnnotatableProps @action - private handleInfoWindowClose = () => { - 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<ViewBoxAnnotatableProps rootSelected={returnFalse} whenChildContentsActiveChanged={this.props.whenChildContentsActiveChanged} childHideDecorationTitle={returnTrue} - childDocumentsActive={returnFalse} + // childDocumentsActive={returnFalse} removeDocument={this.removeDocument} moveDocument={this.moveDocument} addDocument={this.addDocument} @@ -505,6 +502,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps renderDepth={this.props.renderDepth + 1} viewType={CollectionViewType.Stacking} fieldKey={"data"} + pointerEvents={"all"} /></div>; } @@ -523,21 +521,16 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps )) } - private renderInfoWindow = () => { - return this.infoWindowOpen && this.selectedPlace && ( + private renderInfoWindow = (place: Doc) => { + + return place.infoWindowOpen && ( <InfoWindow - anchor={this.markerMap[this.selectedPlace[Id]]} - onCloseClick={this.handleInfoWindowClose} + key={place[Id]} + anchor={this.markerMap[place[Id]]} + onCloseClick={() => this.handleInfoWindowClose(place)} > <div className="mapbox-infowindow" style={{ backgroundColor: 'white', opacity: 0.75, padding: 12, fontSize: 17 }}> - <form> - <label>Title: </label><br /> - <input type="text" id="title" name="title"></input><br /> - <label>Desription: </label><br /> - <textarea style={{ height: 75, width: "100%" }} id="description" name="description" placeholder="Notes, a short description of this location, a brief comment, etc."></textarea> - </form> - <hr /> - {this.renderChildDocs(this.selectedPlace)} + {this.renderChildDocs(place)} <hr /> <div> <button>New link+</button> @@ -547,6 +540,13 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps ) } + private handleMapCenter = (map: google.maps.Map) => { + 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<ViewBoxAnnotatableProps </Autocomplete> {this.renderMarkers()} - {this.renderInfoWindow()} + {this.allMapMarkers.map(place => ( + this.renderInfoWindow(place) + ))} + {this.handleMapCenter(this._map)} </GoogleMap> {!this._marqueeing || !this._mainCont.current || !this._annotationLayer.current ? (null) : <MarqueeAnnotator rootDoc={this.rootDoc} |