create marker click event

Sep 21, 2012 at 2:52 PM

Hi.

we can create marker events like this:

 

        function initialize() {
            var mapOptions = {
                center: new google.maps.LatLng(-34.397, 150.644),
                zoom: 8,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("map_canvas"),
                mapOptions);
           

            var marker = new google.maps.Marker({
                position: new google.maps.LatLng(-34.397, 150.644),
                map: map,
                title: 'Hello World!'
             
                
            });
            
            var marker2 = new google.maps.Marker({
                position: new google.maps.LatLng(-34, 150),
                map: map,
                title: 'Hello World!22222'


            });
            
            google.maps.event.addListener(marker, 'click', function () {
                alert('sadasd');
            });
            google.maps.event.addListener(marker2, 'click', function () {
                alert('sadasd22222222222');
            });
        }
    

How we can create this marker click event by googlemap control?

Thanks!