@@ -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
7172const flight = JSON .parse (' <?php echo json_encode($mapdata); ?>' );
7273console .log (flight);
7374
@@ -89,18 +90,27 @@ selArrMarker = L.marker(arrCoords, {
8990let points = [];
9091points .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
105115points .push (arrCoords);
106116
0 commit comments