google-map-react
redux-toolkit
createAsyncThunk to handle asynchronous requests, signaling loading states.components/map/MapPage.js
Map with location and cluster data.redux/mapSlice.js
redux/viewChange.js
Usage:
<GoogleMapReact
...
center={view.center}
zoom={view.zoom}
onChange={onViewChange}
...
>
GoogleMapReact is a controlled component, meaning the view state is driven by the center and zoom props. We set them up initially, and then let the map keep its center and zoom.
GoogleMapReact calls onChange to provide map bounds.MapPage dispatches actions with the new view:
GoogleMapReact calls onChange with the new view.Map calls onClusterClick.MapPage dispatches clusterClick action in mapSlice.js:
GoogleMapReact calls onChange with the new zoom.onChange in GoogleMapReact.