Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 1.19 KB

File metadata and controls

43 lines (33 loc) · 1.19 KB

⚠️ This document is aim for older versions (from 2.0.0 to 2.2.9). Document for new version is https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.6.0/README.md

htmlInfoWindow.setContent(string|node)

You can change the content of the html info window.

You can set HTML strings or HTML element.

<div id="map_canvas"></div>
var div = document.getElementById("map_canvas");
var map = plugin.google.maps.Map.getMap(div);
map.one(plugin.google.maps.event.MAP_READY, function() {
  var htmlInfoWindow = new plugin.google.maps.HtmlInfoWindow();

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

  map.addMarker({
    position: {lat: 0, lng: 0}
  }, function(marker) {

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

  });
});