Skip to content

Commit

Permalink
feat: readd MapComponent, FloatingMapLogo and BackgroundLayerChooser
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlkoch authored and simonseyock committed May 6, 2024
1 parent 3b13ce1 commit a32aee4
Show file tree
Hide file tree
Showing 43 changed files with 841 additions and 298 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"@terrestris/base-util": "^1.1.0",
"@terrestris/ol-util": "^17.0.0",
"@terrestris/react-util": "^4.0.0",
"@terrestris/react-util": "^5.0.0-beta.0",
"@types/geojson": "^7946.0.14",
"@types/lodash": "^4.17.0",
"ag-grid-community": "^31.1.1",
Expand Down
99 changes: 46 additions & 53 deletions src/BackgroundLayerChooser/BackgroundLayerChooser.example.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ The BackgroundLayerChooser

```jsx
import BackgroundLayerChooser from '@terrestris/react-geo/dist/BackgroundLayerChooser/BackgroundLayerChooser';
import MapComponent from '@terrestris/react-util/dist/Components/MapComponent/MapComponent';
import MapComponent from '@terrestris/react-geo/dist/Map/MapComponent/MapComponent';
import MapContext from '@terrestris/react-util/dist/Context/MapContext/MapContext';
import { useMap } from '@terrestris/react-util/dist/Hooks/useMap/useMap';
import OlLayerTile from 'ol/layer/Tile';
Expand All @@ -12,63 +12,56 @@ import OlSourceTileWMS from 'ol/source/TileWMS';
import OlView from 'ol/View';
import * as React from 'react';

const layers = [
new OlLayerTile({
source: new OlSourceOsm(),
properties: {
name: 'OSM',
isBackgroundLayer: true
}
}),
new OlLayerTile({
visible: false,
source: new OlSourceTileWMS({
url: 'https://sgx.geodatenzentrum.de/wms_topplus_open',
params: {
LAYERS: 'web',
function BackgroundChooserExample() {
const layers = [
new OlLayerTile({
source: new OlSourceOsm(),
properties: {
name: 'OSM',
isBackgroundLayer: true
}
}),
properties: {
name: 'BKG',
isBackgroundLayer: true
}
})
];
const openlayersMap = new OlMap({
view: new OlView({
center: [801045, 6577113],
zoom: 9
}),
layers
});

function ComponentToUseTheMap() {
const map = useMap();

// This is example specific and usually not needed
React.useEffect(() => {
map.setTarget('usemap-map');
}, [map]);
new OlLayerTile({
visible: false,
source: new OlSourceTileWMS({
url: 'https://sgx.geodatenzentrum.de/wms_topplus_open',
params: {
LAYERS: 'web'
},
attributions: '© <a href="https://www.bkg.bund.de">Bundesamt für Kartographie und Geodäsie' +
`(${new Date().getFullYear()})</a>, ` +
'<a href="https://sgx.geodatenzentrum.de/web_public/gdz/datenquellen/Datenquellen_TopPlusOpen.html">' +
'Datenquellen</a>'
}),
properties: {
name: 'BKG',
isBackgroundLayer: true
}
})
];

return (
<MapComponent
id={'usemap-map'}
map={map}
style={{
height: '400px'
}}
/>
);
}
const map = new OlMap({
view: new OlView({
center: [801045, 6577113],
zoom: 9
}),
layers
});

function BackgroundChooserExample() {
return (
<MapContext.Provider value={openlayersMap}>
<ComponentToUseTheMap />
<BackgroundLayerChooser
layers={layers}
allowEmptyBackground={true}
/>
<MapContext.Provider value={map}>
<MapComponent
map={map}
style={{
position: 'relative',
height: '400px'
}}
>
<BackgroundLayerChooser
layers={layers}
allowEmptyBackground={true}
/>
</MapComponent>
</MapContext.Provider>
);
}
Expand Down

0 comments on commit a32aee4

Please sign in to comment.