Yappoさんの Control Google Maps via MacBook を早速自分の MacBook で動かしてみた。すばらしい。
斜め移動がちょっとガクガクする (一度に縦移動、横移動のみしかしない) ので、patch を書いてみました。
--- gmaps.pl.orig 2006-06-16 02:39:30.000000000 +0900 +++ gmaps.pl 2006-06-16 02:40:33.000000000 +0900 @@ -27,21 +27,29 @@ next unless $data; my($x, $y) = ($data->[0], $data->[2]); + my($move_x, $move_y); if (is_move($sumx, $x, 0)) { print "L: $x - $sumx\n"; - lr($x - $sumx); + $move_x = ($x - $sumx); } elsif (is_move($sumx, $x, 1)) { print "R: $x - $sumx\n"; - lr($x - $sumx); + $move_x = ($x - $sumx); } if (is_move($sumy, $y, 0)) { print "D: $y - $sumy\n"; - ud($sumy - $y); + $move_y = ($sumy - $y); } elsif (is_move($sumy, $y, 1)) { print "U: $y - $sumy\n"; - ud($sumy - $y); + $move_y = ($sumy - $y); } + if (defined $move_x && defined $move_y){ + lr_ud($move_x, $move_y); + } elsif (defined $move_x) { + lr($move_x); + } elsif (defined $move_y) { + ud($move_y); + } last; } close($AMS); @@ -71,6 +79,17 @@ LEFT } +sub lr_ud { + my($dx, $dy) = @_; + open my $cmd, '|osascript'; + print $cmd <<LEFT; +tell application "Safari" + do JavaScript "x -= $dx * 0.0001; y += $dy * 0.0001;" in document 1 + do JavaScript "map.panTo(new GLatLng(y, x));" in document 1 +end tell +LEFT +} + sub lr { my $d = shift; open my $cmd, '|osascript';
x, y が両方変わっていたら斜め移動用サブルーチンに飛ばすだけ。