File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,8 @@ type MapSliceStateType = {
3636 fitToExtent ?: Extent
3737 isAreaSelected : boolean
3838 isolatedLayer : IsolatedLayerType | undefined
39- mapView : MapView
4039 locateOnMap : LocateOnMap | undefined
40+ mapView : MapView
4141 selectedBaseLayer : BaseLayer
4242 zoomToCenter ?: Coordinate
4343}
@@ -112,12 +112,12 @@ const mapSlice = createSlice({
112112 setIsolateMode ( state , action : PayloadAction < IsolatedLayerType | undefined > ) {
113113 state . isolatedLayer = action . payload
114114 } ,
115- setMapView ( state , action : PayloadAction < MapView > ) {
116- state . mapView = action . payload
117- } ,
118115 setLocateOnMap ( state , action : PayloadAction < LocateOnMap | undefined > ) {
119116 state . locateOnMap = action . payload
120117 } ,
118+ setMapView ( state , action : PayloadAction < MapView > ) {
119+ state . mapView = action . payload
120+ } ,
121121 setZoomToCenter ( state , action ) {
122122 state . zoomToCenter = action . payload
123123 }
Original file line number Diff line number Diff line change 11import { useAppDispatch } from '@hooks/useAppDispatch'
22import { OPENLAYERS_PROJECTION , WSG84_PROJECTION } from '@mtes-mct/monitor-ui'
33import { setMapView } from 'domain/shared_slices/Map'
4- import { isEqual } from 'lodash'
4+ import { debounce , isEqual } from 'lodash'
55import { transformExtent } from 'ol/proj'
66import { useEffect , useRef } from 'react'
77
@@ -21,7 +21,7 @@ export const useSyncMapViewToRedux = (map: OpenLayerMap | undefined) => {
2121
2222 const view = map . getView ( )
2323
24- const handleMoveEnd = ( ) => {
24+ const handleMoveEnd = debounce ( ( ) => {
2525 const extent3857 = view . calculateExtent ( map . getSize ( ) )
2626 const extent4326 = transformExtent ( extent3857 , OPENLAYERS_PROJECTION , WSG84_PROJECTION )
2727 const zoom = view . getZoom ( )
@@ -36,7 +36,7 @@ export const useSyncMapViewToRedux = (map: OpenLayerMap | undefined) => {
3636
3737 dispatch ( setMapView ( { bbox : extent4326 , zoom : zoomValue } ) )
3838 }
39- }
39+ } , 250 )
4040
4141 map . on ( 'moveend' , handleMoveEnd )
4242
You can’t perform that action at this time.
0 commit comments