vue-mapbox
vue-mapbox copied to clipboard
Self-hosted tile server
How can I use vue-mapbox with self-hosted MapBox GL tile server? I cannot find any info except I should omit accessToken prop.
Hi,
You can set the map-style prop to the url of your style.
Where is this
map-style
prop?
I can't find it anywhere. I have my own Mapbox GL tile server too.
See the documentation: https://soal.github.io/vue-mapbox/api/#mapstyle
The trick is using a blank accessToken, not omitting it, as well as a mapStyle that points to a "font stack". I can remember where I got the fonts, but it was from mapbox directly a while back (edit I think it was this repo https://github.com/openmaptiles/fonts). I've been using this method with mapbox for a while, and it works with this library too. Once you have the font stack files, you just need to do something like below.
<MglMap
:accessToken="accessToken"
:mapStyle="mapStyle"
/>
accessToken: '',
mapStyle: {
glyphs: 'https://myfontstackurl.com/{fontstack}/{range}.pbf',
version: 8,
sources: {},
layers: []
}
and then add a raster layer (I suppose this might work up in sources/layers in the mapStyle above, but I do it seperately.
<MglRasterLayer
:source="rasterWinter.style"
:layer="rasterWinter.style"
source-id="winter-source"
layer-id="winter-layer"
/>
rasterWinter: {
style: {
type: 'raster',
tiles: [
'https://storage.googleapis.com/project/tiles/raster/winter/{z}/{x}/{y}.png'
],
tileSize: 512
}
}