DIV onload Pas de Tir Méthode JavaScript

Je suis en utilisant ASP.NET MVC 4 et j'ai un DIV comme ceci:

<div id="map_canvas" style="width: 500px; height: 400px;" onload="mapAddress();"></div>

Puis, dans un fichier JavaScript (que j'ai vérifié est chargé) est le mapAddress fonction:

function mapAddress() {
    //In this case it gets the address from an element on the page, but obviously you  could just pass it to the method instead
    var address = $("#Address").val();

    geocoder.geocode({ 'address': address }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var myLatLng = results[0].geometry.location.LatLng;

            var mapOptions = {
                center: myLatLng,
                zoom: 15,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };

            var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

            var marker = new google.maps.Marker({
                position: myLatLng,
                map: map,
                title: $("#Name").val() + " Location"
            });
        }
        else {
            alert("The location of the event could not be mapped because: " + status);
        }
    });
}

Mais pour quelque raison il n'est pas appelé. Ai-je mal compris le onload événement?

Merci à tous!

OriginalL'auteur Mike Perrenoud | 2012-10-23