@@ -67,67 +67,49 @@ 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
71+ const flight = JSON .parse (' <?php echo json_encode($mapdata); ?>' );
72+ console .log (flight);
73+
7074const map = createMap ({
7175 render_elem: ' routemap' ,
7276 provider: ' <?php echo Config::Get("MAP_TYPE"); ?>' ,
7377} );
7478
75- const depCoords = L .latLng (< ? php echo $mapdata - > deplat? > , < ? php echo $mapdata - > deplng; ? > );
76- const depMarker = L .marker (depCoords, {
79+ const depCoords = L .latLng (flight . deplat , flight . deplng );
80+ selDepMarker = L .marker (depCoords, {
7781 icon: MapFeatures.icons.departure,
78- } ).bindPopup (" <?php echo $mapdata-> depname;?> " ).addTo (map);
82+ } ).bindPopup (flight . depname ).addTo (map);
7983
80- const arrCoords = L .latLng (< ? php echo $mapdata - > arrlat? > , < ? php echo $mapdata - > arrlng; ? > );
81- const arrMarker = L .marker (arrCoords, {
84+ const arrCoords = L .latLng (flight . arrlat , flight . arrlng );
85+ selArrMarker = L .marker (arrCoords, {
8286 icon: MapFeatures.icons.arrival,
83- } ).bindPopup (" <?php echo $mapdata-> arrname;?> " ).addTo (map);
87+ } ).bindPopup (flight . arrname ).addTo (map);
8488
85- // for drawing the line
8689let points = [];
8790points .push (depCoords);
8891
89- < ? php
90- if (is_array ($mapdata- > route_details)) {
91- foreach ($mapdata -> route_details as $route ) {
92- if ($route -> type == NAV_VOR)
93- $icon = ' MapFeatures.icons.vor' ;
94- else
95- $icon = ' MapFeatures.icons.fix' ;
96-
97- // Build info array for the bubble
98- ?>
99- const v< ?php echo $route -> name ?> _info = {
100- freq: " <?php echo $route->freq ?>" ,
101- name: " <?php echo $route->name ?>" ,
102- title: " <?php echo $route->title ?>" ,
103- type: " <?php echo $route->type ?>" ,
104- lat: " <?php echo $route->lat ?>" ,
105- lng: " <?php echo $route->lng ?>"
106- } ;
107-
108- const < ?php echo $route -> name ?> _point = L.latLng(< ?php echo $route -> lat ?> , < ?php echo $route -> lng ?> );
109- points.push(< ?php echo $route -> name ?> _point);
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);
11096
111- L.marker(< ?php echo $ route -> name ? > _point , {
112- icon: < ?php echo $ icon ? > ,
113- title: " <?php echo $route-> title; ?> " ,
97+ const marker = L.marker(loc , {
98+ icon: icon,
99+ title: nav. title,
114100 } )
115- .bindPopup(tmpl(" navpoint_bubble" , { nav: v < ?php echo $ route -> name ? > _info } ))
101+ .bindPopup(tmpl(" navpoint_bubble" , { nav: nav } ))
116102 .addTo(map);
117- < ?php
118- }
119- }
120- ? >
103+ } );
121104
122105points .push (arrCoords);
123106
124- const geodesicLayer = L .geodesic ([points], {
125- weight: 3 ,
107+ const selPointsLayer = L .geodesic ([points], {
108+ weight: 2 ,
126109 opacity: 0.5,
127110 color: ' black' ,
128111 steps: 10
129112} ).addTo (map);
130113
131- map .fitBounds (geodesicLayer .getBounds ());
132-
114+ map .fitBounds (selPointsLayer .getBounds ());
133115 </script >
0 commit comments