Since popups have a reference back to map, allow them to determine where they should be drawn internally. Thus we can remove the computing from the addPopup() function in Map.js.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@346 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -172,8 +172,7 @@ OpenLayers.Map.prototype = {
|
|||||||
addPopup: function(popup) {
|
addPopup: function(popup) {
|
||||||
popup.map = this;
|
popup.map = this;
|
||||||
this.popups.push(popup);
|
this.popups.push(popup);
|
||||||
var px = this.getLayerPxFromLonLat(popup.lonlat)
|
var popupDiv = popup.draw();
|
||||||
var popupDiv = popup.draw(px);
|
|
||||||
if (popupDiv) {
|
if (popupDiv) {
|
||||||
popupDiv.style.zIndex = this.Z_INDEX_BASE['Popup'] +
|
popupDiv.style.zIndex = this.Z_INDEX_BASE['Popup'] +
|
||||||
this.popups.length;
|
this.popups.length;
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ OpenLayers.Popup.prototype = {
|
|||||||
* @type DOMElement
|
* @type DOMElement
|
||||||
*/
|
*/
|
||||||
draw: function(px) {
|
draw: function(px) {
|
||||||
|
if ((px == null) && (this.map != null)) {
|
||||||
|
px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.div == null) {
|
if (this.div == null) {
|
||||||
this.div = OpenLayers.Util.createDiv(this.id + "_div",
|
this.div = OpenLayers.Util.createDiv(this.id + "_div",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ OpenLayers.Popup.Anchored.prototype =
|
|||||||
* @type DOMElement
|
* @type DOMElement
|
||||||
*/
|
*/
|
||||||
draw: function(px) {
|
draw: function(px) {
|
||||||
|
if ((px == null) && (this.map != null)) {
|
||||||
|
px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||||
|
}
|
||||||
|
|
||||||
//calculate relative position
|
//calculate relative position
|
||||||
this.relativePosition = this.calculateRelativePosition(px);
|
this.relativePosition = this.calculateRelativePosition(px);
|
||||||
|
|||||||
Reference in New Issue
Block a user