You are correct, I though that each marker SHOULD have its own
infowindow, so this is new to me :)

So now I've moved the code outstide the for loop, but no markers show
at all!

My new code:


function ShowMarkers(sDataArray, zoom) {
    //lat & lng format=-34.397, 150.644

    //center window on center of Netherlands
    var latlng = new google.maps.LatLng(sDataArray[0][0], sDataArray[0]
[1]);
    var myOptions = {
        zoom: zoom,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.HYBRID
    };
    map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

    var markersArray = [];


    for (i=0;i<sDataArray.length;i++){

        latlng = new google.maps.LatLng(sDataArray[i][0], sDataArray[i]
[1]);
        var contentString = '<div id="content">' + sDataArray[i][3] +
'</div>';

        //var infowindow = new google.maps.InfoWindow({ content:
contentString });

        var marker = new google.maps.Marker({
            position: latlng,
            title: sDataArray[i][2],
            map: map,
            content: contentString,
            icon: '/images/locationmarker.png'
        });
        markersArray.push(marker);
    }

    for (var i = 0; i < markersArray.length; i++) {
        var marker = markersArray[i];



/*
        var infowindow = new google.maps.InfoWindow({
            content: "holding..."
        });
        google.maps.event.addListener(marker, 'click', function () {
            // where I have added .html to the marker object.
            infowindow.setContent(this.content);
            infowindow.open(map, this);
        });
*/

    }//end for loop


    infoBubble = new InfoBubble({
        maxWidth: 300
    });


    infoBubble2 = new InfoBubble({
        map: map,
        content: '<div class="phoneytext">Some label</div>',
        position: new google.maps.LatLng(-35, 151),
        shadowStyle: 1,
        padding: 0,
        backgroundColor: 'rgb(57,57,57)',
        borderRadius: 4,
        arrowSize: 10,
        borderWidth: 1,
        borderColor: '#2c2c2c',
        disableAutoPan: true,
        hideCloseButton: true,
        arrowPosition: 30,
        backgroundClassName: 'phoney',
        arrowStyle: 2
    });
    infoBubble2.open();

    var div = document.createElement('DIV');
    div.innerHTML = 'Hello';

    google.maps.event.addListener(marker, 'click', function () {
        if (!infoBubble.isOpen()) {
            infoBubble.open(map, marker);
        }
    });


    google.maps.event.addListener(map, "click", function () {
        infoWindow.close();
    });


    AutoCenter(markersArray);

} //ShowMarkers




On Oct 15, 10:06 pm, Esa <[email protected]> wrote:
> The idea in my example is to use a single instance of InfoWindow. It
> looks like you are creating an InfoWindow instance for each marker.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to