InfoWindow with Html on google maps

I use the following code to create an infowindow for map markers. In the message variable, I send a line with Html inside it. When I run my application inside the info box, I get a line without Html styles. For example, inside the box I see blah blah blah ... Does anyone know how to get the info box with the html design inside?

function attachSecretMessage(marker, number) { var infowindow = new google.maps.InfoWindow( { content: message[number], size: new google.maps.Size(50, 50) }); google.maps.event.addListener(marker, 'click', function() { infowindow.open(map1, marker); }); 
+4
source share
2 answers

Put all your custom html code in a variable and set the value to "content" !!!

  var contentString = '<div id="content" style="width:400px; background-color:red;">' + 'My Text comes here' + '</div>'; var infowindow = new google.maps.InfoWindow({ content: contentString, maxWidth: 400 }); 
+9
source

Instead infoWindow try infoBox. This can be styled.

+2
source

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


All Articles