I was wondering if there was a way to bind the shift key to an icon on the screen, so you dont have to hold down the shift key to area zoom to teh map? so when the user clicks on the icon it acts as if the user is holding the shift key down and can highlight an area to zoom into. i found another example but when i try and click on other buttons the zoom box keeps active.
var isactive = false; function switchZoomFunction(map) { if (isactive == false) { olmap = Map1.getOpenLayersMap(); olmap.controls[1].deactivate(); // Please make sure the control id is Navigation for this controls[1]
var zoomBox = new OpenLayers.Control.ZoomBox({ alwaysZoom: false }); olmap.addControl(zoomBox); zoomBox.activate(); isactive = true; } else { isactive = false;
function switchZoomFunction() { olMap = Map1.getOpenLayersMap(); if (olMap.controls[2].active == true) { var zoomBox = new OpenLayers.Control.ZoomBox({ alwaysZoom: false }); olMap.controls[2].deactivate(); // Please make sure the control id is Navigation for this controls[1] //var zoomBox = new OpenLayers.Control.ZoomBox({ alwaysZoom: true }); olMap.addControl(zoomBox); zoomBox.activate(); return false; } else { olMap.removeControl(olMap.controls[10]); //zoomBox.deactivate(); olMap.controls[2].activate(); // This control support common zoom function return true; } }
but now when you zoom in and change it back to the normal mouse the click event wont fire. It wont find any click events after zooming in using the zoom box tool but if you click with the zoom box the mouse click fires then you can switch to the normals mouse and everything works
More details about navigation control, please refer to dev.openlayers.org/releases/OpenLayers-2.13.1/doc/apidocs/files/OpenLayers/Control/Navigation-js.html
Would you please try the attached files by comparing if there is any differences between us? Both the click event and the zoom box switching work fine.
If the issue persists, would you please create a sample for us?