So I have a GeoJSON that I want to pull/filer/select all kitespots with a wind direction that includes "S" in Leaflet. (..and yes, am a beginner at coding..)
var kitespots = {
"type": "FeatureCollection",
"features":[
{
"type": "Feature",
"properties": {"name": "STUBBSAND", "windDirection": "S/SW"},
"geometry": {
"type": "Point",
"coordinates": [18.959655761718746, 63.220636696106915]}
},
{
"type": "Feature",
"properties": {"name": "GULLVIK", "windDirection": "SW/S/SE"},
"geometry": {
"type": "Point",
"coordinates": [ 18.82786273956299, 63.214932082292805]}
},
{
"type": "Feature",
"properties": {"name": "VANNVIKEN", "windDirection": "SE/S"},
"geometry": {
"type": "Point",
"coordinates": [18.815631866455078, 63.20794965080512]}
},
{
"type": "Feature",
"properties": {"name": "STORSANDEN", "windDirection": "N/NW"},
"geometry": {
"type": "Point",
"coordinates": [18.528785705566406, 62.99013053076868]}
}
]
}
So far I have tried;
// - Select all kitespots facing south - //
var southSpotCluster = new L.markerClusterGroup();
var windDirectionS = L.geoJson(kitespots,{windDirection: "S"});
southSpotCluster.addLayer(windDirectionS);
// - ...and.. - //
var southSpotCluster = L.geoJson(kitespots)
var windDirection = ["S"]
for(var windDirection in southSpotCluster){
windDirection.push(southSpotCluster["S"]);
}
southSpotCluster.addLayer(windDirection);
var overLays = {
'All Kitespots': allSpotsCluster,
'Kitespots S': southSpotCluster
};
L.control.layers(baseLayers, overLays).addTo(map);