单击不起作用
问题描述:
我想在单击时调用此功能,但它不能用于单击。单击不起作用
<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();
}
答
它实际上是调用,但在你的代码中的实际问题是谷歌代码,请确保您的第一个代码中的功能处于工作状态。
function codeAddress() {
alert('hello its calling, the problem is in your google code, that is the actual problem!');
}
<input id="search" type="button" onClick="codeAddress();" value="Search Location" />
“它不工作”,这是一个错误,我总是在这个网站 – madalinivascu
你是否包括谷歌地图JavaScript API V3获得最详细的说明?请提供证明问题的[mcve]。 – geocodezip