谷歌地图在多行上格式化标记工具提示的文本

trs*_*trs 5 newline tooltip google-maps-api-3 marker

如何在标记工具提示的文本中插入换行符.我正在使用\n哪个似乎不起作用.

见下面的代码:

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

小智 8

使用单引号('')而不是双引号("")它将起作用,就像这段代码一样.

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


小智 5

使用标记时,多行文本应在contentnot中title.而不是\n你必须使用HTML<br/>


trs*_*trs 1

我使用自定义的谷歌信息框代替工具提示,其格式正确,请参见此处:http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/examples.html