image dans infobulle google map

image dans infobulle google map - SQL/NoSQL - Programmation

Marsh Posté le 22-03-2008 à 23:01:08    

bonjour , je veux mettre une image dans chaque info bulle sous google map.
le nom de mon image est dans un champ de ma base de donnée,et je le recupere pour google map par un fichier xml, mais je n'arrive pas à l'afficher,en fait ca affiche son nom:
EX:
    GDownloadUrl("phpsqlajax_genxml.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker" );
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name" );
            var address = markers[i].getAttribute("address" );
            var type = markers[i].getAttribute("type" );
            var image = markers[i].getAttribute("image" );
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat" )),
                                    parseFloat(markers[i].getAttribute("lng" )));
            var marker = createMarker(point, name, address, type, image);
            map.addOverlay(marker);
          }
        });
      }
    }
 
    function createMarker(point, name, address, type, image) {
      var marker = new GMarker(point, customIcons[type]);
      var html = "<b>" + name + "</b> <br/>" + address + "<br/>" + type + "<br/>" +image;
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
 
Ma variable "image" contient le nom de mon image
 
Voici mon xml:
 
    <?php
require("phpsqlajax_dbinfo.php" );
 
// Start XML file, create parent node
$doc = domxml_new_doc("1.0" );
$node = $doc->create_element("markers" );
$parnode = $doc->append_child($node);
 
// Opens a connection to a mySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
  die('Not connected : ' . mysql_error());
}
 
// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Can\'t use db : ' . mysql_error());
}
 
// Select all the rows in the markers table
$query = "SELECT * FROM markers WHERE 1";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}
 
header("Content-type: text/xml" );
 
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
  $node = $doc->create_element("marker" );
  $newnode = $parnode->append_child($node);
 
  $newnode->set_attribute("name", $row['name']);
  $newnode->set_attribute("address", $row['address']);
  $newnode->set_attribute("lat", $row['lat']);
  $newnode->set_attribute("lng", $row['lng']);
  $newnode->set_attribute("type", $row['type']);
  $newnode->set_attribute("image", $row['image']);
}
 
$xmlfile = $doc->dump_mem();
echo $xmlfile;
 
?>

Reply

Marsh Posté le 22-03-2008 à 23:01:08   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed