Pull up r2181:r2229 to 2.3 branch. Includes fixes for:
#429 fix panning for odd size viewport #478 Double clicking overview map expand/contract button zooms in Safari #484 conflict between _addButton of MouseToolbar and PanZoom #485 null pointer exception on CTRL+F5 in IE for WMS.Untiled #486 add a few sanity checks to overview map #489 requires tag incorrect in OverviewMap.js #498 overviewmap: rectangle has minimum height in IE git-svn-id: http://svn.openlayers.org/branches/openlayers/2.3@2230 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
* @author Tim Schaub
|
||||
*/
|
||||
|
||||
// @require: OpenLayers/Control.js
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.OverviewMap = OpenLayers.Class.create();
|
||||
|
||||
OpenLayers.Control.OverviewMap.prototype =
|
||||
@@ -106,6 +106,7 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
this.extentRectangle = document.createElement('div');
|
||||
this.extentRectangle.style.position = 'absolute';
|
||||
this.extentRectangle.style.zIndex = 1000; //HACK
|
||||
this.extentRectangle.style.overflow = 'hidden';
|
||||
this.extentRectangle.style.backgroundImage = 'url(' +
|
||||
OpenLayers.Util.getImagesLocation() +
|
||||
'/blank.png)';
|
||||
@@ -162,6 +163,11 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
OpenLayers.Event.observe(this.maximizeDiv,
|
||||
'click',
|
||||
this.maximizeControl.bindAsEventListener(this));
|
||||
OpenLayers.Event.observe(this.maximizeDiv,
|
||||
'dblclick',
|
||||
function(e) {
|
||||
OpenLayers.Event.stop(e);
|
||||
});
|
||||
this.div.appendChild(this.maximizeDiv);
|
||||
|
||||
// minimize button div
|
||||
@@ -177,7 +183,11 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
OpenLayers.Event.observe(this.minimizeDiv,
|
||||
'click',
|
||||
this.minimizeControl.bindAsEventListener(this));
|
||||
|
||||
OpenLayers.Event.observe(this.minimizeDiv,
|
||||
'dblclick',
|
||||
function(e) {
|
||||
OpenLayers.Event.stop(e);
|
||||
});
|
||||
this.div.appendChild(this.minimizeDiv);
|
||||
|
||||
this.minimizeControl();
|
||||
@@ -418,12 +428,14 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
// The base layer for overview map needs to be in the same projection
|
||||
// as the base layer for the main map. This should be made more robust.
|
||||
if(this.map.units != 'degrees') {
|
||||
if(this.map.getProjection() != this.ovmap.getProjection()) {
|
||||
if(this.ovmap.getProjection() && (this.map.getProjection() != this.ovmap.getProjection())) {
|
||||
alert('The overview map only works when it is in the same projection as the main map');
|
||||
}
|
||||
}
|
||||
var pxBounds = this.getRectBoundsFromMapBounds(this.map.getExtent());
|
||||
if (pxBounds) {
|
||||
this.setRectPxBounds(pxBounds);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -479,8 +491,12 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
lonLatBounds.top);
|
||||
var leftBottomPx = this.getOverviewPxFromLonLat(leftBottomLonLat);
|
||||
var rightTopPx = this.getOverviewPxFromLonLat(rightTopLonLat);
|
||||
return new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y,
|
||||
var bounds = null;
|
||||
if (leftBottomPx && rightTopPx) {
|
||||
bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y,
|
||||
rightTopPx.x, rightTopPx.y);
|
||||
}
|
||||
return bounds;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -530,10 +546,13 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
getOverviewPxFromLonLat: function(lonlat) {
|
||||
var res = this.ovmap.getResolution();
|
||||
var extent = this.ovmap.getExtent();
|
||||
return new OpenLayers.Pixel(
|
||||
var px = null;
|
||||
if (extent) {
|
||||
px = new OpenLayers.Pixel(
|
||||
Math.round(1/res * (lonlat.lon - extent.left)),
|
||||
Math.round(1/res * (extent.top - lonlat.lat))
|
||||
);
|
||||
Math.round(1/res * (extent.top - lonlat.lat)));
|
||||
}
|
||||
return px;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
|
||||
@@ -85,8 +85,8 @@ OpenLayers.Control.PanZoom.prototype =
|
||||
this.div.appendChild(btn);
|
||||
|
||||
btn.onmousedown = this.buttonDown.bindAsEventListener(btn);
|
||||
btn.onmouseup = this.doubleClick.bindAsEventListener(btn);
|
||||
btn.ondblclick = this.doubleClick.bindAsEventListener(btn);
|
||||
btn.onclick = this.doubleClick.bindAsEventListener(btn);
|
||||
btn.action = id;
|
||||
btn.map = this.map;
|
||||
btn.slideFactor = this.slideFactor;
|
||||
|
||||
@@ -18,6 +18,15 @@ OpenLayers.Layer.prototype = {
|
||||
/** @type DOMElement */
|
||||
div: null,
|
||||
|
||||
/** supported application event types
|
||||
*
|
||||
* @type Array */
|
||||
EVENT_TYPES: [
|
||||
"loadstart", "loadend", "loadcancel"],
|
||||
|
||||
/** @type OpenLayers.Events */
|
||||
events: null,
|
||||
|
||||
/** This variable is set when the layer is added to the map, via the
|
||||
* accessor function setMap()
|
||||
*
|
||||
@@ -121,6 +130,8 @@ OpenLayers.Layer.prototype = {
|
||||
this.div.style.height = "100%";
|
||||
this.div.id = this.id;
|
||||
}
|
||||
|
||||
this.events = new OpenLayers.Events(this, this.div, this.EVENT_TYPES);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -135,6 +146,7 @@ OpenLayers.Layer.prototype = {
|
||||
this.name = null;
|
||||
this.div = null;
|
||||
this.options = null;
|
||||
this.events = null;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -508,8 +520,8 @@ OpenLayers.Layer.prototype = {
|
||||
var center = this.map.getCenter();
|
||||
var res = this.map.getResolution();
|
||||
|
||||
var delta_x = viewPortPx.x - Math.ceil(size.w / 2);
|
||||
var delta_y = viewPortPx.y - Math.ceil(size.h / 2);
|
||||
var delta_x = viewPortPx.x - (size.w / 2);
|
||||
var delta_y = viewPortPx.y - (size.h / 2);
|
||||
|
||||
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
|
||||
center.lat - delta_y * res);
|
||||
|
||||
@@ -31,6 +31,9 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
/** @type OpenLayers.Tile.Image */
|
||||
tile: null,
|
||||
|
||||
/** did the image finish loading before a new draw was initiated?
|
||||
* @type Boolean */
|
||||
doneLoading: false,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -63,8 +66,10 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
*
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.tile) {
|
||||
this.tile.destroy();
|
||||
this.tile = null;
|
||||
}
|
||||
OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
@@ -108,6 +113,10 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
* @param {Boolean} dragging
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
if (!this.doneLoading) {
|
||||
this.events.triggerEvent("loadcancel");
|
||||
this.doneLoading = true;
|
||||
}
|
||||
OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this,arguments);
|
||||
|
||||
if (bounds == null) {
|
||||
@@ -155,10 +164,18 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
this.tile = null;
|
||||
}
|
||||
|
||||
this.events.triggerEvent("loadstart");
|
||||
this.doneLoading = false;
|
||||
if (!this.tile) {
|
||||
this.tile = new OpenLayers.Tile.Image(this, pos, tileBounds,
|
||||
url, tileSize);
|
||||
this.tile.draw();
|
||||
var onload = function() {
|
||||
this.doneLoading = true;
|
||||
this.events.triggerEvent("loadend");
|
||||
}
|
||||
OpenLayers.Event.observe(this.tile.imgDiv, 'load',
|
||||
onload.bindAsEventListener(this));
|
||||
} else {
|
||||
this.tile.moveTo(tileBounds, pos);
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ OpenLayers.Util.createAlphaImageDiv = function(id, px, sz, imgURL,
|
||||
|
||||
var div = OpenLayers.Util.createDiv();
|
||||
var img = OpenLayers.Util.createImage(null, null, null, null, null, null,
|
||||
false);
|
||||
null, false);
|
||||
div.appendChild(img);
|
||||
|
||||
if (delayDisplay) {
|
||||
|
||||
32
tests/grid_inittiles.html
Normal file
32
tests/grid_inittiles.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 800px;
|
||||
height: 475px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
function init(){
|
||||
map = new OpenLayers.Map('map', {'maxResolution': 1.40625/2, tileSize: new OpenLayers.Size(256,256)});
|
||||
ww = new OpenLayers.Layer.WMS( "Basic",
|
||||
"http://labs.metacarta.com/wms-c/Basic.py?",
|
||||
{layers:"basic"});
|
||||
map.addLayers([ww]);
|
||||
map.zoomToMaxExtent();
|
||||
map.zoomIn();
|
||||
map.zoomOut();
|
||||
map.zoomOut();
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<h1>Grid Test</h1>
|
||||
<p>Map should display with two centered tiles. If there appear to be a combination of two zoom levels, then this test is failed, and something is broken in OpenLayers.</p>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user