What does this mean?
google.maps.event.addDomListener(window, 'load', initialize);
I have the function 'initialize()' but I also added two paramters, longitude and latitude so it's like this:
function initialize(longitude, latitude){
}
because of this do I have to do anything to the 'initialize' in the line:
google.maps.event.addDomListener(window, 'load', initialize);
The google.maps.event.addDomListener adds a DOM event listener, in this case to the window
object, for the 'load' event, and specifies a function to run.
from the documentation:
addDomListener(instance:Object, eventName:string, handler:function(?), capture?:boolean)
Return Value: MapsEventListener
Cross browser event handler registration. This listener is removed by calling removeListener(handle) for the handle that is returned by this function.
The initialize
in google.maps.event.addDomListener(window, 'load', initialize);
is a function pointer, you can't pass arguments with that. To pass in arguments, wrap it in an anonymous function (that doesn't take arguments):
google.maps.event.addDomListener(window, 'load', function () {
initialize(latitude, longitude);
});
It looks like it calls initialize
when the DOM is loaded, but probably without the parameters, if I interpret the docs correctly.
But you could wrap the call inside another function and pass that to the method. It can be an anonymous function, like so:
google.maps.event.addDomListener(window, 'load', function(){
initialize(50.0000, 60.0000);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With