Center on active flights #605 (#606)

This commit is contained in:
Nabeel S
2020-03-01 12:41:09 -05:00
committed by GitHub
parent a040e288de
commit 21e2e48a6e
7 changed files with 19 additions and 13 deletions

View File

@@ -1,3 +1,3 @@
export const PLAN_ROUTE_COLOR = '#d9ed53';
export const PLAN_ROUTE_COLOR = '#8B008B';
export const ACTUAL_ROUTE_COLOR = '#067ec1';
export const CIRCLE_COLOR = '#056093';

View File

@@ -41,7 +41,7 @@ export default (_opts) => {
* @type {{}}
*/
const markers_list = {};
let pannedToCenter = false;
let pannedToFlight = false;
let layerFlights = null;
let layerSelFlight = null;
let layerSelFlightFeature = null;
@@ -76,13 +76,13 @@ export default (_opts) => {
layerSelFlightLayer = layer;
// Center on it, but only do it once, in case the map is moved
if (!pannedToCenter) {
if (!pannedToFlight) {
map.panTo({
lat: route.position.lat,
lng: route.position.lon,
});
pannedToCenter = true;
pannedToFlight = true;
}
}
@@ -156,7 +156,7 @@ export default (_opts) => {
layer.on({
// eslint-disable-next-line no-unused-vars
click: (e) => {
pannedToCenter = false;
pannedToFlight = false;
liveMapController.controller.onFlightClick(feature, layer);
},
});
@@ -183,6 +183,12 @@ export default (_opts) => {
// Reload the clicked-flight information
if (layerSelFlight !== null) {
liveMapController.controller.onFlightClick(layerSelFlightFeature, layerSelFlightLayer);
} else {
// Center on active flights
// eslint-disable-next-line no-lonely-if
if (!pannedToFlight) {
map.panTo(layerFlights.getBounds().getCenter());
}
}
});
};