OL3 / Geoserver: Vector tile labels gets cropped

巧了我就是萌 提交于 2019-12-11 00:58:32

问题


I am trying to label vector tile point features but they always gets cropped at the tile border. I have tried (among many other things) using the renderBuffer option with no success. I am using OL 3.19 and the vector tiles are served with Geoserver 2.10RC1 and I get the same errors in my production environment as well as editing an Boundless example (http://suite.opengeo.org/docs/latest/dataadmin/vectortiles/index.html).

I think maybe the tiles are served correctly from Geoserver and that Openlayers somehow render and then slices the tiles before presentation but I am kind of stuck on this.

Any ideas?

Screenshot of the way it looks

And the code snippet:

 <script>
  var style_simple = new ol.style.Style({
    fill: new ol.style.Fill({
      color: '#ADD8E6'
    }),
    stroke: new ol.style.Stroke({
      color: '#880000',
      width: 1
    }),
	text: new ol.style.Text({
	text:'LOREMIPSUM'})
  });

  function simpleStyle(feature) {
    return style_simple;
  }
  
  var map = new ol.Map({
    target: 'map',
    view: new ol.View({
		center: [0,0],
		zoom: 4
    }),
    layers: [new ol.layer.VectorTile({
	renderBuffer:50, //doesn't matter
      style:simpleStyle,
      source: new ol.source.VectorTile({
        tilePixelRatio: 1,
        tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
        format: new ol.format.MVT(),
        url: 'http://localhost:8080/geoserver/gwc/service/tms/1.0.0/testlayer@EPSG%3A3857@pbf/{z}/{x}/{-y}.pbf'
      })
    })]
  });
  </script>

回答1:


I have the same problem with ol.layer.VectorTile and text labels.
All labels are sliced on the tile boundaries.


Full example: https://jsfiddle.net/rn3qc4ca/

I asked the openlayers developers for help: https://github.com/openlayers/ol3/issues/6275
-> This is not a bug in openlayers. The mapbox tiles really repeat the label points in neighbored tiles. If you use very big fonts the label will still be cropped.


My (unimplemented) idea is to place all labels into a separate ol.layer.Vector layer. As this type of layer is not sliced into tiles it is always printed completely.



来源:https://stackoverflow.com/questions/40234804/ol3-geoserver-vector-tile-labels-gets-cropped

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