Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (50 sloc) 2.39 KB
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
html, body { margin: 0; padding: 0; overflow: hidden; width: 100%; height: 100%; background: #000; }
#earth { position: absolute; height: auto; top: 0; bottom: 0; left: 0; right: 0; }
</style>
<script src="https://www.google.com/jsapi?key=AIzaSyAb-oiYynfwQv32qOy1BYRTdwEf8bj4ekw"></script>
<script src="https://raw.github.com/jawj/spindlytext/master/spindlytext.js"></script>
<title>spindlytext demo</title>
</head>
<body>
<div id="earth"></div>
<script>
google.load('earth', '1.x', {other_params:'sensor=false'});
window.onload = function() {
var camCoords = {lat: 51.5047527987133, lon: -0.1263746349634376, alt: 250, heading: 180, tilt: 70};
var bbCoords = {lat: 51.5007286626542, lon: -0.1245953142642975, alt: 200};
var bbDegreesToCam = Math.atan2(bbCoords.lon - camCoords.lon, bbCoords.lat - camCoords.lat) * 180 / Math.PI;
var initCallback = function(ge) {
var lRoot = ge.getLayerRoot();
var layers = [ge.LAYER_TERRAIN, ge.LAYER_TREES, ge.LAYER_BUILDINGS, ge.LAYER_BUILDINGS_LOW_RESOLUTION];
for (var i = 0, len = layers.length; i < len; i ++) lRoot.enableLayerById(layers[i], true);
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT)
var view = ge.getView();
var cam = view.copyAsCamera(ge.ALTITUDE_ABSOLUTE);
cam.setLatitude(camCoords.lat);
cam.setLongitude(camCoords.lon);
cam.setAltitude(camCoords.alt);
cam.setHeading(camCoords.heading);
cam.setTilt(camCoords.tilt);
view.setAbstractView(cam);
// *** Spindlytext action begins here...
var bigBen = new Spindlytext(bbCoords.lat, bbCoords.lon, bbCoords.alt);
bigBen.text('Big Ben', {bearing: bbDegreesToCam, size: 5, lineWidth: 4});
bigBen.text('Palace of Westminster', {bearing: bbDegreesToCam, size: 3});
bigBen.text(new Date().toString(), {bearing: bbDegreesToCam, size: 3});
bigBen.text("https://github.com/jawj/spindlytext", {bearing: bbDegreesToCam, size: 3, colour: 'ff00ffff'});
var bbKml = bigBen.kml();
var bbNode = ge.parseKml(bbKml);
ge.getFeatures().appendChild(bbNode);
// *** and ends here
ge.getWindow().setVisibility(true);
}
google.earth.createInstance('earth', initCallback, function() { console.log("Google Earth error: #{errorCode}"); });
}
</script>
</body>
</html>
Something went wrong with that request. Please try again.