From c0fb10cabf54787b5c316c399e8b25e2e87e296e Mon Sep 17 00:00:00 2001 From: Matthew Kalinin Date: Tue, 24 Sep 2024 18:32:09 +0300 Subject: [PATCH] Fix draggable marker with popup --- example/README.md | 2 ++ src/markers/MMapDefaultMarker/index.ts | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/example/README.md b/example/README.md index 21a30f2..6247b49 100644 --- a/example/README.md +++ b/example/README.md @@ -129,5 +129,7 @@ including double-clicking to delete a point and a steering wheel with two button ([source code](https://github.com/mappable-world/mappable-default-ui-theme/tree/main/example/popups-on-map)) - [Adding a search control to the map](./search-control/vanilla/index.html) ([source code](https://github.com/mappable-world/mappable-default-ui-theme/tree/main/example/search-control)) +- [Adding a route control to the map](./route-control/vanilla/index.html) + ([source code](https://github.com/mappable-world/mappable-default-ui-theme/tree/main/example/route-control)) - [Adding a default ruler to the map](./default-ruler/vanilla/index.html) ([source code](https://github.com/mappable-world/mappable-default-ui-theme/tree/main/example/default-ruler)) diff --git a/src/markers/MMapDefaultMarker/index.ts b/src/markers/MMapDefaultMarker/index.ts index fb24fec..466f5c5 100644 --- a/src/markers/MMapDefaultMarker/index.ts +++ b/src/markers/MMapDefaultMarker/index.ts @@ -139,7 +139,8 @@ export class MMapDefaultMarker extends mappable.MMapComplexEntity { - if (!this._popup) { - return; + if (this._popup) { + this._popup.update({show: this._popup.isOpen}); } - this._popup.update({show: !this._popup.isOpen}); this._props.onClick?.(...args); }; + private _onMarkerDragMove: MMapDefaultMarkerProps['onDragMove'] = (coordinates) => { + if (this._popup) { + this._popup.update({coordinates}); + } + this._props.onDragMove?.(coordinates); + }; + private _updateTheme() { const themeCtx = this._consumeContext(mappable.ThemeContext); const theme = themeCtx.theme;