Kazu46Machi / earth-api-samples

Automatically exported from code.google.com/p/earth-api-samples
0 stars 0 forks source link

Plugin crashes and disappears upon being hidden #141

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a plugin instance
2. Hide it in some way (i.e. by setting its container node's style.display
= 'none')
3. Show the plugin (i.e. by setting its container node's style.display = '')

What is the expected output or behavior? What do you see instead?
The plugin should not crash upon being hidden and should be visible upon
being shown again. Instead, the plugin no longer appears when shown again.

Which plugin version are you using?
4.3x

Which browsers and operating systems are affected?
All operating systems, all browsers, except for Internet Explorer.

Please provide any additional information (code snippets/links) below.
Workarounds in comments.

Original issue reported on code.google.com by api.roman.public@gmail.com on 20 Jan 2009 at 10:34

GoogleCodeExporter commented 8 years ago
First, some background: There is a bug in many modern browsers that causes 
plugin
objects (not just the Earth plugin) to be destroyed when their containing DOM 
nodes
or their ancestors are hidden. Internet Explorer isn't affected by this bug.

Now, I've written a temporary workaround that parents the Earth DOM nodes to the
document body and hackishly positions it where it would usually be. The 
workaround
does nothing in the case of IE, since it isn't affected.

WARNING 1: this is quite a hack; it should only be used temporarily until we 
have a
long term solution. I'll post a message once the bug is fixed in the API.
WARNING 2: this workaround should only be used on sites affected by the bug 
mentioned
in this thread, and where no other workaround will do.

The workaround:

1) Add a call to displayNoneWorkaround before createInstance like so:

displayNoneWorkaround('map3d');
google.earth.createInstance('map3d', ...

2) Paste this displayNoneWorkaround method in your code, before your 
createInstance
is called:

function displayNoneWorkaround(earthNodeID) {
  // IE isn't affected by this bug
  if (navigator.userAgent.toLowerCase().indexOf('msie') < 0) {
    // Firefox, Safari, etc. are affected
    var earthNode = document.getElementById(earthNodeID);
    var earthWatchNode = earthNode.parentNode;

    earthNode.style.position = 'absolute';
    earthNode.style.left = earthNode.style.top = '0';
    earthNode.style.width = earthNode.style.height = '0';
    document.body.appendChild(earthNode);

    function repositionEarth() {
      earthNode.style.height = earthWatchNode.offsetHeight + 'px';
      earthNode.style.width = earthWatchNode.offsetWidth + 'px';

      // calculate position on page
      var left = earthWatchNode.offsetLeft;
      var top = earthWatchNode.offsetTop;
      var p = earthWatchNode.offsetParent;

      while (p && p != document.body) {
        if (isFinite(p.offsetLeft) && isFinite(p.offsetTop)) {
          left += p.offsetLeft;
          top += p.offsetTop;
        }

        p = p.offsetParent;
      }

      earthNode.style.left = left + 'px';
      earthNode.style.top = top + 'px';
    }

    repositionEarth();

    // reposition every 100ms
    window.setInterval(function() {
      repositionEarth();
    }, 100);
  }
}

Original comment by api.roman.public@gmail.com on 20 Jan 2009 at 10:35

GoogleCodeExporter commented 8 years ago
Note for the workaround above... the <div> node containing the plugin should be 
set
up to take up the entire client area of its parent, which should have some 
nonzero
width and height. For example, this node layout is ideal:

  <div id="map3d_container" style="width: 500px; height: 500px;">
    <div id="map3d" style="height: 100%;"></div>
  </div>

This is just like all of the official samples.

Original comment by api.roman.public@gmail.com on 20 Jan 2009 at 10:40

GoogleCodeExporter commented 8 years ago
Hi, 
i have integrated the earth plugin in our application with google map, 2d and 
3d 
mixed, and have the same problem, only in FF.
Our application toggles the complete map to show or not. If I hide the map, the 
earth 
plugin is destroyed.

I tryied the workwround here. I can toggle the map div, but l can't use map 
(default 
sat), clicking and dragging in the map takes no reaktion.

Here are what I did:

1) copy the function displayNoneWorkaround(earthNodeID) at first line
2) add call before create earth instance

var mapDiv = document.getElementById("googleMap");
var map = new google.maps.Map2(mapDiv);

if (isGEInstalled) { 
 displayNoneWorkaround('googleMap');
 map.getEarthInstance(function(ge) {   });
 map.addMapType(G_SATELLITE_3D_MAP);
}

<div id="googleMapContainer" style="width:578px; height:338px;">
    <div id="googleMap" style="height: 100%;"></div>        
</div>

what did I wrong ? thanks for help.

Original comment by idagr...@googlemail.com on 11 Feb 2009 at 7:55

GoogleCodeExporter commented 8 years ago
I had could not get it to work either for a while, but what I forgot to do was 
to
switch the div that I was hiding. 

You should now be hiding the div "googleMapContainer" rather than "googleMap"

Hope this helps

Original comment by darragh....@gmail.com on 12 Mar 2009 at 1:23

GoogleCodeExporter commented 8 years ago
thanks for this workaround - helped a lot. 
However, it seems that it causes problems for content of balloons to be 
displayed
properly (see attached picture).
I hope there will be a final bug-fix on this one - anyway, the plugin is 
fantastic.
Cheers.
C. 

Original comment by christop...@gmail.com on 8 Apr 2009 at 4:45

Attachments:

GoogleCodeExporter commented 8 years ago
I am having the same error and not sure what I am doing wrong. I followed all 
of the
above suggestions. FF's firebug is complaining that "earthNode is null". I am 
using
JQuery tabs and hiding the "googleMapContainer" div. 

Could someone take a look at my code and offer some suggestions. thanks.

http://www.chrisborkowski.info/view-sketchup-projects/project/13

Original comment by cborkows...@gmail.com on 18 May 2009 at 7:13

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago

Original comment by api.roman.public@gmail.com on 22 May 2009 at 1:39

GoogleCodeExporter commented 8 years ago
Bulk edit.

Original comment by api.roman.public@gmail.com on 9 Aug 2009 at 1:02

GoogleCodeExporter commented 8 years ago
May I ask when can be solved this issue or if already be solved in newest 
version? 
thanks 

Original comment by czgzncz...@gmail.com on 29 Sep 2009 at 4:17

GoogleCodeExporter commented 8 years ago
We also anxiously await a fix! Thanks

Original comment by robertsw...@gmail.com on 2 Oct 2009 at 10:18

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Ditto, waiting for a fix.  I tried the workaround, and it did not work for me.  
Thanks!

Original comment by tsachi.s...@gmail.com on 16 Nov 2009 at 6:29

GoogleCodeExporter commented 8 years ago
I'm having the same problem.  I am trying to integrate EXT JS as a portal.  FF 
is
failing at this, but at some points the plug-in fails and at others it doesn't. 
 For
example, when the window is resized or if one of the controls causes the 
plug-in to
resize.  But I guess when the control disappears, that the plug-in goes arwy, 
like
doing a drag and drop or switching tabs, and coming back to the same tab.  But 
other
times, switching tabs where the plug-in is a portlet, does not fail.  So what 
is the
behavior that is causing this.  IE has a similar problem when you attempt to 
drag the
portlet somewhere else.

Original comment by jonetta.ng@gmail.com on 18 Nov 2009 at 11:03

GoogleCodeExporter commented 8 years ago
I'm having the same problem with the Google Earth plugin and FF.  My objective 
is to 
create a map container that is flexible in size:  the user can drag-resize the 
container or the user can hit a "maximize button" to programmaticly resize the 
container (which is one way to generate a "Google earth internal error").

I have 4 online examples (and I've tried countless other paths).  I think that 
we can 
figure this out.  But I have nearly reached my limits of understanding...

First example.  http://www.stjohnhistoricalsociety.org/Maps-3D3.htm
Here I'm using jquery plugin - mbContainterPlus [http://pupunzi.open-
lab.com/2009/01/18/jquery-mbcontainers/]  I can drag and drop the container, I 
can 
drag and resize the container.  But when I try to programmicly resize the 
container 
(hit the toggle-size button in the upper right corner of the earth container), 
the 
contents disappear and when resized animation is completed, the GE contents 
report 
"...internal error. Try reloading..."

I have tried wrapping the resizeTo function with 
"ge.getWindow.setVisibility(false)" 
and "ge.getWindow.setVisibility(true)" -- but this didn't help and introduced 
other 
wierd artifacts.

Isn't it odd, that the user/mouse drag-resize animation works day and night, 
but 
'jQuery.fn.mb_fullscreen()' messes up google earth plugin?

Example 2:  http://www.stjohnhistoricalsociety.org/Maps-3D7.htm
Here I'm using http://layout.jquery-dev.net/demos/simple.html to make a 
user-drag-
resizable google earth container.  My problem here is that the header menu bar 
is a 
drop-down style, and the menu items can be hidden behind the google 
earth/center 
container.

Example 3: http://www.stjohnhistoricalsociety.org/Maps-3D8.htm
Again I'm using layout.jquery stuff and the files from the previous example 
with one 
js line difference in file 'maps3d8.js'
 added line 285:     , center__showOverflowOnHover: true
This line fixes the problem in example #2, but produces the error of example #1.

I have also spent a few days using the jquery-ui and ui_resizable functions -- 
but 
always got "ge internal errors" and there was no method to bind to a button so 
the 
user can toggle the container size.

Example #4: http://www.stjohnhistoricalsociety.org/Articles/STJWomenTelling.htm 
may 
have the seeds for success...
In this example, instead of "google earth plugin" we have a "adobe/flash 
plugin" by
http://flowplayer.org/.  Instead of "resizing the ge earth container", we 
'click' on 
one of the thumbnail photos to trigger a modal overlay which "hides" the 
"browser 
plugin".  As part of the "hide" function, flowplay invokes a 'MAGIC' "plugin 
hide' 
function, and ditto on the "show" function, when the "overlay is unloaded".

So these dudes at Flowplayer.org have figured out to play nicely with browser 
plugins.  Maybe we can, too...

Peter

Original comment by Peter.Ho...@gmail.com on 14 Jan 2010 at 1:03

GoogleCodeExporter commented 8 years ago
Hi 
thanks for the workaround 
any news on a possible real repair of the issue ?

Original comment by oceat...@gmail.com on 26 Mar 2010 at 10:16

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Fixed in 5.2.0.5860.

Original comment by api.roman.public@gmail.com on 2 Apr 2010 at 10:42

GoogleCodeExporter commented 8 years ago
hi,

FF tells me my Google Earth Plugin Version is 1.0.0.1
i try to download it and install it again, but same version.

and the bug is still here, what does it mean 'Fixed in 5.2.0.5860.'
Is there a real issue ?

thks

Original comment by florent....@gmail.com on 28 Apr 2010 at 1:51

GoogleCodeExporter commented 8 years ago
The Google Earth application version is 5.2.0.5920.  That's where most of the 
actual
meat of the program is.  The plugin is a wrapper around the application that 
allows
it to display in Firefox.  The plugin version is 1.0.0.1.  But inside the 
plugin runs
the full GE app, which is 5.2.0.5920.

Original comment by chimpath...@gmail.com on 28 Apr 2010 at 2:04

GoogleCodeExporter commented 8 years ago
ok thks, but i can't see what is different..

the bug is still here with FF, no way to hide and show the plugin container.. 
(GE
plugin disappears after hiding and never comes back)

still need to use displayNoneWorkaround() method.

anyone can tell me a bit more ?

thanks for help

Original comment by florent....@gmail.com on 28 Apr 2010 at 2:58

GoogleCodeExporter commented 8 years ago
http://groups.google.com/group/google-earth-browser-
plugin/browse_thread/thread/dfb958c9a3c690a8/4b6bd6255605c869?
lnk=gst&q=burgess#4b6bd6255605c869

Issue #141 resolved -- yeh! 
But I'm having rendering problems just when using Firefox 3.6.3 on 
this page --http://www.stjohnhistoricalsociety.org/SJGEarth.htm, which 
uses my modified jquery plugin - mbContainterPlus (2.4.8 latest) 
The mbContainer can be 'dragged and dropped' and the corners can be 
adjusted to resize the container.  I also added a simple toggle button 
(upper right) to maximize/restore the size of the container.   And 
that's when the problem occurs: 
Usually when I toggle to maximize, the container resizes but the 
google earth rendering does not resize -- leaving a big black area 
below the earth. 
One user work-around is to 'mouse-grab' a corner of the mbContainer 
and stretch a tiny bit, and then the re-rendering will complete.  But 
I need to implement some fix/work-around. 
Page works fine with Chrome and IE 
Any suggestions/workarounds would be greatly appreciated! 
Peter 

Original comment by Peter.Ho...@gmail.com on 28 Apr 2010 at 6:01

GoogleCodeExporter commented 8 years ago
there is something weird with this bug fixe and i would like to have some
explainations.. I explain the bahavior :

i use my plugin in a Ext.Window framework. I always had to use the
displayNoneWorkaround() function, it worked fine with FF. 
Since the bug fixe, and only with FF 3.6, it's not working anymore. Now, with 
FF 3.6,
i have to use the plugin normaly in a div, but with FF 3.5.9, i still have to 
use
displayNoneWorkaround().

But the worse is this : if i use the plugin normaly in a div, it works with FF 
3.6 on
local sources. But when i commit my sources on the server, there is no way to 
make it
work, the plugin tells me "Internal Error please install the plugin again" (and 
the
re installation doesn't fixe the thing).

so how could i explain this internal error, and this strange behavior when the 
code
is on the server, aswhile the same code is working on local...

Original comment by florent....@gmail.com on 30 Apr 2010 at 3:47

GoogleCodeExporter commented 8 years ago
A workaround i've been using, but by no means is the optimal solution, is just 
setting the height and width of the plugin to 1px.  Resizing the plugin doesn't 
seem to cause any issues.  Likewise to reopen the plugin just set the height 
and width appropriately. 

Original comment by Mindsdec...@gmail.com on 26 Oct 2010 at 2:39

GoogleCodeExporter commented 8 years ago
This stabilizes it immensely: 
http://www.microsoft.com/en-us/download/details.aspx?id=35

Original comment by jms...@gmail.com on 17 Jun 2013 at 8:42

GoogleCodeExporter commented 8 years ago
Had the same problem... In my case the google earth plugin is bound to a div 
that is part of a jQuery UI Dialog. The plugin crashed when the dialog was 
closed and later reopened.
My workaround is very simple. I delete all children of the div the plugin is 
bound to: jQuery("#earthCanvas").empty();

When the dialog is reopened I simply reinitialized the plugin as I did when the 
dialog was opened the first time.

Tested with chrome 27.0.1453.116 m and fire fox 22.0.

Original comment by sebastia...@gmx.net on 30 Jun 2013 at 6:42