向信息窗口添加更多数据

时间:2011-05-30 02:12:20

标签: javascript google-maps google-maps-markers

在我的网络应用中,我目前只在标记信息窗口中显示标记的地址。我也想展示开放时间。我该怎么办?

到目前为止,这是我的代码:

function display()
{
    if ((xhr.readyState == 4) &&(xhr.status == 200))
    {
        var xmlDoc=xhr.responseXML;
        var market = xmlDoc.documentElement.getElementsByTagName("market");
        for (var i = 0; i < market.length; i++)
        {
            var address= market[i].getElementsByTagName("address");
            address = address[0].childNodes[0].nodeValue;
            var openhours= market[i].getElementsByTagName("openhours");
            openhours = openhours[0].childNodes[0].nodeValue;

            geocoder.getLocations(address, addToMap);
        }
    }
}

function addToMap(res)
{
    place = res.Placemark[0];

    point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);

    function createMarker(point,address)
    {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function()
        {
            map.openInfoWindowHtml(point, address);
        });
        return marker;
    }
    map.addOverlay(createMarker(point, res.name));
}

0 个答案:

没有答案