Avoid JS map crash on missing images
This commit is contained in:
parent
4c71ba7a25
commit
c1e8762287
@ -144,18 +144,20 @@ function getLabelClass(pos_or_neg) {
|
||||
}
|
||||
|
||||
function popup(feature, layer) {
|
||||
layer.bindPopup(
|
||||
"<img src='"+feature.properties.images[0].file+"' width='100%'>"+
|
||||
"<div class='popup-head'>"+
|
||||
"<h5>"+feature.properties.entry_name+"</h5>" +
|
||||
"<i>"+feature.properties.country_name+"</i>"+
|
||||
"</div>"+
|
||||
"<div class='popup-labels'>"+
|
||||
"<span class='label label-default'>"+feature.properties.sector_of_economy+"</span> "+
|
||||
"<span class='label label-"+getLabelClass(feature.properties.positive_or_negative)+"'>"+ feature.properties.positive_or_negative_display+"</span>"+
|
||||
"</div>"+
|
||||
"<a class='btn btn-sm btn-primary' href='case-study/"+feature.properties.slug+"'>{% trans "View full case study" %}</a>"
|
||||
);
|
||||
var str = '';
|
||||
if(feature.properties.images.length > 0) {
|
||||
str = "<img src='"+feature.properties.images[0].file+"' width='100%'>";
|
||||
}
|
||||
str += ("<div class='popup-head'>"+
|
||||
"<h5>"+feature.properties.entry_name+"</h5>" +
|
||||
"<i>"+feature.properties.country_name+"</i>"+
|
||||
"</div>"+
|
||||
"<div class='popup-labels'>"+
|
||||
"<span class='label label-default'>"+feature.properties.sector_of_economy+"</span> "+
|
||||
"<span class='label label-"+getLabelClass(feature.properties.positive_or_negative)+"'>"+ feature.properties.positive_or_negative_display+"</span>"+
|
||||
"</div>"+
|
||||
"<a class='btn btn-sm btn-primary' href='case-study/"+feature.properties.slug+"'>{% trans "View full case study" %}</a>")
|
||||
layer.bindPopup(str);
|
||||
};
|
||||
|
||||
// This is called when the map is initialized
|
||||
|
Loading…
Reference in New Issue
Block a user