2

I keep getting the error : Uncaught TypeError: Cannot call method 'lat' of undefined with the google maps when I try to center the map based on the markers. I am using the jquery-ui-maps api v3 for this. Can anyone please help me out ?.

My code is as shown below :

//Auto Center the Map Depending on the Markers
function autoCenter() {

    console.log("Trying to get the map centered around " + arrayMarkers.length + " markers.");

    var map = $('#map_canvas').gmap('get', 'map');
     console.log("1..." + map);
    var bounds = new google.maps.LatLngBounds();
    console.log("2...");
    for (var i = 0, LtLgLen = arrayMarkers.length; i < LtLgLen; i++) {
        console.log("3...");
        bounds.extend(arrayMarkers[i]);
        console.log("4...");
    }
    console.log("5...");
    map.fitBounds(bounds);
    console.log("6...");
}

The error occurs between the logs 3 and 4. So it stops at log message 3..

msrameshp
  • 626
  • 2
  • 12
  • 33

0 Answers0