Filter our multiple occurrences of OSM features in <Infos>

This commit is contained in:
Eric van der Vlist 2023-02-03 17:46:56 +01:00
parent b9d886db69
commit 3daa2d11f9
1 changed files with 12 additions and 6 deletions

View File

@ -55,9 +55,18 @@ export const clickHandler = (event: any) => {
}
});
selectedFeatures = features.filter((feature: any) => feature.get('context'));
vectorLayerFeatures = features.filter(
(feature: any) => !feature.get('context')
);
let osmIds = new Set<string>();
vectorLayerFeatures = features.filter((feature: any) => {
if (feature.get('context')) {
return false;
}
const osmId = feature.get('osm_id');
if (osmIds.has(osmId)) {
return false;
}
osmIds.add(osmId);
return true;
});
selectedFeatures.sort((f1: Feature, f2: Feature) => {
const ctx1 = f1.get('context');
@ -184,7 +193,6 @@ const Infos: Component<{}> = (props) => {
title={
<>
<div>
{`${feature.get('class')}
${feature.get('name') || ''}`}
</div>
<div>
@ -195,8 +203,6 @@ const Infos: Component<{}> = (props) => {
onClick={async () => {
await Browser.open({
url: `https://www.qwant.com/?q=${encodeURIComponent(
feature.get('class') +
' ' +
feature.get('name') || ''
)}&t=web`,
});