vue-mapbox icon indicating copy to clipboard operation
vue-mapbox copied to clipboard

Self-hosted tile server

Open Zvorykin opened this issue 6 years ago • 4 comments

How can I use vue-mapbox with self-hosted MapBox GL tile server? I cannot find any info except I should omit accessToken prop.

Zvorykin avatar Oct 07 '19 12:10 Zvorykin

Hi,

You can set the map-style prop to the url of your style.

francois2metz avatar Oct 22 '19 18:10 francois2metz

Where is this

map-style

prop?

I can't find it anywhere. I have my own Mapbox GL tile server too.

ra0e avatar Nov 22 '19 17:11 ra0e

See the documentation: https://soal.github.io/vue-mapbox/api/#mapstyle

francois2metz avatar Nov 22 '19 23:11 francois2metz

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
        }
      }

gorbypark avatar Feb 15 '20 06:02 gorbypark