diff --git a/x-pack/plugins/maps/public/classes/layers/tiled_vector_layer/tiled_vector_layer.tsx b/x-pack/plugins/maps/public/classes/layers/tiled_vector_layer/tiled_vector_layer.tsx index 5916d90890981..880a47d0981cb 100644 --- a/x-pack/plugins/maps/public/classes/layers/tiled_vector_layer/tiled_vector_layer.tsx +++ b/x-pack/plugins/maps/public/classes/layers/tiled_vector_layer/tiled_vector_layer.tsx @@ -66,22 +66,22 @@ export class TiledVectorLayer extends VectorLayer { this._source = source as ITiledSingleLayerVectorSource; } - getMetaFromTiles(): TileMetaFeature[] { + _getMetaFromTiles(): TileMetaFeature[] { return this._descriptor.__metaFromTiles || []; } getCustomIconAndTooltipContent(): CustomIconAndTooltipContent { - const tileMetas = this.getMetaFromTiles(); + const tileMetas = this._getMetaFromTiles(); if (!tileMetas.length) { return NO_RESULTS_ICON_AND_TOOLTIPCONTENT; } - const totalFeatures: number = tileMetas.reduce((acc: number, tileMeta: Feature) => { + const totalFeaturesCount: number = tileMetas.reduce((acc: number, tileMeta: Feature) => { const count = tileMeta && tileMeta.properties ? tileMeta.properties[KBN_FEATURE_COUNT] : 0; return count + acc; }, 0); - if (totalFeatures === 0) { + if (totalFeaturesCount === 0) { return NO_RESULTS_ICON_AND_TOOLTIPCONTENT; } @@ -93,9 +93,17 @@ export class TiledVectorLayer extends VectorLayer { icon: this.getCurrentStyle().getIcon(), tooltipContent: isIncomplete ? i18n.translate('xpack.maps.tiles.resultsTrimmedMsg', { - defaultMessage: `Layer shows incomplete results`, + defaultMessage: `Results limited to {count} documents.`, + values: { + count: totalFeaturesCount, + }, }) - : null, + : i18n.translate('xpack.maps.tiles.resultsCompleteMsg', { + defaultMessage: `Found {count} documents.`, + values: { + count: totalFeaturesCount, + }, + }), areResultsTrimmed: isIncomplete, }; } @@ -340,7 +348,7 @@ export class TiledVectorLayer extends VectorLayer { return null; } - const metaFromTiles = this.getMetaFromTiles(); + const metaFromTiles = this._getMetaFromTiles(); return await style.pluckStyleMetaFromTileMeta(metaFromTiles); } } diff --git a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_color_property.test.tsx b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_color_property.test.tsx index f5266efbd983e..dfe358586cb94 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_color_property.test.tsx +++ b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_color_property.test.tsx @@ -642,7 +642,7 @@ test('Should read out ordinal type correctly', async () => { }); describe('renderDataMappingPopover', () => { - test('Switch toggle should be enabled', () => { + test('Should render OrdinalDataMappingPopover', () => { const colorStyle = makeProperty( { color: 'Blues', diff --git a/x-pack/plugins/maps/server/mvt/get_tile.ts b/x-pack/plugins/maps/server/mvt/get_tile.ts index 4eb49eeeb41f1..db9b4bab248a9 100644 --- a/x-pack/plugins/maps/server/mvt/get_tile.ts +++ b/x-pack/plugins/maps/server/mvt/get_tile.ts @@ -44,6 +44,9 @@ import { pluckRangeFieldMeta } from '../../common/pluck_range_field_meta'; import { FieldMeta, TileMetaFeature } from '../../common/descriptor_types'; import { pluckCategoryFieldMeta } from '../../common/pluck_category_field_meta'; +// heuristic. largest color-palette has 30 colors. 1 color is used for 'other'. +const TERM_COUNT = 30 - 1; + function isAbortError(error: Error) { return error.message === 'Request aborted' || error.message === 'Aborted'; } @@ -132,7 +135,7 @@ export async function getGridTile({ } }); - const categoryMeta = pluckCategoryFieldMeta(features, fieldName, 20); + const categoryMeta = pluckCategoryFieldMeta(features, fieldName, TERM_COUNT); if (!fieldMeta[fieldName]) { fieldMeta[fieldName] = {}; @@ -341,10 +344,18 @@ export async function getTile({ const fieldMeta: FieldMeta = {}; fieldNames.forEach((fieldName: string) => { + if ( + fieldName === '_index' || + fieldName === '_id' || + fieldName === FEATURE_ID_PROPERTY_NAME + ) { + return; + } + const rangeMeta = pluckRangeFieldMeta(features, fieldName, (rawValue: unknown) => { return typeof rawValue === 'number' ? rawValue : NaN; }); - const categoryMeta = pluckCategoryFieldMeta(features, fieldName, 20); + const categoryMeta = pluckCategoryFieldMeta(features, fieldName, TERM_COUNT); if (!fieldMeta[fieldName]) { fieldMeta[fieldName] = {}; diff --git a/x-pack/test/api_integration/apis/maps/get_tile.js b/x-pack/test/api_integration/apis/maps/get_tile.js index 2b50a4f65a190..03a16175931a5 100644 --- a/x-pack/test/api_integration/apis/maps/get_tile.js +++ b/x-pack/test/api_integration/apis/maps/get_tile.js @@ -56,7 +56,7 @@ export default function ({ getService }) { __kbn_metadata_feature__: true, __kbn_vector_shape_type_counts__: '{"POINT":2,"LINE":0,"POLYGON":0}', fieldMeta: - '{"machine.os.raw":{"categories":{"categories":[{"key":"ios","count":1},{"count":1}]}},"bytes":{"range":{"min":9252,"max":9583,"delta":331},"categories":{"categories":[{"key":9252,"count":1},{"key":9583,"count":1}]}},"_index":{"categories":{"categories":[{"key":"logstash-2015.09.20","count":2}]}},"_id":{"categories":{"categories":[{"key":"AU_x3_BsGFA8no6Qjjug","count":1},{"key":"AU_x3_g3GFA8no6QjkGu","count":1}]}},"__kbn__feature_id__":{"categories":{"categories":[{"key":"logstash-2015.09.20:AU_x3_BsGFA8no6Qjjug:0","count":1},{"key":"logstash-2015.09.20:AU_x3_g3GFA8no6QjkGu:0","count":1}]}}}', + '{"machine.os.raw":{"categories":{"categories":[{"key":"ios","count":1},{"count":1}]}},"bytes":{"range":{"min":9252,"max":9583,"delta":331},"categories":{"categories":[{"key":9252,"count":1},{"key":9583,"count":1}]}}}', }); expect(metadataFeature.loadGeometry()).to.eql([ [