开发者

Infowindow in Googlemaps wont fill

I've got the following problem with Googlemaps.

I've created a createMarker function which returns a marker which I publish with addOverlay(). This works perfect, the marker get shown but the only problem is the click event voor the marker, I want a infowindow which is populated with the 'I want this text to be published' text, instead it gets populated with a var called html which I set in the beginning of my code (var html = 'test';), I received earlier a message with 'html is not defined', this is why is set the html var. Every infowindow has the text 'test' in it. I've tried using updateInfoWindow() but that doesn't work, anyone familiar with this problem? I can supply you with the full source but I think the createMarker function should be enough.

function GM_load() {
   map = new GMap2(document.getElementById("map"));
   map.addControl(new GSmallMapControl());
   map.addControl(new GMapTypeControl());
   map.enableScrollWheelZoom(); 
   map.setMapType(G_HYBRID_MAP);
   geocoder = new GClientGeocoder(); 
   GM_showItems();
}    


function GM_showItems() {
   GDownloadUrl("modules/Googlemaps/ajax/getItems.php", function(data, responseCode) {
        var xml = GXml.parse(data);
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {


            //start 
            var itemid = markers[i].getAttribute('id');
            var title = markers[i].getAttribute('name');
            var address = markers[i].getAttribute('address');
            var city = markers[i].getAttribute('city');
            var x = 0;
            if (geocoder) {

                geocoder.getLatLng(address + ' ' + city,
                    function(point) {
                        if (!point) {
                            alert(address + ' ' + city + " not found");
                        } else {
                            x = x+1;
                            Marker = createMarker(开发者_StackOverflow中文版point, x);
                            map.addOverlay(Marker);
                        }
                    }
                );
            }

        }

    });
}




function createMarker(latlng, number) {
    var marker = new GMarker(latlng);
    marker.value = number;
    GEvent.addListener(marker,"click", function() {
        map.openInfoWindowHtml(latlng,'i want this text to be published');
    });

    return marker;
}


Solved.

I overwrite var html. not perfect but it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜