fix issue where we try to createblocks without a proper this.relativePosition. Robustness++. (Pullup #1479)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6800 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -248,15 +248,18 @@ OpenLayers.Popup.Framed =
|
||||
* Method: createBlocks
|
||||
*/
|
||||
createBlocks: function() {
|
||||
if (!this.relativePosition) {
|
||||
// this.relativePosition can't be set until we have a map
|
||||
// set: if it's not set, we can't create blocks. (See #1479)
|
||||
return false;
|
||||
}
|
||||
|
||||
this.blocks = [];
|
||||
|
||||
var position = this.positionBlocks[this.relativePosition];
|
||||
//since all positions contain the same number of blocks, we can
|
||||
// just pick the first position and use its blocks array to create
|
||||
// our blocks array
|
||||
var firstPosition = null;
|
||||
for(var key in this.positionBlocks) {
|
||||
firstPosition = key;
|
||||
break;
|
||||
}
|
||||
|
||||
var position = this.positionBlocks[firstPosition];
|
||||
for (var i = 0; i < position.blocks.length; i++) {
|
||||
|
||||
var block = {};
|
||||
@@ -280,8 +283,6 @@ OpenLayers.Popup.Framed =
|
||||
block.div.appendChild(block.image);
|
||||
this.groupDiv.appendChild(block.div);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -292,50 +293,48 @@ OpenLayers.Popup.Framed =
|
||||
*/
|
||||
updateBlocks: function() {
|
||||
if (!this.blocks) {
|
||||
var cont = this.createBlocks();
|
||||
if (!cont) {
|
||||
return false;
|
||||
}
|
||||
this.createBlocks();
|
||||
}
|
||||
|
||||
|
||||
var position = this.positionBlocks[this.relativePosition];
|
||||
for (var i = 0; i < position.blocks.length; i++) {
|
||||
|
||||
var positionBlock = position.blocks[i];
|
||||
var block = this.blocks[i];
|
||||
|
||||
// adjust sizes
|
||||
var l = positionBlock.anchor.left;
|
||||
var b = positionBlock.anchor.bottom;
|
||||
var r = positionBlock.anchor.right;
|
||||
var t = positionBlock.anchor.top;
|
||||
|
||||
//note that we use the isNaN() test here because if the
|
||||
// size object is initialized with a "auto" parameter, the
|
||||
// size constructor calls parseFloat() on the string,
|
||||
// which will turn it into NaN
|
||||
//
|
||||
var w = (isNaN(positionBlock.size.w)) ? this.size.w - (r + l)
|
||||
: positionBlock.size.w;
|
||||
|
||||
var h = (isNaN(positionBlock.size.h)) ? this.size.h - (b + t)
|
||||
: positionBlock.size.h;
|
||||
|
||||
block.div.style.width = w + 'px';
|
||||
block.div.style.height = h + 'px';
|
||||
|
||||
block.div.style.left = (l != null) ? l + 'px' : '';
|
||||
block.div.style.bottom = (b != null) ? b + 'px' : '';
|
||||
block.div.style.right = (r != null) ? r + 'px' : '';
|
||||
block.div.style.top = (t != null) ? t + 'px' : '';
|
||||
|
||||
block.image.style.left = positionBlock.position.x + 'px';
|
||||
block.image.style.top = positionBlock.position.y + 'px';
|
||||
if (this.relativePosition) {
|
||||
var position = this.positionBlocks[this.relativePosition];
|
||||
for (var i = 0; i < position.blocks.length; i++) {
|
||||
|
||||
var positionBlock = position.blocks[i];
|
||||
var block = this.blocks[i];
|
||||
|
||||
// adjust sizes
|
||||
var l = positionBlock.anchor.left;
|
||||
var b = positionBlock.anchor.bottom;
|
||||
var r = positionBlock.anchor.right;
|
||||
var t = positionBlock.anchor.top;
|
||||
|
||||
//note that we use the isNaN() test here because if the
|
||||
// size object is initialized with a "auto" parameter, the
|
||||
// size constructor calls parseFloat() on the string,
|
||||
// which will turn it into NaN
|
||||
//
|
||||
var w = (isNaN(positionBlock.size.w)) ? this.size.w - (r + l)
|
||||
: positionBlock.size.w;
|
||||
|
||||
var h = (isNaN(positionBlock.size.h)) ? this.size.h - (b + t)
|
||||
: positionBlock.size.h;
|
||||
|
||||
block.div.style.width = w + 'px';
|
||||
block.div.style.height = h + 'px';
|
||||
|
||||
block.div.style.left = (l != null) ? l + 'px' : '';
|
||||
block.div.style.bottom = (b != null) ? b + 'px' : '';
|
||||
block.div.style.right = (r != null) ? r + 'px' : '';
|
||||
block.div.style.top = (t != null) ? t + 'px' : '';
|
||||
|
||||
block.image.style.left = positionBlock.position.x + 'px';
|
||||
block.image.style.top = positionBlock.position.y + 'px';
|
||||
}
|
||||
|
||||
this.contentDiv.style.left = this.padding.left + "px";
|
||||
this.contentDiv.style.top = this.padding.top + "px";
|
||||
}
|
||||
|
||||
this.contentDiv.style.left = this.padding.left + "px";
|
||||
this.contentDiv.style.top = this.padding.top + "px";
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Popup.Framed"
|
||||
|
||||
Reference in New Issue
Block a user