Get GeoJSON Features using Mapbox?
You can use querySourceFeatures
which return all geojson features within a layer if no filter is applied.
var features = map.querySourceFeatures('your_layer_id');
https://www.mapbox.com/mapbox-gl-js/api/#map#querysourcefeatures
But you may check first that the layer is fully loaded, or you will get an empty array.
map.on("sourcedata", function(e) {
if (map.getSource('your_layer_id') && map.isSourceLoaded('your_layer_id')) {
console.log('source loaded!');
var features = map.querySourceFeatures('your_layer_id');
console.log(features);
}
});
Source about the event: Mapbox GL JS - "Source Loaded" event