Ben Evans
Ben Evans

Reputation: 1557

How can OpenLayers 3 be forced to use new geometry on each zoom with VectorTile

We have features returned from the GeoJSON that ol.source.VectorTile consumes that have differing geometries at the varying zoom levels. When using the ol.layer.VectorTile the geometry doesn't appear to update or uses the geometry provided from a different zoom level.

Is there a way to force a redraw with the feature geometry for the relative zoom level?

So far I've been messing with ol.style.Style's geometry parameter to see if I can get it through that but no joy as of yet.

let map = map = new ol.Map({
  controls: controls,
  loadTilesWhileAnimating: true,
  loadTilesWhileInteracting: true,
  target: config.target,
  interactions: ol.interaction.defaults({
    altShiftDragRotate: false,
    pinchRotate: false
  }),
  view: config.view
});

let tileLayer = new ol.layer.Tile({
  source: new ol.source.XYZ({
    url: config.tileUrl,
    tilePixelRatio: 2,
    projection: config.projection
  });
});
map.addLayer(tileLayer);

let vectorLayer = new ol.layer.VectorTile({
  projection: config.projection,
  renderMode: 'vector',
  source: new ol.source.VectorTile({
    projection: config.projection,
    format: new ol.format.GeoJSON(),
    url: config.vectorUrl,
    tileGrid: ol.tilegrid.createXYZ({
      extent: config.extent
    })
  }),
  style: config.styler
});
map.addLayer(vectorLayer);

Upvotes: 0

Views: 88

Answers (1)

Ben Evans
Ben Evans

Reputation: 1557

Check geometry is correct. I found the data I was getting didn't have the correct geometries hence they weren't appearing where expected!

Upvotes: 0

Related Questions