1
0
forked from MTSR/mapserver

working train signals

This commit is contained in:
Thomas Rudin 2019-07-27 14:28:07 +02:00
parent 16a4fff708
commit 5a383eaae1
4 changed files with 23 additions and 9 deletions

View File

@ -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/)

View File

@ -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 = "<b>Signal</b><hr>";
html += "<b>State:</b> " + signal.green + "<br>";
html += "<b>State:</b> " +
(signal.green ? "Green" : "Red") +
"<br>";
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB