Skip to content

Commit beced6a

Browse files
committed
remove throttling from the map updates - it was laggy
1 parent 6263817 commit beced6a

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/components/Map.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import { MapState } from "../types";
88
import { MAP_SOURCES } from "../constants/mapSources";
99
import { useApp } from "../contexts/AppContext";
1010
import { SourceSpecification } from "maplibre-gl";
11-
import { useCallback } from "react";
12-
import throttle from "lodash.throttle";
1311

1412
interface MapProps {
1513
mapState: MapState;
@@ -29,21 +27,6 @@ export function Map({
2927
const { state } = useApp();
3028
const source = MAP_SOURCES[sourceId] || state.customSources[sourceId];
3129

32-
// Create throttled callbacks
33-
const throttledOnMapChange = useCallback(
34-
throttle((newState: Partial<MapState>) => {
35-
onMapChange(newState);
36-
}, 500),
37-
[onMapChange]
38-
);
39-
40-
const throttledOnViewStateChange = useCallback(
41-
throttle((newState: Partial<MapState>) => {
42-
onViewStateChange(newState);
43-
}, 500),
44-
[onViewStateChange]
45-
);
46-
4730
function handleMove(evt: ViewStateChangeEvent) {
4831
const newState: Partial<MapState> = {
4932
center: [evt.viewState.longitude, evt.viewState.latitude] as [
@@ -56,9 +39,9 @@ export function Map({
5639
};
5740

5841
if (synchronized) {
59-
throttledOnMapChange(newState);
42+
onMapChange(newState);
6043
} else {
61-
throttledOnViewStateChange(newState);
44+
onViewStateChange(newState);
6245
}
6346
}
6447

0 commit comments

Comments
 (0)