由于新的ol版本(3.12.1)和VectorTile层,矢量标签被剪切 [英] Vector labels get cutted since new ol-version (3.12.1) and VectorTile layer

查看:221
本文介绍了由于新的ol版本(3.12.1)和VectorTile层,矢量标签被剪切的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我将应用程序从ol.3.9.0升级到ol.3.12.1并实现了新的VectorTile层和Source以来,我得到了一些正常但不好的渲染行为.问题是与瓷砖铺砌工相交的标签被切掉了.我看了看源代码,但发现没有设置选项的可能性,例如部分或重叠,就像其他使用图块的库(mapserver或e.g)一样. 有人知道解决方法吗?我看了请求请求,这似乎不是一个问题.附有屏幕截图.

仅供参考,GeoJson的几何形状是点,因此问题很可能是文字被截断.

解决方案

使用缓冲区一起使用,以避免呈现问题.

在您的情况下,您可能要使用 ol.source.Vector ol.loadingstrategy.tile 一起加载策略.

这里是一个示例: http://openlayers.org/en/master/examples/vector-osm.html

  var vectorSource = new ol.source.Vector({
    format: new ol.format.GeoJSON(),
    url: function(extent, resolution, projection) {
      var epsg4326Extent =
          ol.proj.transformExtent(extent, projection, 'EPSG:4326');
      return 'http://your-webservice?bbox=' +
          epsg4326Extent.join(',');
    },
    strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
      maxZoom: 19
    }));

请确保您的GeoJSON功能设置了正确的标识符,以确保功能不会两次插入到源中(请参见 GeoJSON:功能对象).

Since i upgraded my application to ol.3.12.1 from ol.3.9.0 and implemented the new VectorTile Layer and Source i got some normal but bad rendering behaviour. The problem is that labels which are intersecting the tileborders get cut off. I looked ate the Sourcecode but i found no possibility to set an option, like partials or overlap like in other libaries which are working with tiles (mapserver or e.g). Does anyone know a Workaround? I looked at the pull request and it doesn't seem to be an issue right know. Screenshot attached.

FYI The GeoJson geometries are points, and the problem is a lable as a Text which get cut off.

解决方案

When using ol.source.VectorTile geometries are clipped at the tile borders. Vector tiles are supposed to work with a buffer to avoid rendering issues.

In your case, you probably want to use ol.source.Vector with ol.loadingstrategy.tile as loading strategy.

Here is an example: http://openlayers.org/en/master/examples/vector-osm.html

  var vectorSource = new ol.source.Vector({
    format: new ol.format.GeoJSON(),
    url: function(extent, resolution, projection) {
      var epsg4326Extent =
          ol.proj.transformExtent(extent, projection, 'EPSG:4326');
      return 'http://your-webservice?bbox=' +
          epsg4326Extent.join(',');
    },
    strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
      maxZoom: 19
    }));

Make sure that your GeoJSON features have a proper identifier set, so that features are not inserted twice into the source (see GeoJSON: Feature Objects).

这篇关于由于新的ol版本(3.12.1)和VectorTile层,矢量标签被剪切的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆