Hi! I am trying to make a small application with google maps!

I have successfully addded few points on the map using xml output to php from mysql database..

function load() {
      var map = new google.maps.Map(document.getElementById("map"), {
        center: new google.maps.LatLng(38.99,22.49),
        zoom: 7,
        mapTypeId: 'roadmap'
      var infoWindow = new google.maps.InfoWindow;

      // Change this depending on the name of your PHP file
      downloadUrl("phpsqlajax_genxml2.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("name");
          var info = markers[i].getAttribute("info");
          var type = markers[i].getAttribute("type");
          var point = new google.maps.LatLng(
         var html = "<b>" + name + "</b> <br/>" + info;

          var icon = customIcons[type] || {};
          var marker = new google.maps.Marker({
            map: map,
            position: point,
            icon: icon.icon
          bindInfoWindow(marker, map, infoWindow, html);

My problem is that info variable is stored in mysql like this:
firstline<br />secondline<br />thirdiline<br /> .
I managed to do in before i insert the data to my mysql database:
$myinfo = htmlspecialchars($_POST['info']);
$myinfo = str_replace("\n", "<br />", $myinfo);

So, why i click on the point on the map i get this infobox:
firstline<br />secondline<br />thirdiline<br />

i wanted to get something like this:

what am i doing wrong? I understand that <br /> is html code and not java code..however i tried to replace <br /> in the database with \n\n but nothing happened.. i get something like this

any help?
thanks in advance!

i solved it by myself..if you ever face the same problem with me:

i insert the data to the database using:
$myinfo = str_replace("\n", "|||", $myinfo);

and back to the html file where i have the map:

        var array = info.split('|||');
        var html = "<b>" + name + "</b> <br/>" + array[0];
    for (var i=1; i<array.length; i++) {
        html += '<br ></array>' + array[i];

problem...after adding:

 for (var i=1; i<array.length; i++) {
html += '<br ></array>' + array[i];

works but only 1 marker is shown now..

i got my answer again alone :D i is being used in the outter for loop.. using j in the second for solved the problem :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.