Closed fastrde closed 11 years ago
You should use a html doctype, and your CSS looks a bit suspicious. Try the following instead:
<!DOCTYPE html>
<html>
<head>
<style>
html, body, #map { width 100%; height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
</body>
</html>
sorry, the code above is a quick and dirty example... In my project I've set a doctype and html, body, #map to width and height 100% via CSS.
But i think i found a workaround because of your post. Directly formatting is ugly but it looks like the error is gone.
<div id="map" style="width: 100%; height: 100%"></div>
Do you think there is a chance to init the map or add the layers not until the div size is calculated by the browser (or this.size != null) or sounds it more like a chrome issue to you?
I am not sure if div#map is a valid CSS selector. So in your
the error looks like a timing issue. I try to explain it on a simple example...
I cloned the map Object before map.addLayers is called and it doesn't have a map.size object when the error happens. Looks like the Browser (Chrome in my case) is not ready with calculating the pixel height and width at this moment. When you give static pixel values in css the error doesn't happen. I can't reproduce the error with firefox on the same machine. Maybe firefox ist faster in calculating the height/width or the internal handling is different.
Here are the Points where the error occured
Uncaught TypeError: Cannot read property 'w' of null in OpenLayers/Layer/Vector.js:400
Uncaught TypeError: Cannot read property 'w' of null im OpenLayers/Map.js:1787