Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps - Same text appears in info window when using multiple markers
    primarykey
    data
    text
    <p>I'm having an issue with multiple markers on google maps - I currently have a MySQL database storing info (location info). In php I then extract this info and loop through each postcode to dynamically create the required javascript to place a marker for each place in my database. </p> <p>This works successfully so I know that I'm passing the correct information to the js function - Now what I'm trying to achieve is adding additional information when the marker is clicked but its showing the same on every marker window.</p> <p>This is the js I'm using (I initiate an icon at the top but excluded this from the code for now):</p> <pre><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); } </code></pre> <p>The php code I have is:</p> <pre><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></pre> <p>$code is then echo'ed.</p> <p>Any advice on why this is occuring would be much appreciated! Thanks !</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload