Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

update code to use identifier flags from config #2144

Benjamin King31a2da779291
diff --git a/web/js/modules/vector-styles/selectors.js b/web/js/modules/vector-styles/selectors.js
index 87d0fce2f..7ab25b09d 100644
--- a/web/js/modules/vector-styles/selectors.js
+++ b/web/js/modules/vector-styles/selectors.js
@@ -142,12 +142,11 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
} else if (glStyle.name === 'SEDAC' &&
((selected[layerId] && selected[layerId].length))) {
const selectedFeatures = selected[layerId];
+
layer.setStyle(function (feature, resolution) {
const data = state.config.vectorData[def.vectorData.id];
- const properties = data.mvt_properties;
- const titleKey = lodashFind(properties, { Function: 'Identify' })['Identifier'];
- const id = feature.getProperties()[titleKey];
- if (selectedFeatures && selectedFeatures.includes(id)) {
+ const features = feature.getProperties();
+ if (def.uniqueIdenitifier && selectedFeatures && selectedFeatures.includes(features[def.uniqueIdenitifier])) {
return selectedStyleFunction(feature, styleFunction(feature, resolution));
} else {
return styleFunction(feature, resolution);
diff --git a/web/js/modules/vector-styles/util.js b/web/js/modules/vector-styles/util.js
index 488048966..d2033979a 100644
--- a/web/js/modules/vector-styles/util.js
+++ b/web/js/modules/vector-styles/util.js
@@ -103,7 +103,6 @@ export function onMapClickGetVectorFeatures(e, map, store) {
map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
const def = lodashGet(layer, 'wv.def');
if (!def) return;
-
if (def.vectorData && def.vectorData.id && def.title) {
const layerId = def.id;
if (!selected[layerId]) selected[layerId] = [];
@@ -112,6 +111,7 @@ export function onMapClickGetVectorFeatures(e, map, store) {
const data = config.vectorData[vectorDataId];
const properties = data.mvt_properties;
const titleKey = lodashFind(properties, { Function: 'Identify' })['Identifier'];
+ const featureId = features[def.uniqueIdenitifier];
const title = features[titleKey];
if (selected[layerId].includes(title)) return
const obj = {
@@ -122,7 +122,7 @@ export function onMapClickGetVectorFeatures(e, map, store) {
featureTitle: title
};
metaArray.push(obj);
- selected[layerId].push(title);
+ selected[layerId].push(featureId);
}
});