誰かがJavascriptの原則で私を助けることができるかどうか疑問に思っています. 関数をパラメーターとして渡したい場合、これはかなりコアだと思います。私は Javascript について少し知っていますが、その微妙な点についてはおそらく十分ではないことを認めます。
したがって、codeAddress が呼び出され、最初のアラート (HERE2) に到達し、コードが showOnMap 関数に戻り、2 番目のアラート (HERE3) に到達します。HERE2 アラートの前に HERE3 アラートが表示されるのはなぜですか? Javascriptに待機するように指示するためにできることはありますか?
前もって感謝します
function showOnMap() {
    var inputStart = document.getElementById('CurrentHitch_StartDescription').value;
    var inputEnd = document.getElementById('CurrentHitch_EndDescription').value;
    codeAddress(inputStart, true); //HERE1*************
    codeAddress(inputEnd, false);
    var bounds2 = new google.maps.LatLngBounds(this.markerStart.getPosition());
    bounds2.extend(this.markerEnd.getPosition());
    map.fitBounds(bounds2);
    alert('showOnMap'); //HERE3*************
}
function codeAddress(address, isStart) {
    geocoder.geocode({ 'address': address }, function (results, status) {
        alert('codeAddress'); //HERE2*************
        if (status == google.maps.GeocoderStatus.OK) {
            if (isStart) {
                markerStart.setPosition(results[0].geometry.location);
            }
            else {
                markerEnd.setPosition(results[0].geometry.location);
            }
        } else {
            alert("Sorry, couldn't find your destination: " + status);
        }
    });
    return;
}