Fix for autoSize popups too big when panMapIntoView is false, r=euzuro,

(Closes #1957)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@9092 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2009-03-19 17:33:27 +00:00
parent 22af9d6412
commit e49f1435bc
4 changed files with 195 additions and 9 deletions

View File

@@ -173,6 +173,20 @@ OpenLayers.Popup = OpenLayers.Class({
* Default is false.
*/
panMapIfOutOfView: false,
/**
* APIProperty: keepInMap
* {Boolean} If panMapIfOutOfView is false, and this property is true,
* contrain the popup such that it always fits in the available map
* space. By default, this is not set on the base class. If you are
* creating popups that are near map edges and not allowing pannning,
* and especially if you have a popup which has a
* fixedRelativePosition, setting this to false may be a smart thing to
* do. Subclasses may want to override this setting.
*
* Default is false.
*/
keepInMap: false,
/**
* APIProperty: closeOnMove
@@ -743,22 +757,44 @@ OpenLayers.Popup = OpenLayers.Class({
// is bigger than the map's viewport.
//
if (this.map && this.map.size) {
// Note that there *was* a reference to a
// 'OpenLayers.Popup.SCROLL_BAR_WIDTH' constant here, with special
// tolerance for it and everything... but it was never defined in
// the first place, so I don't know what to think.
var extraX = 0, extraY = 0;
if (this.keepInMap && !this.panMapIfOutOfView) {
var px = this.map.getPixelFromLonLat(this.lonlat);
switch (this.relativePosition) {
case "tr":
extraX = px.x;
extraY = this.map.size.h - px.y;
break;
case "tl":
extraX = this.map.size.w - px.x;
extraY = this.map.size.h - px.y;
break;
case "bl":
extraX = this.map.size.w - px.x;
extraY = px.y;
break;
case "br":
extraX = px.x;
extraY = px.y;
break;
default:
extraX = px.x;
extraY = this.map.size.h - px.y;
break;
}
}
var maxY = this.map.size.h -
this.map.paddingForPopups.top -
this.map.paddingForPopups.bottom -
hPadding;
hPadding - extraY;
var maxX = this.map.size.w -
this.map.paddingForPopups.left -
this.map.paddingForPopups.right -
wPadding;
wPadding - extraX;
safeContentSize.w = Math.min(safeContentSize.w, maxX);
safeContentSize.h = Math.min(safeContentSize.h, maxY);
}

View File

@@ -21,6 +21,20 @@ OpenLayers.Popup.Anchored =
* {String} Relative position of the popup ("br", "tr", "tl" or "bl").
*/
relativePosition: null,
/**
* APIProperty: keepInMap
* {Boolean} If panMapIfOutOfView is false, and this property is true,
* contrain the popup such that it always fits in the available map
* space. By default, this is set. If you are creating popups that are
* near map edges and not allowing pannning, and especially if you have
* a popup which has a fixedRelativePosition, setting this to false may
* be a smart thing to do.
*
* For anchored popups, default is true, since subclasses will
* usually want this functionality.
*/
keepInMap: true,
/**
* Parameter: anchor