Javascript 单键单击不工作

Javascript 单键单击不工作,javascript,jquery,google-maps,latitude-longitude,Javascript,Jquery,Google Maps,Latitude Longitude,我想在单击时调用此函数,但它在单击时不起作用 <input id="search" type="button" onClick="codeAddress();" value="Search Location" /> function codeAddress() { geocoder = new google.maps.Geocoder(); var address = document.getElementById("box").value; geocode

我想在单击时调用此函数,但它在单击时不起作用

<input id="search" type="button" onClick="codeAddress();" value="Search Location" />

function codeAddress() {
    geocoder = new google.maps.Geocoder();
    var address = document.getElementById("box").value;
    geocoder.geocode( { 'address': address}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            a = results[0].geometry.location.lat();
            b = results[0].geometry.location.lng();
            myLatlng = new google.maps.LatLng(a, b);
        } 
        else {
            alert("Geocode was not successful for the following reason: " + status);
        }
    });
    initialize();
}

函数代码地址(){
geocoder=新的google.maps.geocoder();
var address=document.getElementById(“框”).value;
geocoder.geocode({'address':address},函数(结果,状态){
if(status==google.maps.GeocoderStatus.OK){
a=结果[0]。几何体。位置。纬度();
b=结果[0]。几何体。位置。lng();
myLatlng=新的google.maps.LatLng(a,b);
} 
否则{
警报(“地理编码因以下原因未成功:“+状态”);
}
});
初始化();
}

它实际上正在调用,但您的代码中的实际问题是google代码,请首先确保函数中的代码处于工作状态

函数代码地址(){
警报('你好,它在呼叫,问题在你的谷歌代码中,这就是实际问题!');
}

“它不工作”这是我在这个网站上经常遇到的错误的最详细的描述。您是否包括Google Maps Javascript API v3?请提供一个示例来说明问题。是的,codeAddress()正在工作,错误在我在codeAddress()中调用的函数“initialize()”中。我解决了…谢谢你Jagar7521是的这就是我在回答中说的你读过了吗?