简体   繁体   English

如何通过VectorTile强制OpenLayers 3在每次缩放时使用新的几何

[英]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. ol.source.VectorTile是从GeoJSON返回的功能,它们在不同的缩放级别具有不同的几何形状。 When using the ol.layer.VectorTile the geometry doesn't appear to update or uses the geometry provided from a different zoom level. 使用ol.layer.VectorTile ,几何似乎没有更新或使用其他缩放级别提供的几何。

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. 到目前为止,我一直在弄乱ol.style.Style的geometry参数,以查看是否可以通过它实现,但到目前为止还没有任何乐趣。

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! 我发现我得到的数据没有正确的几何形状,因此它们没有出现在预期的位置!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在OpenLayers 4.2.0中为VectorTile图层设置范围? - How to set an extent to a VectorTile layer in OpenLayers 4.2.0? 我如何缩放到 openlayers 中的特定几何图形,从下拉列表中选择 - how can i zoom to specific geometry in openlayers , selected from drop down Openlayers几何形状在缩小时看起来失真 - Openlayers geometry shapes looks distorted on zoom out 将Mapbox样式转换为Openlayers 3 vector - Convert mapbox-style to openlayers 3 vectorTile style 如何在 OpenLayers 中加入具有 Vectortile 源特征的外部 json 文件? - How do i join an external json file with features from Vectortile source in OpenLayers? 如何在openlayers中获取当前缩放 - how to get the current zoom in openlayers OpenLayers 4中如何按比例缩放? - How zoom base on scale in OpenLayers 4? 来自两个不同来源的两个图层的 OpenLayers 地图缩放不同。 OpenLayers 可以改变缩放级别的行为吗? - OpenLayers map with two layers from two different sources zoom differently. Can OpenLayers change how zoom levels behave? 如何仅在OpenLayers 5中发送修改后的几何图形? - How to send only the modified geometry in OpenLayers 5? 如何从JSON文件中在OpenLayers中绘制点类型几何 - How can I plot Point type geometry in OpenLayers from a JSON file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM