Making it so the Map constructor doesn't fail when the provided viewport element isn't displayed. r=ahocevar (closes #2461)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10022 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1326,8 +1326,9 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
*/
|
*/
|
||||||
updateSize: function() {
|
updateSize: function() {
|
||||||
// the div might have moved on the page, also
|
// the div might have moved on the page, also
|
||||||
this.events.clearMouseCache();
|
|
||||||
var newSize = this.getCurrentSize();
|
var newSize = this.getCurrentSize();
|
||||||
|
if (newSize && !isNaN(newSize.h) && !isNaN(newSize.w)) {
|
||||||
|
this.events.clearMouseCache();
|
||||||
var oldSize = this.getSize();
|
var oldSize = this.getSize();
|
||||||
if (oldSize == null) {
|
if (oldSize == null) {
|
||||||
this.size = oldSize = newSize;
|
this.size = oldSize = newSize;
|
||||||
@@ -1351,6 +1352,7 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1361,9 +1361,30 @@
|
|||||||
t.eq(moveToCnt, 1, "updateSize move the map if it has a center");
|
t.eq(moveToCnt, 1, "updateSize move the map if it has a center");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_invisible_map(t) {
|
||||||
|
/**
|
||||||
|
* This test confirms that initializing a map using an element that is
|
||||||
|
* not currently displayed doesn't cause any trouble.
|
||||||
|
*/
|
||||||
|
t.plan(1);
|
||||||
|
|
||||||
|
var map, msg = "initializing a map on an undisplayed element";
|
||||||
|
try {
|
||||||
|
map = new OpenLayers.Map("invisimap");
|
||||||
|
} catch (err) {
|
||||||
|
msg += ": " + err;
|
||||||
|
}
|
||||||
|
t.ok(!!map, msg);
|
||||||
|
|
||||||
|
if (map) {
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map" style="width: 600px; height: 300px;"/>
|
<div id="map" style="width: 600px; height: 300px;"/>
|
||||||
|
<div style="display: none;"><div id="invisimap"></div></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user