I am using the following code to create an infowindow for the markers in the map. In the message variable i am sending a string with Html inside it. When i run my application inside the infobox i am getting the string without the Html styling. For example inside the box i see blah blah blah ... Does anyone know how to get the infobox with html styling 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);
});
An InfoWindow displays content (usually text or images) in a popup window above the map, at a given location. The info window has a content area and a tapered stem. The tip of the stem is attached to a specified location on the map. Info windows appear as a Dialog to screen readers.
addListener(marker, 'mouseover', function() { infoWindow. setContent(html); infoWindow. open(map, marker); //infoWindow. setStyle("background-color: red"); });
By assigning the infowindow to a marker property, each marker can have it's own infowindow. This was how I approached the problem, with the relevant sample code. //create a marker object first, or instantiate it by passing a JSON to the constructor. //this can be done inside a for loop var infowindow = new google.
Put all your custom html code in a variable and assign 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
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With