Created
May 28, 2011 19:32
-
-
Save aknosis/997144 to your computer and use it in GitHub Desktop.
Execute callback once when a google map is loaded (google maps api)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Fill in the blanks :) | |
var map = new google.maps.Map(), | |
tileListener = google.maps.event.addListener(map,'tilesloaded',fixMyPageOnce); | |
function fixMyPageOnce(){ | |
//immediately remove the listener (or this thing fires for every tile that gets loaded, which is a lot when you start to pan) | |
google.maps.event.removeListener(tileListener); | |
} |
This will call once the map is finished doing its thing.
google.maps.event.addListenerOnce(map, 'idle', function(){
// do something only the first time the map is loaded
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also use the following and avoid having to remove the listener manually: