I have published a vector file in GeoServer 2.15.1. How can I add this layer to Mapbox? The example in doc.geoserver.com works fine but when I use my layer in the provided format it keeps showing 404 error for the request. After that, I used the code below but still can't get any progress.

mapboxgl.accessToken = 'pk.eyJ1IjoibW9oYW1tYWRob3NzZWluOCIsImEiOiJjazZrYmM5YmEwMmQ2M2RwNmppMzBvbHd3In0.Ki5iFg47J1PJB3W0Z6wlgQ';
    var map = new mapboxgl.Map({
        container: 'map',
        style: 'mapbox://styles/mapbox/streets-v11',
        center: [80, -50],
        zoom: 4

    map.on('load', function() {
        var layers = map.getStyle().layers;
        // Find the index of the first symbol layer in the map style
        var firstSymbolId;
        for (var i = 0; i < layers.length; i++) {
            if (layers[i].type === 'symbol') {
                firstSymbolId = layers[i].id;
        'large_area_tight_modelling', {
            'type': 'vector',
            "tiles": [

            "minZoom": 0,
            "maxZoom": 14

            'id': 'large_area_tight_modelling',
            'type': 'fill',
            'source': 'test:large_area_tight_modelling',
            'layout': {},
            'paint': {
                'fill-color': '#f08',
                'fill-opacity': 0.4

  • 1
    Look at the network tab of the debugger and see what is returned from geoserver
    – Ian Turton
    Commented Apr 5, 2020 at 18:10
  • This is the error shown on the inspector Error: layers.opengeo:countries: layer "large_area_tight_modelling" must specify a "source-layer" Commented Apr 10, 2020 at 12:41

1 Answer 1


To your map.addLayer method, you need to provide one more input

'source-layer' : 'name_of_your_geoserver_layer'

Also, the source you provided should be changed as

'source' : 'large_area_tight_modelling'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.