Google Maps Api v3 - getBounds is undefined

Posted by Via Lactea on Stack Overflow See other posts from Stack Overflow or by Via Lactea
Published on 2010-05-14T07:59:07Z Indexed on 2010/05/14 8:04 UTC
Read the original article Hit count: 653

Hi All,

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 initialization.

Here is my javascript code:


var gMap;
$(document).ready(

    function() {

        var latlng = new google.maps.LatLng(55.755327, 37.622166);
        var myOptions = {
            zoom: 12,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        gMap = new google.maps.Map(document.getElementById("GoogleMapControl"), myOptions);

        alert(gMap.getBounds());

So now it alerts me that gMap.getBounds() is undefined.

I've tryed to get getBounds values in click event and it works fine for me, but I cannot get the same results in load map event.

Also getBounds works fine while document is loading in Google Maps API v2, but it fails in V3.

Could you please help me to solve this problem?

© Stack Overflow or respective owner

Related posts about google-maps

Related posts about google-maps-api-3