3

I have some polygons I am drawing on an OpenLayers 3 map.

Some of these are above latitude 85, and used to be rendered fine with OpenLayers 3 v3.15.1: https://jsfiddle.net/adlerhn/98mn4w5z/

However, in the latest version of OpenLayers (3.20.0), there is clipping in place, and polygons outside the extent of the map are not rendered: https://jsfiddle.net/adlerhn/xt5m1o6d/

The reason I am trying to render outside of the bounds of a map is because I am using ol3-cesium to render into a 3D globe, and in there you can see latitudes between 85 and 90, which would otherwise appear as a gap on the top.

I have tried adding the extent property to the vector layer, but I haven't got any result.

var extent = ol.proj.get("EPSG:4326").getExtent();

var vectorLayer = new ol.layer.Vector({
    map: this.map,
    source: new ol.source.Vector({
        features: [new ol.Feature({
            geometry: geometry
        })]
    }),
    extent: extent,
    style: new ol.style.Style({
        fill: new ol.style.Fill({
            color: 'rgba(0, 128, 255, 0.5)'
        })
      })
});

How can I get OpenLayers to render outside the extent of the map?

2

Latitudes beyond +/- 85.06 degrees cannot be rendered using Web Mercator (EPSG:3857) as projection, which is the default. Just configure your map's view with a projection like EPSG:4326, and you will be fine:

new ol.Map({
  /* ... */
  view: new ol.View({
    /* ... */
    projection: 'EPSG:4326'
  })
})
| improve this answer | |
  • Thanks, that seems to do the trick, even though of course it affects the appearance of the map. I wonder which projection would users prefer. Also, on a separate note, this projection seems to cause an issue when used with ol3-cesium. – Jose Gómez Dec 12 '16 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.