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