From 79cf519b6fa97916cf19699328aacf073eac47da Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Fri, 7 Aug 2015 14:17:05 +0200 Subject: [PATCH] Phi: map improvements - make the AircraftMarker CSS style-able - assing individual styles to AI, multiplayer and own aircraft --- Phi/topics/Map/AILayer.js | 13 ++++++++++-- Phi/widgets/AircraftMarker.html | 1 - Phi/widgets/map.html | 32 +++++++++++++++++++++++++++++- Phi/widgets/map.js | 35 ++++++++++++++++----------------- 4 files changed, 59 insertions(+), 22 deletions(-) diff --git a/Phi/topics/Map/AILayer.js b/Phi/topics/Map/AILayer.js index 0f3eb2ceb..1c9240e9b 100644 --- a/Phi/topics/Map/AILayer.js +++ b/Phi/topics/Map/AILayer.js @@ -10,6 +10,15 @@ } }(function(ko, leaflet, SGPropertyNode ) { + var AITypeToCssClassMap = { + aircraft: "ai-aircraft-marker-icon", + multiplayer: "mp-aircraft-marker-icon" + } + + function formatFL(num) { + return "F" + ("000" + (num/100).toFixed(0)).substr(-3,3); + } + function ViewModel(h,l1,l2) { var self = this; @@ -29,8 +38,8 @@ if (feature.properties.type == "aircraft" || feature.properties.type == "multiplayer") { var l1 = feature.properties.callsign, l2 = feature.properties.heading + 'T ' + feature.properties.speed + 'KTAS ' + - 'F' + (feature.geometry.coordinates[2]/100).toFixed(0); - var m = L.aircraftMarker(latlng); + formatFL(feature.geometry.coordinates[2]); + var m = L.aircraftMarker(latlng, { className: AITypeToCssClassMap[feature.properties.type] } ); m.on('add', function(e) { ko.applyBindings( new ViewModel(feature.properties.heading,l1,l2), e.target._icon); }); diff --git a/Phi/widgets/AircraftMarker.html b/Phi/widgets/AircraftMarker.html index 794cd2d5b..6864799cc 100644 --- a/Phi/widgets/AircraftMarker.html +++ b/Phi/widgets/AircraftMarker.html @@ -1,7 +1,6 @@
', - }), - zIndexOffset : 10000, - updateInterval : 100, - }, - - initialize : function(latlng, options) { - L.Marker.prototype.initialize(latlng, options); - L.Util.setOptions(this, options); + })); }, }); @@ -129,7 +128,7 @@ define( L.control.scale(params.scale).addTo(self.map); } - var aircraftMarker = L.aircraftMarker(self.map.getCenter()); + var aircraftMarker = L.aircraftMarker(self.map.getCenter(), { className: 'you-aircraft-marker-icon' }); aircraftMarker.addTo(self.map);