flight follow if one is selected in map; don't draw full map

This commit is contained in:
Nabeel Shahzad
2017-12-28 16:00:43 -06:00
parent 8e2ef409f9
commit e2ab6445d2
3 changed files with 26 additions and 9 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ class AcarsReplay extends Command
*/ */
protected function postUpdate($pirep_id, $data) protected function postUpdate($pirep_id, $data)
{ {
$uri = '/api/pirep/' . $pirep_id . '/acars'; $uri = '/api/pireps/' . $pirep_id . '/acars';
$upd = [ $upd = [
'log' => '', 'log' => '',
+6 -2
View File
@@ -174,7 +174,7 @@ class GeoService extends BaseService
{ {
$route_line = []; $route_line = [];
$route_points = []; $route_points = [];
$route_line[] = [$pirep->dpt_airport->lon, $pirep->dpt_airport->lat]; #$route_line[] = [$pirep->dpt_airport->lon, $pirep->dpt_airport->lat];
/** /**
* @var $point \App\Models\Acars * @var $point \App\Models\Acars
@@ -192,7 +192,7 @@ class GeoService extends BaseService
++$counter; ++$counter;
} }
# Arrival # Arrival
$route_line[] = [$pirep->arr_airport->lon, $pirep->arr_airport->lat]; #$route_line[] = [$pirep->arr_airport->lon, $pirep->arr_airport->lat];
$route_line = new Feature(new LineString($route_line)); $route_line = new Feature(new LineString($route_line));
return [ return [
@@ -217,6 +217,10 @@ class GeoService extends BaseService
* @var $point \App\Models\Acars * @var $point \App\Models\Acars
*/ */
$point = $pirep->position; $point = $pirep->position;
if(!$point) {
continue;
}
$flight_points[] = new Feature( $flight_points[] = new Feature(
new Point([$point->lon, $point->lat]), [ new Point([$point->lon, $point->lat]), [
'pirep_id' => $pirep->id, 'pirep_id' => $pirep->id,
+19 -6
View File
@@ -12,7 +12,9 @@ const phpvms = (function() {
opts = _.defaults(opts, { opts = _.defaults(opts, {
render_elem: 'map', render_elem: 'map',
zoom: 12, center: [29.98139, -95.33374],
zoom: 5,
maxZoom: 10,
layers: [], layers: [],
set_marker: false, set_marker: false,
}); });
@@ -59,6 +61,7 @@ const phpvms = (function() {
let map = L.map('map', { let map = L.map('map', {
layers: [openaip_basemap_phys_osm], layers: [openaip_basemap_phys_osm],
center: opts.center,
zoom: opts.zoom, zoom: opts.zoom,
scrollWheelZoom: false, scrollWheelZoom: false,
}); });
@@ -227,13 +230,14 @@ const phpvms = (function() {
const map = draw_base_map(opts); const map = draw_base_map(opts);
const aircraftIcon = L.icon({ const aircraftIcon = L.icon({
iconUrl: opts.aircraft_icon, iconUrl: opts.aircraft_icon,
iconSize: [48, 48], iconSize: [42, 42],
iconAnchor: [0, 0], iconAnchor: [21, 21],
popupAnchor: [-3, -76],
}); });
let layerFlights = null; let layerFlights = null;
let layerSelFlight = null; let layerSelFlight = null;
let layerSelFlightFeature = null;
let layerSelFlightLayer = null;
/** /**
* When a flight is clicked on, show the path, etc for that flight * When a flight is clicked on, show the path, etc for that flight
@@ -241,6 +245,7 @@ const phpvms = (function() {
* @param layer * @param layer
*/ */
const onFlightClick = (feature, layer) => { const onFlightClick = (feature, layer) => {
const uri = opts.pirep_uri.replace('{id}', feature.properties.pirep_id); const uri = opts.pirep_uri.replace('{id}', feature.properties.pirep_id);
console.log('flight check uri', uri); console.log('flight check uri', uri);
@@ -263,6 +268,9 @@ const phpvms = (function() {
}).addTo(map); }).addTo(map);
layerSelFlight.geoJson(routeJson.line); layerSelFlight.geoJson(routeJson.line);
layerSelFlightFeature = feature;
layerSelFlightLayer = layer;
//map.fitBounds(layerSelFlight.getBounds()); //map.fitBounds(layerSelFlight.getBounds());
}); });
}; };
@@ -312,12 +320,17 @@ const phpvms = (function() {
}); });
layerFlights.addTo(map); layerFlights.addTo(map);
map.fitBounds(layerFlights.getBounds());
if (layerSelFlight !== null) {
onFlightClick(layerSelFlightFeature, layerSelFlightLayer);
}
//map.fitBounds(layerFlights.getBounds());
//map.fitBounds('39.8283° N, 98.5795° W', 40);
}); });
}; };
updateMap(); updateMap();
setTimeout(updateMap, 10000); setInterval(updateMap, 10000);
}; };
return { return {