I have the following code, which is loading in the full JSON file.
$.getJSON("data/Data1.json", function (data) {
currentStatus.addData(data);
map.addLayer(currentStatusLayer);
});
What I am trying to do is filter the JSON file, but am struggling to get only the filtered value from the JSON data record.
What I am trying to get is the record which has 'Status: Watch'.
Here is my code below:
$.getJSON("data/Data1.json", function (data) {
currentStatus = data.features.filter(function(feature) {
return feature.status === 'Watch';
});
currentStatus.addData(data);
map.addLayer(currentStatusLayer);
});
Trimmed down JSON data file:
[
{
"type": "Feature",
"id": 0,
"status": "watch",
"properties": {
"NAME": "Watch Test"
}
},
{
"type": "Feature",
"id": 1,
"status": "act",
"properties": {
"NAME": "Act Test"
}
}
]
Thank you