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) {
|
function popup(feature, layer) {
|
||||||
layer.bindPopup(
|
var str = '';
|
||||||
"<img src='"+feature.properties.images[0].file+"' width='100%'>"+
|
if(feature.properties.images.length > 0) {
|
||||||
"<div class='popup-head'>"+
|
str = "<img src='"+feature.properties.images[0].file+"' width='100%'>";
|
||||||
"<h5>"+feature.properties.entry_name+"</h5>" +
|
}
|
||||||
"<i>"+feature.properties.country_name+"</i>"+
|
str += ("<div class='popup-head'>"+
|
||||||
"</div>"+
|
"<h5>"+feature.properties.entry_name+"</h5>" +
|
||||||
"<div class='popup-labels'>"+
|
"<i>"+feature.properties.country_name+"</i>"+
|
||||||
"<span class='label label-default'>"+feature.properties.sector_of_economy+"</span> "+
|
"</div>"+
|
||||||
"<span class='label label-"+getLabelClass(feature.properties.positive_or_negative)+"'>"+ feature.properties.positive_or_negative_display+"</span>"+
|
"<div class='popup-labels'>"+
|
||||||
"</div>"+
|
"<span class='label label-default'>"+feature.properties.sector_of_economy+"</span> "+
|
||||||
"<a class='btn btn-sm btn-primary' href='case-study/"+feature.properties.slug+"'>{% trans "View full case study" %}</a>"
|
"<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
|
// This is called when the map is initialized
|
||||||
|
Loading…
Reference in New Issue
Block a user