root/gmaps-thinkpad/gmaps.html

Revision 1866 (checked in by miyagawa, 13 years ago)

add meta tag to set Content-Type

Line 
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <script src="http://maps.google.com/maps?file=api&v=2.x&key=foobar" type="text/javascript"></script>
5
6     <script type="text/javascript" language="JavaScript">
7     //<![CDATA[
8
9     var map = null;
10     var x;
11     var y;
12     var base;
13     var dragging = 0;
14     var debug = 0;
15     var interval = 100; // ms
16    
17     function load() {
18       if (GBrowserIsCompatible()) {
19         map = new GMap2(document.getElementById("map"));
20         map.addControl(new GLargeMapControl());
21         map.addControl(new GMapTypeControl());
22
23         if (debug)
24           document.getElementById('log').style.visibility = 'visible';
25
26         GEvent.addListener(map, "dragstart", function() { dragging = 1 });
27         GEvent.addListener(map, "dragend", function() {
28           var center = map.getCenter();
29           x = center.x;
30           y = center.y;
31           dragging = 0;
32         });
33
34         y = 37.4419;
35         x = -122.1419;
36         map.setCenter(new GLatLng(y, x), 14);
37         base = get_pos(1).split(/,/);
38        
39         window.setTimeout(loop, interval);
40       }
41     }
42    
43     function loop() {
44       var pos = get_pos(0).split(/,/);
45       var ax = (pos[0] - base[0]) / 20;
46       var ay = (pos[1] - base[1]) / 20;
47      
48       x += ax * 0.0005;
49       y -= ay * 0.0005; // opposite way
50       map.panTo(new GLatLng(y, x));
51       if (debug)
52         document.getElementById('log').value += "moving to " + x + "," + y + "\n";
53        
54       if (dragging) {
55         window.setTimeout(void_loop, interval);
56       } else {
57         window.setTimeout(loop, interval);
58       }
59     }
60    
61     function void_loop() {
62       if (dragging) {
63         window.setTimeout(void_loop, interval);
64       } else {
65         window.setTimeout(loop, interval);
66       }
67     }
68     //]]>
69     </script>
70     <script language="PerlScript">
71     use Win32API::File qw(:ALL);
72
73     sub get_pos {
74         my $base = shift;
75         my $file = createFile("//./ShockMgr", "r ke") or die "Can't get ShockMgr device";
76         DeviceIoControl($file, 0x733fc, [], 0, my($buf), 0x24, my($bytes), []);
77         my @data = unpack "x4s*", $buf;
78         return join ",", ($base ? @data[3, 2] : @data[1, 0]);
79     }
80     </script>
81 </head>
82 <body onload="load()" onunload="GUnload()">
83   <div id="map" style="width: 800px; height: 450px"></div>
84   <textarea id="log" rows="10" cols="80" style="visibility:hidden"></textarea>
85 </body>
Note: See TracBrowser for help on using the browser.