Skip to content

Commit

Permalink
chore: remove radio button group, make on layer instead
Browse files Browse the repository at this point in the history
  • Loading branch information
danji90 committed Dec 4, 2023
1 parent cdd05bc commit 650938d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
25 changes: 4 additions & 21 deletions src/config/ch.sbb.netzentwicklung/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Layer } from 'mobility-toolbox-js/ol';
import TrafimageMapboxLayer from '../../layers/TrafimageMapboxLayer';
import MapboxStyleLayer from '../../layers/MapboxStyleLayer';
import { kilometrageLayer } from '../ch.sbb.infrastruktur';
Expand Down Expand Up @@ -47,12 +46,12 @@ export const netzentwicklungStrategischLayer = new MapboxStyleLayer({
},
});

// Not used for now but may be reinserted
export const netzentwicklungSkPlanerByRegionLayer = new MapboxStyleLayer({
name: 'ch.sbb.netzentwicklung.sk_planer.by_region',
mapboxLayer: netzentwicklungDataLayer,
visible: true,
styleLayersFilter: ({ id }) => /sk_planer$/.test(id),
group: 'netzentwicklung.sk_planer',
properties: {
isQueryable: true,
popupComponent: 'NetzentwicklungPopup',
Expand All @@ -63,11 +62,11 @@ export const netzentwicklungSkPlanerByRegionLayer = new MapboxStyleLayer({
},
});

export const netzentwicklungSkPlanerBySkplanerLayer = new MapboxStyleLayer({
name: 'ch.sbb.netzentwicklung.sk_planer.by_person',
export const netzentwicklungSkPlanerLayer = new MapboxStyleLayer({
name: 'ch.sbb.netzentwicklung.sk_planer',
mapboxLayer: netzentwicklungDataLayer,
styleLayersFilter: ({ id }) => /sk_planer.by_person/.test(id),
group: 'netzentwicklung.sk_planer',
group: 'netzentwicklung',
properties: {
isQueryable: true,
popupComponent: 'NetzentwicklungPopup',
Expand All @@ -77,22 +76,6 @@ export const netzentwicklungSkPlanerBySkplanerLayer = new MapboxStyleLayer({
},
});

export const netzentwicklungSkPlanerLayer = new Layer({
name: 'ch.sbb.netzentwicklung.sk_planer',
mapboxLayer: netzentwicklungDataLayer,
visible: true,
styleLayersFilter: ({ id }) => /sk_planer$/.test(id),
group: 'netzentwicklung',
children: [
netzentwicklungSkPlanerBySkplanerLayer,
netzentwicklungSkPlanerByRegionLayer,
],
properties: {
hasInfos: true,
layerInfoComponent: 'NetzentwicklungLayerInfo',
},
});

export default [
kilometrageLayer,
netzentwicklungDataLayer,
Expand Down
8 changes: 4 additions & 4 deletions src/popups/NetzentwicklungPopup/NetzentwicklungPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ const renderRoleCard = (rolle, classes, t) => {

const NetzentwicklungPopup = ({ feature, layer, t }) => {
const classes = useStyles();
const isSkPlanerByName = /sk_planer.by_person/.test(layer.key);
const isSkPlanerByName = /sk_planer/.test(layer.key);
const rollen = JSON.parse(feature.get('rollen') || '[]').filter((r) =>
['Alle', layer.properties.netzentwicklungRoleType].includes(r.typ),
);
const regionRollen = JSON.parse(feature.get('region_rollen') || '[]').filter(
(r) => ['Alle', layer.properties.netzentwicklungRoleType].includes(r.typ),
);
const mbFeature = feature.get('mapboxFeature');
let regionColor = 'transparent';
let color = 'transparent';
if (mbFeature) {
const { r, g, b, a } = mbFeature.layer.paint['line-color'] || {
r: 1,
g: 1,
b: 1,
a: 1,
};
regionColor = `rgba(${r * 255},${g * 255},${b * 255},${a})`;
color = `rgba(${r * 255},${g * 255},${b * 255},${a})`;
}

useEffect(() => {
Expand All @@ -98,7 +98,7 @@ const NetzentwicklungPopup = ({ feature, layer, t }) => {
<div className={classes.title}>
<div
style={{
backgroundColor: regionColor,
backgroundColor: color,
width: 19,
height: 19,
borderRadius: '50%',
Expand Down

0 comments on commit 650938d

Please sign in to comment.