L.RotatedMarker = L.Marker.extend({ options : { angle : 0 }, _setPos : function(pos) { L.Marker.prototype._setPos.call(this, pos); if (L.DomUtil.TRANSFORM) { // use the CSS transform rule if available this._icon.style[L.DomUtil.TRANSFORM] += ' rotate(' + this.options.angle + 'deg)'; } else if (L.Browser.ie) { // fallback for IE6, IE7, IE8 var rad = this.options.angle * (Math.PI / 180), costheta = Math.cos(rad), sintheta = Math.sin(rad); this._icon.style.filter += ' progid:DXImageTransform.Microsoft.Matrix(sizingMethod=\'auto expand\', M11=' + costheta + ', M12=' + (-sintheta) + ', M21=' + sintheta + ', M22=' + costheta + ')'; } }, initialize: function(latlng,options) { L.Marker.prototype.initialize(latlng,options); if( options ) L.Util.setOptions(this,options); }, }); L.rotatedMarker = function(pos,options) { return new L.RotatedMarker(pos,options); } L.AircraftMarker = L.RotatedMarker.extend({ options : { angle : 0, clickable: false, keyboard: false, getProperties:function() { return {}; }, icon : L.divIcon({ iconSize : [ 60, 60 ], iconAnchor : [ 30, 30 ], className: 'aircraft-marker-icon', html: '', }), zIndexOffset : 10000, updateInterval: 100, }, initialize: function(latlng,options) { L.RotatedMarker.prototype.initialize(latlng,options); L.Util.setOptions(this,options); }, onAdd: function( map ) { L.RotatedMarker.prototype.onAdd.call(this,map); this.popup = L.popup( { autoPan: false, keepInView: false, closeButton: false, className: 'aircraft-marker-popup', closeOnClick: false, maxWidth: 200, minWidth: 100, offset: [30,30], }, this ); this.popup.setContent(""); this.bindPopup( this.popup ); this.addTo(this._map); this.openPopup(); this.timeout(); }, onRemove: function( map ) { if( this.timeoutid != null ) clearTimeout(this.timeoutid); L.RotatedMarker.prototype.onRemove.call(this,map); }, timeoutid: null, timeout: function() { var props = this.options.getProperties.call(this); var popup = '
' + props.callsign + '
' + '
' + props.model + '
' + '
' + props.altitude + '
' + '
' + props.speed + '
'; this.popup.setContent(popup); this.options.angle = props.heading; // this.options.title = props.callsign + ' Heading ' + props.heading + '°'; // this.options.alt = this.options.title; this.setLatLng( props.position ); var that = this; this.timeoutid = setTimeout( function() { that.timeout(); }, this.options.updateInterval ); }, }); L.aircraftMarker = function(latlng,options) { return new L.AircraftMarker(latlng,options); }