deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

Some question about TileLayer

Open HeiYanjing opened this issue 7 years ago • 1 comments

Firstly. I publish a building Layer by geoserver. And I test it successful by mapbox . image I set different color for buildings ,some 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
	            } 
	        });
		 });

the most important tiles url : 'http://192.168.1.125:8090/geoserver/gwc/service/tms/1.0.0/mysapce%3Achognqing@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf'

I try it in my project like TileLayer some code: import DeckGL, {PolygonLayer, ScatterplotLayer, PointCloudLayer, HexagonLayer,GridLayer,ArcLayer,IconLayer,TextLayer, FlyToInterpolator, PathLayer} from 'deck.gl'; import {VectorTile} from '@mapbox/vector-tile'; import Protobuf from 'pbf'; import {TripsLayer} from '@deck.gl/experimental-layers'; import {TileLayer} from '@deck.gl/geo-layers';

      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;
              });
          }
      }),

for mapSource, I use the same url . It occur some problem: image image And some other type problem in console: Unimplemented type:4 deck.gl :assertion failed Are the caused by my url? image

HeiYanjing avatar Jul 08 '19 12:07 HeiYanjing

.../{z}/{x}/{y}.pbf

needs to be

.../${z}/${x}/${y}.pbf

Pessimistress avatar Jul 08 '19 19:07 Pessimistress