简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM