[GIS] OpenLayers 3: World is wrapped but Vector layers are not repeated

openlayers

With OpenLayers v.3.1.1, the world is wrapped so that you can pan without limits horizontally or along the axis of Longitude but features on a Vector layer are not repeated, should you pan beyond the original instance of the base layer. I find this is very inconsistent and makes for a terrible user experience!

I want to either prevent horizontal wrapping around the date-line of the base layer or force vector layers to be repeated similarly to the tiles of the base layer.

Apparently, there used to be a wrapX property on some sources or wrapDateLine property on Layer but neither of those are documented in the API documentation for v.3.1.1: http://openlayers.org/en/v3.1.1/apidoc/

In fact, I can find no reference to them at all and no alternative solutions to the problem.

Is there some way to either prevent world wrapping or to cause vector layers to wrap, too?

Best Answer

According to the release notes, the wrapX property is only available on tileJSON sources as of version 3.1.1, and available on OSM and BingMaps sources as of version 3.2.0.

If you are using one of these types of sources, and have a recent enough version of OpenLayers, you can disable horizontal wrapping by adding wrapX: false to your source options.

This is illustrated in the following jsFiddle with an OSM source: https://jsfiddle.net/fg1oxpu0/

If you zoom out, you can see that the layer is not repeated horizontally.

Related Question