1
0
Fork 0
fgdata/Phi/widgets/AircraftMarker.js
Torsten Dreyer 2812cc6321 Phi: refactor some map marker
- better aircraft marker symbol
- aircraft symbol loaded from file, no longer hardcoded
- marker as knockout component
2015-07-30 21:03:06 +02:00

41 lines
1.2 KiB
JavaScript

define([
'jquery', 'knockout', 'text!./AircraftMarker.html', 'text!../images/aircraft.svg'
], function(jquery, ko, htmlString, aircraftSvgFileContent ) {
// extract root element which should be <svg> from image xml (strip pi) and convert to string
// what an easy way to make Safari happy :-P
var iconSvgString = jquery('<div>') // wrap into detached <div> to get it's innerHTML
.append(
jquery( aircraftSvgFileContent ) // parse the file content
.filter(":first")[0]) // get root element
.html();
function ViewModel(params) {
var self = this;
self.iconSvg = iconSvgString;
self.rotate = 0;
self.label = [];
if( params && params.rotate ) {
self.rotate = params.rotate;
}
if( params && params.label ) {
self.label = params.label;
}
self.transformCss = function() {
return 'rotate(' + ko.unwrap(self.rotate) + 'deg)';
}
}
// ViewModel.prototype.dispose = function() {
// }
// Return component definition
return {
viewModel : ViewModel,
template : htmlString
};
});