I have a problem with multiple markers on google maps. Currently, I have a MySQL database that stores information (location information). In php, I extract this information and go through each zip code to dynamically create the necessary javascript to place a marker for every location in my database.
This works successfully, so I know that I am passing the correct information to the js function. Now what I'm trying to achieve is adding extra information when the marker is clicked, but its display is the same in every marker window.
This is the js I'm using (I start the icon at the top, but exclude this from the code):
function usePointFromPostcode(postcode, callbackFunction, text) {
localSearch.setSearchCompleteCallback(null,
function() {
if (localSearch.results[0])
{
var resultLat = localSearch.results[0].lat;
var resultLng = localSearch.results[0].lng;
var point = new GLatLng(resultLat,resultLng);
callbackFunction(point, text);
}else{
alert("Postcode not found!");
}
});
localSearch.execute(postcode + ", UK");
}
function placeMarkerAtPoint(point, html, icon)
{
var marker = new GMarker(point,{icon: icon});
GEvent.addListener(marker,"click",function() {
marker.openInfoWindowHtml(html);
});
map.addOverlay(marker);
}
I have php code:
$query = "SELECT * FROM hospitalInfo";
$result = mysql_query($query);
if($result) {
while ($row = mysql_fetch_assoc($result)) {
$code .= "usePointFromPostcode('".$row['Postcode']."', placeMarkerAtPoint,
'".$row['placeName']."');";
}
}
$ code then echo'ed.
, , ! !