PageSourceSearch

https://welcomebreak.co.uk/wp-content/themes/cn-theme-child/widgets/static-map-widget/js/infobox.js

js welcomebreak.co.uk collected 2026-09-25 18:42:14 UTC 22,200 bytes, 772 lines download raw bytes

vendor: 22,200 bytes, lines 1-772
1/*jslint browser:true */
2/*global google */
3
4/**
5 * @name InfoBox
6 * @version 1.1.9 [October 2, 2011]
7 * @author Gary Little (inspired by proof-of-concept code from Pamela Fox of Google)
8 * @copyright Copyright 2010 Gary Little [gary at luxcentral.com]
9 * @fileoverview InfoBox extends the Google Maps JavaScript API V3 <tt>OverlayView</tt> class.
10 *  <p>
11 *  An InfoBox behaves like a <tt>google.maps.InfoWindow</tt>, but it supports several
12 *  additional properties for advanced styling. An InfoBox can also be used as a map label.
13 *  <p>
14 *  An InfoBox also fires the same events as a <tt>google.maps.InfoWindow</tt>.
15 *  <p>
16 *  Browsers tested:
17 *  <p>
18 *  Mac -- Safari (4.0.4), Firefox (3.6), Opera (10.10), Chrome (4.0.249.43), OmniWeb (5.10.1)
19 *  <br>
20 *  Win -- Safari, Firefox, Opera, Chrome (3.0.195.38), Internet Explorer (8.0.6001.18702)
21 *  <br>
22 *  iPod Touch/iPhone -- Safari (3.1.2)
23 */
24
25/*!
26 *
27 * Licensed under the Apache License, Version 2.0 (the "License");
28 * you may not use this file except in compliance with the License.
29 * You may obtain a copy of the License at
30 *
31 *       http://www.apache.org/licenses/LICENSE-2.0
32 *
33 * Unless required by applicable law or agreed to in writing, software
34 * distributed under the License is distributed on an "AS IS" BASIS,
35 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36 * See the License for the specific language governing permissions and
37 * limitations under the License.
38 */
39
40/**
41 * @name InfoBoxOptions
42 * @class This class represents the optional parameter passed to the {@link InfoBox} constructor.
43 * @property {string|Node} content The content of the InfoBox (plain text or an HTML DOM node).
44 * @property {boolean} disableAutoPan Disable auto-pan on <tt>open</tt> (default is <tt>false</tt>).
45 * @property {number} maxWidth The maximum width (in pixels) of the InfoBox. Set to 0 if no maximum.
46 * @property {Size} pixelOffset The offset (in pixels) from the top left corner of the InfoBox
47 *  (or the bottom left corner if the <code>alignBottom</code> property is <code>true</code>)
48 *  to the map pixel corresponding to <tt>position</tt>.
49 * @property {LatLng} position The geographic location at which to display the InfoBox.
50 * @property {number} zIndex The CSS z-index style value for the InfoBox.
51 *  Note: This value overrides a zIndex setting specified in the <tt>boxStyle</tt> property.
52 * @property {string} boxClass The name of the CSS class defining the styles for the InfoBox container.
53 *  The default name is <code>infoBox</code>.
54 * @property {Object} [boxStyle] An object literal whose properties define specific CSS
55 *  style values to be applied to the InfoBox. Style values defined here override those that may
56 *  be defined in the <code>boxClass</code> style sheet. If this property is changed after the
57 *  InfoBox has been created, all previously set styles (except those defined in the style sheet)
58 *  are removed from the InfoBox before the new style values are applied.
59 * @property {string} closeBoxMargin The CSS margin style value for the close box.
60 *  The default is "2px" (a 2-pixel margin on all sides).
61 * @property {string} closeBoxURL The URL of the image representing the close box.
62 *  Note: The default is the URL for Google's standard close box.
63 *  Set this property to "" if no close box is required.
64 * @property {Size} infoBoxClearance Minimum offset (in pixels) from the InfoBox to the
65 *  map edge after an auto-pan.
66 * @property {boolean} isHidden Hide the InfoBox on <tt>open</tt> (default is <tt>false</tt>).
67 * @property {boolean} alignBottom Align the bottom left corner of the InfoBox to the <code>position</code>
68 *  location (default is <tt>false</tt> which means that the top left corner of the InfoBox is aligned).
69 * @property {string} pane The pane where the InfoBox is to appear (default is "floatPane").
70 *  Set the pane to "mapPane" if the InfoBox is being used as a map label.
71 *  Valid pane names are the property names for the <tt>google.maps.MapPanes</tt> object.
72 * @property {boolean} enableEventPropagation Propagate mousedown, click, dblclick,
73 *  and contextmenu events in the InfoBox (default is <tt>false</tt> to mimic the behavior
74 *  of a <tt>google.maps.InfoWindow</tt>). Set this property to <tt>true</tt> if the InfoBox
75 *  is being used as a map label. iPhone note: This property setting has no effect; events are
76 *  always propagated.
77 */
78
79/**
80 * Creates an InfoBox with the options specified in {@link InfoBoxOptions}.
81 *  Call <tt>InfoBox.open</tt> to add the box to the map.
82 * @constructor
83 * @param {InfoBoxOptions} [opt_opts]
84 */
85function InfoBox(opt_opts) {
86
87  opt_opts = opt_opts || {};
88
89  google.maps.OverlayView.apply(this, arguments);
90
91  // Standard options (in common with google.maps.InfoWindow):
92  //
93  this.content_ = opt_opts.content || "";
94  this.disableAutoPan_ = opt_opts.disableAutoPan || false;
95  this.maxWidth_ = opt_opts.maxWidth || 0;
96  this.pixelOffset_ = opt_opts.pixelOffset || new google.maps.Size(0, 0);
97  this.position_ = opt_opts.position || new google.maps.LatLng(0, 0);
98  this.zIndex_ = opt_opts.zIndex || null;
99
100  // Additional options (unique to InfoBox):
101  //
102  this.boxClass_ = opt_opts.boxClass || "infoBox";
103  this.boxStyle_ = opt_opts.boxStyle || {};
104  this.closeBoxMargin_ = opt_opts.closeBoxMargin || "2px";
105  this.closeBoxURL_ = opt_opts.closeBoxURL || "http://www.google.com/intl/en_us/mapfiles/close.gif";
106  if (opt_opts.closeBoxURL === "") {
107    this.closeBoxURL_ = "";
108  }
109  this.infoBoxClearance_ = opt_opts.infoBoxClearance || new google.maps.Size(1, 1);
110  this.isHidden_ = opt_opts.isHidden || false;
111  this.alignBottom_ = opt_opts.alignBottom || false;
112  this.pane_ = opt_opts.pane || "floatPane";
113  this.enableEventPropagation_ = opt_opts.enableEventPropagation || false;
114
115  this.div_ = null;
116  this.closeListener_ = null;
117  this.eventListener1_ = null;
118  this.eventListener2_ = null;
119  this.eventListener3_ = null;
120  this.moveListener_ = null;
121  this.contextListener_ = null;
122  this.fixedWidthSet_ = null;
123}
124
125/* InfoBox extends OverlayView in the Google Maps API v3.
126 */
127InfoBox.prototype = new google.maps.OverlayView();
128
129/**
130 * Creates the DIV representing the InfoBox.
131 * @private
132 */
133InfoBox.prototype.createInfoBoxDiv_ = function () {
134
135  var bw;
136  var me = this;
137
138  // This handler prevents an event in the InfoBox from being passed on to the map.
139  //
140  var cancelHandler = function (e) {
141    e.cancelBubble = true;
142
143    if (e.stopPropagation) {
144
145      e.stopPropagation();
146    }
147  };
148
149  // This handler ignores the current event in the InfoBox and conditionally prevents
150  // the event from being passed on to the map. It is used for the contextmenu event.
151  //
152  var ignoreHandler = function (e) {
153
154    e.returnValue = false;
155
156    if (e.preventDefault) {
157
158      e.preventDefault();
159    }
160
161    if (!me.enableEventPropagation_) {
162
163      cancelHandler(e);
164    }
165  };
166
167  if (!this.div_) {
168
169    this.div_ = document.createElement("div");
170
171    this.setBoxStyle_();
172
173    if (typeof this.content_.nodeType === "undefined") {
174      this.div_.innerHTML = this.getCloseBoxImg_() + this.content_;
175    } else {
176      this.div_.innerHTML = this.getCloseBoxImg_();
177      this.div_.appendChild(this.content_);
178    }
179
180    // Add the InfoBox DIV to the DOM
181    this.getPanes()[this.pane_].appendChild(this.div_);
182
183    this.addClickHandler_();
184
185    if (this.div_.style.width) {
186
187      this.fixedWidthSet_ = true;
188
189    } else {
190
191      if (this.maxWidth_ !== 0 && this.div_.offsetWidth > this.maxWidth_) {
192
193        this.div_.style.width = this.maxWidth_;
194        this.div_.style.overflow = "auto";
195        this.fixedWidthSet_ = true;
196
197      } else { // The following code is needed to overcome problems with MSIE
198
199        bw = this.getBoxWidths_();
200
201        this.div_.style.width = (this.div_.offsetWidth - bw.left - bw.right) + "px";
202        this.fixedWidthSet_ = false;
203      }
204    }
205
206    this.panBox_(this.disableAutoPan_);
207
208    if (!this.enableEventPropagation_) {
209
210      // Cancel event propagation.
211      //
212      this.eventListener1_ = google.maps.event.addDomListener(this.div_, "mousedown", cancelHandler);
213      this.eventListener2_ = google.maps.event.addDomListener(this.div_, "click", cancelHandler);
214      this.eventListener3_ = google.maps.event.addDomListener(this.div_, "dblclick", cancelHandler);
215      this.eventListener4_ = google.maps.event.addDomListener(this.div_, "mouseover", function (e) {
216        this.style.cursor = "default";
217      });
218    }
219
220    this.contextListener_ = google.maps.event.addDomListener(this.div_, "contextmenu", ignoreHandler);
221
222    /**
223     * This event is fired when the DIV containing the InfoBox's content is attached to the DOM.
224     * @name InfoBox#domready
225     * @event
226     */
227    google.maps.event.trigger(this, "domready");
228  }
229};
230
231/**
232 * Returns the HTML <IMG> tag for the close box.
233 * @private
234 */
235InfoBox.prototype.getCloseBoxImg_ = function () {
236
237  var img = "";
238
239  if (this.closeBoxURL_ !== "") {
240
241    img  = "<img";
242    img += " src='" + this.closeBoxURL_ + "'";
243    img += " align=right"; // Do this because Opera chokes on style='float: right;'
244    img += " style='";
245    img += " position: relative;"; // Required by MSIE
246    img += " cursor: pointer;";
247    img += " margin: " + this.closeBoxMargin_ + ";";
248    img += "'>";
249  }
250
251  return img;
252};
253
254/**
255 * Adds the click handler to the InfoBox close box.
256 * @private
257 */
258InfoBox.prototype.addClickHandler_ = function () {
259
260  var closeBox;
261
262  if (this.closeBoxURL_ !== "") {
263
264    closeBox = this.div_.firstChild;
265    this.closeListener_ = google.maps.event.addDomListener(closeBox, 'click', this.getCloseClickHandler_());
266
267  } else {
268
269    this.closeListener_ = null;
270  }
271};
272
273/**
274 * Returns the function to call when the user clicks the close box of an InfoBox.
275 * @private
276 */
277InfoBox.prototype.getCloseClickHandler_ = function () {
278
279  var me = this;
280
281  return function (e) {
282
283    // 1.0.3 fix: Always prevent propagation of a close box click to the map:
284    e.cancelBubble = true;
285
286    if (e.stopPropagation) {
287
288      e.stopPropagation();
289    }
290
291    me.close();
292
293    /**
294     * This event is fired when the InfoBox's close box is clicked.
295     * @name InfoBox#closeclick
296     * @event
297     */
298    google.maps.event.trigger(me, "closeclick");
299  };
300};
301
302/**
303 * Pans the map so that the InfoBox appears entirely within the map's visible area.
304 * @private
305 */
306InfoBox.prototype.panBox_ = function (disablePan) {
307
308  var map;
309  var bounds;
310  var xOffset = 0, yOffset = 0;
311
312  if (!disablePan) {
313
314    map = this.getMap();
315
316    if (map instanceof google.maps.Map) { // Only pan if attached to map, not panorama
317
318      if (!map.getBounds().contains(this.position_)) {
319      // Marker not in visible area of map, so set center
320      // of map to the marker position first.
321        map.setCenter(this.position_);
322      }
323
324      bounds = map.getBounds();
325
326      var mapDiv = map.getDiv();
327      var mapWidth = mapDiv.offsetWidth;
328      var mapHeight = mapDiv.offsetHeight;
329      var iwOffsetX = this.pixelOffset_.width;
330      var iwOffsetY = this.pixelOffset_.height;
331      var iwWidth = this.div_.offsetWidth;
332      var iwHeight = this.div_.offsetHeight;
333      var padX = this.infoBoxClearance_.width;
334      var padY = this.infoBoxClearance_.height;
335      var pixPosition = this.getProjection().fromLatLngToContainerPixel(this.position_);
336
337      if (pixPosition.x < (-iwOffsetX + padX)) {
338        xOffset = pixPosition.x + iwOffsetX - padX;
339      } else if ((pixPosition.x + iwWidth + iwOffsetX + padX) > mapWidth) {
340        xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;
341      }
342      if (this.alignBottom_) {
343        if (pixPosition.y < (-iwOffsetY + padY + iwHeight)) {
344          yOffset = pixPosition.y + iwOffsetY - padY - iwHeight;
345        } else if ((pixPosition.y + iwOffsetY + padY) > mapHeight) {
346          yOffset = pixPosition.y + iwOffsetY + padY - mapHeight;
347        }
348      } else {
349        if (pixPosition.y < (-iwOffsetY + padY)) {
350          yOffset = pixPosition.y + iwOffsetY - padY;
351        } else if ((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight) {
352          yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;
353        }
354      }
355
356      if (!(xOffset === 0 && yOffset === 0)) {
357
358        // Move the map to the shifted center.
359        //
360        var c = map.getCenter();
361        map.panBy(xOffset, yOffset);
362      }
363    }
364  }
365};
366
367/**
368 * Sets the style of the InfoBox by setting the style sheet and applying
369 * other specific styles requested.
370 * @private
371 */
372InfoBox.prototype.setBoxStyle_ = function () {
373
374  var i, boxStyle;
375
376  if (this.div_) {
377
378    // Apply style values from the style sheet defined in the boxClass parameter:
379    this.div_.className = this.boxClass_;
380
381    // Clear existing inline style values:
382    this.div_.style.cssText = "";
383
384    // Apply style values defined in the boxStyle parameter:
385    boxStyle = this.boxStyle_;
386    for (i in boxStyle) {
387
388      if (boxStyle.hasOwnProperty(i)) {
389
390        this.div_.style[i] = boxStyle[i];
391      }
392    }
393
394    // Fix up opacity style for benefit of MSIE:
395    //
396    if (typeof this.div_.style.opacity !== "undefined" && this.div_.style.opacity !== "") {
397
398      this.div_.style.filter = "alpha(opacity=" + (this.div_.style.opacity * 100) + ")";
399    }
400
401    // Apply required styles:
402    //
403    this.div_.style.position = "absolute";
404    this.div_.style.visibility = 'hidden';
405    if (this.zIndex_ !== null) {
406
407      this.div_.style.zIndex = this.zIndex_;
408    }
409  }
410};
411
412/**
413 * Get the widths of the borders of the InfoBox.
414 * @private
415 * @return {Object} widths object (top, bottom left, right)
416 */
417InfoBox.prototype.getBoxWidths_ = function () {
418
419  var computedStyle;
420  var bw = {top: 0, bottom: 0, left: 0, right: 0};
421  var box = this.div_;
422
423  if (document.defaultView && document.defaultView.getComputedStyle) {
424
425    computedStyle = box.ownerDocument.defaultView.getComputedStyle(box, "");
426
427    if (computedStyle) {
428
429      // The computed styles are always in pixel units (good!)
430      bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
431      bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
432      bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
433      bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
434    }
435
436  } else if (document.documentElement.currentStyle) { // MSIE
437
438    if (box.currentStyle) {
439
440      // The current styles may not be in pixel units, but assume they are (bad!)
441      bw.top = parseInt(box.currentStyle.borderTopWidth, 10) || 0;
442      bw.bottom = parseInt(box.currentStyle.borderBottomWidth, 10) || 0;
443      bw.left = parseInt(box.currentStyle.borderLeftWidth, 10) || 0;
444      bw.right = parseInt(box.currentStyle.borderRightWidth, 10) || 0;
445    }
446  }
447
448  return bw;
449};
450
451/**
452 * Invoked when <tt>close</tt> is called. Do not call it directly.
453 */
454InfoBox.prototype.onRemove = function () {
455
456  if (this.div_) {
457
458    this.div_.parentNode.removeChild(this.div_);
459    this.div_ = null;
460  }
461};
462
463/**
464 * Draws the InfoBox based on the current map projection and zoom level.
465 */
466InfoBox.prototype.draw = function () {
467
468  this.createInfoBoxDiv_();
469
470  var pixPosition = this.getProjection().fromLatLngToDivPixel(this.position_);
471
472  this.div_.style.left = (pixPosition.x + this.pixelOffset_.width) + "px";
473
474  if (this.alignBottom_) {
475    this.div_.style.bottom = -(pixPosition.y + this.pixelOffset_.height) + "px";
476  } else {
477    this.div_.style.top = (pixPosition.y + this.pixelOffset_.height) + "px";
478  }
479
480  if (this.isHidden_) {
481
482    this.div_.style.visibility = 'hidden';
483
484  } else {
485
486    this.div_.style.visibility = "visible";
487  }
488};
489
490/**
491 * Sets the options for the InfoBox. Note that changes to the <tt>maxWidth</tt>,
492 *  <tt>closeBoxMargin</tt>, <tt>closeBoxURL</tt>, and <tt>enableEventPropagation</tt>
493 *  properties have no affect until the current InfoBox is <tt>close</tt>d and a new one
494 *  is <tt>open</tt>ed.
495 * @param {InfoBoxOptions} opt_opts
496 */
497InfoBox.prototype.setOptions = function (opt_opts) {
498  if (typeof opt_opts.boxClass !== "undefined") { // Must be first
499
500    this.boxClass_ = opt_opts.boxClass;
501    this.setBoxStyle_();
502  }
503  if (typeof opt_opts.boxStyle !== "undefined") { // Must be second
504
505    this.boxStyle_ = opt_opts.boxStyle;
506    this.setBoxStyle_();
507  }
508  if (typeof opt_opts.content !== "undefined") {
509
510    this.setContent(opt_opts.content);
511  }
512  if (typeof opt_opts.disableAutoPan !== "undefined") {
513
514    this.disableAutoPan_ = opt_opts.disableAutoPan;
515  }
516  if (typeof opt_opts.maxWidth !== "undefined") {
517
518    this.maxWidth_ = opt_opts.maxWidth;
519  }
520  if (typeof opt_opts.pixelOffset !== "undefined") {
521
522    this.pixelOffset_ = opt_opts.pixelOffset;
523  }
524  if (typeof opt_opts.alignBottom !== "undefined") {
525
526    this.alignBottom_ = opt_opts.alignBottom;
527  }
528  if (typeof opt_opts.position !== "undefined") {
529
530    this.setPosition(opt_opts.position);
531  }
532  if (typeof opt_opts.zIndex !== "undefined") {
533
534    this.setZIndex(opt_opts.zIndex);
535  }
536  if (typeof opt_opts.closeBoxMargin !== "undefined") {
537
538    this.closeBoxMargin_ = opt_opts.closeBoxMargin;
539  }
540  if (typeof opt_opts.closeBoxURL !== "undefined") {
541
542    this.closeBoxURL_ = opt_opts.closeBoxURL;
543  }
544  if (typeof opt_opts.infoBoxClearance !== "undefined") {
545
546    this.infoBoxClearance_ = opt_opts.infoBoxClearance;
547  }
548  if (typeof opt_opts.isHidden !== "undefined") {
549
550    this.isHidden_ = opt_opts.isHidden;
551  }
552  if (typeof opt_opts.enableEventPropagation !== "undefined") {
553
554    this.enableEventPropagation_ = opt_opts.enableEventPropagation;
555  }
556
557  if (this.div_) {
558
559    this.draw();
560  }
561};
562
563/**
564 * Sets the content of the InfoBox.
565 *  The content can be plain text or an HTML DOM node.
566 * @param {string|Node} content
567 */
568InfoBox.prototype.setContent = function (content) {
569  this.content_ = content;
570
571  if (this.div_) {
572
573    if (this.closeListener_) {
574
575      google.maps.event.removeListener(this.closeListener_);
576      this.closeListener_ = null;
577    }
578
579    // Odd code required to make things work with MSIE.
580    //
581    if (!this.fixedWidthSet_) {
582
583      this.div_.style.width = "";
584    }
585
586    if (typeof content.nodeType === "undefined") {
587      this.div_.innerHTML = this.getCloseBoxImg_() + content;
588    } else {
589      this.div_.innerHTML = this.getCloseBoxImg_();
590      this.div_.appendChild(content);
591    }
592
593    // Perverse code required to make things work with MSIE.
594    // (Ensures the close box does, in fact, float to the right.)
595    //
596    if (!this.fixedWidthSet_) {
597      this.div_.style.width = this.div_.offsetWidth + "px";
598      if (typeof content.nodeType === "undefined") {
599        this.div_.innerHTML = this.getCloseBoxImg_() + content;
600      } else {
601        this.div_.innerHTML = this.getCloseBoxImg_();
602        this.div_.appendChild(content);
603      }
604    }
605
606    this.addClickHandler_();
607  }
608
609  /**
610   * This event is fired when the content of the InfoBox changes.
611   * @name InfoBox#content_changed
612   * @event
613   */
614  google.maps.event.trigger(this, "content_changed");
615};
616
617/**
618 * Sets the geographic location of the InfoBox.
619 * @param {LatLng} latlng
620 */
621InfoBox.prototype.setPosition = function (latlng) {
622
623  this.position_ = latlng;
624
625  if (this.div_) {
626
627    this.draw();
628  }
629
630  /**
631   * This event is fired when the position of the InfoBox changes.
632   * @name InfoBox#position_changed
633   * @event
634   */
635  google.maps.event.trigger(this, "position_changed");
636};
637
638/**
639 * Sets the zIndex style for the InfoBox.
640 * @param {number} index
641 */
642InfoBox.prototype.setZIndex = function (index) {
643
644  this.zIndex_ = index;
645
646  if (this.div_) {
647
648    this.div_.style.zIndex = index;
649  }
650
651  /**
652   * This event is fired when the zIndex of the InfoBox changes.
653   * @name InfoBox#zindex_changed
654   * @event
655   */
656  google.maps.event.trigger(this, "zindex_changed");
657};
658
659/**
660 * Returns the content of the InfoBox.
661 * @returns {string}
662 */
663InfoBox.prototype.getContent = function () {
664
665  return this.content_;
666};
667
668/**
669 * Returns the geographic location of the InfoBox.
670 * @returns {LatLng}
671 */
672InfoBox.prototype.getPosition = function () {
673
674  return this.position_;
675};
676
677/**
678 * Returns the zIndex for the InfoBox.
679 * @returns {number}
680 */
681InfoBox.prototype.getZIndex = function () {
682
683  return this.zIndex_;
684};
685
686/**
687 * Shows the InfoBox.
688 */
689InfoBox.prototype.show = function () {
690
691  this.isHidden_ = false;
692  if (this.div_) {
693    this.div_.style.visibility = "visible";
694  }
695};
696
697/**
698 * Hides the InfoBox.
699 */
700InfoBox.prototype.hide = function () {
701
702  this.isHidden_ = true;
703  if (this.div_) {
704    this.div_.style.visibility = "hidden";
705  }
706};
707
708/**
709 * Adds the InfoBox to the specified map or Street View panorama. If <tt>anchor</tt>
710 *  (usually a <tt>google.maps.Marker</tt>) is specified, the position
711 *  of the InfoBox is set to the position of the <tt>anchor</tt>. If the
712 *  anchor is dragged to a new location, the InfoBox moves as well.
713 * @param {Map|StreetViewPanorama} map
714 * @param {MVCObject} [anchor]
715 */
716InfoBox.prototype.open = function (map, anchor) {
717
718  var me = this;
719
720  if (anchor) {
721
722    this.position_ = anchor.getPosition();
723    this.moveListener_ = google.maps.event.addListener(anchor, "position_changed", function () {
724      me.setPosition(this.getPosition());
725    });
726  }
727
728  this.setMap(map);
729
730  if (this.div_) {
731
732    this.panBox_();
733  }
734};
735
736/**
737 * Removes the InfoBox from the map.
738 */
739InfoBox.prototype.close = function () {
740
741  if (this.closeListener_) {
742
743    google.maps.event.removeListener(this.closeListener_);
744    this.closeListener_ = null;
745  }
746
747  if (this.eventListener1_) {
748
749    google.maps.event.removeListener(this.eventListener1_);
750    google.maps.event.removeListener(this.eventListener2_);
751    google.maps.event.removeListener(this.eventListener3_);
752    google.maps.event.removeListener(this.eventListener4_);
753    this.eventListener1_ = null;
754    this.eventListener2_ = null;
755    this.eventListener3_ = null;
756    this.eventListener4_ = null;
757  }
758
759  if (this.moveListener_) {
760
761    google.maps.event.removeListener(this.moveListener_);
762    this.moveListener_ = null;
763  }
764
765  if (this.contextListener_) {
766
767    google.maps.event.removeListener(this.contextListener_);
768    this.contextListener_ = null;
769  }
770
771  this.setMap(null);
772};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.