Vector labels get cutted since new ol-version (3.12.1) and VectorTile layer

╄→尐↘猪︶ㄣ 提交于 2019-12-13 14:08:30

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/34719478/vector-labels-get-cutted-since-new-ol-version-3-12-1-and-vectortile-layer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!