I was trying Google maps. I found this statement.
google.maps.event.addDomListener(window, 'load', initialize);
what is the function of that statement ?
I was trying Google maps. I found this statement.
google.maps.event.addDomListener(window, 'load', initialize);
what is the function of that statement ?
Share Improve this question edited Jul 19, 2013 at 9:14 Sathyajith Bhat 21.9k22 gold badges99 silver badges139 bronze badges asked Jul 19, 2013 at 9:13 Daniel Listyo EmanuelDaniel Listyo Emanuel 3371 gold badge6 silver badges13 bronze badges 2- from the looks of it, it adds a call to "initialize" when the DOM is loaded. – Thilo Commented Jul 19, 2013 at 9:16
- it runs the function 'initialize' when the window 'load' event is fired? – EvilEpidemic Commented Jul 19, 2013 at 9:17
2 Answers
Reset to default 13It adds a listener to the window
object, which as soon as the load
event is triggered (i.e. "the page has finished loading") executes the function initialize
.
I.e. it delays the Google Map related script until the page has finished loading.
@Dust function is initialize and it is called only after the <div> element is loaded. in maps.event..., I think event is element because essentially it contains the map-canvas information.