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(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
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:
NameOFBox
firstline<br />secondline<br />thirdiline<br />
i wanted to get something like this:
NameOFBox
firstline
secondline
thirdline
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
NameOFBox
firstline\n\nsecondline\n\nthirdline\n\n
any help?
thanks in advance!