I am advised to reference my layers as variables rather than as functions, so I can order the layers using .bringtofront.
I have tried several combinations of var skull = L.geoJSON(fatalities)etc.) but everything I have tried simply causes all the layers to vanish from the map.
Here's the map: https://pdxcyclesafetymap.neocities.org/
And here's the .js for one of the layers, as it works now:
var skull = L.icon({
iconUrl: 'images/blackSkull.svg',
iconSize: [38, 95],
popupAnchor: [-10, -30],
});
function fatalitiesLayer (feature,
layer) {
layer.bindPopup("<h1>Cyclist Fatality</h1><p> "+feature.properties.name+
"</p>"+feature.properties.description+
"</p>Date: "+feature.properties.date+
"</p>Location: "+feature.properties.location+
"</p>Cause: "+feature.properties.cause+
"</p>");
layer.setIcon(skull);
}
L.geoJson(fatalities,{
onEachFeature: fatalitiesLayer
}).addTo(map);
pointToLayer
- here's a nice example linkL.featureGroup()
for each layer type(skulls, hazards etc) and than add the layers to each featureGroup by example:skulls.layerAdd(layer)
in theonEachFeature
function? By that you will create a featureGroup for each accident type (a collection of layers is featureGroup