Google maps v3 formatting multiple lines of content in infoWindow

I am trying to create infoWindow in google maps v3 that contains several lines of content. However, the "\ n" that I use to insert a new line does not seem to work. What is the recommended way to insert a new line?

see code:

//set content of infoWindow window.setContent(inspStates[i].name+ "\n"+"total: "+inspStates[i].totalInsp+ "\n"+ info); 
+6
source share
1 answer

The easiest way to do this is by wrapping the contents in a div or in p , and then use <br /> for line breaks.

So something like

 //set content of infoWindow window.setContent("<p>" + inspStates[i].name + "<br />" + "total: " + inspStates[i].totalInsp + "<br />" + info + "</p>"); 
+17
source

Source: https://habr.com/ru/post/893008/


All Articles