O'Reilly logo

OpenLayers Cookbook by Antonio Santiago Perez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Wrapping the date line options

There might be situations where you do not want your map ends at -180 or +180 longitude degrees as you are working in that area and need a continuous map. For example, imagine a map where on the left you can see the end of Russia and at the right Alaska, as shown in the following screenshot:

Wrapping the date line options

This property is a common attribute from base class OpenLayers.Layer and is called the wrapDateLine.

How to do it...

To wrap the date line options, perform the following steps:

  1. Create an HTML file and add the OpenLayers dependency.
  2. In the beginning, we have put a checkbox to activate/deactivate the wrap data line feature, as follows: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required