Skip to content

InfoWindow

InfoWindow is the map bubble window. It extends UIComponent. It shows content in a floating bubble on the map, commonly used to show details after clicking a feature. It has a title and a content area, and can be combined with custom HTML.

js
import { InfoWindow } from "maptalks";

const infoWindow = new InfoWindow({
  title: "Hello",
  content: "<div>World</div>"
});

infoWindow.addTo(map).show(coordinate);

Constructor

js
new InfoWindow(options)

Parameters:

  • options — InfoWindow options. Some properties match the InfoWindow.options table below.

options

NameTypeDescriptionDefault
titleString / HTMLElementThe bubble titlenull
contentString / HTMLElementThe bubble contentnull
widthStringThe bubble width'auto'
minHeightNumberThe minimum height of the bubble120
autoPanBooleanWhether to auto-pan the map when showntrue
autoCloseOnStringThe event that triggers auto-closenull
autoOpenOnStringThe event that triggers auto-open'click'
customBooleanWhether custom content is usedfalse
enableTemplateBooleanWhether the default template is usedfalse

Member Methods

  • setTitle(title): InfoWindow — Sets the bubble title.
  • getTitle(): String — Gets the bubble title.
  • setContent(content): InfoWindow — Sets the bubble content.
  • getContent(): String — Gets the bubble content.
  • addTo(owner): InfoWindow — Attaches the bubble to owner.
  • show(coordinate): InfoWindow — Shows the bubble at the given coordinate.
  • getOffset(): Point — Gets the bubble offset.
  • getTransformOrigin(): String — Gets the transform origin of the bubble.

Events

  • contentchange — Fired when the bubble content changes.