Skip to content

Commit

Permalink
Merge pull request #610 from SUI-Components/fix/clean-listeners-googl…
Browse files Browse the repository at this point in the history
…e-maps-drawer

Fix: Clean listeners GoogleMapsDrawer
  • Loading branch information
Pato2790 committed Aug 31, 2023
2 parents 8045276 + f625573 commit 16ec38e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions components/map/google/src/drawer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function GoogleMapsDrawer({
} else {
stopDrawing()
}
return () => clearListeners()
}, [drawing]) // eslint-disable-line react-hooks/exhaustive-deps

const draw = ({polyline}) => {
Expand All @@ -33,9 +34,10 @@ function GoogleMapsDrawer({
}

const clearListeners = () => {
mapsLibrary.event.clearListeners(mapRef, 'mousemove')
mapsLibrary.event.clearListeners(mapRef, 'mousedown')
mapsLibrary.event.clearListeners(mapRef, 'mousemove')
mapsLibrary.event.clearListeners(mapRef, 'mouseup')
mapsLibrary.event.clearListeners(mapRef, 'touchmove')
}

// This will convert the path from MVCArray<LatLng> to a LatLngLiteral array
Expand All @@ -56,8 +58,6 @@ function GoogleMapsDrawer({
// Remove the polyline from the map
polyline.setMap(null)

clearListeners()

mapRef.setOptions(ENABLED_MAP_INTERACTION_OPTIONS)

onStopDrawing({path})
Expand Down
6 changes: 2 additions & 4 deletions components/map/google/src/drawer/settings.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
export const DISABLED_MAP_INTERACTION_OPTIONS = {
disableDoubleClickZoom: false,
draggable: false,
scrollwheel: false,
zoomControl: false
scrollwheel: false
}

export const ENABLED_MAP_INTERACTION_OPTIONS = {
disableDoubleClickZoom: true,
draggable: true,
scrollwheel: true,
zoomControl: true
scrollwheel: true
}

0 comments on commit 16ec38e

Please sign in to comment.