layer = {
const style = {
"color": "crimson",
"weight": 5,
"opacity": 0.65
};
function onEachFeature(feature, layer) {
if (feature.properties && feature.properties.tags && feature.properties.tags.name) {
layer.bindPopup(feature.properties.tags.name);
} else {
layer.bindPopup(feature.properties.type + " id: " + feature.properties.id)
}
}
const layer = L.geoJSON([geojson], {
style: style,
onEachFeature: onEachFeature,
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, {
radius: 4,
fillColor: "blue",
stroke: "black",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.5
});
}
}).addTo(map);
map.fitBounds(layer.getBounds(), {padding: [20, 20]});
invalidation.then(() => map.removeLayer(layer));
return layer
}