mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Set 'map bounds' and 'global query' default to 'false' for indexed geojson layers * Add constants file * Clean up * Dynamically determine whether or not to filter by map bounds based upon docCount # Conflicts: # x-pack/legacy/plugins/maps/public/layers/sources/client_file_source/geojson_file_source.js # x-pack/legacy/plugins/maps/public/reducers/map.js
This commit is contained in:
parent
990347912b
commit
562cd0af6e
3 changed files with 32 additions and 10 deletions
|
@ -47,19 +47,21 @@ export class AddLayerPanel extends Component {
|
|||
return panelDescription;
|
||||
}
|
||||
|
||||
_viewLayer = async source => {
|
||||
_viewLayer = async (source, options = {}) => {
|
||||
if (!source) {
|
||||
this.setState({ layer: null });
|
||||
this.props.removeTransientLayer();
|
||||
return;
|
||||
}
|
||||
|
||||
const layerOptions = this.state.layer
|
||||
? { style: this.state.layer.getCurrentStyle().getDescriptor() }
|
||||
: {};
|
||||
const newLayer = source.createDefaultLayer(layerOptions, this.props.mapColors);
|
||||
this.setState({ layer: newLayer }, () =>
|
||||
this.props.viewLayer(this.state.layer));
|
||||
const layerInitProps = {
|
||||
...options,
|
||||
...(this.state.layer && { style: this.state.layer.getCurrentStyle().getDescriptor() })
|
||||
};
|
||||
const newLayer = source.createDefaultLayer(layerInitProps, this.props.mapColors);
|
||||
this.setState(
|
||||
{ layer: newLayer },
|
||||
() => this.props.viewLayer(this.state.layer)
|
||||
);
|
||||
};
|
||||
|
||||
_clearLayerData = ({ keepSourceType = false }) => {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const DEFAULT_APPLY_GLOBAL_QUERY = false;
|
|
@ -6,11 +6,18 @@
|
|||
|
||||
import { AbstractVectorSource } from '../vector_source';
|
||||
import React from 'react';
|
||||
import { ES_GEO_FIELD_TYPE, GEOJSON_FILE } from '../../../../../common/constants';
|
||||
import {
|
||||
ES_GEO_FIELD_TYPE,
|
||||
GEOJSON_FILE,
|
||||
ES_SIZE_LIMIT
|
||||
} from '../../../../../common/constants';
|
||||
import { ClientFileCreateSourceEditor } from './create_client_file_source_editor';
|
||||
import { ESSearchSource } from '../es_search_source';
|
||||
import uuid from 'uuid/v4';
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
DEFAULT_APPLY_GLOBAL_QUERY
|
||||
} from './constants';
|
||||
|
||||
export class GeojsonFileSource extends AbstractVectorSource {
|
||||
|
||||
|
@ -20,6 +27,9 @@ export class GeojsonFileSource extends AbstractVectorSource {
|
|||
static icon = 'importAction';
|
||||
static isIndexingSource = true;
|
||||
static isBeta = true;
|
||||
static layerDefaults = {
|
||||
applyGlobalQuery: DEFAULT_APPLY_GLOBAL_QUERY
|
||||
}
|
||||
|
||||
static createDescriptor(geoJson, name) {
|
||||
// Wrap feature as feature collection if needed
|
||||
|
@ -56,12 +66,15 @@ export class GeojsonFileSource extends AbstractVectorSource {
|
|||
if (!indexPatternId || !geoField) {
|
||||
addAndViewSource(null);
|
||||
} else {
|
||||
// Only turn on bounds filter for large doc counts
|
||||
const filterByMapBounds = indexDataResp.docCount > ES_SIZE_LIMIT;
|
||||
const source = new ESSearchSource({
|
||||
id: uuid(),
|
||||
indexPatternId,
|
||||
geoField,
|
||||
filterByMapBounds
|
||||
}, inspectorAdapters);
|
||||
addAndViewSource(source);
|
||||
addAndViewSource(source, this.layerDefaults);
|
||||
importSuccessHandler(indexResponses);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue