住所を緯度と経度に変換しようとしていますが、値が表示されていません。 私は結果をデータベースに保存したいと思っていますが、私は最初に緯度/経度を取得することができません。私はどこが間違っているのか知りたい。住所を緯度と経度に変換する
以下コードです:
<html>
<head>
<title>Theater</title>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&language=en" ></script>
<script>
// Called when page is loaded
function Init()
{
var address = Document.getElementById("address");
var city = Document.getElementById("city");
var state = Document.getElementById("state");
var zip = Document.getElementById("zip");
var country = Document.getElementById("country");
// make google call to convert address to lat/lng coordinate
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address+city+state+zip+country}, ShowLatLng);
}
// This function is the called when Google geocode() returns the result of geocoding an address
function ShowLatLng(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
document.getElementById('latlng').innerHTML = results[0].geometry.location;
}
}
</script>
</head>
<body>
<table><tr>
<td> Address   </td>
<td><input type="text" name="address" id="address"> </td> </tr>
<tr><td> City</td><td><input type="text" name="city" id="city"></td>
<td>State </td><td><input type="text" name="state" id="state"></td></tr>
<tr><td>zip</td><td><input type="text" name="zip" id="zip"></td>
<td>Country</td><td><input type="text" name="country" id="country"></td>
</tr></table>
<input type="button" onclick="Init()" value="Determine Lat/Lon">
<label id="latlng"></label>
ブラウザのJavaScriptコンソールにどのようなエラーメッセージを見ていますか?目立つエラーが1つあります。 - Documet –
エラーはありません。それだけでは表示されません。 @Pekkaくそ – Shraddha
オスの 'Documet'のため、' var address = Documet.getElementById( "address"); 'にエラーがあります。エラーコンソールが表示されていますか? –