With much assistance from kleptog, make the map wrap when zoomed right out.
This commit is contained in:
parent
4358a6adcb
commit
2804e77cc3
1 changed files with 14 additions and 4 deletions
|
@ -8,7 +8,7 @@ function createMap(divName, centre, zoom) {
|
||||||
}
|
}
|
||||||
|
|
||||||
map = new OpenLayers.Map(divName,
|
map = new OpenLayers.Map(divName,
|
||||||
{ maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
|
{ maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
|
||||||
numZoomLevels: 19,
|
numZoomLevels: 19,
|
||||||
maxResolution: 156543,
|
maxResolution: 156543,
|
||||||
units: 'm',
|
units: 'm',
|
||||||
|
@ -16,12 +16,12 @@ function createMap(divName, centre, zoom) {
|
||||||
|
|
||||||
var mapnik = new OpenLayers.Layer.TMS("Mapnik",
|
var mapnik = new OpenLayers.Layer.TMS("Mapnik",
|
||||||
"http://tile.openstreetmap.org/",
|
"http://tile.openstreetmap.org/",
|
||||||
{ type: 'png', getURL: getTileURL });
|
{ type: 'png', getURL: getTileURL, displayOutsideMaxExtent: true });
|
||||||
map.addLayer(mapnik);
|
map.addLayer(mapnik);
|
||||||
|
|
||||||
var osmarender = new OpenLayers.Layer.TMS("Osmarender",
|
var osmarender = new OpenLayers.Layer.TMS("Osmarender",
|
||||||
"http://dev.openstreetmap.org/~ojw/Tiles/tile.php/",
|
"http://dev.openstreetmap.org/~ojw/Tiles/tile.php/",
|
||||||
{ type: 'png', getURL: getTileURL });
|
{ type: 'png', getURL: getTileURL, displayOutsideMaxExtent: true });
|
||||||
map.addLayer(osmarender);
|
map.addLayer(osmarender);
|
||||||
|
|
||||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
|
@ -35,8 +35,18 @@ function getTileURL(bounds) {
|
||||||
var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
|
var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
|
||||||
var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
|
var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
|
||||||
var z = this.map.getZoom();
|
var z = this.map.getZoom();
|
||||||
|
var limit = Math.pow(2, z);
|
||||||
|
|
||||||
return this.url + z + "/" + x + "/" + y + "." + this.type;
|
if (y < 0 || y >= limit)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = ((x % limit) + limit) % limit;
|
||||||
|
|
||||||
|
return this.url + z + "/" + x + "/" + y + "." + this.type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMarkerToMap(position, icon, description) {
|
function addMarkerToMap(position, icon, description) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue