Skip to content

Commit 754e544

Browse files
committed
fix: locatecontrol
1 parent fb432e1 commit 754e544

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/hooks/useLocation.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
// TODO: Not sure if this is possible to actually type correctly with how the leaflet.locatecontrol library is written
33

44
import { useEffect, useMemo, useState } from 'react'
5-
import { LayerGroup, DomEvent, DomUtil, Control } from 'leaflet'
5+
import { LayerGroup, DomEvent, DomUtil } from 'leaflet'
66
import { useTranslation } from 'react-i18next'
77
import { useMap } from 'react-leaflet'
8-
import 'leaflet.locatecontrol'
8+
import { LocateControl } from 'leaflet.locatecontrol'
99

1010
import { useStorage } from '@store/useStorage'
1111
import { useLocationError } from '@hooks/useLocationError'
1212

1313
/**
1414
* Use location hook
15-
* @returns {{ lc: Control.Locate & { _onClick: () => void }, requesting: boolean, color: import('@mui/material').ButtonProps['color'], locationError: { show: boolean, message: string }, hideLocationError: () => void }}
15+
* @returns {{ lc: import('leaflet.locatecontrol').LocateControl & { _onClick: () => void }, requesting: boolean, color: import('@mui/material').ButtonProps['color'], locationError: { show: boolean, message: string }, hideLocationError: () => void }}
1616
*/
1717
export function useLocation(dependency = false) {
1818
const map = useMap()
@@ -26,7 +26,7 @@ export function useLocation(dependency = false) {
2626
useLocationError()
2727

2828
const lc = useMemo(() => {
29-
const LocateFab = Control.Locate.extend({
29+
const LocateFab = LocateControl.extend({
3030
_setClasses(state) {
3131
if (state === 'requesting') setColor('secondary')
3232
else if (state === 'active') setColor('success')

src/pages/map/components/Layers.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react'
33
import { TileLayer, useMap } from 'react-leaflet'
44
import { useTranslation } from 'react-i18next'
55
import { control } from 'leaflet'
6+
import { locate } from 'leaflet.locatecontrol'
67
import { useStorage } from '@store/useStorage'
78
import { useLocationError } from '@hooks/useLocationError'
89
import { Notification } from '@components/Notification'
@@ -44,7 +45,7 @@ export function ControlledLocate() {
4445

4546
const lc = React.useMemo(
4647
() =>
47-
control.locate({
48+
locate({
4849
position: 'bottomright',
4950
metric,
5051
icon: 'fas fa-crosshairs',

0 commit comments

Comments
 (0)