From 5a383eaae1e73776f0253744302faa771d6e3f7a Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Sat, 27 Jul 2019 14:28:07 +0200 Subject: [PATCH] working train signals --- doc/license.md | 2 ++ static/js/overlays/TrainsignalOverlay.js | 30 ++++++++++++------ .../pics/advtrains/advtrains_signal_off.png | Bin 0 -> 856 bytes static/pics/advtrains/advtrains_signal_on.png | Bin 0 -> 2585 bytes 4 files changed, 23 insertions(+), 9 deletions(-) create mode 100755 static/pics/advtrains/advtrains_signal_off.png create mode 100755 static/pics/advtrains/advtrains_signal_on.png diff --git a/doc/license.md b/doc/license.md index 83cc8ff..c40f38b 100644 --- a/doc/license.md +++ b/doc/license.md @@ -48,6 +48,8 @@ * advtrains_wagon_japan_inv.png * advtrains_wagon_tank_inv.png * advtrains_wagon_wood_inv.png +* advtrains_signal_on.png +* advtrains_signal_off.png * License: CC BY-SA 3.0 * Source [advtrains](http://advtrains.bleipb.de/) diff --git a/static/js/overlays/TrainsignalOverlay.js b/static/js/overlays/TrainsignalOverlay.js index 566f9c8..186d9f9 100644 --- a/static/js/overlays/TrainsignalOverlay.js +++ b/static/js/overlays/TrainsignalOverlay.js @@ -1,4 +1,20 @@ +var IconOn = L.icon({ + iconUrl: "pics/advtrains/advtrains_signal_on.png", + iconSize: [16, 16], + iconAnchor: [8, 8], + popupAnchor: [0, -16] +}); + +var IconOff = L.icon({ + iconUrl: "pics/advtrains/advtrains_signal_off.png", + iconSize: [16, 16], + iconAnchor: [8, 8], + popupAnchor: [0, -16] +}); + + + export default L.LayerGroup.extend({ initialize: function(wsChannel, layerMgr) { L.LayerGroup.prototype.initialize.call(this); @@ -20,7 +36,9 @@ export default L.LayerGroup.extend({ createPopup: function(signal){ var html = "Signal
"; - html += "State: " + signal.green + "
"; + html += "State: " + + (signal.green ? "Green" : "Red") + + "
"; return html; }, @@ -35,14 +53,7 @@ export default L.LayerGroup.extend({ createMarker: function(signal){ - var Icon = L.icon({ - iconUrl: "TODO", - - iconSize: [16, 16], - iconAnchor: [8, 8], - popupAnchor: [0, -16] - }); - + var Icon = signal.green ? IconOn : IconOff; var marker = L.marker([signal.pos.z, signal.pos.x], {icon: Icon}); marker.bindPopup(this.createPopup(signal)); @@ -84,6 +95,7 @@ export default L.LayerGroup.extend({ let marker = this.currentObjects[signalId]; marker.setLatLng([signal.pos.z, signal.pos.x]); marker.setPopupContent(this.createPopup(signal)); + marker.setIcon(signal.green ? IconOn : IconOff); } else { //marker does not exist diff --git a/static/pics/advtrains/advtrains_signal_off.png b/static/pics/advtrains/advtrains_signal_off.png new file mode 100755 index 0000000000000000000000000000000000000000..ed64ed91127a3b3efd5d1ff285f1c32262d8713c GIT binary patch literal 856 zcmV-e1E>6nP)p)u3UZ+ZiNqp6fJpIN&##EW1g2;-uZo(^>lh1 z;2!W6z;Rrpl=TcJjMo?!P%0G(!;orNu6kZ(zIMJ$upxkn|3;D(5JDt&DQml|UEd45 zPp8Mb8vy{Qy<`m*o=E%ZpqnmC%4UCr&bRe3(JoX=r0-Yf8T;ipW<&?&Q`uTPjfiHi28qi`agd zD2nQ&RGR>#l$fa$BYt_CmI|2oyl+n!B|Qb-QI)AxZeD&h842e6-?8_FidRQWoYOazV8zRerFX>N|DR0VOiF;F-_BPoF0N8XgVjF zybBbz?Ii9rl}aI{wx6o#;0g#KaU2)d?O}6sgE)>6LJ)=(48uUvwD$f5e=FUcVbFC0 z$I&Ph3IN!))3EYs?{!>N!*zT1d?R!epjF3>05sayVx`CnfvP@SRih+Sz$X;XQiEMz zTJ>%i#!L|Sr+_oSIiR@jn)%xGo0DNBdIyL|g#XYZLZpz`y1VW9C8dn=`K`}F2m@HD iD*SkM_QPB~AAbNlstT339~rCw0000 zaB^>EX>4U6ba`-PAZ2)IW&i+q+O1b|{Ld+Jgccwnjw81Ba)TT{C5)Gu@qAn2 zes0=o7O6@qaG3x6y~1Dk#FTT$TvV#ag-@=zM#F<%x6iGmEARXM#PbTjKiI?LMT9A# zO}C#iPk)1*p94xh_V&>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