@opengeoweb/core
v9.33.0
Published
GeoWeb Core library for the opengeoweb project
Downloads
1,660
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 { mapActions } from '@opengeoweb/store';
import { TimeSliderConnect } from '@opengeoweb/timeslider';
import { createStore } from '@redux-eggs/redux-toolkit';
const store = createStore({});
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/