开发者

Using custom control with Google Maps KeyDragZoom - how to activate drag zoom?

开发者 https://www.devze.com 2023-03-31 01:01 出处:网络
I am using KeyDragZoom http://google-maps-utility-library-v3.googlecode.com/svn/tags/keydragzoom/2.0.5/docs/examples.html

I am using KeyDragZoom

http://google-maps-utility-library-v3.googlecode.com/svn/tags/keydragzoom/2.0.5/docs/examples.html

I would like to put the control somewhere else on the page, not within the google map. I can not figure out how to do this. I would even be fine with having a button off the map that would just trigger a click of the button within the map. How can I activate the drag zoom?

P.开发者_JS百科S. I am using the Visual Drag Zoom Control instead of using a keyboard key like shift.


Ended up doing this $('img[src=http://maps.gstatic.com/mapfiles/ftr/controls/dragzoom_btn.png]').click();

Thanks hookedonwinter


The accepted answer assumes that the zoom control is on the map. If visualEnabled is false, the dragzoom_btn image will not exist.

A hack that seems to work:

function onZoomClick() {
   var myKeyDragZoom = map.getDragZoomObject();
   myKeyDragZoom.hotKeyDown_ = !myKeyDragZoom.hotKeyDown_;
}

When clicked, the zoom mode is turned on. When clicked again or the rectangle is drawn, zoom mode is automatically turned off.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号