问题
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