本文介绍了什么是“google.maps.event.addDomListener(window,'load',initialize);”意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是什么意思?

  google.maps.event.addDomListener(window,'load',initialize); 

我有函数'initialize()',但我还添加了两个参数,经度和纬度,像这样:

$ p $ 函数初始化(经度,纬度){

}
code>

因为这样,我必须对行中的'initialize'做任何事情:

  google.maps.event.addDomListener(window,'load',initialize); 


解决方案

将DOM事件侦听器添加到窗口中对象,用于'load'事件,并指定一个要运行的函数。



来自:

google.maps.event.addDomListener(window,'load',initialize)中初始化; 是一个函数指针,你不能传递参数接着就,随即。要传入参数,请将其包装在匿名函数(不带参数)中:

  google.maps.event。 addDomListener(window,'load',function(){
initialize(latitude,longitude);
});


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:

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);
});

这篇关于什么是“google.maps.event.addDomListener(window,'load',initialize);”意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 21:07