diff --git a/packages/client/src/MeasureControl.tsx b/packages/client/src/MeasureControl.tsx index 1581e6f6..6bf89ee4 100644 --- a/packages/client/src/MeasureControl.tsx +++ b/packages/client/src/MeasureControl.tsx @@ -26,10 +26,10 @@ import { useMediaQuery } from "beautiful-react-hooks"; let featureId = 0; const emptyFeatureCollection = () => -({ - type: "FeatureCollection", - features: [], -} as FeatureCollection); + ({ + type: "FeatureCollection", + features: [], + } as FeatureCollection); export const MeasureControlLockId = "MeasureControl"; @@ -315,6 +315,9 @@ class MeasureControl extends EventEmitter { // unregister all event handlers this.removeEventListeners(this.map); } + if (this.map && !this.map.loaded()) { + this.map.once("load", this.destroy); + } document.body.removeEventListener("keydown", this.onKeyDown); this.isDestroyed = true; }; @@ -767,11 +770,11 @@ export function MeasurementToolsOverlay({ placement, }: { placement: - | "top-right" - | "top-left" - | "bottom-right" - | "bottom-left" - | "top-right-homepage"; + | "top-right" + | "top-left" + | "bottom-right" + | "bottom-left" + | "top-right-homepage"; }) { const mapContext = useContext(MapContext); const measureContext = useContext(MeasureControlContext); @@ -845,15 +848,19 @@ export function MeasurementToolsOverlay({ transition={{ duration: 0.15, }} - className={`${placement === "top-right" - ? isSmall - ? "right-20 top-5" - : "right-24 mr-1 top-5" - : placement === "top-right-homepage" + className={`${ + placement === "top-right" + ? isSmall + ? "right-20 top-5" + : "right-24 mr-1 top-5" + : placement === "top-right-homepage" ? "right-14 top-2.5" - : placement === "bottom-right" ? "right-2 bottom-14" : "left-20 top-5" - } ${state === "paused" ? "pointer-events-none" : "pointer-events-auto" - } absolute z-10 bg-white shadow rounded border w-72`} + : placement === "bottom-right" + ? "right-2 bottom-14" + : "left-20 top-5" + } ${ + state === "paused" ? "pointer-events-none" : "pointer-events-auto" + } absolute z-10 bg-white shadow rounded border w-72`} >