Adding support for new generation 'framed' popups. This patch includes numerous improvements to the main popups, including the addition of autoSizing, panIntoView, and full support for overflow:auto of the contents div. Thanks go out to the CloudAmber folks, to Pierre in la belle France, to the guys at TOPP and of course, to senior cr5 for his patience and help in the last and final stretch. this is a huge improvement in the popup arena and couldn't have been done without the broad help of everyone out there in the community. Thank you everyone for making this possible. Big step for OpenLayers. (Closes #926)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6718 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -53,27 +53,71 @@ OpenLayers.Popup.Anchored =
|
||||
offset: new OpenLayers.Pixel(0,0)};
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
this.anchor = null;
|
||||
this.relativePosition = null;
|
||||
|
||||
OpenLayers.Popup.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: show
|
||||
* Overridden from Popup since user might hide popup and then show() it
|
||||
* in a new location (meaning we might want to update the relative
|
||||
* position on the show)
|
||||
*/
|
||||
show: function() {
|
||||
this.updatePosition();
|
||||
OpenLayers.Popup.prototype.show.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: moveTo
|
||||
* Since the popup is moving to a new px, it might need also to be moved
|
||||
* relative to where the marker is. We first calculate the new
|
||||
* relativePosition, and then we calculate the new px where we will
|
||||
* put the popup, based on the new relative position.
|
||||
*
|
||||
* If the relativePosition has changed, we must also call
|
||||
* updateRelativePosition() to make any visual changes to the popup
|
||||
* which are associated with putting it in a new relativePosition.
|
||||
*
|
||||
* Parameters:
|
||||
* px - {<OpenLayers.Pixel>}
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} Reference to a div that contains the drawn popup.
|
||||
*/
|
||||
draw: function(px) {
|
||||
if (px == null) {
|
||||
if ((this.lonlat != null) && (this.map != null)) {
|
||||
px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
}
|
||||
}
|
||||
|
||||
//calculate relative position
|
||||
moveTo: function(px) {
|
||||
var oldRelativePosition = this.relativePosition;
|
||||
this.relativePosition = this.calculateRelativePosition(px);
|
||||
|
||||
return OpenLayers.Popup.prototype.draw.apply(this, arguments);
|
||||
var newPx = this.calculateNewPx(px);
|
||||
|
||||
var newArguments = new Array(newPx);
|
||||
OpenLayers.Popup.prototype.moveTo.apply(this, newArguments);
|
||||
|
||||
//if this move has caused the popup to change its relative position,
|
||||
// we need to make the appropriate cosmetic changes.
|
||||
if (this.relativePosition != oldRelativePosition) {
|
||||
this.updateRelativePosition();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: setSize
|
||||
*
|
||||
* Parameters:
|
||||
* size - {<OpenLayers.Size>}
|
||||
*/
|
||||
setSize:function(size) {
|
||||
OpenLayers.Popup.prototype.setSize.apply(this, arguments);
|
||||
|
||||
if ((this.lonlat) && (this.map)) {
|
||||
var px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
this.moveTo(px);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: calculateRelativePosition
|
||||
@@ -95,37 +139,19 @@ OpenLayers.Popup.Anchored =
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: moveTo
|
||||
* Since the popup is moving to a new px, it might need also to be moved
|
||||
* relative to where the marker is.
|
||||
* Method: updateRelativePosition
|
||||
* The popup has been moved to a new relative location, so we may want to
|
||||
* make some cosmetic adjustments to it.
|
||||
*
|
||||
* Parameters:
|
||||
* px - {<OpenLayers.Pixel>}
|
||||
* Note that in the classic Anchored popup, there is nothing to do
|
||||
* here, since the popup looks exactly the same in all four positions.
|
||||
* Subclasses such as the AnchoredBubble and Framed, however, will
|
||||
* want to do something special here.
|
||||
*/
|
||||
moveTo: function(px) {
|
||||
this.relativePosition = this.calculateRelativePosition(px);
|
||||
|
||||
var newPx = this.calculateNewPx(px);
|
||||
|
||||
var newArguments = new Array(newPx);
|
||||
OpenLayers.Popup.prototype.moveTo.apply(this, newArguments);
|
||||
updateRelativePosition: function() {
|
||||
//to be overridden by subclasses
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setSize
|
||||
*
|
||||
* Parameters:
|
||||
* size - {<OpenLayers.Size>}
|
||||
*/
|
||||
setSize:function(size) {
|
||||
OpenLayers.Popup.prototype.setSize.apply(this, arguments);
|
||||
|
||||
if ((this.lonlat) && (this.map)) {
|
||||
var px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
this.moveTo(px);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: calculateNewPx
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user