1

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?

1

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.

0

I totally agree that OpenLayers should document how it manages continuous panning around the globe. However, a little experimenting with the asking the map for its current extents reveals that OpenLayers does not reset its longitude to within 360 degrees once you've panned all the way across the globe in one direction. Instead it just renders longitude in ever increasing longitude (e.g. 361 degrees, and -361 degrees). Thus if your code isn't savvy enough to feed it features/imagery for rediculously large longitudes or latitudes, or you don't tell it restrict the extents, then it allows the user to leave the map entirely. Fortunately, once you figure this out, it's not too difficult to feed OpenLayers data even for nonsensical extents. FWIW, look up the floormod function that windy.js uses.

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.