views:

413

answers:

1

How to create something like on this video (1-2 minutes http://www.ted.com/index.php/talks/sergey_brin_and_larry_page_on_google.html) using "Google Earth API" or some other?

Especially: I have an online game and want to show dynamical data on some "virtual earth". 3 types of objects changing their state in real-time. It's enough to update each 5 seconds. I already have open api for it.

The problem is i do not know if it's possible to draw something like colored lines from a sphere's center and change them dynamically.

Sorry for an abstract question, but the goal is the same. Thanks for all advises.

+3  A: 

Well, if you're using the Google Earth API (requires that the Google Earth Plugin be installed), you can just create a bunch of extruded polygons. For example, if you go to the Earth API Interactive Sampler and paste/run this:

var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
var lat = lookAt.getLatitude();
var lng = lookAt.getLongitude();

// first create inner and outer boundaries
// outer boundary is a square
var outerBoundary = ge.createLinearRing('');
var coords = outerBoundary.getCoordinates();
coords.pushLatLngAlt(lat - 0.5, lng - 0.5, 1000000); 
coords.pushLatLngAlt(lat - 0.5, lng + 0.5, 1000000); 
coords.pushLatLngAlt(lat + 0.5, lng + 0.5, 1000000); 
coords.pushLatLngAlt(lat + 0.5, lng - 0.5, 1000000); 

// create the polygon and set its boundaries
var polygon = ge.createPolygon('');
polygon.setExtrude(true);
polygon.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
polygon.setOuterBoundary(outerBoundary);

// create the polygon placemark and add it to Earth
var polygonPlacemark = ge.createPlacemark('');
polygonPlacemark.setGeometry(polygon);
ge.getFeatures().appendChild(polygonPlacemark);

// persist the placemark for other interactive samples
window.placemark = polygonPlacemark;
window.polygonPlacemark = polygonPlacemark;

You'll see a 3D polygon extruded out of the globe.

There's much more you can do with this; I suggest playing with the Earth API and KML (foundation for geometry primitives in the Earth API) by visiting code.google.com/apis/earth and code.google.com/apis/kml.

Roman Nurik