Ticket #1702 (closed bug: invalid)
map DIV width and height can only be set in the own DIV element
| Reported by: | diegoalberto.arias | Owned by: | |
|---|---|---|---|
| Priority: | trivial | Milestone: | 2.7 Release |
| Component: | Map | Version: | 2.6 |
| Keywords: | map DIV, width, height | Cc: | diegoalberto.arias@… |
| State: |
Description
* plaform, OS: Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.9) Gecko/2008052912 Firefox/3.0
* detailed steps:
No map is shown if width and height of map's DIV is not set in the own DIV element.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OL bug</title>
<style type="text/css">
//<![CDATA[
#map {width: 800; height: 600; border: 1px solid #000; position: absolute; top: 25px; left: 25px;}
//]]>
</style>
<script type="text/javascript" src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript">
//<![CDATA[
function init() {
// a Spanish 'Plan Nacional de Ortofotografía Aérea' WMS server
var PNOA = {
url: 'http://www.idee.es/wms/PNOA/PNOA',
layers: 'pnoa'
};
var PNOALayer = new OpenLayers.Layer.WMS('ortofoto', PNOA['url'], {layers: PNOA['layers'], transparent: false, format: 'image/png'}, {isBaseLayer: true});
var mapOptions = {
units: 'm',
projection: 'epsg:23029',
maxExtent: new OpenLayers.Bounds(584534.625000, 4769742.500000, 641442.096834, 4823618.352881),
maxResolution: 'auto',
controls: []
};
var map = new OpenLayers.Map('map', mapOptions);
map.addLayers([PNOALayer]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.NavToolbar());
map.addControl(new OpenLayers.Control.PanZoomBar());
map.zoomToMaxExtent();
}
//]]>
</script>
<body onLoad="javascript: init();">
<div id="map"></div>
</body>
</html>
No map in shown. However, if the width and height of the map's DIV is set in the own DIV element
<div id="map" style="width: 800px; height: 600px;"></div>
it works fine.
Another way of reproducing this error consists on putting the style information in a separate CSS file and importing it from the HTML file, something like
<style type="text/css"> //<![CDATA[ @import "style.css" //]]> </style>
in the head section.
note: Firebug will not show any error or warning message.
* Link to code: none
* Planned Solution: none
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

