From 778c3f27728071e63b2c15bbcf581885fede75ef Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 1 Oct 2019 15:41:42 -0600 Subject: [PATCH] Set default visibility to true on injected data --- .../plugins/maps/public/layers/layer.js | 5 +- .../maps/public/layers/vector_layer.js | 49 ++++++++++++++----- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/x-pack/legacy/plugins/maps/public/layers/layer.js b/x-pack/legacy/plugins/maps/public/layers/layer.js index d50670b9efa56..c1e45d9b7c7a8 100644 --- a/x-pack/legacy/plugins/maps/public/layers/layer.js +++ b/x-pack/legacy/plugins/maps/public/layers/layer.js @@ -10,7 +10,10 @@ import turf from 'turf'; import turfBooleanContains from '@turf/boolean-contains'; import { DataRequest } from './util/data_request'; import { InjectedData } from './util/injected_data'; -import { MB_SOURCE_ID_LAYER_ID_PREFIX_DELIMITER, SOURCE_DATA_ID_ORIGIN } from '../../common/constants'; +import { + MB_SOURCE_ID_LAYER_ID_PREFIX_DELIMITER, + SOURCE_DATA_ID_ORIGIN +} from '../../common/constants'; import uuid from 'uuid/v4'; import { copyPersistentState } from '../reducers/util'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/legacy/plugins/maps/public/layers/vector_layer.js b/x-pack/legacy/plugins/maps/public/layers/vector_layer.js index 285fd388bc09e..9ab3c79603bb0 100644 --- a/x-pack/legacy/plugins/maps/public/layers/vector_layer.js +++ b/x-pack/legacy/plugins/maps/public/layers/vector_layer.js @@ -131,9 +131,21 @@ export class VectorLayer extends AbstractLayer { return true; } + getInjectedData() { + const featureCollection = super.getInjectedData(); + if (featureCollection) { + // Set default visible property on data + featureCollection.features.forEach( + feature => _.set(feature, `properties.${FEATURE_VISIBLE_PROPERTY_NAME}`, true) + ); + return featureCollection; + } else { + return null; + } + } + getCustomIconAndTooltipContent() { - const sourceDataRequest = this.getSourceDataRequest(); - const featureCollection = sourceDataRequest ? sourceDataRequest.getData() : null; + const featureCollection = this._getSourceFeatureCollection(); const noResultsIcon = (