aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/MapBox/MapBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-08-26 22:48:39 -0400
committerbobzel <zzzman@gmail.com>2023-08-26 22:48:39 -0400
commita142ff5e6ce017686e9bf418c502417d8cea5cad (patch)
tree43203ac0d620db12ce3a69f725e1f9aa6e062364 /src/client/views/nodes/MapBox/MapBox.tsx
parent0a813fdf7d73018ad5248d87fecbd9e55f3dc2d7 (diff)
fixed map anchors to be configs, not maps! fixed doc decorations to not allow clicking on them when showNothing is set. increased font size of map search.
Diffstat (limited to 'src/client/views/nodes/MapBox/MapBox.tsx')
-rw-r--r--src/client/views/nodes/MapBox/MapBox.tsx25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx
index 94944b83d..284e598c5 100644
--- a/src/client/views/nodes/MapBox/MapBox.tsx
+++ b/src/client/views/nodes/MapBox/MapBox.tsx
@@ -5,7 +5,7 @@ import { action, computed, IReactionDisposer, observable, ObservableMap, reactio
import { observer } from 'mobx-react';
import * as React from 'react';
import { Doc, DocListCast, Opt } from '../../../../fields/Doc';
-import { Highlight, Width } from '../../../../fields/DocSymbols';
+import { DocCss, Highlight, Width } from '../../../../fields/DocSymbols';
import { InkTool } from '../../../../fields/InkField';
import { DocCast, NumCast, StrCast } from '../../../../fields/Types';
import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnEmptyString, returnFalse, returnOne, returnTrue, setupMoveUpEvents, Utils } from '../../../../Utils';
@@ -62,6 +62,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
public static LayoutString(fieldKey: string) {
return FieldView.LayoutString(MapBox, fieldKey);
}
+ private _dragRef = React.createRef<HTMLDivElement>();
private _mainCont: React.RefObject<HTMLDivElement> = React.createRef();
private _annotationLayer: React.RefObject<HTMLDivElement> = React.createRef();
private _sidebarRef = React.createRef<SidebarAnnos>();
@@ -430,7 +431,7 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
*/
getAnchor = (addAsAnnotation: boolean, pinProps?: PinProps) => {
/// this should use SELECTED pushpin for lat/long if there is a selection, otherwise CENTER
- const anchor = Docs.Create.MapanchorDocument({
+ const anchor = Docs.Create.ConfigDocument({
title: 'MapAnchor:' + this.rootDoc.title,
text: StrCast(this.selectedPin?.map) || StrCast(this.rootDoc.map) || 'map location',
config_latitude: NumCast(this.selectedPin?.latitude ?? this.dataDoc.latitude),
@@ -667,8 +668,26 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
searchbarKeyDown = (e: any) => e.key === 'Enter' && this.bingSearch();
- _dragRef = React.createRef<HTMLDivElement>();
+ static _firstRender = true;
+ static _rerenderDelay = 0;
+ _rerenderTimeout: any;
render() {
+ // bcz: no idea what's going on here, but bings maps have some kind of bug
+ // such that we need to delay rendering a second map on startup until the first map is rendered.
+ this.rootDoc[DocCss];
+ if (MapBox._firstRender) {
+ MapBox._firstRender = false;
+ MapBox._rerenderDelay = 500;
+ } else if (MapBox._rerenderDelay) {
+ // prettier-ignore
+ this._rerenderTimeout = this._rerenderTimeout ??
+ setTimeout(action(() => {
+ MapBox._rerenderDelay = 0;
+ this.rootDoc[DocCss] = this.rootDoc[DocCss] + 1;
+ }), MapBox._rerenderDelay);
+ return null;
+ }
+
const renderAnnotations = (childFilters?: () => string[]) => null;
return (
<div className="mapBox" ref={this._ref}>