Skip to content Skip to sidebar Skip to footer

Maximum Call Stack Size Exceeded / Too Much Recursion On Google Maps Api Custom Map Type With Allowed Bounds

I'm trying to create a page using an custom map type image map as a background. I needed to restrict the panning on the image, so that it's not possible to pan past the image, but

Solution 1:

In your center_changed listener where you check if your newLat and newLng are out of bounds, you assign to newLng the return value (number) of center.lng(), but to newLat you assign the function center.lat:

if(center.lng() > boundLimits.minLng && center.lng() < boundLimits.maxLng) {
    newLng = center.lng();
}
if(center.lat() > boundLimits.minLat && center.lat() < boundLimits.maxLat) {
    newLat = center.lat;
}

Obviously, you need to call center.lat:

newLat = center.lat();

Post a Comment for "Maximum Call Stack Size Exceeded / Too Much Recursion On Google Maps Api Custom Map Type With Allowed Bounds"