foedchr
foedchr

Reputation: 123

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

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.

enter image description here

Upvotes: 4

Views: 1650

Answers (1)

tsauerwein
tsauerwein

Reputation: 6031

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

Upvotes: 2

Related Questions