Hi, I'm tinkering a bit with DragZoom library. I would like to create a setup where a user can just shift-drag to zoom in or out as many. I have troble with the control zoom state though.
My current code: http://map.ter.dk/shiftdragzoom.html It's easy to create a general DOM handler for checking if shift is pressed (as Pamela mentioned in an old post) using document.onkeydown and document.onkeyup. I can also create a global variable and store the control here: var dzc; function load() { if (GBrowserIsCompatible()) { ... dzc = new DragZoomControl(); map.addControl(dzc); } } And further on fire the zoom control using dzc.initiateZoom(); However it seems like as initiateZoom() just toggles the state and I can't see any way to explicit set or check the current state (if the control is selected/active) I run into problems when the zoom has been executed (and initiateZoom() seem to be called when the zoom is performed. My key handler: document.onkeydown = keyDownHandler; document.onkeyup = keyUpHandler; function keyDownHandler(e){ if (!e) var e = window.event; if ( (e.shiftKey) && !shiftOn){ dzc.initiateZoom(); shiftOn = true; } } function keyUpHandler(e){ if (!e) var e = window.event; if (shiftOn) { dzc.initiateZoom(); shiftOn = false; } } My problems are: 1. When the zoom has been performed I'm in a reverse state. I might be able to have a switch variable for this but it just seems like I'm overcomplicating the feature. Furthermore I guess there are several edge cases where an event is not registered. Other programs or windows taking focus and so on. 2. I wouldn't like the control to be visible. I could just remove its visibility using CSS. However I keep thinking I should just use some methods in a more direct fashion instead of requiring a GControl at first. Is my current method just bad usage of a control where I would just need some events instead or am I getting close to a pretty solution? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
