谷歌地图v3格式化infoWindow中的多行内容
我正在尝试在谷歌地图 v3 中创建一个包含多行内容的信息窗口。然而,我用来插入换行符的“\n”似乎不起作用。插入换行符的推荐方法是什么?
参见代码:
//set content of infoWindow
window.setContent(inspStates[i].name+ "\n"+"total: "+inspStates[i].totalInsp+ "\n"+ info);
I am trying to create an infoWindow in google maps v3 which contains multiple lines of content. However the "\n" I am using to insert a newline doesn't seem to work. What is the recommended way to insert a newline?
see code:
//set content of infoWindow
window.setContent(inspStates[i].name+ "\n"+"total: "+inspStates[i].totalInsp+ "\n"+ info);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法是将内容包装在
div
或p
中,然后使用
进行换行。所以像
The easiest thing to do it wrap the content in a
div
or in ap
and then use<br />
for line breaks.So something like
使用 HTML 作为内容,并将每一行放在自己的段落中。行分隔有助于提高可读性,特别是当任何行足够长以换行时。
Use HTML for the content, and put each line in its own paragraph. Line separation helps with readability, especially if any of the lines is long enough to wrap.