Daniel.fshr
Daniel.fshr

Reputation: 85

Mapbox - How can I add a .pbf file as a Layer in Mapbox?

I want to add a tile layer over my map in Mapbox. The tiles are hosted local with a php tileserver.

My previous attempt looks like this:

map.addLayer({
            'id': 'tiles',
            'type': 'fill',
            'Source': {
                'type': 'vector',
                'tiles': ['http://localhost/tileserver-php-master/{z}/{x}/{y}.pbf'],
            },
            'paint': {
                'fill-color': 'rgb(53, 175, 109)',
                'fill-outline-color': 'rgb(53, 175, 109)'
            }
        });

The tiles are individual polygons that should be placed over the map. The map is visible, but not the individual tiles.

A layer as geojson is not an option, since the file size is too big.

Upvotes: 1

Views: 3673

Answers (1)

Daniel.fshr
Daniel.fshr

Reputation: 85

@Henhuy You can host your tiles as .mbtiles with: https://github.com/maptiler/tileserver-php. There you will also see the names of the source layers.

map.addLayer({
        'id': 'uniqID',
        'type': 'fill',
        'source': {
            'type': 'vector',
            'tiles': ["LINK_TO_TILESEVER.pdf"],
        },
        'source-layer': "SOURCE_LAYER_ID",
});

Upvotes: 0

Related Questions