Google Maps Api v3 - getBounds is undefined

前端 未结 5 1694
春和景丽
春和景丽 2020-11-30 21:41

I\'m switching from v2 to v3 google maps api and got a problem with gMap.getBounds() function.

I need to get the bounds of my map after its initializati

5条回答
  •  爱一瞬间的悲伤
    2020-11-30 22:19

    Well, i'm not sure if i'm too late, but here's my solution using gmaps.js plugin:

    map = new GMaps({...});
    
    // bounds loaded? if not try again after 0.5 sec
    var check_bounds = function(){
    
            var ok = true;
    
            if (map.getBounds() === undefined)
                ok = false;
    
            if (! ok) 
                setTimeout(check_bounds, 500);
            else {
                 //ok to query bounds here
                  var bounds = map.getBounds();
            }   
        }
    
        //call it
        check_bounds();
    

提交回复
热议问题