Open GoogleCodeExporter opened 9 years ago
Hmm, interesting. We recently added the ability to turn on right-click to
reverse
zoom. So this option and the right-click zoom out feature couldn't be enabled
at the
same time. (Which might be OK).
If you end up implementing this yourself, feel free to attach a patch to the
issue.
Original comment by pamela.fox
on 1 Jul 2008 at 10:26
This would probably also run into the Safari right-drag-problem: Issue 33. A
right-click to activate with a
subsequent left drag to zoom would be easier and more cross-browser to
implement, but probably less
functional too.
Original comment by lem...@gmail.com
on 3 Jul 2008 at 5:49
OK, I've finally figured out how to get this to work. To avoid the right-click
problem, I've instead figured out a
way to begin a drag zoom operation when you hold down the Option key
(Macintosh) or Alt key (PC). The
tricky part is canceling the operation properly when the Option key is released
-- that requires a knowledge
of the DragZoom implementation details.
Here's what you need to do.
1. Add onkeydown and onkeyup handlers to your document:
document.onkeydown = keyDown;
document.onkeyup = keyUp;
2. Here's what the handlers look like (gDragZoom is an instance of the control
created with new
DragZoomControl(...)):
function keyDown( e ) {
if ( !e ) { e = window.event; }
if ( e.altKey ) { gDragZoom.initiateZoom(); }
}
function keyUp( e ) {
if ( !e ) { e = window.event; }
if ( !e.altKey ) { gDragZoom.cancelZoom(); }
3. The cancelZoom() function is currently not part of DragZoom. The following
code needs to be added to the
library:
/**
* Method called to cancel a dragZoom as if the user had clicked the dragZoom button
* after the dragZoom operation has started.
* (Works even if the drag is already in progress.)
*
* Added by Gary Little
*/
DragZoomControl.prototype.cancelZoom = function(){
var G = this.globals;
if (G.mapCover.style.display == 'block') {
G.draggingOn = false; // ignore further mousemove events
this.initiateZoom(); // cancels the zoom in progress
}
};
4. If you turn dragzoom on and off with Option/Alt, you no longer need to
clutter the screen with a button to
begin and end the operation. To make sure it doesn't appear on the screen, set
the display option of the
buttonStartingStyle to none when you create the instance of the DragZoom
control.
Now you can quickly perform a DragZoom simply by holding down Option/Alt and
dragging the mouse. You
can cancel the operation by releasing the Option/Alt key, even if you're in the
middle of drag operation (that's
something new you couldn't do before).
Original comment by garylitt...@gmail.com
on 19 Dec 2008 at 5:29
Oh, and by the way, you can now see the "Option DragZoom" technique in action
on my real estate map at
map.GaryLittle.ca
Original comment by garylitt...@gmail.com
on 19 Dec 2008 at 5:41
Hey Gary-
That works for me on my PC, but fails in Linux as it appears that alt in Linux
serves
to move the current application window. Do you know if there's an equivalent
button
to trigger this kind of thing in on Linux machines?
Original comment by pamela.fox
on 28 Dec 2008 at 3:09
Pamela -
It appears that both KDE and GNOME bind Alt + Left Button to the window move
operation you mentioned. If
the Google Maps application developer doesn't want to use a "hot" key other
than Alt when using the
technique I described above, a Linux user will have to deactivate the Alt +
Left Button binding. See how to do
this for KDE at
http://www.infohit.net/blog/post/firefox-one-click-download-and-kde-4.html
where there
is also a discussion of another clash involving Alt clicks on Linux. I'm sure
that GNOME has a similar utility for
changing key bindings.
I was considering using the Meta key (i.e., the Apple command key), but I
believe this key on a PC (the
"Windows" key) pops up the Startup menu (Windows) or Launch menu (Linux). I'll
report back once I've had a
chance to investigate this further.
Original comment by garylitt...@gmail.com
on 28 Dec 2008 at 8:11
I always thought the drag icon is not necessary. Hold a extra key while
dragging is
the most efficient way to zoom in a point of interest. I do not own a mac, but
in a
GIS environment, hold shift key is common. See this example:
http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/demos/map
/map_add.html
I think a new drag zoom util can be implemented with this behavior with a lot
less code.
Original comment by nian...@gmail.com
on 29 Dec 2008 at 11:57
It's up to the application developer which key to use to trigger the start of a
drag zoom -- I wouldn't like to see
it hard-coded into the dragzoom.js code. The Shift key could certainly be used
(perhaps avoiding the Linux
issue noted above). On my map, however, I use a Shift-click to select a marker
as a favorite.
I picked the Alt (Option) key as the modifier key because I've seen it used for
a drag zoom on several other real
estate maps I've seen which are based on (ugh) Visual Earth.
Original comment by garylitt...@gmail.com
on 29 Dec 2008 at 5:58
Pamela -
Regarding possible use of the Meta (Windows) key instead of Alt to trigger the
start of a drag zoom: this isn't a
good choice because if you press it and immediately release it (to cancel the
drag zoom), the Startup menu will
pop up on Windows.
Using the Shift key might be the best choice in order to avoid clashing with
Linux (GNOME/KDE) bindings.
Original comment by garylitt...@gmail.com
on 29 Dec 2008 at 6:07
See this example:
http://gmaps-utility-gis.googlecode.com/svn/trunk/dragboxzoom/examples/dragzoom.
html
It is a much smaller implementation (actual code ~100 lines). It also allows you
customize the style and which key you want to use.
Original comment by nian...@gmail.com
on 29 Dec 2008 at 8:52
Nianwei -
Very nice implementation, I like it. You might as well add support for all the
modifier keys, including Caps
Lock and Meta.
I don't think the code works if the user begins the drag over a marker or a map
control (such as the zoom
slider) -- would be nice if it did otherwise users will be confused as to why
it doesn't work in certain
situations. The current dragzoom uses a large rectangle to cover the entire map
to make this happen (this
allows it to capture the mouseclick before anything else).
Gary
Original comment by garylitt...@gmail.com
on 29 Dec 2008 at 10:15
Nianwei and I have teamed up to create a very nice "interfaceless" utility
library for zooming to a rectangle which
is drawn while holding down a "hot" key (Shift, Alt, or Control). It's called
KeyDragZoom and you can investigate
it here:
http://code.google.com/p/gmaps-utility-gis/source/browse/#svn/trunk/keydragzoom
Original comment by garylitt...@gmail.com
on 3 Mar 2009 at 10:57
That's quite nice. Let's add it -- nothing wrong with giving developers a
variety of
options. The bigger issue is that there's no standard UI for drag-to-zoom or
hot key,
since Google Maps doesn't have those features. But for now developers can
indicate on
their maps what the technique for drag zooming is.
Original comment by pamela.fox
on 4 Mar 2009 at 5:44
The standard for GIS applications seems to be to hold down the Shift key while
dragging the rectangle -- so
that's what I'm now using in my application. This also avoids the problems with
Alt/Option and Meta noted
earlier.
Microsoft's VE uses the Alt/Option key.
By the way, I strongly believe this feature should be built into the Google API
-- every map should have the
benefit of Shift-drag zoom by default.... Of course, I'm biased.
Original comment by garylitt...@gmail.com
on 4 Mar 2009 at 6:16
OK. I added the lib in r952.
Original comment by nian...@gmail.com
on 5 Mar 2009 at 3:34
Awesome, just one issue: http://code.google.com/p/gmaps-utility-library-
dev/issues/detail?id=93
Original comment by pamela.fox
on 8 Mar 2009 at 8:28
Original issue reported on code.google.com by
garylitt...@gmail.com
on 28 Jun 2008 at 9:19