asroboy / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
Apache License 2.0
0 stars 0 forks source link

Google Earth API for Google Maps v3 getInstance method #154

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The object returned from getInstance is obviously undefined until the plugin 
has fully initialized...yet there is no way to know if the plugin is 
initialized before calling getInstance as there is no callback method exposed 
when the plugin is created via the GoogleEarth() method. This makes actually 
working with the plugin object problematic. 

What steps will reproduce the problem?

    var map = new google.maps.Map(document.getElementById('map'), myOptions);
    var ge = new GoogleEarth(map);
    var earth = ge.getInstance(); // earth is undefined 

Expected result:
This is what I would expect, as the plugin is not initialized it should be 
undefined...but then when can I call getInstance?

Actual result:
To actually use the getInstance method you have to do something like the 
following...Although this is probably not the best way to do it...

    var map = new google.maps.Map(document.getElementById('map'), myOptions);
    var ge = new GoogleEarth(map);

    google.maps.event.addListenerOnce(map, 'tilesloaded', function()
      {
        google.maps.event.addListener(map, 'maptypeid_changed', getEarthInstance);
        map.setMapTypeId(ge.MAP_TYPE_ID);
      });

    function getEarthInstance()
    {
      if(typeof googleEarth.getInstance() === 'undefined')
      {
        setTimeout("getEarthInstance()", 500);
      } else {
        var earth = ge.getInstance(); // earth is GEPlugin
      }
    }

Version: all

Browser / Operating System: all

Additional comments:

Not really a bug, more of an issue.

Original issue reported on code.google.com by fraser.c...@gmail.com on 19 Jan 2012 at 6:05

GoogleCodeExporter commented 8 years ago
Having the same issue. Was a fix ever found for this? I was looking to interact 
with Google Earth by flying to a loction onclick

Original comment by go3dexpa...@gmail.com on 11 Sep 2012 at 1:57

GoogleCodeExporter commented 8 years ago
Also having the same issue. Any word on a fix?

Original comment by j...@earthknowledge.net on 20 Jun 2013 at 6:24