Skip to content

Commit

Permalink
Trying to access mb draw instamce
Browse files Browse the repository at this point in the history
  • Loading branch information
nerik authored and danielfdsilva committed Oct 25, 2023
1 parent 2769527 commit d8a7b49
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ const SelectorButton = styled(Button)`
}
`;

function ResetAoI() {
// This doesn't work as this Context is not reachable frome here :()
const { main } = useMaps();

function ResetAoI({ map }: { map: any }) {
const onReset = useCallback(() => {
const mbDraw = (main as any)?.instance?._drawControl;
const mbDraw = map?.instance?._drawControl;
if (!mbDraw) return;
mbDraw.trash();
}, [main]);
}, [map]);

return (
<>
Expand All @@ -39,9 +36,10 @@ function ResetAoI() {
}

export default function ResetAoIControl() {
const { main } = useMaps();
useThemedControl(
() => {
return <ResetAoI />;
return <ResetAoI map={main} />;
},
{
position: 'top-left'
Expand Down

0 comments on commit d8a7b49

Please sign in to comment.