Google Maps API에서 작업 중입니다. 나는 왜 아래 함수가 인덱스 ++ 이후에 호출되는지 알지 못한다. 내가 아는 한 ReverseGeocode()가 먼저 호출되어야합니다. 그 대신에 그것은 나를 위해 문제를 만들고있는 함수를 먼저 증가시키고 호출하는 것입니다. 경고 상자는 작성된대로 표시되지만 중간 기능은 함수의 마지막 줄이 실행 된 후 (즉, index ++) 호출됩니다.실행중인 함수 호출 후 Javascript 함수가 완료됩니다.
function placeMarker(location)
{
alert("iiii");
ReverseGeocode(location.lat(),location.lng());
alert("jjjk");
index++;
}
은 여기 내 ReverseGeoCode
function ReverseGeocode(lat,lng) {
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({'latLng': latlng}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
if (results[1])
{
places[index]=results[0].formatted_address;
alert(places[index]+"index="+index);
AddRow('table',results[0].formatted_address);
document.getElementById("dataa").innerHTML+=results[0].formatted_address+"<br/>";
}
}
else
{
alert("Geocoder failed due to: " + status);
}
});
}
설명해주십시오이다. 미리 감사드립니다.
** ReverseGeocode ** 기능을 게시 할 수 있습니까? – McGarnagle
'ReverseGeoCode'가'index ++'다음에 실행되는 것을 어떻게 결정합니까? – Deestan
@dbaseman 질문을 편집했습니다. – Mj1992