Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(poi-layer): add pois to marker select popup #881

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/component/map/tile-layer/MarkerSelectPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SelectCarpoolRow from './SelectCarpoolRow';
import SelectRoadworksRow from './SelectRoadworksRow';
import SelectChargingStationRow from './SelectChargingStationRow';
import SelectDatahubPoiRow from './SelectDatahubPoiRow';
import SelectPublicPoiRow from './SelectPublicPoiRow';

function MarkerSelectPopup(props) {
const hasStop = () =>
Expand Down Expand Up @@ -132,6 +133,19 @@ function MarkerSelectPopup(props) {
/>
);
}

if (option.layer === 'publicPois') {
const { lat, lon } = option.coords;
return (
<SelectPublicPoiRow
{...option.feature}
key={option.feature.properties.id}
latitude={lat}
longitude={lon}
/>
);
}

return null;
});
let id = 'choose-stop';
Expand Down
70 changes: 70 additions & 0 deletions app/component/map/tile-layer/SelectPublicPoiRow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React from 'react';
import Link from 'found/Link';
import PropTypes from 'prop-types';
import pickBy from 'lodash/pickBy';
import { getLayerByCode } from '../../../util/mapLayerUtils';
import Icon from '../../Icon';

export default function SelectPublicPoi(props, { config, intl }) {
const { properties, latitude, longitude } = props;

const { category3: code, name, address, website, phone } = properties;

const layer = getLayerByCode(code, config);

const svg = layer?.properties?.icon?.svg;

const detailsProperties = { ...properties };

// Filter out properties that are not in the layer's attributes
Object.keys(detailsProperties).forEach(key => {
if (!layer?.properties?.attributes?.includes(key)) {
delete detailsProperties[key];
}
});

const params = pickBy(
{
...detailsProperties,
lat: latitude,
lng: longitude,
code,
name: name || layer.translations[intl.locale],
address,
website,
phone,
},
value => value !== undefined,
);

return (
<Link
className="stop-popup-choose-row"
to={`/pois/${code}?${new URLSearchParams(params).toString()}`}
>
<div className="padding-vertical-normal select-row-icon">
{svg && <Icon dataURI={`data:image/svg+xml;base64,${btoa(svg)}`} />}
</div>
<span className="choose-row-center-column">
<h5 className="choose-row-header">
{name || layer.translations[intl.locale]}
</h5>
</span>
<span className="choose-row-right-column">
<Icon img="icon-icon_arrow-collapse--right" />
</span>
<hr className="no-margin gray" />
</Link>
);
}

SelectPublicPoi.propTypes = {
properties: PropTypes.object.isRequired,
latitude: PropTypes.number.isRequired,
longitude: PropTypes.number.isRequired,
};

SelectPublicPoi.contextTypes = {
intl: PropTypes.object.isRequired,
config: PropTypes.object.isRequired,
};
1 change: 1 addition & 0 deletions app/component/map/tile-layer/TileLayerContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class TileLayerContainer extends GridLayer {
}

if (
selectableTargets.length === 1 &&
selectableTargets?.find(({ layer }) => {
return layer === 'publicPois';
})
Expand Down
3 changes: 3 additions & 0 deletions app/util/mapLayerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const isFeatureLayerEnabled = (
if (!feature || !layerName || !mapLayers) {
return false;
}
if (layerName === 'publicPois') {
return true;
}
if (!Object.keys(mapLayers).includes(layerName)) {
return false;
}
Expand Down
Loading