PageSourceSearch

https://www.numark-pharmacy.co.uk/plugins/GoogleMaps/include/infobox.js

js numark-pharmacy.co.uk collected 2026-10-05 22:13:13 UTC 24,814 bytes, 819 lines download raw bytes

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

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.