mercredi 2 décembre 2015

Remove "null" attributes in Leaflet popups with an if-statement

I am using external geojson attributes to fill my popup windows in Leaflet, like this:

function popUp (feature, geojson) {
var popupText=
"/*Name:*/" + feature.properties.name  + 
"/*Amount*/" + feature.properties.amounts;
geojson.bindPopup(popupText);
};

The problem: some of the amounts are "null". So, how do I write an if statement, so that if an amount is "null" then both the string ("Amount") and the attribute ("null") don't show up in the popup?

Aucun commentaire:

Enregistrer un commentaire