Ajouter un Marqueur de la fonction avec l'API Google Maps

J'ai le code Javascript suivant, qui comprend à la fois le standard de l'API Google Maps initialize() fonction et personnalisé addMarker() fonction. La carte sera à la charge de l'amende cependant, le marqueur n'est pas ajouté à la carte.

<script type="text/javascript">

    //Standard google maps function
    function initialize() {
        var myLatlng = new google.maps.LatLng(40.779502, -73.967857);
        var myOptions = {
            zoom: 12,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    }

    //Function for adding a marker to the page.
    function addMarker(location) {
        marker = new google.maps.Marker({
            position: location,
            map: map
        });
    }

    //Testing the addMarker function
    CentralPark = new google.maps.LatLng(37.7699298, -122.4469157);
    addMarker(CentralPark);

</script>
InformationsquelleAutor Quaye | 2011-10-09