Trying to use OpenLayers to (eventually) load markers, vectors & WMS on top of a google earth plugin base map. Google Earth does not appear to 'play well with others'.
If I instantiate a map in the 'google way': google.earth.createInstance('map', initCB, failCB);
I get a google map that I can add google placemarks to, but I can't pass that instance to OpenLayers.
Using the following:
map = new OpenLayers.Map('ol-map');
map.addControl(new OpenLayers.Control.LayerSwitcher());
var gphy = new OpenLayers.Layer.Google(
"Google Physical",
{type: G_PHYSICAL_MAP}
);
var gmap = new OpenLayers.Layer.Google(
"Google Streets", // the default
{numZoomLevels: 20}
);
var ghyb = new OpenLayers.Layer.Google(
"Google Hybrid",
{type: G_HYBRID_MAP, numZoomLevels: 20}
);
var gsat = new OpenLayers.Layer.Google(
"Google Satellite",
{type: G_SATELLITE_MAP, numZoomLevels: 22}
);
var gearth = new OpenLayers.Layer.Google(
"Google Earth",
{type: G_SATELLITE_3D_MAP}
);
map.addLayers([gphy, gmap, ghyb, gsat, gearth]);
map.setCenter(new OpenLayers.LonLat(-120, 32), 5)
addMarker();
This creates a basic OL map with 5 googly layers. I can see the marker I add when any of the map layers except when gearth is selected. As soon as I load the google earth map, it 'takes over' the entire div. All the OL controls such as the LayerSwitcher are gone and I haven't been able to figure out how to access the google earth instance from OL.
I'm assuming the markers are still present, but behind the basemap. Setting the opacity on the basemap has no effect.
Questions:
Half-baked ideas welcome.
In general, OpenLayers has absolutely no support for the Google Earth 3D mode. (I'm a developer for OpenLayers, and I only became aware that this was possible via this question.) Because of the way that the 3D display code works (via a 3rd party plugin), I can not imagine any way that the default OpenLayers tools -- for drawing, etc. -- are going to work: the pieces that OpenLayers would need to integrate with simply don't exist in the 3D API.
OpenLayers -- primarily being a 2D drawing client -- is unlikely to ever implement something that would translate all of its various calls into Google Maps/Earth API calls.
OpenLayers does have support for Protocols and Formats: in theory, this would allow you to use the OpenLayers WFS processing toolchain to some extent when interacting with third party APIs like the Google Earth API. However, I expect that in this case, you don't gain sufficiently enough from this to solve your problem.
In short: This doesn't work, and there is no simple solution. If you want 3D, you'll probably need to build a lot more yourself.