以下がうまくいかない理由がわかりません。geocoder.geocode セグメントにはまったく入りません。私が望むのは、入力した住所のジオコードを、地図にプロットせずに受信できるようにすることだけです。
var geocoder;
function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
alert(results[0].geometry.location);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
html コード:
<div>
<input id="address" type="textbox" value="Sydney, NSW">
<input type="button" value="Encode" onclick="codeAddress()">
</div>