Fix error with map centering on invalid layers #704
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user