Skip to content

Commit

Permalink
fixing maps bounding box filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar authored and thomasneirynck committed Jul 4, 2017
1 parent 5eac36d commit 8d61033
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions src/core_plugins/tile_map/public/maps_visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import 'ui/vislib';
import 'plugins/kbn_vislib_vis_types/controls/vislib_basic_options';
import $ from 'jquery';
import _ from 'lodash';
import { FilterBarPushFilterProvider } from 'ui/filter_bar/push_filter';
import { KibanaMap } from './kibana_map';
import { GeohashLayer } from './geohash_layer';
import './lib/service_settings';
import './styles/_tilemap.less';


export function MapsVisualizationProvider(Private, serviceSettings, Notifier, getAppState) {
export function MapsVisualizationProvider(serviceSettings, Notifier, getAppState) {

const notify = new Notifier({ location: 'Coordinate Map' });

Expand Down Expand Up @@ -105,10 +104,10 @@ export function MapsVisualizationProvider(Private, serviceSettings, Notifier, ge


this._kibanaMap.on('drawCreated:rectangle', event => {
addSpatialFilter(_.get(this._chartData, 'geohashGridAgg'), 'geo_bounding_box', event.bounds);
this.addSpatialFilter(_.get(this._chartData, 'geohashGridAgg'), 'geo_bounding_box', event.bounds);
});
this._kibanaMap.on('drawCreated:polygon', event => {
addSpatialFilter(_.get(this._chartData, 'geohashGridAgg'), 'geo_polygon', { points: event.points });
this.addSpatialFilter(_.get(this._chartData, 'geohashGridAgg'), 'geo_polygon', { points: event.points });
});
this._kibanaMap.on('baseLayer:loaded', () => {
this._baseLayerDirty = false;
Expand Down Expand Up @@ -237,24 +236,25 @@ export function MapsVisualizationProvider(Private, serviceSettings, Notifier, ge
}
}

}
addSpatialFilter(agg, filterName, filterData) {
if (!agg) {
return;
}

function addSpatialFilter(agg, filterName, filterData) {
if (!agg) {
return;
const indexPatternName = agg.vis.indexPattern.id;
const field = agg.fieldName();
const filter = { meta: { negate: false, index: indexPatternName } };
filter[filterName] = { ignore_unmapped: true };
filter[filterName][field] = filterData;
getAppState().filters.push(filter);
this.vis.updateState();
}

const indexPatternName = agg.vis.indexPattern.id;
const field = agg.fieldName();
const filter = {};
filter[filterName] = { ignore_unmapped: true };
filter[filterName][field] = filterData;

const putFilter = Private(FilterBarPushFilterProvider)(getAppState());
return putFilter(filter, false, indexPatternName);
}




return MapsVisualization;
}

4 changes: 2 additions & 2 deletions src/ui/public/visualize/visualize.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ uiModules
const requestHandler = getHandler(requestHandlers, $scope.vis.type.requestHandler);
const responseHandler = getHandler(responseHandlers, $scope.vis.type.responseHandler);

$scope.fetch = function () {
$scope.fetch = _.debounce(function () {
// searchSource is only there for courier request handler
requestHandler($scope.vis, $scope.appState, $scope.uiState, $scope.savedObj.searchSource)
.then(resp => responseHandler($scope.vis, resp), e => {
Expand All @@ -71,7 +71,7 @@ uiModules
$scope.$broadcast('render');
return resp;
});
};
}, 100);

$scope.vis.on('update', () => {
if ($scope.editorMode) {
Expand Down

0 comments on commit 8d61033

Please sign in to comment.