2016-11-07 8 views
-2

シングルクリックでこの機能を呼び出すが、シングルクリックでは機能しない。シングルクリックが機能しない

<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(); 
} 
+1

これはエラーの最も詳細な説明である「それが動作していない」私はいつもこのサイト – madalinivascu

+0

に乗るは、Google Maps JavaScript API V3を含めていますか?問題を示す[mcve]を入力してください。 – geocodezip

答えて

0

これは実際には呼び出していますが、あなたのコードに実際に問題があるのはGoogleコードです。関数内のコードが機能していることを確認してください。

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" />

+0

はい、codeAddress()は動作していますが、エラーはcodeAddress()で呼び出された関数 "initialize()"にあります。私はそれを解決しました...ありがとうございますJagar7521 – mansoor

+0

はい、私はあなたが私の答えでそれを読んで言ったことですか? – Jigar7521

+0

はい私はそれを読んだ。 – mansoor

関連する問題