I'm trying to add a GeoJSON polygon layer from a file, give it a specific style and show the label (ToolTip) but couldn't find a way to do it in a single function call . I only found different code samples doing each task alone (styling data or showing labels), then I mixed both codes and got something weird, it just created another layer on top of the previous one.
var geojson = L.geoJSON(myGeoJson);
L.geoJson(myGeoJson,{
onEachFeature: function (feature, layer) {
layer.bindTooltip(feature.properties.CASOS.toString(), {permanent: true}).openTooltip();
}
}).addTo(map)
L.geoJSON(myGeoJson, {
style: myStyle
}).addTo(map);
How could I show labels and style the polygons without creating a stack of layers?
EDIT: I edited the question because I think I was unclear, I want to style the data, not the labels.