fix js crash if advtrains wagons not present
This commit is contained in:
parent
be20dff27e
commit
1dd8d52639
@ -48,12 +48,14 @@ var TrainOverlay = L.LayerGroup.extend({
|
|||||||
//search for wagin in front (whatever "front" is...)
|
//search for wagin in front (whatever "front" is...)
|
||||||
var type;
|
var type;
|
||||||
var lowest_pos = 100;
|
var lowest_pos = 100;
|
||||||
train.wagons.forEach(function(w){
|
if (train.wagons){
|
||||||
if (w.pos_in_train < lowest_pos){
|
train.wagons.forEach(function(w){
|
||||||
lowest_pos = w.pos_in_train;
|
if (w.pos_in_train < lowest_pos){
|
||||||
type = w.type;
|
lowest_pos = w.pos_in_train;
|
||||||
}
|
type = w.type;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var Icon = L.icon({
|
var Icon = L.icon({
|
||||||
iconUrl: getTrainImageUrlForType(type),
|
iconUrl: getTrainImageUrlForType(type),
|
||||||
@ -71,11 +73,13 @@ var TrainOverlay = L.LayerGroup.extend({
|
|||||||
html += "<b>Line:</b> " + train.line + "<br>";
|
html += "<b>Line:</b> " + train.line + "<br>";
|
||||||
html += "<b>Velocity:</b> "+ Math.floor(train.velocity*10)/10 + "<br>";
|
html += "<b>Velocity:</b> "+ Math.floor(train.velocity*10)/10 + "<br>";
|
||||||
|
|
||||||
html += "<b>Composition: </b>";
|
if (train.wagons){
|
||||||
train.wagons.forEach(function(w){
|
html += "<b>Composition: </b>";
|
||||||
var iconUrl = getTrainImageUrlForType(w.type);
|
train.wagons.forEach(function(w){
|
||||||
html += "<img src='"+iconUrl+"'>";
|
var iconUrl = getTrainImageUrlForType(w.type);
|
||||||
});
|
html += "<img src='"+iconUrl+"'>";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
marker.bindPopup(html);
|
marker.bindPopup(html);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user