Skip to content

Commit f72881c

Browse files
authored
UI design/ogc api+sketch tool (#221)
1 parent 45f4646 commit f72881c

File tree

5 files changed

+239
-93
lines changed

5 files changed

+239
-93
lines changed

src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@ const getDefaultPaintPropsByType = (
1010
return defaultPaintOverrides.fill;
1111
}
1212
return {
13-
'fill-color': 'rgba(10,240,256,0.6)',
14-
'fill-outline-color': 'rgba(20,230,256,0.8)',
13+
// 'fill-color': 'rgba(10,240,256,0.6)',
14+
// 'fill-outline-color': 'rgba(20,230,256,0.8)',
15+
'fill-color': '#009EE0',
16+
'fill-outline-color': '#009EE0',
1517
};
1618
case 'line':
1719
if (defaultPaintOverrides?.line) {
20+
console.log(defaultPaintOverrides.line);
1821
return defaultPaintOverrides.line;
1922
}
2023
return {
21-
'line-color': 'rgb(203,211,2)',
24+
// // 'line-color': 'rgb(203,211,2)',
25+
// 'line-width': 5,
26+
// 'line-blur': 0,
27+
'line-color': '#009EE0',
2228
'line-width': 5,
2329
'line-blur': 0,
2430
};
@@ -27,10 +33,14 @@ const getDefaultPaintPropsByType = (
2733
return defaultPaintOverrides.circle;
2834
}
2935
return {
30-
'circle-color': 'rgba(10,240,256,0.8)',
36+
// 'circle-color': 'rgba(10,240,256,0.8)',
37+
// 'circle-stroke-color': '#fff',
38+
// 'circle-stroke-width': 2,
39+
// 'circle-radius': 4,
40+
'circle-color': '#009EE0',
3141
'circle-stroke-color': '#fff',
3242
'circle-stroke-width': 2,
33-
'circle-radius': 4,
43+
'circle-radius': 5,
3444
};
3545
default:
3646
return {};

src/components/MlOgcApiFeatures/MlOgcApiFeatures.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const PointTemplate = (props: TemplateProps) => {
5858
mapId={props.mapId}
5959
ogcApiFeatureParams={props.ogcApiFeatureParams}
6060
reloadFeaturesOnMapMove={true}
61+
mlGeoJsonLayerProps={{ defaultPaintOverrides: { circle: { 'circle-color': '#CF003D' } } }}
6162
></MlOgcApiFeatures>
6263
</>
6364
);

src/components/MlSketchTool/MlSketchTool.stories.tsx

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React, { useState } from 'react';
22

33
import MlSketchTool from './MlSketchTool';
4+
import { Feature } from 'geojson';
45

56
import mapContextDecorator from '../../decorators/MapContextDecorator';
67
import Sidebar from '../../ui_components/Sidebar';
78
import TopToolbar from '../../ui_components/TopToolbar';
8-
import { Box, Button, Theme, useMediaQuery } from '@mui/material';
9+
import { Button, Paper, Typography } from '@mui/material';
910

1011
const storyoptions = {
1112
title: 'MapComponents/MlSketchTool',
@@ -40,33 +41,31 @@ const Template = () => {
4041
};
4142

4243
const catalgoueTemplate = () => {
43-
const mediaIsMobile = useMediaQuery((theme: Theme) => theme.breakpoints.down('lg'));
44+
// const mediaIsMobile = useMediaQuery((theme: Theme) => theme.breakpoints.down('lg'));
4445

4546
const [openSidebar, setOpenSidebar] = useState(true);
47+
const [instructionText, setInstructionText] = useState('Select a sketch tool.');
48+
49+
const getInstructionText = (drawMode?: keyof MapboxDraw.Modes, selectedGeoJson?: Feature) => {
50+
if (drawMode === 'simple_select' && selectedGeoJson) {
51+
const geoType = selectedGeoJson.geometry.type;
52+
return `Edit ${geoType}: Click the geometry to edit.`;
53+
}
54+
55+
switch (drawMode) {
56+
case 'draw_point':
57+
return 'Click to draw point.';
58+
case 'draw_line_string':
59+
return 'Click to add vertices. Double-click to finish drawing.';
60+
case 'draw_polygon':
61+
return 'Click to add vertices. Double-click to finish drawing.';
62+
default:
63+
return 'Select a sketch tool.';
64+
}
65+
};
66+
4667
return (
4768
<>
48-
<Box
49-
sx={{
50-
position: 'fixed',
51-
width: { xs: '100%', sm: 'auto' },
52-
top: { xs: '62px', sm: '22px' },
53-
right: { xs: '0px', sm: '180px' },
54-
paddingRight: { xs: '20px', sm: '0px' },
55-
color: '#009ee0',
56-
backgroundColor: '#fff',
57-
textAlign: 'right',
58-
fontSize: '16px',
59-
fontFamily: 'sans-serif',
60-
display: 'flex',
61-
flexDirection: 'column',
62-
gap: '5px',
63-
zIndex: 5000,
64-
}}
65-
>
66-
{mediaIsMobile
67-
? 'Zum Beenden erneut auf denselben Punkt klicken.'
68-
: 'Die Zeichnung kann beendet werden, indem erneut auf den zuletzt gezeichneten Punkt geklickt wird.'}
69-
</Box>
7069
<TopToolbar
7170
buttons={
7271
<>
@@ -81,8 +80,30 @@ const catalgoueTemplate = () => {
8180
}
8281
/>
8382
<Sidebar open={openSidebar} setOpen={setOpenSidebar} name={'Sketch Tool'}>
84-
<MlSketchTool onChange={(state) => console.log(state)} />
83+
<MlSketchTool
84+
onChange={(state) => {
85+
const { drawMode, selectedGeoJson } = state;
86+
setInstructionText(getInstructionText(drawMode, selectedGeoJson));
87+
}}
88+
/>
8589
</Sidebar>
90+
91+
<Paper
92+
sx={{
93+
position: 'fixed',
94+
bottom: '25px',
95+
left: '50%',
96+
padding: '10px',
97+
zIndex: 101,
98+
}}
99+
>
100+
<Typography>
101+
{/* {mediaIsMobile
102+
? 'Zum Beenden erneut auf denselben Punkt klicken.'
103+
: 'Die Zeichnung kann beendet werden, indem erneut auf den zuletzt gezeichneten Punkt geklickt wird.'} */}
104+
{instructionText}
105+
</Typography>
106+
</Paper>
86107
</>
87108
);
88109
};

0 commit comments

Comments
 (0)