Fix error with map centering on invalid layers #704

This commit is contained in:
Nabeel Shahzad
2020-05-19 17:41:55 -04:00
parent 3b1936e110
commit bcf7acf957
247 changed files with 8617 additions and 164 deletions

View File

@@ -4,6 +4,7 @@ import draw_base_map from './base_map';
import { ACTUAL_ROUTE_COLOR } from './config';
import request from '../request';
import {LatLng} from "leaflet/dist/leaflet-src.esm";
// const geolib = require('geolib');
const leaflet = require('leaflet');
@@ -36,6 +37,8 @@ export default (_opts) => {
iconAnchor: [21, 21],
});
const centerCoords = new LatLng(opts.center[0], opts.center[1]);
/**
* Hold the markers
* @type {{}}
@@ -187,7 +190,11 @@ export default (_opts) => {
// Center on active flights
// eslint-disable-next-line no-lonely-if
if (!pannedToFlight) {
map.panTo(layerFlights.getBounds().getCenter());
try {
map.panTo(layerFlights.getBounds().getCenter());
} catch (e) {
map.panTo(centerCoords);
}
}
}
});