diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/MapBox/MapBox.tsx | 15 | ||||
-rw-r--r-- | src/client/views/nodes/MapBox/MapPushpinBox.tsx | 1 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/client/views/nodes/MapBox/MapBox.tsx b/src/client/views/nodes/MapBox/MapBox.tsx index 6f552953d..f0106dbbb 100644 --- a/src/client/views/nodes/MapBox/MapBox.tsx +++ b/src/client/views/nodes/MapBox/MapBox.tsx @@ -98,10 +98,13 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps } componentDidMount() { + this._unmounting = false; this.props.setContentView?.(this); } + _unmounting = false; componentWillUnmount(): void { + this._unmounting = true; this.deselectPin(); Object.keys(this._disposers).forEach(key => this._disposers[key]?.()); } @@ -343,10 +346,14 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps Doc.setDocFilter(this.rootDoc, '-linkedTo', Field.toString(DocCast(this.selectedPin.mapPin)), 'removeAll'); const temp = this.selectedPin; - this._bingMap.current.entities.remove(this.map_docToPinMap.get(temp)); + if (!this._unmounting) { + this._bingMap.current.entities.remove(this.map_docToPinMap.get(temp)); + } const newpin = new this.MicrosoftMaps.Pushpin(new this.MicrosoftMaps.Location(temp.latitude, temp.longitude)); this.MicrosoftMaps.Events.addHandler(newpin, 'click', (e: any) => this.pushpinClicked(temp as Doc)); - this._bingMap.current.entities.push(newpin); + if (!this._unmounting) { + this._bingMap.current.entities.push(newpin); + } this.map_docToPinMap.set(temp, newpin); this.selectedPin = undefined; this.bingSearchBarContents = this.rootDoc.map; @@ -488,7 +495,9 @@ export class MapBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps * Removes pushpin from map render */ deletePushpin = (pinDoc: Doc) => { - this._bingMap.current.entities.remove(this.map_docToPinMap.get(pinDoc)); + if (!this._unmounting) { + this._bingMap.current.entities.remove(this.map_docToPinMap.get(pinDoc)); + } this.map_docToPinMap.delete(pinDoc); this.selectedPin = undefined; }; diff --git a/src/client/views/nodes/MapBox/MapPushpinBox.tsx b/src/client/views/nodes/MapBox/MapPushpinBox.tsx index 552bceace..42bada0ef 100644 --- a/src/client/views/nodes/MapBox/MapPushpinBox.tsx +++ b/src/client/views/nodes/MapBox/MapPushpinBox.tsx @@ -15,7 +15,6 @@ export class MapPushpinBox extends ViewBoxBaseComponent<FieldViewProps>() { return FieldView.LayoutString(MapPushpinBox, fieldKey); } componentDidMount() { - // if (this.mapBoxView) this.mapBoxView.addPushpin(this.rootDoc); } componentWillUnmount() { |