Skip to content

Instantly share code, notes, and snippets.

@cmawhorter
Created June 15, 2016 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cmawhorter/a1b0b6a6b73678b97920f748ebca244b to your computer and use it in GitHub Desktop.
Save cmawhorter/a1b0b6a6b73678b97920f748ebca244b to your computer and use it in GitHub Desktop.
if you absolutely want to use that SO code
// snippet for SO: http://stackoverflow.com/a/14138133/670023
// Never do this. Handlers inside of handlers is a Bad Idea regardless of whether they're once or not.
google.maps.event.addListenerOnce(map, 'tilesloaded', function(){
//this part runs when the mapobject is created and rendered
google.maps.event.addListenerOnce(map, 'tilesloaded', function(){
//this part runs when the mapobject shown for the first time
});
});
// i'm not saying that answer is correct, but if you absolutely want to use that solution, do this instead:
var tilesLoadedCount = 0;
google.maps.event.addListener(map, 'tilesloaded', function() {
tilesLoadedCount++;
if (tilesLoadedCount === 2) {
}
});
@fernandoPalaciosGit
Copy link

thanks for your gits, maybe last tilesload subscription is the question to be solved, I try to debug for "last change of tiles loaded before idle map", and my research found nearly your solution:

google.maps.event.addListener(map, 'tilesloaded', _.after(function() {
  // you are sour to refresh or center bounds
}, 3));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment