Removing getBoundsFromBaseLayer method.
This method is only needed when the deprecated reproject option is set to true.
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>OpenLayers Google with Overlay Example</title>
|
||||
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<!-- this gmaps key generated for http://openlayers.org/dev/ -->
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map;
|
||||
|
||||
function init(){
|
||||
map = new OpenLayers.Map('map');
|
||||
|
||||
var satellite = new OpenLayers.Layer.Google(
|
||||
"Google Satellite" , {type: G_SATELLITE_MAP}
|
||||
);
|
||||
|
||||
var wms = new OpenLayers.Layer.WMS(
|
||||
"World Map",
|
||||
"http://world.freemap.in/cgi-bin/mapserv",
|
||||
{
|
||||
map: '/www/freemap.in/world/map/factbooktrans.map',
|
||||
transparent: 'TRUE',
|
||||
layers: 'factbook'
|
||||
},
|
||||
{'reproject': true}
|
||||
);
|
||||
|
||||
map.addLayers([satellite, wms]);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(10.205188,48.857593), 5);
|
||||
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<h1 id="title">Google with Overlay Example</h1>
|
||||
|
||||
<div id="tags">
|
||||
Google, overlay, mercator, reproject, cleanup
|
||||
</div>
|
||||
|
||||
<p id="shortdesc">
|
||||
Demonstrate a Google basemap used with boundary overlay layer.
|
||||
</p>
|
||||
|
||||
<div id="map" class="smallmap"></div>
|
||||
|
||||
<div id="docs">
|
||||
<p>An overlay in a Geographic projection can be stretched to somewhat
|
||||
line up with Google tiles (in a Mercator projection). Results get
|
||||
worse farther from the equator. Use the "reproject" option on a
|
||||
layer to get this behavior. Use the sphericalMercator option on
|
||||
a Google layer to get proper overlays (with other layers in
|
||||
Spherical Mercator).</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -31,17 +31,6 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
format: "image/jpeg"
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: reproject
|
||||
* *Deprecated*. See http://trac.openlayers.org/wiki/SphericalMercator
|
||||
* for information on the replacement for this functionality.
|
||||
* {Boolean} Try to reproject this layer if its coordinate reference system
|
||||
* is different than that of the base layer. Default is false.
|
||||
* Set this in the layer options. Should be set to false in
|
||||
* most cases.
|
||||
*/
|
||||
reproject: false,
|
||||
|
||||
/**
|
||||
* APIProperty: isBaseLayer
|
||||
* {Boolean} Default is true for WMS layer
|
||||
|
||||
@@ -236,43 +236,5 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
// to be implemented by subclasses
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getBoundsFromBaseLayer
|
||||
* Take the pixel locations of the corner of the tile, and pass them to
|
||||
* the base layer and ask for the location of those pixels, so that
|
||||
* displaying tiles over Google works fine.
|
||||
*
|
||||
* Parameters:
|
||||
* position - {<OpenLayers.Pixel>}
|
||||
*
|
||||
* Returns:
|
||||
* bounds - {<OpenLayers.Bounds>}
|
||||
*/
|
||||
getBoundsFromBaseLayer: function(position) {
|
||||
var msg = OpenLayers.i18n('reprojectDeprecated',
|
||||
{'layerName':this.layer.name});
|
||||
OpenLayers.Console.warn(msg);
|
||||
var topLeft = this.layer.map.getLonLatFromLayerPx(position);
|
||||
var bottomRightPx = position.clone();
|
||||
bottomRightPx.x += this.size.w;
|
||||
bottomRightPx.y += this.size.h;
|
||||
var bottomRight = this.layer.map.getLonLatFromLayerPx(bottomRightPx);
|
||||
// Handle the case where the base layer wraps around the date line.
|
||||
// Google does this, and it breaks WMS servers to request bounds in
|
||||
// that fashion.
|
||||
if (topLeft.lon > bottomRight.lon) {
|
||||
if (topLeft.lon < 0) {
|
||||
topLeft.lon = -180 - (topLeft.lon+180);
|
||||
} else {
|
||||
bottomRight.lon = 180+bottomRight.lon+180;
|
||||
}
|
||||
}
|
||||
var bounds = new OpenLayers.Bounds(topLeft.lon,
|
||||
bottomRight.lat,
|
||||
bottomRight.lon,
|
||||
topLeft.lat);
|
||||
return bounds;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Tile"
|
||||
});
|
||||
|
||||
@@ -1053,6 +1053,49 @@ if (window.Event) {
|
||||
var Event = OpenLayers.Event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Tile
|
||||
*/
|
||||
OpenLayers.Util.extend(OpenLayers.Tile.prototype, {
|
||||
/**
|
||||
* Method: getBoundsFromBaseLayer
|
||||
* Take the pixel locations of the corner of the tile, and pass them to
|
||||
* the base layer and ask for the location of those pixels, so that
|
||||
* displaying tiles over Google works fine.
|
||||
*
|
||||
* Parameters:
|
||||
* position - {<OpenLayers.Pixel>}
|
||||
*
|
||||
* Returns:
|
||||
* bounds - {<OpenLayers.Bounds>}
|
||||
*/
|
||||
getBoundsFromBaseLayer: function(position) {
|
||||
var msg = OpenLayers.i18n('reprojectDeprecated',
|
||||
{'layerName':this.layer.name});
|
||||
OpenLayers.Console.warn(msg);
|
||||
var topLeft = this.layer.map.getLonLatFromLayerPx(position);
|
||||
var bottomRightPx = position.clone();
|
||||
bottomRightPx.x += this.size.w;
|
||||
bottomRightPx.y += this.size.h;
|
||||
var bottomRight = this.layer.map.getLonLatFromLayerPx(bottomRightPx);
|
||||
// Handle the case where the base layer wraps around the date line.
|
||||
// Google does this, and it breaks WMS servers to request bounds in
|
||||
// that fashion.
|
||||
if (topLeft.lon > bottomRight.lon) {
|
||||
if (topLeft.lon < 0) {
|
||||
topLeft.lon = -180 - (topLeft.lon+180);
|
||||
} else {
|
||||
bottomRight.lon = 180+bottomRight.lon+180;
|
||||
}
|
||||
}
|
||||
var bounds = new OpenLayers.Bounds(topLeft.lon,
|
||||
bottomRight.lat,
|
||||
bottomRight.lon,
|
||||
topLeft.lat);
|
||||
return bounds;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.MouseDefaults
|
||||
* This class is DEPRECATED in 2.4 and will be removed by 3.0.
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.Google("Google");
|
||||
map.addLayer(layer);
|
||||
layer = new OpenLayers.Layer.MapServer(name, url, params, {isBaseLayer: false, reproject: true, buffer: 2});
|
||||
layer = new OpenLayers.Layer.MapServer(name, url, params, {isBaseLayer: false, buffer: 2});
|
||||
layer.isBaseLayer=false;
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
|
||||
@@ -296,46 +296,6 @@
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Layer_WMS_Reproject (t) {
|
||||
var validkey = (window.location.protocol == "file:") ||
|
||||
(window.location.host == "localhost") ||
|
||||
(window.location.host == "openlayers.org");
|
||||
if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") {
|
||||
t.plan(1);
|
||||
t.debug_print("Can't test google reprojection in Opera or Safari.");
|
||||
} else if(validkey) {
|
||||
t.plan(5);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.Google("Google");
|
||||
map.addLayer(layer);
|
||||
var wmslayer = new OpenLayers.Layer.WMS(name, url, params,
|
||||
{isBaseLayer: false, reproject:true, buffer: 2});
|
||||
wmslayer.isBaseLayer=false;
|
||||
map.addLayer(wmslayer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = wmslayer.grid[0][0];
|
||||
t.eq( tile.bounds.left, -22.5, "left side matches" );
|
||||
t.eq( tile.bounds.right, -11.25, "right side matches" );
|
||||
t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" );
|
||||
t.eq( tile.bounds.top.toFixed(6), '21.943046', "top side matches" );
|
||||
map.destroy();
|
||||
} else {
|
||||
t.plan(1);
|
||||
t.debug_print("can't test google layer from " +
|
||||
window.location.host);
|
||||
}
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params, {buffer: 2});
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
t.ok( tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)), "okay");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Layer_WMS_noGutters (t) {
|
||||
t.plan(2);
|
||||
var map = new OpenLayers.Map('map');
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
|
||||
"prov_bound,fedlimit,rail,road,popplace",
|
||||
transparent: "true", format: "image/png"},
|
||||
{wrapDateLine: true, reproject: false,encodeBBOX:true, buffer:2});
|
||||
{wrapDateLine: true, encodeBBOX:true, buffer:2});
|
||||
var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}});
|
||||
m.addLayers([baselayer,layer]);
|
||||
m.zoomToMaxExtent();
|
||||
|
||||
@@ -255,7 +255,7 @@
|
||||
var size = new OpenLayers.Size(5,6);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {'reproject': true});
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size);
|
||||
@@ -263,7 +263,7 @@
|
||||
tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true);
|
||||
t.delay_call( 1, function() { t.eq(tile.imgDiv.style.display, "none", "Tile image is invisible.") } );
|
||||
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {'reproject': true, 'alpha':true});
|
||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {'alpha':true});
|
||||
map.addLayer(layer);
|
||||
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-90,-85,-90,85), url, size);
|
||||
tile.draw();
|
||||
|
||||
57
tests/deprecated/Layer/WMS.html
Normal file
57
tests/deprecated/Layer/WMS.html
Normal file
@@ -0,0 +1,57 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../OLLoader.js"></script>
|
||||
<script src="../../../lib/deprecated.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var name = 'Test Layer';
|
||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||
var params = { map: '/mapdata/vmap_wms.map',
|
||||
layers: 'basic',
|
||||
format: 'image/jpeg'};
|
||||
|
||||
function test_Layer_WMS_Reproject (t) {
|
||||
var validkey = (window.location.protocol == "file:") ||
|
||||
(window.location.host == "localhost") ||
|
||||
(window.location.host == "openlayers.org");
|
||||
if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") {
|
||||
t.plan(1);
|
||||
t.debug_print("Can't test google reprojection in Opera or Safari.");
|
||||
} else if(validkey) {
|
||||
t.plan(5);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.Google("Google");
|
||||
map.addLayer(layer);
|
||||
var wmslayer = new OpenLayers.Layer.WMS(name, url, params,
|
||||
{isBaseLayer: false, reproject:true, buffer: 2});
|
||||
wmslayer.isBaseLayer=false;
|
||||
map.addLayer(wmslayer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = wmslayer.grid[0][0];
|
||||
t.eq( tile.bounds.left, -22.5, "left side matches" );
|
||||
t.eq( tile.bounds.right, -11.25, "right side matches" );
|
||||
t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" );
|
||||
t.eq( tile.bounds.top.toFixed(6), '21.943046', "top side matches" );
|
||||
map.destroy();
|
||||
} else {
|
||||
t.plan(1);
|
||||
t.debug_print("can't test google layer from " +
|
||||
window.location.host);
|
||||
}
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params, {buffer: 2});
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
t.ok( tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)), "okay");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:550px"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -230,6 +230,7 @@
|
||||
<li>deprecated/Layer/MapServer/Untiled.html</li>
|
||||
<li>deprecated/Layer/MultiMap.html</li>
|
||||
<li>deprecated/Layer/WFS.html</li>
|
||||
<li>deprecated/Layer/WMS.html</li>
|
||||
<li>deprecated/Layer/WMS/Post.html</li>
|
||||
<li>deprecated/Tile/WFS.html</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user