htmlInfoWindow.setContent(content)

April 20, 2019 ยท View on GitHub

:green_heart: This is the latest document.

htmlInfoWindow.setContent(content)

You can change the content of the html info window.

You can set HTML strings or HTML element.

htmlInfoWindow.setContent(color);

Parameters

nametypedescription
contentstring,nodetext, HTML strings, or HTML element

Demo code

<div id="map_canvas"></div>
var div = document.getElementById("map_canvas");
var map = plugin.google.maps.Map.getMap(div);

var htmlInfoWindow = new plugin.google.maps.HtmlInfoWindow();

var button = document.createElement("button");
button.innerText = "Click me!";
button.addEventListener("click", function() {
  var html = "<img src='./House-icon.png' width='64' height='64' >" +
             "<br>" +
             "Ta-da!";
  htmlInfoWindow.setContent(html);
});

htmlInfoWindow.setContent(button);

var marker = map.addMarker({
  position: {lat: 0, lng: 0}
});

marker.on(plugin.google.maps.event.MARKER_CLICK, function() {
  htmlInfoWindow.open(marker);
});

marker.trigger(plugin.google.maps.event.MARKER_CLICK);