Reputation: 13
I'm creating a webmap which shows all health services in a city where I've made a custom styled Mapbox basemap, and have a variety of point files in a postgis database hosted on a company server.
Initially I had used Openlayers 3, which allowed me to include datasets from a source URL on Geoserver, though am unsure of interoperability between Mapbox GL JS and datasets held on non-mapbox servers / Geoserver functionality. I have only been able to link local geoJSON files within the same directory so far using Mapbox GL JS. Is it possible to host the dataset files on a personal server with Geoserver enabled and still use the Mapbox GL JS basemap?
Thank you!
Upvotes: 1
Views: 3538
Reputation: 19
It is possible to load data either geojson or mvt from an external source.
Here is a link with loading from a GitHub source. https://docs.mapbox.com/help/troubleshooting/working-with-large-geojson-data/
From the link. "If possible, consider loading your GeoJSON from a data URL instead of holding it in a JavaScript object and passing to a Mapbox GL GeoJSON Source. This reduces client memory overhead. There are many different places where you can store your data. For GitHub files, you can use GitHub Pages to store and link to your data. Dropbox allows you to create a public folder and link directly to your data.
map.addSource('some id', { type: 'geojson', data: 'https://mydomain.mydata.geojson' }); "
You could just swap the data string for your geoserver url. We use the dirt simple API with node for more custom functions.
https://github.com/tobinbradley/dirt-simple-postgis-http-api
Upvotes: 2