diff --git a/src/components/MlGeoJsonLayer/assets/sample_1.json b/src/components/MlGeoJsonLayer/assets/sample_1.json index 457e16e8d..e89b4bb32 100644 --- a/src/components/MlGeoJsonLayer/assets/sample_1.json +++ b/src/components/MlGeoJsonLayer/assets/sample_1.json @@ -89,7 +89,7 @@ } }, { - "id": "2c3972ac51f4350582ecc9de57d47c75", + "id": "4", "type": "Feature", "properties": { "name": "Keiserplatz" }, "geometry": { diff --git a/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts b/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts index a9f32cfac..ab4901199 100644 --- a/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts +++ b/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts @@ -10,15 +10,15 @@ const getDefaultPaintPropsByType = ( return defaultPaintOverrides.fill; } return { - 'fill-color': 'rgba(10,240,256,0.6)', - 'fill-outline-color': 'rgba(20,230,256,0.8)', + 'fill-color': 'rgba(0, 158, 224,0.6)', + 'fill-outline-color': 'rgba(0, 158, 224,0.8)', }; case 'line': if (defaultPaintOverrides?.line) { return defaultPaintOverrides.line; } return { - 'line-color': 'rgb(203,211,2)', + 'line-color': 'rgb(0, 158, 224)', 'line-width': 5, 'line-blur': 0, }; @@ -27,10 +27,10 @@ const getDefaultPaintPropsByType = ( return defaultPaintOverrides.circle; } return { - 'circle-color': 'rgba(10,240,256,0.8)', - 'circle-stroke-color': '#fff', - 'circle-stroke-width': 2, - 'circle-radius': 4, + 'circle-color': 'rgb(0, 158, 224)', + //'circle-stroke-color': 'rgba(255, 255, 255, 0.5)', + //'circle-stroke-width': 2, + 'circle-radius': 6, }; default: return {}; diff --git a/src/components/MlHighlightFeature/MlHighlightFeature.meta_.json b/src/components/MlHighlightFeature/MlHighlightFeature.meta_.json new file mode 100644 index 000000000..996ad2a0a --- /dev/null +++ b/src/components/MlHighlightFeature/MlHighlightFeature.meta_.json @@ -0,0 +1,14 @@ +{ + "name": "MlHighlightFeature", + "title": "", + "description": "", + "i18n": { + "de": { + "title": "", + "description": "" + } + }, + "tags": [], + "category": "", + "type": "component" +} diff --git a/src/components/MlHighlightFeature/MlHighlightFeature.stories.tsx b/src/components/MlHighlightFeature/MlHighlightFeature.stories.tsx new file mode 100644 index 000000000..b49bb26a4 --- /dev/null +++ b/src/components/MlHighlightFeature/MlHighlightFeature.stories.tsx @@ -0,0 +1,177 @@ +import React, { useCallback, useEffect, useRef, useState } from 'react'; + +import MlHighlightFeature, { MlHighlightFeatureProps } from './MlHighlightFeature'; + +import mapContextDecorator from '../../decorators/MapContextDecorator'; + +import examplePolygons from '../MlGeoJsonLayer/assets/sample_1.json'; +import exampleLines from './assets/sample_lines.json'; +import examplePoints from './assets/sample_points.json'; +import MlGeoJsonLayer from '../MlGeoJsonLayer/MlGeoJsonLayer'; +import { Feature, FeatureCollection } from '@turf/turf'; +import useMap from '../../hooks/useMap'; +import TopToolbar from '../../ui_components/TopToolbar'; +import { Button, Menu, MenuItem, Typography } from '@mui/material'; + +const storyoptions = { + title: 'MapComponents/MlHighlightFeature', + component: MlHighlightFeature, + argTypes: {}, + decorators: mapContextDecorator, +}; +export default storyoptions; + +interface TemplateProps extends MlHighlightFeatureProps { + type: + | 'symbol' + | 'circle' + | 'fill' + | 'line' + | 'heatmap' + | 'fill-extrusion' + | 'hillshade' + | 'background' + | undefined; + sample: FeatureCollection; +} + +const configTitles = { + circle: 'Highlight point geometries', + line: 'Highlight line geometries', + polygon: 'Highlight polygon geometries', +}; + +const Template = (props: TemplateProps) => { + const [selectedFeatures, setSelectedFeatures] = useState(props.features); + const selectedId = useRef([]); + const mapHook = useMap({ + mapId: undefined, + }); + const initializedRef = useRef(false); + + useEffect(() => { + if (!mapHook.map || initializedRef.current) return; + + initializedRef.current = true; + mapHook.map.map.flyTo({ center: [7.105175528281227, 50.73348799274236], zoom: 15 }); + }, [mapHook.map]); + + const handleClick = useCallback((event: any) => { + const featureId = event.features[0].id; + const featureExists = selectedId.current.includes(featureId); + + setSelectedFeatures((current) => { + if (featureExists) { + selectedId.current = selectedId.current.filter((id) => id !== featureId); + return current?.filter((feature) => feature.id !== featureId); + } else { + selectedId.current.push(featureId); + return [ + ...(current || []), + { + type: event.features[0].type, + geometry: event.features[0].geometry, + id: featureId, + } as Feature, + ]; + } + }); + }, []); + + return ( + <> + + + + + ); +}; + +export const Polygon = Template.bind({}); +Polygon.parameters = {}; +Polygon.args = { + sample: examplePolygons, + type: 'fill', + offset: -5, + //paint: { 'line-color': "#3598DB" }, +}; + +export const Line = Template.bind({}); +Line.parameters = {}; +Line.args = { sample: exampleLines, type: 'line'}; + +export const Circle = Template.bind({}); +Circle.parameters = {}; +Circle.args = { sample: examplePoints, type: 'circle', offset: 8 }; + +/// Catalogue Story + +const catalogueTemplate = () => { + const [selectedLayer, setSelectedLayer] = useState('polygon'); + + const [anchorEl, setAnchorEl] = React.useState(null); + const open = Boolean(anchorEl); + const handleClick = (event: React.MouseEvent) => { + setAnchorEl(event.currentTarget); + }; + const handleClose = () => { + setAnchorEl(null); + }; + + const handleLayerSelect = (layer: string) => { + setSelectedLayer(layer); + }; + + return ( + <> + + + {configTitles[selectedLayer]} + + + + + handleLayerSelect('polygon')}> + Polygon Configuration + + handleLayerSelect('circle')}>Circle Configuration + handleLayerSelect('line')}>Line Configuration + + {selectedLayer === 'circle' &&