From 9fef93103a1d2bc1ffc52c6ca4e9c0390aecdec4 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 10 May 2017 21:59:52 -0400 Subject: [PATCH] should not throw error when fitting on empty data (#11620) (#11710) --- src/ui/public/vis_maps/__tests__/geohash_layer.js | 14 ++++++++++++++ src/ui/public/vis_maps/kibana_map.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ui/public/vis_maps/__tests__/geohash_layer.js b/src/ui/public/vis_maps/__tests__/geohash_layer.js index 9502107253aace..135410321ba899 100644 --- a/src/ui/public/vis_maps/__tests__/geohash_layer.js +++ b/src/ui/public/vis_maps/__tests__/geohash_layer.js @@ -483,6 +483,20 @@ describe('kibana_map tests', function () { }); + it('should not throw when fitting on empty-data layer', function () { + + const geohashLayer = new GeohashLayer({ + type: 'FeatureCollection', + features: [] + }, { 'mapType': 'Scaled Circle Markers' }, kibanaMap.getZoomLevel(), kibanaMap); + kibanaMap.addLayer(geohashLayer); + + expect(() => { + kibanaMap.fitToData(); + }).to.not.throwException(); + }); + + }); }); diff --git a/src/ui/public/vis_maps/kibana_map.js b/src/ui/public/vis_maps/kibana_map.js index 6139ea248bc27a..2d8e9cc4cf9411 100644 --- a/src/ui/public/vis_maps/kibana_map.js +++ b/src/ui/public/vis_maps/kibana_map.js @@ -473,7 +473,7 @@ class KibanaMap extends EventEmitter { } }); - if (bounds) { + if (bounds && bounds.isValid()) { this._leafletMap.fitBounds(bounds); } }