From 1fc11fb0cc8bade149fa1724aa1fc33d95b772ce Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 25 Mar 2020 23:14:47 -0700 Subject: Fix issues with no devices --- modern/src/MainMap.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'modern/src') diff --git a/modern/src/MainMap.js b/modern/src/MainMap.js index 01230da..aea6dd8 100644 --- a/modern/src/MainMap.js +++ b/modern/src/MainMap.js @@ -116,14 +116,17 @@ class MainMap extends Component { this.map.addControl(new mapboxgl.NavigationControl()); - this.map.fitBounds(this.calculateBounds(), { - padding: 100, - maxZoom: 9 - }); + const bounds = this.calculateBounds(); + if (bounds) { + this.map.fitBounds(bounds, { + padding: 100, + maxZoom: 9 + }); + } } calculateBounds() { - if (this.props.data.features) { + if (this.props.data.features && this.props.data.features.length) { const first = this.props.data.features[0].geometry.coordinates; const bounds = [[...first], [...first]]; for (let feature of this.props.data.features) { @@ -142,7 +145,7 @@ class MainMap extends Component { } return bounds; } else { - return [[0, 0], [0, 0]]; + return null; } } -- cgit v1.2.3