I would like to serve vector data to Mapbox clients: Mapbox-GL javascript clients (browsers) and possibly native Android and iOS app with the Mapbox SDKs. It looks like you only have 2 options when using Mapbox: vector tiles and geoJson. I use the latter in an OpenLayers browser app:
var geoJSONFormat = new ol.format.GeoJSON();
var gaugesSource = new ol.source.Vector({
loader: function(extent, resolution, projection) {
var url = 'http://myurl.org/gauges_geojson.php?bbox=' + extent.join(',');
$.ajax({
url: url,
success: function(data) {
var features = geoJSONFormat.readFeatures(data);
gaugesSource.addFeatures(features);
}
});
},
strategy: ol.loadingstrategy.bbox
});
As the user pans or zooms the map, it calls the php script on my server. That php script then queries the PostGIS database using the bounding box in the URL parameters and returns the results using geoJson. Super simple!
Is there a similar approach when working with Mapbox? There are plenty of geoJson examples on this website, but they mostly seem to come from a static geoJson file that gets loaded when the map loads. I will have way too much map data to load when my map is contains the entire US. There's an example where a server sends a new location every x seconds, but that doesn't meet my use case. Vector tiles don't seem to be a great option because my data will change quite frequently. Crunchy Data's vector tile server is a really great (and simple!) app, but it seems like there should be a way to do this with vector data, not tiles. And what if my data changes? How easy is it to reload a tile?