In OpenMapTiles' docs it is said, that it can serve vector tiles for MapBox GL JS.
But digging docs for both projects I didn't find an option: how to configure self-hosted MapBox GL JS library to use tiles from my self-hosted OpenMapTiles server?
In OpenMapTiles' docs it is said, that it can serve vector tiles for MapBox GL JS.
But digging docs for both projects I didn't find an option: how to configure self-hosted MapBox GL JS library to use tiles from my self-hosted OpenMapTiles server?
If you install https://openmaptiles.com/server/ you will get a self-hosted vector tile maps with all assets including a local copy of Mapbox GL JS.
If you click on the "Viewer" button next to the style you get a sample viewer - running even without an internet connection - using the local vector tiles, local assets and local JavaScript.
This is the place to start to develop your application.
I was also use able to successfully use Klokantech's tileserver-gl
However, I really wanted something even more minimalist than that. Something smaller and more suited to my low intelligence.
As it happens there is an MBTiles module in npm. That made setting up a node tileserver very easy. I explain it in a blog here and here. They are both the same blog.
Here is the js code for the server (borrowed in part from this Git GIST by manuelroth). I recommend reading the above blog (here and here) which shows a minimalist example combining display and server sides. (There are a few gotchas which can be avoided by looking at the example).