I'm working with the API for JavaScript to create a map of tornadoes in the US. I'm using sliders and other inputs to allow the user to query the data client-side. I'm having some difficulty getting the results from the query to be added to the map. The client-side slider is supposed to query the layer for number of fatalities from tornado events.
I used this sample code from the API for JS page as reference, but can't figure out where I made a mistake.
Link to entire code on jsfiddle
Here's the gist of what I did:
Added an event listener to listen for slider input change.
fatal.addEventListener("input", function() {
queryFatalities().then(displayResults);
});
Performed query of feature layer using createQuery() method to search for number of fatalities:
function queryFatalities() {
var query = tornadoLayer.createQuery();
query.where = "fat <=" + fatal.value;
return tornadoLayer.queryFeatures(query);
}
Used addMany() method to add queried features to webmap. This is the part that I suspect I screwed up on.
function displayResults(results) {
resultsLayer.removeAll();
var features = results.features.map(function(graphic) {
graphic.symbol = {
type: "simple-line",
width: 2,
color: "darkorange"
};
return graphic;
});
resultsLayer.addMany(features);
}
Any advice on how to proceed to get this query function working would be much appreciated.
Thanks!