@opengeoweb/core
v9.37.0
Published
GeoWeb Core library for the opengeoweb project
Downloads
2,383
Keywords
Readme
Core
React component library with Core components for the opengeoweb project. This library was generated with Nx.
Installation
npm install @opengeoweb/core @opengeoweb/store @opengeoweb/timeslider @redux-eggs/redux-toolkit
Use
You can use any component exported from core by importing them. Some components need to be wrapped in the CoreThemeProvider, or CoreThemeStoreProvider for a connected component. You can also pass in your own theme if needed. Below you can find a simplified example on how the MapViewConnect component and several mapActions could be used:
import { useDispatch } from 'react-redux';
import {
MapViewConnect,
LegendConnect,
LegendMapButtonConnect,
CoreThemeStoreProvider,
} from '@opengeoweb/core';
import {
genericListener,
mapStoreModuleConfig,
mapStoreReducers,
mapActions,
syncGroupsReducer,
uiReducer,
} from '@opengeoweb/store';
import { TimeSliderConnect } from '@opengeoweb/timeslider';
import { configureStore } from '@reduxjs/toolkit';
const store = configureStore({
reducer: {
...mapStoreReducers,
ui: uiReducer,
syncronizationGroupStore: syncGroupsReducer,
snackbar: snackbarReducer,
},
middleware: [
...mapStoreModuleConfig.middlewares!,
genericListener.middleware,
],
});
const ConnectedMapWithTimeSlider = ({ mapId }) => {
const dispatch = useDispatch();
React.useEffect(() => {
// set layers
dispatch(mapActions.setLayers({ layers: [radarLayer], mapId }));
// baseLayers
dispatch(
mapActions.setBaseLayers({
mapId,
layers: [baseLayerGrey, overLayer],
}),
);
}, []);
return (
<CoreThemeStoreProvider store={store}>
<LegendConnect initialActiveMapId={mapId} />
<LegendMapButtonConnect mapId={mapId} />
<MapViewConnect mapId={mapId} displayTimeInMap />
<TimeSliderConnect sourceId="timeslider-1" mapId={mapId} />
</CoreThemeStoreProvider>
);
};
export default ConnectedMapWithTimeSlider;
Documentation
https://opengeoweb.gitlab.io/opengeoweb/docs/core/