Avoid JS map crash on missing images

This commit is contained in:
Carl van Tonder 2018-06-18 15:28:16 -04:00
parent 4c71ba7a25
commit c1e8762287

View File

@ -144,9 +144,11 @@ 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%'>";
}
str += ("<div class='popup-head'>"+
"<h5>"+feature.properties.entry_name+"</h5>" + "<h5>"+feature.properties.entry_name+"</h5>" +
"<i>"+feature.properties.country_name+"</i>"+ "<i>"+feature.properties.country_name+"</i>"+
"</div>"+ "</div>"+
@ -154,8 +156,8 @@ function popup(feature, layer) {
"<span class='label label-default'>"+feature.properties.sector_of_economy+"</span> "+ "<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>"+ "<span class='label label-"+getLabelClass(feature.properties.positive_or_negative)+"'>"+ feature.properties.positive_or_negative_display+"</span>"+
"</div>"+ "</div>"+
"<a class='btn btn-sm btn-primary' href='case-study/"+feature.properties.slug+"'>{% trans "View full case study" %}</a>" "<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