Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Error Too much recursions #366

Closed
batzidi opened this issue Nov 6, 2014 · 9 comments
Closed

Error Too much recursions #366

batzidi opened this issue Nov 6, 2014 · 9 comments

Comments

@batzidi
Copy link

batzidi commented Nov 6, 2014

Hello.
I setup a page to show the error: http://cloud.bzimg.com/gmaps

The Problem:
When I try to resize the window and set the Center again for the map it's going into recurstion and eventually breaks the map.
Chrome just shows error in the console while Firefox shows the exact error: Too much recursions. The line on which the error occurs is different everytime, but so far it repeatly says lines: 13, 14, 17

Every suggestion or advise is welcome.
Thank you

@hpneo
Copy link
Owner

hpneo commented Nov 6, 2014

Hi, try this: #330 (comment)

@batzidi
Copy link
Author

batzidi commented Nov 6, 2014

Hello,
Thank you for your reply.
Unfortunatelly it still gives the error mentioned above.
After a little digging it turns out that map.setCenter calling gives the error.

@batzidi
Copy link
Author

batzidi commented Nov 6, 2014

Silly me !!!
Here is the solution:

$( window ).resize(function() {
var lat = map.getCenter()['k'];
var lng = map.getCenter()['B'];
map.refresh();
map.setCenter(lat, lng);
});

@batzidi batzidi closed this as completed Nov 6, 2014
@krishunt
Copy link

How does this solve the recursion problem? Using that same code, Chrome still locks up for me with 100% CPU usage.

@hpneo
Copy link
Owner

hpneo commented Apr 30, 2015

Could you please post your code here?

@ffflabs
Copy link

ffflabs commented May 1, 2015

@batzidi you shouldn't try to access map center's properties ( lat and lng ) directly. The key keeps changing and probably 'k' and 'B' doesn't mean anything at this point. Always try to use the getters.

var lat = map.getCenter().lat(),
    lng = map.getCenter().lng();

@krishunt
Copy link

krishunt commented May 1, 2015

Felipe, that fixed it! It actually works better than I expected, since it continually and quickly recenters on the fly as you resize. The code that works is:

$(window).resize(function() {
var lat = map.getCenter().lat(),
    lng = map.getCenter().lng();
map.refresh();
map.setCenter(lat, lng);
});

Thank you very much!

@batzidi
Copy link
Author

batzidi commented Jun 24, 2015

@amenadiel You're right! This is what I am using right now. But forgot to put a comment about it.

@ffflabs
Copy link

ffflabs commented Jun 25, 2015

Cheers then @batzidi

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants