import { AnyAction } from 'redux' ; import { ThunkDispatch } from 'redux-thunk' ; import { connect } from 'react-redux' ; import { MbMap } from './mb_map' ; import { clearGoto , clearMouseCoordinates , mapDestroyed , mapExtentChanged , mapReady , setAreTilesLoaded , setMapInitError , setMouseCoordinates , updateMetaFromTiles , } from '../../actions' ; import { getGoto , getLayerList , getMapReady , getMapSettings , getScrollZoom , getSpatialFiltersLayer , getTimeslice , } from '../../selectors/map_selectors' ; import { getDrawMode , getIsFullScreen } from '../../selectors/ui_selectors' ; import { getInspectorAdapters } from '../../reducers/non_serializable_instances' ; import { MapStoreState } from '../../reducers/store' ; import { DRAW_MODE } from '../../../common/constants' ; import { TileMetaFeature } from '../../../common/descriptor_types' ; import type { MapExtentState } from '../../reducers/map/types' ; function mapStateToProps ( state ) { return { isMapReady : getMapReady ( state ) , settings : getMapSettings ( state ) , layerList : getLayerList ( state ) , spatialFiltersLayer : getSpatialFiltersLayer ( state ) , goto : getGoto ( state ) , inspectorAdapters : getInspectorAdapters ( state ) , scrollZoom : getScrollZoom ( state ) , isFullScreen : getIsFullScreen ( state ) , timeslice : getTimeslice ( state ) , featureModeActive : getDrawMode ( state ) === DRAW_MODE . DRAW_SHAPES || getDrawMode ( state ) === DRAW_MODE . DRAW_POINTS , filterModeActive : getDrawMode ( state ) === DRAW_MODE . DRAW_FILTERS , } ; } function mapDispatchToProps ( dispatch ) { return { extentChanged : ( mapExtentState ) => { dispatch ( mapExtentChanged ( mapExtentState ) ) ; } , onMapReady : ( mapExtentState ) => { dispatch ( clearGoto ( ) ) ; dispatch ( mapExtentChanged ( mapExtentState ) ) ; dispatch ( mapReady ( ) ) ; } , onMapDestroyed : ( ) => { dispatch ( mapDestroyed ( ) ) ; } , setMouseCoordinates : ( { lat , lon } ) => { dispatch ( setMouseCoordinates ( { lat , lon } ) ) ; } , clearMouseCoordinates : ( ) => { dispatch ( clearMouseCoordinates ( ) ) ; } , clearGoto : ( ) => { dispatch ( clearGoto ( ) ) ; } , setMapInitError ( errorMessage ) { dispatch ( setMapInitError ( errorMessage ) ) ; } , setAreTilesLoaded ( layerId , areTilesLoaded ) { dispatch ( setAreTilesLoaded ( layerId , areTilesLoaded ) ) ; } , updateMetaFromTiles ( layerId , features ) { dispatch ( updateMetaFromTiles ( layerId , features ) ) ; } , } ; } const connected = connect ( mapStateToProps , mapDispatchToProps ) ( MbMap ) ; export { connected as MBMap } ;