2012-10-30 5 views
0

다음 이유가 확실하지 않습니다. geocoder.geocode 세그먼트를 전혀 입력하지 않습니다. 필자가 원하는 것은 모든지도에 플롯하지 않고 입력 한 주소에 대한 지오 코드를 수신 할 수 있어야한다는 것입니다.Google Maps API 지오 코딩이 결과를 반환하지 않습니다.

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> 
+0

코드는 저에게 매우 효과적입니다. 문제 또는 jsfiddle을 보여주는 실시간지도는 어떻습니까? – geocodezip

+0

지오 코더를 초기화하지 않았습니다. 결정된. 감사. – Den

답변

0

지오 코더를 초기화하지 못했습니다. geocoder = new google.maps.Geocoder();

관련 문제