Filter our multiple occurrences of OSM features in <Infos>
This commit is contained in:
parent
b9d886db69
commit
3daa2d11f9
|
@ -55,9 +55,18 @@ export const clickHandler = (event: any) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
selectedFeatures = features.filter((feature: any) => feature.get('context'));
|
selectedFeatures = features.filter((feature: any) => feature.get('context'));
|
||||||
vectorLayerFeatures = features.filter(
|
let osmIds = new Set<string>();
|
||||||
(feature: any) => !feature.get('context')
|
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) => {
|
selectedFeatures.sort((f1: Feature, f2: Feature) => {
|
||||||
const ctx1 = f1.get('context');
|
const ctx1 = f1.get('context');
|
||||||
|
@ -184,7 +193,6 @@ const Infos: Component<{}> = (props) => {
|
||||||
title={
|
title={
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
{`${feature.get('class')}
|
|
||||||
${feature.get('name') || ''}`}
|
${feature.get('name') || ''}`}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -195,8 +203,6 @@ const Infos: Component<{}> = (props) => {
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await Browser.open({
|
await Browser.open({
|
||||||
url: `https://www.qwant.com/?q=${encodeURIComponent(
|
url: `https://www.qwant.com/?q=${encodeURIComponent(
|
||||||
feature.get('class') +
|
|
||||||
' ' +
|
|
||||||
feature.get('name') || ''
|
feature.get('name') || ''
|
||||||
)}&t=web`,
|
)}&t=web`,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue