aytee / 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

Objects not visible immediately after click in Earth mode #178

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I use Google Earth as primary view, but problem is because all changes I make 
aren't visible immediately. For exapmle, if I want to view created marker, I 
need to switch to one of Maps views an then back to Earth.
Relevant part of my source code:

// Init map
function init() {       
    map = new google.maps.Map(document.getElementById('map'), {
        zoom: 10,
        center: new google.maps.LatLng(xx, yy),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    // Google Earth view on Map
    googleEarth = new GoogleEarth(map);

    // Google Maps Event Handlers
    google.maps.event.addListener(map, 'click', function(event) {
        var marker = new google.maps.Marker({
            position: latlng,
            map: map,
            draggable: true
        });

        marker.setMap(map);
    });

    google.maps.event.addListener(map, 'center_changed', function() {
        // Clear timeout for sync
        if (timer) clearTimeout(timer);

        // Set new timeout function
        timer = setTimeout(function() {
            sync();
        }, 500);
    });

    // Show Google Earth first time when map loaded
    google.maps.event.addListenerOnce(map, 'tilesloaded', function() {
        google.maps.event.addListener(map, 'maptypeid_changed', getEarthInstance);
        map.setMapTypeId(GoogleEarth.MAP_TYPE_ID);
    });
}

// Try changing to show Earth until Google Earth initialized
function getEarthInstance() {
    if(typeof googleEarth.getInstance() === 'undefined') {
        setTimeout('getEarthInstance()', 500);
    } else {
        ge = googleEarth.getInstance(); // earth is GEPlugin
        startEarth();
    }
}

What steps will reproduce the problem?
1. Show map in Google Earth view
2. Click to add new Marker on Map in Earth mode

Expected result:
Expected result is that Marker is visible immediately after I click on Earth 
view, like in any of Maps view. But it is visible after switch to Maps and then 
back to Earth view.

Actual result:
Marker is not displayed on Earth.

Browser / Operating System:
[e.g. FF, IE, Chrome / Win7, Ubuntu]

Additional comments:
It looks like Earth view is not perfectly connected to Maps like in another 
problem I have. It is that when I resize parent div (with jQuery UI Layout 
Plug-in), Maps change size to fit parent div, but Earth stays small like before.

Original issue reported on code.google.com by srecko.z...@gmail.com on 4 Jun 2012 at 10:56

GoogleCodeExporter commented 9 years ago
Also having the same issue. I am assuming we need to use the Earth API specific 
functions found in the Earth API documentation 
https://developers.google.com/earth/documentation/index to fully interact with 
Earth API yet have had trouble accessing the Earth API object as outlined in 
issue #154 
https://code.google.com/p/google-maps-utility-library-v3/issues/detail?id=154&q=
getInstance&colspec=ID%20Type%20Status%20Priority%20Fixed%20Owner%20Summary%20St
ars

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