2016-11-07 3 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지도 자바 스크립트 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