I'm working on a fictional events management website. On this site, I get the information from my database using XML to feed the lat and long values into the google map in order to create various markers around the world.
code that creates the markers:
var infoWindow = new google.maps.InfoWindow;
// Change this depending on the name of your PHP file
downloadUrl("../php/phpsqlajax_genxml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("eventName");
var series = markers[i].getAttribute("eventSeries");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("eventLat")),
parseFloat(markers[i].getAttribute("eventLong")));
var html = name + "<br>" + series + "<br>" + "test";
var marker = new google.maps.Marker({
map: map,
position: point
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
When you click any of the markers, a little 'infowindow' will pop up stating the event name and the event series.
Is there a way for me to add an html link at the bottom of the window instead of test
? What I wanted to do is to make it an html link that's generated using php, similar to this:
<?php
$queryEvents = "SELECT * FROM events GROUP BY eventStart DESC";
$resultEvents = $mysqli->query($queryEvents);
while($rowEvents = $resultEvents->fetch_assoc()){
echo "<tr>";
echo "<td>{$rowEvents['eventName']}</td>";
echo "<td><a href=\"../php/viewEvent.php?eventID={$rowEvents['eventID']}\">View</a></t
d>";
echo "<td><a href=\"edit.php?eventID={$rowEvents['eventID']}\">Edit</a></td>";
echo "<td><a href=\"delete.php?eventID={$rowEvents['eventID']}\">Delete</a></td>";
echo "</tr>";
}
?>
Where it would take the eventName
value and use the post value of it's ID in order to generate another, external, php page which displays the event information. Is this possible?