[OpenLayers-Commits] r11607 - in trunk/openlayers: examples
lib/OpenLayers
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Mar 2 04:55:31 EST 2011
Author: ahocevar
Date: 2011-03-02 01:55:28 -0800 (Wed, 02 Mar 2011)
New Revision: 11607
Modified:
trunk/openlayers/examples/restricted-extent.html
trunk/openlayers/lib/OpenLayers/Layer.js
trunk/openlayers/lib/OpenLayers/Map.js
Log:
fixing restrictedExtent check in moveByPx. r=bartvde (closes #3138)
Modified: trunk/openlayers/examples/restricted-extent.html
===================================================================
--- trunk/openlayers/examples/restricted-extent.html 2011-03-02 08:15:20 UTC (rev 11606)
+++ trunk/openlayers/examples/restricted-extent.html 2011-03-02 09:55:28 UTC (rev 11607)
@@ -9,7 +9,7 @@
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map = null;
- var extent = new OpenLayers.Bounds(-180, -90, 180, 90);
+ var extent = new OpenLayers.Bounds(8, 44.5, 19, 50);
function init() {
var options = {
@@ -24,7 +24,7 @@
);
map.addLayers([wms]);
- map.setCenter(extent, 1);
+ map.zoomToExtent(extent);
document.getElementById("toggle").checked = true;
}
@@ -68,8 +68,8 @@
<input type="checkbox" id="toggle" checked="checked"
onclick="toggleRestrictedExtent();" />
<label for="toggle">
- Toggle restricted extent (to [-180, -90, 180, 90]).
+ Toggle restricted extent (to [8, 44.5, 19, 50]).
</label>
</body>
-</html>
+</html>
\ No newline at end of file
Modified: trunk/openlayers/lib/OpenLayers/Layer.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer.js 2011-03-02 08:15:20 UTC (rev 11606)
+++ trunk/openlayers/lib/OpenLayers/Layer.js 2011-03-02 09:55:28 UTC (rev 11607)
@@ -1215,7 +1215,7 @@
var map = this.map;
if (viewPortPx != null && map.minPx) {
var res = map.getResolution();
- var maxExtent = map.getMaxExtent();
+ var maxExtent = map.getMaxExtent({restricted: true});
var lon = (viewPortPx.x - map.minPx.x) * res + maxExtent.left;
var lat = (map.minPx.y - viewPortPx.y) * res + maxExtent.top;
lonlat = new OpenLayers.LonLat(lon, lat);
Modified: trunk/openlayers/lib/OpenLayers/Map.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Map.js 2011-03-02 08:15:20 UTC (rev 11606)
+++ trunk/openlayers/lib/OpenLayers/Map.js 2011-03-02 09:55:28 UTC (rev 11607)
@@ -1671,22 +1671,22 @@
var hh = this.size.h / 2;
var x = hw + dx;
var y = hh + dy;
- var valid = y <= this.maxPx.y &&
- y >= this.minPx.y;
- var minX, maxX;
- if (this.baseLayer.wrapDateLine === true) {
- minX = this.minPx.x, maxX = this.maxPx.x;
- } else {
+ var wrapDateLine = this.baseLayer.wrapDateLine;
+ var xRestriction = yRestriction = 0;
+ if (this.restrictedExtent) {
+ xRestriction = hw;
+ yRestriction = hh;
+ // wrapping the date line makes no sense for restricted extents
+ wrapDateLine = false;
+ }
+ var valid = y <= this.maxPx.y - yRestriction &&
+ y >= this.minPx.y + yRestriction;
+ var minX = this.minPx.x, maxX = this.maxPx.x;
+ if (!wrapDateLine) {
valid = valid &&
- x <= this.maxPx.x &&
- x >= this.minPx.x;
+ x <= this.maxPx.x - xRestriction &&
+ x >= this.minPx.x + xRestriction;
}
- if (this.restrictedExtent && valid) {
- valid = !(this.maxPx.x - x < hw ||
- x - this.minPx.x < hw ||
- this.maxPx.y - y < hh ||
- y - this.minPx.y < hh);
- }
if (valid) {
this.center = null;
if (dx) {
@@ -1694,7 +1694,7 @@
parseInt(this.layerContainerDiv.style.left) - dx + "px";
this.minPx.x -= dx;
this.maxPx.x -= dx;
- if (this.baseLayer.wrapDateLine === true) {
+ if (wrapDateLine) {
if (this.maxPx.x > maxX) {
this.maxPx.x -= (maxX - minX);
};
More information about the Commits
mailing list