Monday, 15 June 2015

javascript - Google Map mouse wheel bug -



javascript - Google Map mouse wheel bug -

normally it's possible scroll / zoom vertically out of map. there gray background. "disabled / blocked" that.

this works fine if utilize controls google map. if zoom mouse wheel it's kinda buggy , can zoom out of map, gray area visible.

here live example: example

how prepare without disabling mouse wheel zoom?

image:

theme.gmap.position = function () { var allowedbounds; var lastcenter; var lastzoom; var initcenter; var initzoom; function checkbounds() { if (theme.base.isundefined(allowedbounds)) { homecoming false; } if (allowedbounds.getnortheast().lat() > theme.gmap.google_map.getbounds().getnortheast().lat()) { if (allowedbounds.getsouthwest().lat() < theme.gmap.google_map.getbounds().getsouthwest().lat()) { lastcenter = theme.gmap.google_map.getcenter(); lastzoom = theme.gmap.google_map.getzoom(); homecoming true; } } theme.gmap.google_map.panto(lastcenter); theme.gmap.google_map.setzoom(lastzoom); homecoming false; } homecoming { createlatlng:function (lat, lng) { homecoming new google.maps.latlng(lat, lng); }, centermap:function (latlng) { theme.gmap.google_map.setcenter(latlng); }, setlimit:function () { allowedbounds = new google.maps.latlngbounds( this.createlatlng(-85.0511, -122.591), this.createlatlng(85.0511, -122.333) ); initcenter, lastcenter = theme.gmap.google_map.getcenter(); initzoom, lastzoom = theme.gmap.google_map.getzoom(); google.maps.event.addlistener(theme.gmap.google_map, 'bounds_changed', function () { checkbounds(); }); google.maps.event.addlistener(theme.gmap.google_map, 'center_changed', function () { checkbounds(); }); } }; }();

i guess forced 2 competing events, both event fire each time. center_changed event redundant(the bounds alter when center changes), may remove center_changed-listener(for me fixes issue)

javascript google-maps google-maps-api-3 zoom mousewheel

No comments:

Post a Comment