Skip to main content
added 376 characters in body
Source Link
Sorin Călinică
  • 5.1k
  • 1
  • 18
  • 23

I've made some minor changes to your code. In fact I've added a few properties to your layer:

var skoLayer = new OpenLayers.Layer.XYZ("skobbler",
                ["${z}/${x}/${y}.png?api_key=<Your Key Here>"], 
                    {numZoomLevels: 18, 
                    sphericalMercator: true, 
                    isBaseLayer: true, 
                    wrapDateLine: true, 
                    maxExtent: new OpenLayers.Bounds(-180, -180, 180, 120),
                    attribution: attrib
                });

Some explanations:

  • wrapDateLine repeats the maps horizontally but only if

  • the layer isBaseLayer

  • the 120 value in the maxExtent is not choosed arbitrary, but for centering the map, focusing like in your example. It seems that using wrapDateLine: true overrides setCenter. If you need another center you must to adjust all the values by attempts.

And here's the whole code for you, to easily test it. Just unzip the archive (tested for viruses), extract the scrobbler.html file and double click it.

Just zoom out and move the map, as you like.

I've made some minor changes to your code. In fact I've added a few properties to your layer:

var skoLayer = new OpenLayers.Layer.XYZ("skobbler",
                ["${z}/${x}/${y}.png?api_key=<Your Key Here>"], 
                    {numZoomLevels: 18, 
                    sphericalMercator: true, 
                    isBaseLayer: true, 
                    wrapDateLine: true, 
                    maxExtent: new OpenLayers.Bounds(-180, -180, 180, 120),
                    attribution: attrib
                });

And here's the whole code for you, to easily test it. Just unzip the archive (tested for viruses), extract the scrobbler.html file and double click it.

Just zoom out and move the map, as you like.

I've made some minor changes to your code. In fact I've added a few properties to your layer:

var skoLayer = new OpenLayers.Layer.XYZ("skobbler",
                ["${z}/${x}/${y}.png?api_key=<Your Key Here>"], 
                    {numZoomLevels: 18, 
                    sphericalMercator: true, 
                    isBaseLayer: true, 
                    wrapDateLine: true, 
                    maxExtent: new OpenLayers.Bounds(-180, -180, 180, 120),
                    attribution: attrib
                });

Some explanations:

  • wrapDateLine repeats the maps horizontally but only if

  • the layer isBaseLayer

  • the 120 value in the maxExtent is not choosed arbitrary, but for centering the map, focusing like in your example. It seems that using wrapDateLine: true overrides setCenter. If you need another center you must to adjust all the values by attempts.

And here's the whole code for you, to easily test it. Just unzip the archive (tested for viruses), extract the scrobbler.html file and double click it.

Just zoom out and move the map, as you like.

added code to answer, in case link goes bad.
Source Link
Devdatta Tengshe
  • 41.6k
  • 35
  • 144
  • 263

I've made some minor changes to your code. In fact I've added a few properties to your layer:

var skoLayer = new OpenLayers.Layer.XYZ("skobbler",
                ["${z}/${x}/${y}.png?api_key=<Your Key Here>"], 
                    {numZoomLevels: 18, 
                    sphericalMercator: true, 
                    isBaseLayer: true, 
                    wrapDateLine: true, 
                    maxExtent: new OpenLayers.Bounds(-180, -180, 180, 120),
                    attribution: attrib
                });

And here's the whole code for you, to easily test it. Just unzip the archive (tested for viruses), extract the scrobbler.html file and double click it.

Just zoom out and move the map, as you like.

I've made some minor changes to your code. In fact I've added a few properties to your layer:

isBaseLayer: true, 
wrapDateLine: true,
maxExtent: new OpenLayers.Bounds(-180, -180, 180, 120)

And here's the whole code for you, to easily test it. Just unzip the archive (tested for viruses), extract the scrobbler.html file and double click it.

Just zoom out and move the map, as you like.

I've made some minor changes to your code. In fact I've added a few properties to your layer:

var skoLayer = new OpenLayers.Layer.XYZ("skobbler",
                ["${z}/${x}/${y}.png?api_key=<Your Key Here>"], 
                    {numZoomLevels: 18, 
                    sphericalMercator: true, 
                    isBaseLayer: true, 
                    wrapDateLine: true, 
                    maxExtent: new OpenLayers.Bounds(-180, -180, 180, 120),
                    attribution: attrib
                });

And here's the whole code for you, to easily test it. Just unzip the archive (tested for viruses), extract the scrobbler.html file and double click it.

Just zoom out and move the map, as you like.

deleted 1403 characters in body
Source Link
Sorin Călinică
  • 5.1k
  • 1
  • 18
  • 23

I've made some minor changes to your code. In fact I've added a few properties to your layer:

isBaseLayer: true, 
wrapDateLine: true,
maxExtent: new OpenLayers.Bounds(-180, -180, 180, 120)

And here's the whole code for you, to easily test it. Just unzip the filearchive (tested for viruses), extract the scrobbler.html file and double click it.

Just zoom out and move the map, as you like.

I've made some minor changes to your code. In fact I've added a few properties to your layer:

isBaseLayer: true, 
wrapDateLine: true,
maxExtent: new OpenLayers.Bounds(-180, -180, 180, 120)

And here's the whole code for you, to easily test it. Just unzip the file, extract the scrobbler.html file and double click it.

Just zoom out and move the map, as you like.

I've made some minor changes to your code. In fact I've added a few properties to your layer:

isBaseLayer: true, 
wrapDateLine: true,
maxExtent: new OpenLayers.Bounds(-180, -180, 180, 120)

And here's the whole code for you, to easily test it. Just unzip the archive (tested for viruses), extract the scrobbler.html file and double click it.

Just zoom out and move the map, as you like.

deleted 1403 characters in body
Source Link
Sorin Călinică
  • 5.1k
  • 1
  • 18
  • 23
Loading
Source Link
Sorin Călinică
  • 5.1k
  • 1
  • 18
  • 23
Loading