diff options
author | ditoaugusta <dt_ap@ymail.com> | 2020-03-27 18:30:47 +0700 |
---|---|---|
committer | ditoaugusta <dt_ap@ymail.com> | 2020-03-27 18:30:47 +0700 |
commit | 114604e02eea84d3de78fb340f1c91c72b46e904 (patch) | |
tree | 8ef061009cd1823ccadd06d28113c254dde0ec5a /modern/src/MainMap.js | |
parent | 8bef4f04c2b0b203450fe5753b6109a0b0d04e82 (diff) | |
parent | 79c36b9a84623fb99db0ab71cc9a31391f06489e (diff) | |
download | trackermap-web-114604e02eea84d3de78fb340f1c91c72b46e904.tar.gz trackermap-web-114604e02eea84d3de78fb340f1c91c72b46e904.tar.bz2 trackermap-web-114604e02eea84d3de78fb340f1c91c72b46e904.zip |
Merge branch 'master' of https://github.com/traccar/traccar-web into experimental/hooks
Diffstat (limited to 'modern/src/MainMap.js')
-rw-r--r-- | modern/src/MainMap.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/modern/src/MainMap.js b/modern/src/MainMap.js index 01230da9..aea6dd89 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; } } |