From ace6812e89b5108c00d321d378b58332568ec34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Wolan=CC=81ski?= Date: Tue, 5 Dec 2017 23:27:17 +0100 Subject: [PATCH 1/4] Remove duplicated features from popups (#41) --- src/components/map/FeatureLayerPopup.jsx | 20 ++++++++++++--- src/components/map/FeaturePropertyPopup.jsx | 27 +++++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/components/map/FeatureLayerPopup.jsx b/src/components/map/FeatureLayerPopup.jsx index ca67de5..c9196a7 100644 --- a/src/components/map/FeatureLayerPopup.jsx +++ b/src/components/map/FeatureLayerPopup.jsx @@ -4,13 +4,26 @@ import InputBlock from '../inputs/InputBlock' import StringInput from '../inputs/StringInput' import LayerIcon from '../icons/LayerIcon' - function groupFeaturesBySourceLayer(features) { const sources = {} + + let returnedFeatures = {}; + features.forEach(feature => { - sources[feature.layer['source-layer']] = sources[feature.layer['source-layer']] || [] - sources[feature.layer['source-layer']].push(feature) + if(returnedFeatures.hasOwnProperty(feature.layer.id)) { + returnedFeatures[feature.layer.id]++ + + const featureObject = sources[feature.layer['source-layer']].find(f => f.layer.id === feature.layer.id) + + featureObject.counter = returnedFeatures[feature.layer.id] + } else { + sources[feature.layer['source-layer']] = sources[feature.layer['source-layer']] || [] + sources[feature.layer['source-layer']].push(feature) + + returnedFeatures[feature.layer.id] = 1 + } }) + return sources } @@ -34,6 +47,7 @@ class FeatureLayerPopup extends React.Component { paddingRight: 3 }}/> {feature.layer.id} + {feature.counter && × {feature.counter}} }) return
diff --git a/src/components/map/FeaturePropertyPopup.jsx b/src/components/map/FeaturePropertyPopup.jsx index bf2c505..5d5c9e5 100644 --- a/src/components/map/FeaturePropertyPopup.jsx +++ b/src/components/map/FeaturePropertyPopup.jsx @@ -23,7 +23,7 @@ function renderProperties(feature) { function renderFeature(feature) { return
-
{feature.layer['source-layer']}
+
{feature.layer['source-layer']}{feature.inspectModeCounter && × {feature.inspectModeCounter}}
@@ -31,13 +31,36 @@ function renderFeature(feature) {
} +function removeDuplicatedFeatures(features) { + let uniqueFeatures = []; + + features.forEach(feature => { + const featureIndex = uniqueFeatures.findIndex(feature2 => { + return feature.layer['source-layer'] === feature2.layer['source-layer'] + && JSON.stringify(feature.properties) === JSON.stringify(feature2.properties) + }) + + if(featureIndex === -1) { + uniqueFeatures.push(feature) + } else { + if(uniqueFeatures[featureIndex].hasOwnProperty('counter')) { + uniqueFeatures[featureIndex].inspectModeCounter++ + } else { + uniqueFeatures[featureIndex].inspectModeCounter = 2 + } + } + }) + + return uniqueFeatures +} + class FeaturePropertyPopup extends React.Component { static propTypes = { features: PropTypes.array } render() { - const features = this.props.features + const features = removeDuplicatedFeatures(this.props.features) return
{features.map(renderFeature)}
From ed495c32169c91cea3dac691bb2247f5bfb7b62f Mon Sep 17 00:00:00 2001 From: Tobin Bradley Date: Fri, 12 Jan 2018 11:37:05 -0500 Subject: [PATCH 2/4] Update export to use GL JS 0.43.0 Fixes #212 broken bl.ocks preview. --- src/components/modals/ExportModal.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/modals/ExportModal.jsx b/src/components/modals/ExportModal.jsx index 1371835..d093f38 100644 --- a/src/components/modals/ExportModal.jsx +++ b/src/components/modals/ExportModal.jsx @@ -56,8 +56,8 @@ class Gist extends React.Component { `+styleTitle+` Preview - - + +