webglearth / webglearth2

[UNMAINTAINED] WebGL Earth 2 - the source code of the project
Apache License 2.0
888 stars 212 forks source link

WebGL earth sizing problem #79

Open kingmaryjonatan opened 8 years ago

kingmaryjonatan commented 8 years ago

Hello,

So i am lazyloading my "world.js" (the WebGl Earth dependency). When finally loaded i initiate the map (great) and it works like 9.5 / 10 times 100%.

Sometimes the Canvas is fullwidth but the WebGL context isn't updated so i got a 1px/1px WebGL context that's trying to spin a globe and DDOS maptiles constantly bringing the browser to crash or halt.

So to fix that i have to run

<FOUND THAT THE CANVAS WIDTH IS 0> (timer 100ms) forcedPaused = true; (timer 100ms) handleResize(); (timer 100ms) forcePaused = false; </FOUND THAT THE CANVAS WIDTH IS 0>

And this i have to run twice for it to update correctly..

bugdanov commented 8 years ago

Try using a parent div with the following properties

  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;

And to set the following properites for the child (webglearth2) div

    position: relative;
    height: 100%;
    width: 100%;