aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-03-25 23:14:47 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-03-25 23:14:47 -0700
commit1fc11fb0cc8bade149fa1724aa1fc33d95b772ce (patch)
tree6a0131ed401f6abebf05496f64eca1ce56c08e4a /modern/src
parent6bee8cb1944677f8c3ede0a0bf799c92b86e08a0 (diff)
downloadetbsa-traccar-web-1fc11fb0cc8bade149fa1724aa1fc33d95b772ce.tar.gz
etbsa-traccar-web-1fc11fb0cc8bade149fa1724aa1fc33d95b772ce.tar.bz2
etbsa-traccar-web-1fc11fb0cc8bade149fa1724aa1fc33d95b772ce.zip
Fix issues with no devices
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/MainMap.js15
1 files changed, 9 insertions, 6 deletions
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;
}
}