Since we now can have delayed map rendering, take care to only apply attributes to the map viewport element (map.div may change). Some deprecated controls still modify style properties of map.div. If you use a combination of deprecated controls and delayed rendering, you may get unexpected results. r=ahocevar (closes #1901)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9259 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2009-04-09 22:03:41 +00:00
parent 1fd32e0ff8
commit 736b3ff08c
3 changed files with 6 additions and 1 deletions

View File

@@ -129,7 +129,7 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
draw: function() { draw: function() {
// disable right mouse context menu for support of right click events // disable right mouse context menu for support of right click events
if (this.handleRightClicks) { if (this.handleRightClicks) {
this.map.div.oncontextmenu = function () { return false;}; this.map.viewPortDiv.oncontextmenu = function () { return false;};
} }
var clickCallbacks = { var clickCallbacks = {

View File

@@ -601,6 +601,7 @@ OpenLayers.Map = OpenLayers.Class({
*/ */
render: function(div) { render: function(div) {
this.div = OpenLayers.Util.getElement(div); this.div = OpenLayers.Util.getElement(div);
OpenLayers.Element.addClass(this.div, 'olMap');
this.events.attachToElement(this.div); this.events.attachToElement(this.div);
this.viewPortDiv.parentNode.removeChild(this.viewPortDiv); this.viewPortDiv.parentNode.removeChild(this.viewPortDiv);
this.div.appendChild(this.viewPortDiv); this.div.appendChild(this.viewPortDiv);

View File

@@ -48,6 +48,10 @@
t.ok(map.viewPortDiv.parentNode == map.div, "Map is attached to a temporary div that holds the viewPortDiv."); t.ok(map.viewPortDiv.parentNode == map.div, "Map is attached to a temporary div that holds the viewPortDiv.");
var mapDiv = document.getElementById("map"); var mapDiv = document.getElementById("map");
// clean up the effects of other tests
while(OpenLayers.Element.hasClass(mapDiv, "olMap")) {
OpenLayers.Element.removeClass(mapDiv, "olMap");
}
map.render(mapDiv); // Can also take a string. map.render(mapDiv); // Can also take a string.
t.ok(map.div == mapDiv, "Map is now rendered to the 'map' div.") t.ok(map.div == mapDiv, "Map is now rendered to the 'map' div.")