Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 54 lines (50 sloc) 2.443 kB
0291efc @jawj Added demo page
authored
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <style>
6 html, body { margin: 0; padding: 0; overflow: hidden; width: 100%; height: 100%; background: #000; }
7 #earth { position: absolute; height: auto; top: 0; bottom: 0; left: 0; right: 0; }
8 </style>
f66ea63 @jawj Added API key
authored
9 <script src="https://www.google.com/jsapi?key=AIzaSyAb-oiYynfwQv32qOy1BYRTdwEf8bj4ekw"></script>
0291efc @jawj Added demo page
authored
10 <script src="https://raw.github.com/jawj/spindlytext/master/spindlytext.js"></script>
11 <title>spindlytext demo</title>
12 </head>
13 <body>
14 <div id="earth"></div>
15 <script>
16 google.load('earth', '1.x', {other_params:'sensor=false'});
17 window.onload = function() {
e87dafb @jawj Changed camera angle
authored
18 var camCoords = {lat: 51.5047527987133, lon: -0.1263746349634376, alt: 250, heading: 180, tilt: 70};
0291efc @jawj Added demo page
authored
19 var bbCoords = {lat: 51.5007286626542, lon: -0.1245953142642975, alt: 200};
2fc8cc6 @jawj Tweaked demo
authored
20 var bbDegreesToCam = Math.atan2(bbCoords.lon - camCoords.lon, bbCoords.lat - camCoords.lat) * 180 / Math.PI;
0291efc @jawj Added demo page
authored
21
22 var initCallback = function(ge) {
23 var lRoot = ge.getLayerRoot();
24 var layers = [ge.LAYER_TERRAIN, ge.LAYER_TREES, ge.LAYER_BUILDINGS, ge.LAYER_BUILDINGS_LOW_RESOLUTION];
2fc8cc6 @jawj Tweaked demo
authored
25 for (var i = 0, len = layers.length; i < len; i ++) lRoot.enableLayerById(layers[i], true);
0291efc @jawj Added demo page
authored
26 ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT)
27 var view = ge.getView();
28 var cam = view.copyAsCamera(ge.ALTITUDE_ABSOLUTE);
29 cam.setLatitude(camCoords.lat);
30 cam.setLongitude(camCoords.lon);
31 cam.setAltitude(camCoords.alt);
32 cam.setHeading(camCoords.heading);
33 cam.setTilt(camCoords.tilt);
34 view.setAbstractView(cam);
35
36 // *** Spindlytext action begins here...
37 var bigBen = new Spindlytext(bbCoords.lat, bbCoords.lon, bbCoords.alt);
3101093 @jawj Switched to link
authored
38 bigBen.text('Big Ben', {bearing: bbDegreesToCam, size: 5, lineWidth: 4});
0291efc @jawj Added demo page
authored
39 bigBen.text('Palace of Westminster', {bearing: bbDegreesToCam, size: 3});
3101093 @jawj Switched to link
authored
40 bigBen.text(new Date().toString(), {bearing: bbDegreesToCam, size: 3});
41 bigBen.text("https://github.com/jawj/spindlytext", {bearing: bbDegreesToCam, size: 3, colour: 'ff00ffff'});
0291efc @jawj Added demo page
authored
42 var bbKml = bigBen.kml();
43 var bbNode = ge.parseKml(bbKml);
44 ge.getFeatures().appendChild(bbNode);
45 // *** and ends here
46
47 ge.getWindow().setVisibility(true);
48 }
49 google.earth.createInstance('earth', initCallback, function() { console.log("Google Earth error: #{errorCode}"); });
50 }
51 </script>
52 </body>
53 </html>
Something went wrong with that request. Please try again.