I have a geojson layer with a divIcon and now i want to change it. i have tried whit seticon but it does not work. How could i do it?
This is what I am trying:
papesjson.eachLayer(function(layer){
if (layer.feature.properties.estado == "BAJA"){
awesomeclase ="fa-circle-o-notch";
}
else if (layer.feature.properties.estado == "PENDIENTE REPOSICION"){
awesomeclase = "fa-plus";
}
else if (layer.feature.properties.estado == "RETIRADA"){
awesomeclase = "fa-times";
}
else {
awesomeclase = "fa-circle";
}
var myIcon = L.divIcon({
iconSize: new L.Point(50, 50),
//iconAnchor:[50, 50],
className: "divicon",
html:'<i id = "'+layer.feature.properties.codigo+'" class="fa ' + awesomeclase + '" style="color:'+ getColor(layer.feature.properties.modelo) + ';">'
});
layer.setIcon(myIcon);
});
Best Answer
not sure if this fits your use case, but you might be able to use
pointToLayer
when constructing the geojson