1 | declare namespace google.maps {
|
2 | interface InfoWindowHandlerMap {
|
3 | /**
|
4 | * This event is fired when the close button was clicked.
|
5 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.closeclick Maps JavaScript API}
|
6 | * @see {@link InfoWindow#close}
|
7 | */
|
8 | closeclick: [];
|
9 |
|
10 | /**
|
11 | * This event is fired when the content property changes.
|
12 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.content_changed Maps JavaScript API}
|
13 | * @see {@link InfoWindowOptions#content}
|
14 | * @see {@link InfoWindow#getContent}
|
15 | * @see {@link InfoWindow#setContent}
|
16 | */
|
17 | content_changed: [];
|
18 |
|
19 | /**
|
20 | * This event is fired when the `<div>` containing the {@link InfoWindow}'s content is attached to the DOM. You
|
21 | * may wish to monitor this event if you are building out your info window content dynamically.
|
22 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.domready Maps JavaScript API}
|
23 | */
|
24 | domready: [];
|
25 |
|
26 | /**
|
27 | * This event is fired when the position property changes.
|
28 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.position_changed Maps JavaScript API}
|
29 | * @see {@link InfoWindowOptions#position}
|
30 | * @see {@link InfoWindow#getPosition}
|
31 | * @see {@link InfoWindow#setPosition}
|
32 | */
|
33 | position_changed: [];
|
34 |
|
35 | /**
|
36 | * This event is fired when the InfoWindow's zIndex changes.
|
37 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.zindex_changed Maps JavaScript API}
|
38 | * @see {@link InfoWindowOptions#zIndex}
|
39 | * @see {@link InfoWindow#getZIndex}
|
40 | * @see {@link InfoWindow#setZIndex}
|
41 | */
|
42 | zindex_changed: [];
|
43 | }
|
44 |
|
45 | /**
|
46 | * An overlay that looks like a bubble and is often connected to a marker.
|
47 | * This class extends MVCObject.
|
48 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow Maps JavaScript API}
|
49 | */
|
50 | class InfoWindow extends MVCObject {
|
51 | /**
|
52 | * Creates an info window with the given options. An {@link InfoWindow} can be placed on a map at a particular
|
53 | * position or above a marker, depending on what is specified in the options. Unless auto-pan is disabled, an
|
54 | * {@link InfoWindow} will pan the map to make itself visible when it is opened. After constructing an
|
55 | * {@link InfoWindow}, you must call open to display it on the map. The user can click the close button on the
|
56 | * {@link InfoWindow} to remove it from the map, or the developer can call {@link close}() for the same effect.
|
57 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.constructor Maps JavaScript API}
|
58 | */
|
59 | constructor(opts?: InfoWindowOptions);
|
60 |
|
61 | /**
|
62 | * @see { InfoWindowHandlerMap#closeclick closeclick} event
|
63 | * { InfoWindowHandlerMap#content_changed content_changed} event
|
64 | * { InfoWindowHandlerMap#domready domready} event
|
65 | * { InfoWindowHandlerMap#position_changed position_changed} event
|
66 | * { InfoWindowHandlerMap#zindex_changed zindex_changed} event
|
67 | */
|
68 | addListener<N extends keyof InfoWindowHandlerMap>(
|
69 | eventName: N,
|
70 | handler: MVCEventHandler<this, InfoWindowHandlerMap[N]>,
|
71 | ): MapsEventListener;
|
72 |
|
73 | addListener(eventName: string, handler: MVCEventHandler<this, unknown[]>): MapsEventListener;
|
74 |
|
75 | /**
|
76 | * Closes this {@link InfoWindow} by removing it from the DOM structure.
|
77 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.close Maps JavaScript API}
|
78 | * @see {@link InfoWindowHandlerMap#closeclick closeclick} event
|
79 | * @see {@link open}
|
80 | */
|
81 | close(): void;
|
82 |
|
83 | /**
|
84 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.getContent Maps JavaScript API}
|
85 | * @see {@link InfoWindowOptions#content}
|
86 | * @see {@link InfoWindowHandlerMap#content_changed content_changed} event
|
87 | * @see {@link setContent}
|
88 | */
|
89 | getContent(): string | Node;
|
90 |
|
91 | /**
|
92 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.getPosition Maps JavaScript API}
|
93 | * @see {@link InfoWindowOptions#position}
|
94 | * @see {@link InfoWindowHandlerMap#position_changed position_changed} event
|
95 | * @see {@link setPosition}
|
96 | */
|
97 | getPosition(): LatLng;
|
98 |
|
99 | /**
|
100 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.getZIndex Maps JavaScript API}
|
101 | * @see {@link InfoWindowOptions#zIndex}
|
102 | * @see {@link InfoWindowHandlerMap#zindex_changed zindex_changed} event
|
103 | * @see {@link setZIndex}
|
104 | */
|
105 | getZIndex(): number;
|
106 |
|
107 | // TODO: Strict `position` & `anchorPoint` in `anchor` argument
|
108 | /**
|
109 | * Opens this {@link InfoWindow} on the given map. Optionally, an {@link InfoWindow} can be associated with an
|
110 | * anchor. In the core API, the only anchor is the {@link Marker} class. However, an anchor can be any
|
111 | * {@link MVCObject} that exposes a {@link LatLng} position property and optionally a {@link Point} anchorPoint
|
112 | * property for calculating the {@link InfoWindowOptions#pixelOffset pixelOffset}. The anchorPoint is the offset
|
113 | * from the anchor's position to the tip of the {@link InfoWindow}.
|
114 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.open Maps JavaScript API}
|
115 | * @see {@link close}
|
116 | */
|
117 | open(map?: Map | StreetViewPanorama, anchor?: MVCObject): void;
|
118 |
|
119 | /**
|
120 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.setContent Maps JavaScript API}
|
121 | * @see {@link InfoWindowOptions#content}
|
122 | * @see {@link InfoWindowHandlerMap#content_changed content_changed} event
|
123 | * @see {@link getContent}
|
124 | */
|
125 | setContent(content: string | Node): void;
|
126 |
|
127 | /**
|
128 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.setOptions Maps JavaScript API}
|
129 | */
|
130 | setOptions(options: InfoWindowOptions): void;
|
131 |
|
132 | /**
|
133 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.setPosition Maps JavaScript API}
|
134 | * @see {@link InfoWindowOptions#position}
|
135 | * @see {@link InfoWindowHandlerMap#position_changed position_changed} event
|
136 | * @see {@link getPosition}
|
137 | */
|
138 | setPosition(position: LatLng | LatLngLiteral): void;
|
139 |
|
140 | /**
|
141 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow.setZIndex Maps JavaScript API}
|
142 | * @see {@link InfoWindowOptions#zIndex}
|
143 | * @see {@link InfoWindowHandlerMap#zindex_changed zindex_changed} event
|
144 | * @see {@link getZIndex}
|
145 | */
|
146 | setZIndex(zIndex: number): void;
|
147 | }
|
148 |
|
149 | /**
|
150 | * {@link InfoWindowOptions} object used to define the properties that can be set on a {@link InfoWindow}.
|
151 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions Maps JavaScript API}
|
152 | * @see {@link InfoWindow#setOptions}
|
153 | */
|
154 | interface InfoWindowOptions {
|
155 | /**
|
156 | * Content to display in the {@link InfoWindow}. This can be an HTML element, a plain-text string, or a string
|
157 | * containing HTML. The InfoWindow will be sized according to the content. To set an explicit size for the
|
158 | * content, set content to be a HTML element with that size.
|
159 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.content Maps JavaScript API}
|
160 | * @see {@link InfoWindow#getContent}
|
161 | * @see {@link InfoWindow#setContent}
|
162 | */
|
163 | content?: string | Node;
|
164 |
|
165 | /**
|
166 | * Disable auto-pan on open. By default, the {@link InfoWindow} will pan the map so that it is fully visible
|
167 | * when it opens.
|
168 | * @see {@link https://developers.google.com/maps/documetntation/javascript/reference/info-window#InfoWindowOptions.disableAutoPan Maps JavaScript API}
|
169 | */
|
170 | disableAutoPan?: boolean;
|
171 |
|
172 | /**
|
173 | * Maximum width of the {@link InfoWindow}, regardless of content's width. This value is only considered if it
|
174 | * is set before a call to open. To change the maximum width when changing content, call close,
|
175 | * {@link InfoWindow#setOptions setOptions}, and then open.
|
176 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.maxWidth Maps JavaScript API}
|
177 | */
|
178 | maxWidth?: number;
|
179 |
|
180 | /**
|
181 | * The offset, in pixels, of the tip of the info window from the point on the map at whose geographical
|
182 | * coordinates the info window is anchored. If an {@link InfoWindow} is opened with an anchor, the
|
183 | * {@link pixelOffset} will be calculated from the anchor's {@link MarkerOptions#anchorPoint anchorPoint}
|
184 | * property.
|
185 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.pixelOffset Maps JavaScript API}
|
186 | */
|
187 | pixelOffset?: Size;
|
188 |
|
189 | /**
|
190 | * The {@link LatLng} at which to display this {@link InfoWindow}. If the {@link InfoWindow} is opened with an
|
191 | * anchor, the anchor's position will be used instead.
|
192 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.position Maps JavaScript API}
|
193 | * @see {@link InfoWindow#getPosition}
|
194 | * @see {@link InfoWindow#setPosition}
|
195 | */
|
196 | position?: LatLng | LatLngLiteral;
|
197 |
|
198 | /**
|
199 | * All {@link InfoWindow} are displayed on the map in order of their {@link zIndex}, with higher values
|
200 | * displaying in front of {@link InfoWindow} with lower values. By default, {@link InfoWindow} are displayed
|
201 | * according to their latitude, with {@link InfoWindow} of lower latitudes appearing in front of
|
202 | * {@link InfoWindow} at higher latitudes. {@link InfoWindow} are always displayed in front of markers.
|
203 | * @see {@link https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.zIndex Maps JavaScript API}
|
204 | * @see {@link InfoWindow#getZIndex}
|
205 | * @see {@link InfoWindow#setZIndex}
|
206 | */
|
207 | zIndex?: number;
|
208 | }
|
209 | }
|