adding more data to info window

百般思念 提交于 2019-12-13 04:13:13

问题


In my web app, I have currently show just the address of a marker in the marker info window. I want to show the open hours as well. How would I do that?

Here is my code so far:

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));
}

来源:https://stackoverflow.com/questions/6171725/adding-more-data-to-info-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!