我收到以下错误:
Uncaught Error: Invalid value for property <address>:
以下是执行地理编码的代码:
function codeAddress(zipcode){
var address = zipcode;
alert("Address is: " +address);
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
该函数从以下代码中获取参数'zipcode':
<input type="button" value="Geocode" onclick="codeAddress(<%=resultset.getString(3)%>)">
请帮我解决这个问题。
答案 0 :(得分:1)
确保呈现的onclick="codeAddress(<%=resultset.getString(3)%>)"
实际上有一个字符串传递给codeAddress()
。您可能必须在其中添加单引号:onclick="codeAddress('<%=resultset.getString(3)%>')"