0

I have searched everywhere but I have not found any results.

Currently I am trying to load a Vector Tile layer with MVT format hosted by geoserver using OpenLayers 4.6.4. When creating the map, I get a "Uncaught TypeError: l.Db is not a function" and the map does not appear.

    this.tileLayer = new ol.layer.VectorTile({
  declutter: true,
   source: new ol.source.Vector({
     format: new ol.format.MVT(),
     url: `https://domain.com/geowebcache/service/tms/1.0.0/OpenMapTiles/{z}/{x}/{y}.pbf`,
   })
});
this.map = new ol.Map({
    layers: [this.tileLayer],
    target: targetId,
    view: this.view,
  controls : ol.control.defaults({
    attribution : false,
    zoom : false,
  })
});

Any Ideas?

1 Answer 1

0

I figured it out. I could not find an example anywhere on how to accomplish this. Turns out I had to create a tile grid and give it a tile-pixel ratio.

Here is my code:

  var t_tilegrid = ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 22});
   var t_layer = new ol.layer.VectorTile({
     source: new ol.source.VectorTile({
       attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
         '© <a href="http://www.openstreetmap.org/copyright">' +
         'OpenStreetMap contributors</a>',
       format: new ol.format.MVT(),
       tileGrid: t_tilegrid,
       tilePixelRatio: 8,
       url: geo_web_cache.url,
     })
   });

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.