2

sorry if this a novice question. I am using node-mapnik to generate vector tiles from a database query, but the vector tiles always return empty, whereas I am pretty sure postgis actually returns data (tested the query separately on psql, with the same bounding box).

Is there something obvious missing in the following code ? I have not added a style to the map layer rendered to vector tile, because I thought that vector tiles are not actually "rendered" on the server, is this the issue ? Thanks for your answer,

pgMapRouter.get('/:z/:x/:y.pbf', function(req, res) {


  var bbox = mercator.bbox(
    +req.params.x,
    +req.params.y,
    +req.params.z,
    false,
    '4326'
  );

  var map = new mapnik.Map(256, 256);
  map.extent = bbox;

 var layer = new mapnik.Layer('fixture_layer');
   layer.datasource = new mapnik.Datasource({
       type: 'postgis',
       dbname: 'citydb',
       table: 'test2',
       user: 'postgres',
       password: 'postgres',
       host: 'localhost',
       port:5432,
       geometry_field: 'wkb_geometry',
       srid:4326,
       extent: bbox
   });

   map.add_layer(layer);

   var vtile = new mapnik.VectorTile(+req.params.z, +req.params.x, +req.params.y);

   map.render(vtile, function (err, vtile) {
       if (err) console.log(err);

       res.setHeader('Content-Encoding', 'deflate');
       res.setHeader('Content-Type', 'application/x-protobuf');

       zlib.deflate(vtile.getData(), function(err, pbf) {
         console.log(mapnik.VectorTile.info(pbf))
         res.send(pbf);
       });
   });
});
Clouddie
  • 103
  • 2
  • 11
  • did you have any luck with this? I just asked a very [similar question](http://stackoverflow.com/q/42960495/2399799). – dan-man Mar 23 '17 at 09:14
  • Hi, no I gave up, i am trying with Tippecanoe now (https://github.com/mapbox/tippecanoe), after creating geojson from postgre. – Clouddie Mar 24 '17 at 21:18

0 Answers0