From fbdd45bf7467267a4629a78e4ad87bae10879573 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 21 Aug 2023 12:48:19 -0400
Subject: fixed map pushpins by only rendering them after the map is ready

---
 src/client/views/nodes/MapBox/MapBox.tsx | 53 +++++++++++++++++---------------
 1 file changed, 29 insertions(+), 24 deletions(-)

(limited to 'src/client/views/nodes/MapBox/MapBox.tsx')

diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx
index 860528ec4..453a3d6fc 100644
--- a/src/client/views/nodes/MapBox/MapBox.tsx
+++ b/src/client/views/nodes/MapBox/MapBox.tsx
@@ -711,7 +711,10 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
      * Called when BingMap is first rendered
      * Initializes starting values
      */
+    @observable _mapReady = false;
+    @action
     bingMapReady = (map: any) => {
+        this._mapReady = true;
         this._bingMap = map.map;
         if (!this._bingMap.current) {
             alert('NO Map!?');
@@ -844,30 +847,32 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
                     {/* {this.pinIsSelected_TEMPORARY? <input type="button" value="Delete Pin" onClick={this.removeSelectedPin} /> : null} */}
                     <BingMapsReact onMapReady={this.bingMapReady} bingMapsKey={bingApiKey} height="100%" mapOptions={this.bingMapOptions} width="100%" viewOptions={this.bingViewOptions}></BingMapsReact>
                     <div>
-                        {this.allMapPushpins.map(pushpin => (
-                            <DocumentView
-                                {...this.props}
-                                Document={pushpin}
-                                DataDoc={undefined}
-                                PanelWidth={returnOne}
-                                PanelHeight={returnOne}
-                                NativeWidth={returnOne}
-                                NativeHeight={returnOne}
-                                onClick={() => new ScriptField(undefined)}
-                                onKey={undefined}
-                                onDoubleClick={undefined}
-                                onBrowseClick={undefined}
-                                childFilters={returnEmptyFilter}
-                                childFiltersByRanges={returnEmptyFilter}
-                                searchFilterDocs={returnEmptyDoclist}
-                                isDocumentActive={returnFalse}
-                                isContentActive={returnFalse}
-                                addDocTab={returnFalse}
-                                ScreenToLocalTransform={() => new Transform(0, 0, 0)}
-                                fitContentsToBox={undefined}
-                                focus={returnOne}
-                            />
-                        ))}
+                        {!this._mapReady
+                            ? null
+                            : this.allMapPushpins.map(pushpin => (
+                                  <DocumentView
+                                      {...this.props}
+                                      Document={pushpin}
+                                      DataDoc={undefined}
+                                      PanelWidth={returnOne}
+                                      PanelHeight={returnOne}
+                                      NativeWidth={returnOne}
+                                      NativeHeight={returnOne}
+                                      onClick={() => new ScriptField(undefined)}
+                                      onKey={undefined}
+                                      onDoubleClick={undefined}
+                                      onBrowseClick={undefined}
+                                      childFilters={returnEmptyFilter}
+                                      childFiltersByRanges={returnEmptyFilter}
+                                      searchFilterDocs={returnEmptyDoclist}
+                                      isDocumentActive={returnFalse}
+                                      isContentActive={returnFalse}
+                                      addDocTab={returnFalse}
+                                      ScreenToLocalTransform={() => new Transform(0, 0, 0)}
+                                      fitContentsToBox={undefined}
+                                      focus={returnOne}
+                                  />
+                              ))}
                     </div>
                     {/* <MapBoxInfoWindow
                                     key={Docs.Create.MapMarkerDocument(NumCast(40), NumCast(40), false, [], {})[Id]}
-- 
cgit v1.2.3-70-g09d2

