Skip to content
This repository was archived by the owner on Dec 6, 2019. It is now read-only.

Commit e4c0b06

Browse files
Nabeel Shahzadnabeelio
authored andcommitted
Render the smartcars rawdata column in pirep map
1 parent 9c21175 commit e4c0b06

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

core/templates/route_map.tpl

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ if(isset($schedule))
6767
<script src="<?php echo SITE_URL?>/lib/js/base_map.js"></script>
6868
<script type="text/javascript">
6969
70-
// Convert the map data into JSON
70+
// Write the PIREP data out into JSON
71+
// The big reason being we don't need to have PHP writing JS - yuck
7172
const flight = JSON.parse('<?php echo json_encode($mapdata); ?>');
7273
console.log(flight);
7374
@@ -89,18 +90,27 @@ selArrMarker = L.marker(arrCoords, {
8990
let points = [];
9091
points.push(depCoords);
9192
92-
$.each(flight.route_details, function(i, nav) {
93-
const loc = L.latLng(nav.lat, nav.lng);
94-
const icon = (nav.type === 3) ? MapFeatures.icons.vor : MapFeatures.icons.fix;
95-
points.push(loc);
93+
// rendering for if there's smartcars data
94+
if(flight.rawdata instanceof Object && Array.isArray(flight.rawdata.points)) {
95+
console.log('using raw data');
96+
$.each(flight.rawdata.points, function(i, nav) {
97+
const loc = L.latLng(nav.lat, nav.lng);
98+
points.push(loc);
99+
});
100+
} else {
101+
$.each(flight.route_details, function(i, nav) {
102+
const loc = L.latLng(nav.lat, nav.lng);
103+
const icon = (nav.type === 3) ? MapFeatures.icons.vor : MapFeatures.icons.fix;
104+
points.push(loc);
96105
97-
const marker = L.marker(loc, {
98-
icon: icon,
99-
title: nav.title,
100-
})
101-
.bindPopup(tmpl("navpoint_bubble", { nav: nav }))
102-
.addTo(map);
103-
});
106+
const marker = L.marker(loc, {
107+
icon: icon,
108+
title: nav.title,
109+
})
110+
.bindPopup(tmpl("navpoint_bubble", { nav: nav }))
111+
.addTo(map);
112+
});
113+
}
104114
105115
points.push(arrCoords);
106116

lib/js/acarsmap.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ function renderAcarsMap(opts) {
107107

108108
selPoints.push(depCoords);
109109

110+
console.log(flight);
111+
110112
$.each(flight.route_details, function(i, nav) {
111113
const loc = L.latLng(nav.lat, nav.lng);
112114
const icon = (nav.type === 3) ? MapFeatures.icons.vor : MapFeatures.icons.fix;

0 commit comments

Comments
 (0)