PageSourceSearch

https://sumaity.com/js/libs/map/jquery.infobox.js?v202610011246

js sumaity.com collected 2026-10-02 16:42:59 UTC 23,761 bytes, 825 lines download raw bytes

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

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.