some question about TileLayer
Unfortunately ,#3316 closed ,because occur some deck.gl version problem . now it resolved.
Firstly. I publish a building Layer by geoserver. And I test it successful by mapbox .
For my mapbox js code:
map.on('load', function() {
map.addSource('building',{
'type':'vector',
'scheme':'tms',
'tiles':['http://192.168.1.125:8090/geoserver/gwc/service/tms/1.0.0/mysapce%3Achognqing@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf']
});
map.addLayer({
'id': '3d-buildings',
'source': 'building',
'source-layer':'chognqing',
'type': 'fill-extrusion',
'paint': {
'fill-extrusion-color': [
'interpolate',
['linear'],
['get', 'height'],
0, 'rgb(255,255,191)',
10, 'rgb(253,174,97)',
20, "#aaa",
],
'fill-extrusion-height': ['get', 'height'],
'fill-extrusion-opacity': 0.6
}
});
});
I try it in my project like TileLayer
For my package.json:
"@deck.gl/core": "^7.1.7",
"@deck.gl/geo-layers": "^7.1.7",
"@deck.gl/layers": "^7.1.7",
"@deck.gl/react": "^7.1.7",
"@mapbox/vector-tile": "^1.3.1",
"pbf": "^3.2.0",
For my deck.gl code:
import {TileLayer} from '@deck.gl/geo-layers';
import {VectorTile} from '@mapbox/vector-tile';
import Protobuf from 'pbf';
new TileLayer({
opacity: 0.7,
lineWidthMinPixels: 1,
getTileData: ({x, y, z}) => {
const mapSource = `http://192.168.1.125:8090/geoserver/gwc/service/tms/1.0.0/mysapce%3Achognqing@EPSG%3A900913@pbf/${z}/${x}/${y}.pbf`;
return fetch(mapSource)
.then(response => response.arrayBuffer())
.then(buffer => {
const tile = new VectorTile(new Protobuf(buffer));
const features = [];
for (const layerName in tile.layers) {
const vectorTileLayer = tile.layers[layerName];
console.log('---------',vectorTileLayer);
for (let i = 0; i < vectorTileLayer.length; i++) {
const vectorTileFeature = vectorTileLayer.feature(i);
const feature = vectorTileFeature.toGeoJSON(x, y, z);
features.push(feature);
}
}
return features;
});
}
})
In netwrok. I compare the difference :
and in console, there are three types of error:

It looks like fetch error , and decoding tiles error. I don't know where is the mistake.
I check the url by postman, it looks everything's ok.

I set method,mode,headers in fetch. the mode 'cors' and 'no-cors' both tried.
let option = {
method:'get',
mode:'cors',
headers:{
'Access-Control-Allow-Origin':'*',
"Content-Type": "application/x-protobuf",
"Access-Control-Allow-Credentials":"true"
}
}
return fetch(mapSource,option)
...
no matter what the value of x,y,z .
Is there any requirements in deck.gl layer's fetch operation?
In your getTileData function you are not passing any option to the fetch call.
@Pessimistress
I made some change for my code .
cause Cross-domain error . I set proxy in webpack.config.js:
'/maptiles/*': {
target: 'http://192.168.1.125:8090',
secure: false,
changeOrigin: true
},
and my js code:
getTileData: ({x, y, z}) => {
const mapSource = `/maptiles/geoserver/gwc/service/tms/1.0.0/mysapce%3Achognqing@EPSG%3A900913@pbf/${z}/${x}/${y}.pbf`;
let option = {
method:'get',
mode:'cors',
};
return fetch(mapSource,option)
.then(response => response.arrayBuffer())
.then(buffer => {
console.log(buffer);
const tile = new VectorTile(new Protobuf(buffer));
const features = [];
for (const layerName in tile.layers) {
const vectorTileLayer = tile.layers[layerName];
console.log('---------',vectorTileLayer);
for (let i = 0; i < vectorTileLayer.length; i++) {
const vectorTileFeature = vectorTileLayer.feature(i);
const feature = vectorTileFeature.toGeoJSON(x, y, z);
features.push(feature);
}
}
return features;
});
}
Even 404 error still exist for my fetch call:
print console.log(buffer); is not empty:

Embarrassed,I don't know where I was wrong.
it seems wrong when buffer convert to VectorTile
As of 8.1 there's a purpose-built MVTLayer, so you don't need to do your own vector tile parsing anymore. Open a new issue if you still have problems.