This class extends BaseClass.
HtmlInfoWindow is able to display any HTML elements on it.
While regular InfoWindow is rendered in map view, HtmlInfoWindow is rendered in browser view.
var htmlInfoWindow = new plugin.google.maps.HtmlInfoWindow();
var html = [
'This is <b>Html</b> InfoWindow',
'<br>',
'<button onclick="javascript:alert(\'clicked!\');">click here</button>',
].join("");
htmlInfoWindow.setContent(html);
map.addMarker({
position: {lat: 0, lng: 0},
draggable: true
}, function(marker) {
marker.on(plugin.google.maps.event.MARKER_CLICK, function() {
htmlInfoWindow.open(marker);
});
marker.trigger(plugin.google.maps.event.MARKER_CLICK);
});
The setContent()
method accepts either HTML strings
or DOM elements
.
var htmlInfoWindow = new plugin.google.maps.HtmlInfoWindow();
var iframe = document.createElement("iframe");
iframe.setAttribute("width", "560");
iframe.setAttribute("height", "315");
iframe.setAttribute("src", "https://www.youtube.com/embed/g8jTeS_Ey4A");
iframe.setAttribute("frameboarder", "0");
htmlInfoWindow.setContent(iframe);
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);
});
new plugin.google.maps.HtmlInfoWindow | Add a HTML infoWindow. |
---|
setBackgroundColor | Change the backgroundColor |
---|---|
setContent(string|node) | Set your HTML contents. |
open(marker) | Open the htmlInfoWindow |
close() | Close the htmlInfoWindow |
INFO_OPEN | Arguments: none This event is fired when the infoWindow is opened. |
---|---|
INFO_CLOSE | Arguments: none This event is fired when the infoWindow is closed. |