1

I have uploaded the data to a local Geoserver and am connecting it to my map on MapBox GL JS. The data is displayed correctly on the map and does not cause any errors in the logs. But when I start moving the map to where the data is not, the following errors pop up in the logs:

xe {status: 400, url: 'http://localhost:8081/geoserver/gwc/service/wmts?R…/vnd.mapbox-vector-tile&TILECOL=2478&TILEROW=1277', message: 'Bad Request'}

xe {status: 400, url: 'http://localhost:8081/geoserver/gwc/service/wmts?R…/vnd.mapbox-vector-tile&TILECOL=2477&TILEROW=1277', message: 'Bad Request'}

xe {status: 400, url: 'http://localhost:8081/geoserver/gwc/service/wmts?R…/vnd.mapbox-vector-tile&TILECOL=2476&TILEROW=1276', message: 'Bad Request'}

I understand that GeoServer tries in these squares to find tiles, does not find them and an error is issued. Is there any way to avoid it?

The way I connect the layer:

    map.addSource("buildings_pushkino_how_old", {
      // может быть любое имя
      type: "vector",
      tiles: [
        "http://localhost:8081/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=how_old:buildings_pushkino_how_old_wfs&STYLE=&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}",
      ],
    });

    map.addLayer({
      id: "buildings_pushkino_how_old_id",
      type: "fill", 
      source: "buildings_pushkino_how_old",
      "source-layer": "buildings_pushkino_how_old_wfs", // Имя слоя в Geoserver
      paint: {
        "fill-color": "#ff0000",
        "fill-opacity": 0.5,
      },
    });

Layer settings in Geosrver: enter image description here

0

1 Answer 1

0

You can use bounds option of vector source style to limit tile requests to desired bounds (see https://docs.mapbox.com/style-spec/reference/sources/#vector-bounds).

Your code could then look something like this:

map.addSource("buildings_pushkino_how_old", {
  type: "vector",
  tiles: [
    "http://localhost:8081/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=how_old:buildings_pushkino_how_old_wfs&STYLE=&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}",
  ],
  bounds: [37.78089132, 55.96388819, 37.93968874, 56.060285621]
});
1
  • Thanks, it works! Commented Apr 5, 2024 at 8:13

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.