google maps formatting text of a marker tooltip on multiple lines

trs picture trs · Jul 26, 2011 · Viewed 18.8k times · Source

How do I insert a newline into text of a marker tooltip. I am using \n which doesn't seem to be working.

See code below:

mark = new google.maps.Marker({          
        map: map,             
        position: center,
        title:inspStates[i].name+ "\n"+"total: "+inspStates[i].totalInsp+ "\n"+ info,
        zIndex:3
});

Answer

Sonu Kumar picture Sonu Kumar · Jun 25, 2016

Use single quotes (' ') instead of double quotes (" ")it will work, like this code.

mark = new google.maps.Marker({          
            map: map,             
            position: center,
            title:inspStates[i].name+ '\n total: '+inspStates[i].totalInsp+ '\n'+ info,
            zIndex:3
    });