Skip to content Skip to sidebar Skip to footer

Google Map Api V3 - Maximum Call Stack Size Exceeded

I have been developing a JS widget for the last 5 or 6 weeks. The idea is that it can be added to any site by simply adding a href to the remote .js file and also a DIV container w

Solution 1:

Thanks Matt Alexander this was exactly the problem and the solution, however it seems that Google changed the names of the Location properties AGAIN, not .k and .D anymore, now its .A and .F!, take a look at the following console log:

Console Log

Solution 2:

For nowadays it's '.G' and '.K'. And as said - it's better to use '.lat()' and '.lng()'.

Solution 3:

You can also use

 keys = Object.keys(LatLng);
 geometry.location[keys[0]]; // Obtain value for latitude

Solution 4:

I have found the cause of this issue and have a fix.

I was using the following code:

        address = document.getElementById("strSearch").value;

    geocoder.geocode({ 'address': address, componentRestrictions: { country: 'GB' } }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            toggleModal();

            deleteMarkers();
            deleteBanks();

            searchSourceLatLng = new google.maps.LatLng(results[0].geometry.location.k, results[0].geometry.location.B);
            setSearchPointPostcode(results, buildResults);
        }

        else {
            callback();
        }
    })

The particular line that caused the issue is:

searchSourceLatLng = new google.maps.LatLng(results[0].geometry.location.k, results[0].geometry.location.B);

".B" has worked for weeks, but now it would seem that is no longer a valid property. Instead, ".D" works and so my code now works.

As the property was no longer valid, I had a LatLng object with a null value and this caused the map to crash when I tried to see my map boundaries.

I would love to know how or why this has changed in the API.

Also, a stupid question I'm sure, but why ".k" and ".D"? What's wrong with ".Lng" and ".Lat"?

Glad it's sorted though, just hope the API doesn't change again.

Solution 5:

You can loop over the properties of location and get the coordinates without accessing its properties directly:

geocoder.geocode({ 'address': value.address }, function (results, status) {
if (status === google.maps.GeocoderStatus.OK && results.length > 0) {

    var coords = [];
    for (var key in results[0].geometry.location) {
        coords.push(results[0].geometry.location[key]);
    }
    return {
        'latitude': coords[0],
        'longitude': coords[1]
    };
}
});

Post a Comment for "Google Map Api V3 - Maximum Call Stack Size Exceeded"