Changeset 1859

Show
Ignore:
Timestamp:
06/15/06 01:00:05
Author:
miyagawa
Message:

bind events to dragstart and dragevent so that while you're dragging, the script doesn't detec the sensor. It allows you to move to your favorite place before driving the sky.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gmaps-thinkpad/gmaps.html

    r1857 r1859  
    11<html> 
    22<head> 
    3 <script src="http://maps.google.com/maps?file=api&v=2&key=foobar" type="text/javascript"></script> 
     3<script src="http://maps.google.com/maps?file=api&v=2.x&key=foobar" type="text/javascript"></script> 
    44 
    55    <script type="text/javascript" language="JavaScript"> 
    66    //<![CDATA[ 
    77 
    8     var map
     8    var map = null
    99    var x; 
    1010    var y; 
    1111    var base; 
     12    var dragging = 0; 
    1213    var debug = 0; 
    1314    var interval = 100; // ms 
     
    1819        map.addControl(new GLargeMapControl()); 
    1920        map.addControl(new GMapTypeControl()); 
    20         if (debug) { 
     21 
     22        if (debug)  
    2123          document.getElementById('log').style.visibility = 'visible'; 
    22           //document.getElementById('log').styles = "visibility:visible;display:block"; 
    23           } 
    24          
     24 
     25        GEvent.addListener(map, "dragstart", function() { dragging = 1 }); 
     26        GEvent.addListener(map, "dragend", function() { 
     27          var center = map.getCenter(); 
     28          x = center.x; 
     29          y = center.y; 
     30          dragging = 0; 
     31        }); 
     32 
    2533        y = 37.4419; 
    2634        x = -122.1419; 
     
    4250      if (debug) 
    4351        document.getElementById('log').value += "moving to " + x + "," + y + "\n"; 
    44       window.setTimeout(loop, interval); 
     52         
     53      if (dragging) { 
     54        window.setTimeout(void_loop, interval); 
     55      } else { 
     56        window.setTimeout(loop, interval); 
     57      } 
     58    } 
     59     
     60    function void_loop() { 
     61      if (dragging) { 
     62        window.setTimeout(void_loop, interval); 
     63      } else { 
     64        window.setTimeout(loop, interval); 
     65      } 
    4566    } 
    4667    //]]>