refactoring of the systemjs file
This commit is contained in:
@@ -86,31 +86,23 @@ const phpvms = (function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param opts
|
* @param opts
|
||||||
|
* @private
|
||||||
*/
|
*/
|
||||||
render_route_map: (opts) => {
|
const _render_route_map = (opts) => {
|
||||||
|
|
||||||
opts = _.defaults(opts, {
|
opts = _.defaults(opts, {
|
||||||
route_points: null,
|
route_points: null,
|
||||||
planned_route_line: null, // [ {name, lat, lon}, {name, lat, lon} ];
|
planned_route_line: null,
|
||||||
actual_route_points: null,
|
actual_route_points: null,
|
||||||
actual_route_line: null,
|
actual_route_line: null,
|
||||||
center: [],
|
|
||||||
render_elem: 'map',
|
render_elem: 'map',
|
||||||
overlay_elem: '',
|
|
||||||
zoom: 5,
|
|
||||||
geodesic: true,
|
|
||||||
layers: [],
|
|
||||||
set_marker: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let map = draw_base_map(opts);
|
let map = draw_base_map(opts);
|
||||||
|
|
||||||
//if(opts.geodesic) {
|
|
||||||
let geodesicLayer = L.geodesic([], {
|
let geodesicLayer = L.geodesic([], {
|
||||||
weight: 7,
|
weight: 7,
|
||||||
opacity: 0.9,
|
opacity: 0.9,
|
||||||
@@ -122,40 +114,6 @@ const phpvms = (function() {
|
|||||||
geodesicLayer.geoJson(opts.planned_route_line);
|
geodesicLayer.geoJson(opts.planned_route_line);
|
||||||
map.fitBounds(geodesicLayer.getBounds());
|
map.fitBounds(geodesicLayer.getBounds());
|
||||||
|
|
||||||
if(opts.actual_route_line !== null) {
|
|
||||||
let geodesicLayer = L.geodesic([], {
|
|
||||||
weight: 7,
|
|
||||||
opacity: 0.9,
|
|
||||||
color: '#172aea',
|
|
||||||
steps: 50,
|
|
||||||
wrap: false,
|
|
||||||
}).addTo(map);
|
|
||||||
|
|
||||||
geodesicLayer.geoJson(opts.actual_route_line);
|
|
||||||
map.fitBounds(geodesicLayer.getBounds());
|
|
||||||
}
|
|
||||||
/*} else {
|
|
||||||
let route = L.geoJSON(opts.planned_route_line, {
|
|
||||||
"color": "#ff7800",
|
|
||||||
"weight": 7,
|
|
||||||
"opacity": 0.9
|
|
||||||
});
|
|
||||||
|
|
||||||
route.addTo(map);
|
|
||||||
map.fitBounds(route.getBounds());
|
|
||||||
|
|
||||||
if(opts.actual_route_line !== null) {
|
|
||||||
let route = L.geoJSON(opts.actual_route_line, {
|
|
||||||
"color": "#36b123",
|
|
||||||
"weight": 7,
|
|
||||||
"opacity": 0.9
|
|
||||||
});
|
|
||||||
|
|
||||||
route.addTo(map);
|
|
||||||
map.fitBounds(route.getBounds());
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Draw the route points after
|
// Draw the route points after
|
||||||
if (opts.route_points !== null) {
|
if (opts.route_points !== null) {
|
||||||
console.log(opts.route_points);
|
console.log(opts.route_points);
|
||||||
@@ -172,6 +130,22 @@ const phpvms = (function() {
|
|||||||
route_points.addTo(map);
|
route_points.addTo(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draw the actual route
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (opts.actual_route_line !== null) {
|
||||||
|
let geodesicLayer = L.geodesic([], {
|
||||||
|
weight: 7,
|
||||||
|
opacity: 0.9,
|
||||||
|
color: '#172aea',
|
||||||
|
steps: 50,
|
||||||
|
wrap: false,
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
|
geodesicLayer.geoJson(opts.actual_route_line);
|
||||||
|
map.fitBounds(geodesicLayer.getBounds());
|
||||||
|
}
|
||||||
|
|
||||||
if (opts.actual_route_points !== null) {
|
if (opts.actual_route_points !== null) {
|
||||||
let route_points = L.geoJSON(opts.actual_route_points, {
|
let route_points = L.geoJSON(opts.actual_route_points, {
|
||||||
@@ -186,14 +160,14 @@ const phpvms = (function() {
|
|||||||
|
|
||||||
route_points.addTo(map);
|
route_points.addTo(map);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render a map with the airspace, etc around a given set of coords
|
* Render a map with the airspace, etc around a given set of coords
|
||||||
* e.g, the airport map
|
* e.g, the airport map
|
||||||
* @param opts
|
* @param opts
|
||||||
*/
|
*/
|
||||||
render_airspace_map: (opts) => {
|
const _render_airspace_map = (opts) => {
|
||||||
opts = _.defaults(opts, {
|
opts = _.defaults(opts, {
|
||||||
render_elem: 'map',
|
render_elem: 'map',
|
||||||
overlay_elem: '',
|
overlay_elem: '',
|
||||||
@@ -214,6 +188,28 @@ const phpvms = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the live map
|
||||||
|
* @param opts
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
const _render_live_map = (opts) => {
|
||||||
|
opts = _.defaults(opts, {
|
||||||
|
route_points: null,
|
||||||
|
planned_route_line: null,
|
||||||
|
actual_route_points: null,
|
||||||
|
actual_route_line: null,
|
||||||
|
render_elem: 'map',
|
||||||
|
});
|
||||||
|
|
||||||
|
let map = draw_base_map(opts);
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
render_route_map: _render_route_map,
|
||||||
|
render_airspace_map: _render_airspace_map,
|
||||||
|
render_live_map: _render_live_map,
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user