@react-google-maps/infobox
Advanced tools
Comparing version 2.10.1 to 2.11.1
101
dist/cjs.js
@@ -5,22 +5,55 @@ 'use strict'; | ||
var InfoBox = /** @class */ (function () { | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
var InfoBox = /** @class */ (function (_super) { | ||
__extends(InfoBox, _super); | ||
function InfoBox(options) { | ||
if (options === void 0) { options = {}; } | ||
this.extend(InfoBox, google.maps.OverlayView); | ||
var _this = _super.call(this) || this; | ||
_this.extend(InfoBox, google.maps.OverlayView); | ||
// Standard options (in common with google.maps.InfoWindow): | ||
this.content = options.content || ''; | ||
this.disableAutoPan = options.disableAutoPan || false; | ||
this.maxWidth = options.maxWidth || 0; | ||
this.pixelOffset = options.pixelOffset || new google.maps.Size(0, 0); | ||
this.position = options.position || new google.maps.LatLng(0, 0); | ||
this.zIndex = options.zIndex || null; | ||
_this.content = options.content || ''; | ||
_this.disableAutoPan = options.disableAutoPan || false; | ||
_this.maxWidth = options.maxWidth || 0; | ||
_this.pixelOffset = options.pixelOffset || new google.maps.Size(0, 0); | ||
_this.position = options.position || new google.maps.LatLng(0, 0); | ||
_this.zIndex = options.zIndex || null; | ||
// Additional options (unique to InfoBox): | ||
this.boxClass = options.boxClass || 'infoBox'; | ||
this.boxStyle = options.boxStyle || {}; | ||
this.closeBoxMargin = options.closeBoxMargin || '2px'; | ||
this.closeBoxURL = options.closeBoxURL || 'http://www.google.com/intl/en_us/mapfiles/close.gif'; | ||
_this.boxClass = options.boxClass || 'infoBox'; | ||
_this.boxStyle = options.boxStyle || {}; | ||
_this.closeBoxMargin = options.closeBoxMargin || '2px'; | ||
_this.closeBoxURL = options.closeBoxURL || 'http://www.google.com/intl/en_us/mapfiles/close.gif'; | ||
if (options.closeBoxURL === '') { | ||
this.closeBoxURL = ''; | ||
_this.closeBoxURL = ''; | ||
} | ||
this.infoBoxClearance = options.infoBoxClearance || new google.maps.Size(1, 1); | ||
_this.infoBoxClearance = options.infoBoxClearance || new google.maps.Size(1, 1); | ||
if (typeof options.visible === 'undefined') { | ||
@@ -34,13 +67,14 @@ if (typeof options.isHidden === 'undefined') { | ||
} | ||
this.isHidden = !options.visible; | ||
this.alignBottom = options.alignBottom || false; | ||
this.pane = options.pane || 'floatPane'; | ||
this.enableEventPropagation = options.enableEventPropagation || false; | ||
this.div = null; | ||
this.closeListener = null; | ||
this.moveListener = null; | ||
this.mapListener = null; | ||
this.contextListener = null; | ||
this.eventListeners = null; | ||
this.fixedWidthSet = null; | ||
_this.isHidden = !options.visible; | ||
_this.alignBottom = options.alignBottom || false; | ||
_this.pane = options.pane || 'floatPane'; | ||
_this.enableEventPropagation = options.enableEventPropagation || false; | ||
_this.div = null; | ||
_this.closeListener = null; | ||
_this.moveListener = null; | ||
_this.mapListener = null; | ||
_this.contextListener = null; | ||
_this.eventListeners = null; | ||
_this.fixedWidthSet = null; | ||
return _this; | ||
} | ||
@@ -77,6 +111,6 @@ InfoBox.prototype.createInfoBoxDiv = function () { | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
var panes = this.getPanes(); | ||
panes[this.pane].appendChild(this.div); // Add the InfoBox div to the DOM | ||
if (panes !== null) { | ||
panes[this.pane].appendChild(this.div); // Add the InfoBox div to the DOM | ||
} | ||
this.addClickHandler(); | ||
@@ -555,14 +589,7 @@ if (this.div.style.width) { | ||
return function applyExtend(object) { | ||
// eslint-disable-next-line guard-for-in | ||
for (var property in object.prototype) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
if (!Object.prototype.hasOwnProperty.call(this, property)) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.prototype[property] = object.prototype[property]; | ||
this.prototype.set(property, object.prototype.get(property)); | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return this; | ||
@@ -572,5 +599,5 @@ }.apply(obj1, [obj2]); | ||
return InfoBox; | ||
}()); | ||
}(google.maps.OverlayView)); | ||
exports.InfoBox = InfoBox; | ||
//# sourceMappingURL=cjs.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function t(i){void 0===i&&(i={}),this.extend(t,google.maps.OverlayView),this.content=i.content||"",this.disableAutoPan=i.disableAutoPan||!1,this.maxWidth=i.maxWidth||0,this.pixelOffset=i.pixelOffset||new google.maps.Size(0,0),this.position=i.position||new google.maps.LatLng(0,0),this.zIndex=i.zIndex||null,this.boxClass=i.boxClass||"infoBox",this.boxStyle=i.boxStyle||{},this.closeBoxMargin=i.closeBoxMargin||"2px",this.closeBoxURL=i.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",""===i.closeBoxURL&&(this.closeBoxURL=""),this.infoBoxClearance=i.infoBoxClearance||new google.maps.Size(1,1),void 0===i.visible&&(void 0===i.isHidden?i.visible=!0:i.visible=!i.isHidden),this.isHidden=!i.visible,this.alignBottom=i.alignBottom||!1,this.pane=i.pane||"floatPane",this.enableEventPropagation=i.enableEventPropagation||!1,this.div=null,this.closeListener=null,this.moveListener=null,this.mapListener=null,this.contextListener=null,this.eventListeners=null,this.fixedWidthSet=null}return t.prototype.createInfoBoxDiv=function(){var t=this;function i(t){t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}if(!this.div){if(this.div=document.createElement("div"),this.setBoxStyle(),"string"==typeof this.content?this.div.innerHTML=this.getCloseBoxImg()+this.content:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(this.content)),this.getPanes()[this.pane].appendChild(this.div),this.addClickHandler(),this.div.style.width)this.fixedWidthSet=!0;else if(0!==this.maxWidth&&this.div.offsetWidth>this.maxWidth)this.div.style.width=this.maxWidth+"px",this.fixedWidthSet=!0;else{var e=this.getBoxWidths();this.div.style.width=this.div.offsetWidth-e.left-e.right+"px",this.fixedWidthSet=!1}if(this.panBox(this.disableAutoPan),!this.enableEventPropagation){this.eventListeners=[];for(var s=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove"],o=0;o<s.length;o++)this.eventListeners.push(google.maps.event.addListener(this.div,s[o],i));this.eventListeners.push(google.maps.event.addListener(this.div,"mouseover",(function(){t.div&&(t.div.style.cursor="default")})))}this.contextListener=google.maps.event.addListener(this.div,"contextmenu",(function(e){e.returnValue=!1,e.preventDefault&&e.preventDefault(),t.enableEventPropagation||i(e)})),google.maps.event.trigger(this,"domready")}},t.prototype.getCloseBoxImg=function(){var t="";return""!==this.closeBoxURL&&(t='<img alt=""',t+=' aria-hidden="true"',t+=" src='"+this.closeBoxURL+"'",t+=" align=right",t+=" style='",t+=" position: relative;",t+=" cursor: pointer;",t+=" margin: "+this.closeBoxMargin+";",t+="'>"),t},t.prototype.addClickHandler=function(){if(this.div&&this.div.firstChild&&""!==this.closeBoxURL){var t=this.div.firstChild;this.closeListener=google.maps.event.addListener(t,"click",this.getCloseClickHandler())}else this.closeListener=null},t.prototype.getCloseClickHandler=function(){var t=this;return function(i){i.cancelBubble=!0,i.stopPropagation&&i.stopPropagation(),google.maps.event.trigger(t,"closeclick"),t.close()}},t.prototype.panBox=function(t){if(this.div&&!t){var i=this.getMap();if(i instanceof google.maps.Map){var e=0,s=0,o=i.getBounds();o&&!o.contains(this.position)&&i.setCenter(this.position);var n=i.getDiv(),h=n.offsetWidth,l=n.offsetHeight,d=this.pixelOffset.width,r=this.pixelOffset.height,a=this.div.offsetWidth,p=this.div.offsetHeight,v=this.infoBoxClearance.width,g=this.infoBoxClearance.height,c=this.getProjection().fromLatLngToContainerPixel(this.position);null!==c&&(c.x<-d+v?e=c.x+d-v:c.x+a+d+v>h&&(e=c.x+a+d+v-h),this.alignBottom?c.y<-r+g+p?s=c.y+r-g-p:c.y+r+g>l&&(s=c.y+r+g-l):c.y<-r+g?s=c.y+r-g:c.y+p+r+g>l&&(s=c.y+p+r+g-l)),0===e&&0===s||i.panBy(e,s)}}},t.prototype.setBoxStyle=function(){if(this.div){this.div.className=this.boxClass,this.div.style.cssText="";var t=this.boxStyle;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(this.div.style[i]=t[i]);if(this.div.style.webkitTransform="translateZ(0)",void 0!==this.div.style.opacity&&""!==this.div.style.opacity){var e=parseFloat(this.div.style.opacity||"");this.div.style.msFilter='"progid:DXImageTransform.Microsoft.Alpha(Opacity='+100*e+')"',this.div.style.filter="alpha(opacity="+100*e+")"}this.div.style.position="absolute",this.div.style.visibility="hidden",null!==this.zIndex&&(this.div.style.zIndex=this.zIndex+""),this.div.style.overflow||(this.div.style.overflow="auto")}},t.prototype.getBoxWidths=function(){var t={top:0,bottom:0,left:0,right:0};if(!this.div)return t;if(document.defaultView){var i=this.div.ownerDocument,e=i&&i.defaultView?i.defaultView.getComputedStyle(this.div,""):null;e&&(t.top=parseInt(e.borderTopWidth||"",10)||0,t.bottom=parseInt(e.borderBottomWidth||"",10)||0,t.left=parseInt(e.borderLeftWidth||"",10)||0,t.right=parseInt(e.borderRightWidth||"",10)||0)}else if(document.documentElement.currentStyle){var s=this.div.currentStyle;s&&(t.top=parseInt(s.borderTopWidth||"",10)||0,t.bottom=parseInt(s.borderBottomWidth||"",10)||0,t.left=parseInt(s.borderLeftWidth||"",10)||0,t.right=parseInt(s.borderRightWidth||"",10)||0)}return t},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.div.parentNode.removeChild(this.div),this.div=null)},t.prototype.draw=function(){if(this.createInfoBoxDiv(),this.div){var t=this.getProjection().fromLatLngToDivPixel(this.position);null!==t&&(this.div.style.left=t.x+this.pixelOffset.width+"px",this.alignBottom?this.div.style.bottom=-(t.y+this.pixelOffset.height)+"px":this.div.style.top=t.y+this.pixelOffset.height+"px"),this.isHidden?this.div.style.visibility="hidden":this.div.style.visibility="visible"}},t.prototype.setOptions=function(t){void 0===t&&(t={}),void 0!==t.boxClass&&(this.boxClass=t.boxClass,this.setBoxStyle()),void 0!==t.boxStyle&&(this.boxStyle=t.boxStyle,this.setBoxStyle()),void 0!==t.content&&this.setContent(t.content),void 0!==t.disableAutoPan&&(this.disableAutoPan=t.disableAutoPan),void 0!==t.maxWidth&&(this.maxWidth=t.maxWidth),void 0!==t.pixelOffset&&(this.pixelOffset=t.pixelOffset),void 0!==t.alignBottom&&(this.alignBottom=t.alignBottom),void 0!==t.position&&this.setPosition(t.position),void 0!==t.zIndex&&this.setZIndex(t.zIndex),void 0!==t.closeBoxMargin&&(this.closeBoxMargin=t.closeBoxMargin),void 0!==t.closeBoxURL&&(this.closeBoxURL=t.closeBoxURL),void 0!==t.infoBoxClearance&&(this.infoBoxClearance=t.infoBoxClearance),void 0!==t.isHidden&&(this.isHidden=t.isHidden),void 0!==t.visible&&(this.isHidden=!t.visible),void 0!==t.enableEventPropagation&&(this.enableEventPropagation=t.enableEventPropagation),this.div&&this.draw()},t.prototype.setContent=function(t){this.content=t,this.div&&(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.fixedWidthSet||(this.div.style.width=""),"string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t)),this.fixedWidthSet||(this.div.style.width=this.div.offsetWidth+"px","string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t))),this.addClickHandler()),google.maps.event.trigger(this,"content_changed")},t.prototype.setPosition=function(t){this.position=t,this.div&&this.draw(),google.maps.event.trigger(this,"position_changed")},t.prototype.setVisible=function(t){this.isHidden=!t,this.div&&(this.div.style.visibility=this.isHidden?"hidden":"visible")},t.prototype.setZIndex=function(t){this.zIndex=t,this.div&&(this.div.style.zIndex=t+""),google.maps.event.trigger(this,"zindex_changed")},t.prototype.getContent=function(){return this.content},t.prototype.getPosition=function(){return this.position},t.prototype.getZIndex=function(){return this.zIndex},t.prototype.getVisible=function(){var t=this.getMap();return null!=t&&!this.isHidden},t.prototype.show=function(){this.isHidden=!1,this.div&&(this.div.style.visibility="visible")},t.prototype.hide=function(){this.isHidden=!0,this.div&&(this.div.style.visibility="hidden")},t.prototype.open=function(t,i){var e=this;i&&(this.position=i.getPosition(),this.moveListener=google.maps.event.addListener(i,"position_changed",(function(){var t=i.getPosition();e.setPosition(t)})),this.mapListener=google.maps.event.addListener(i,"map_changed",(function(){e.setMap(i.map)}))),this.setMap(t),this.div&&this.panBox()},t.prototype.close=function(){if(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.eventListeners){for(var t=0;t<this.eventListeners.length;t++)google.maps.event.removeListener(this.eventListeners[t]);this.eventListeners=null}this.moveListener&&(google.maps.event.removeListener(this.moveListener),this.moveListener=null),this.mapListener&&(google.maps.event.removeListener(this.mapListener),this.mapListener=null),this.contextListener&&(google.maps.event.removeListener(this.contextListener),this.contextListener=null),this.setMap(null)},t.prototype.extend=function(t,i){return function(t){for(var i in t.prototype)Object.prototype.hasOwnProperty.call(this,i)||(this.prototype[i]=t.prototype[i]);return this}.apply(t,[i])},t}();exports.InfoBox=t; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(i,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])},t(i,e)};var i=function(i){function e(t){void 0===t&&(t={});var o=i.call(this)||this;return o.extend(e,google.maps.OverlayView),o.content=t.content||"",o.disableAutoPan=t.disableAutoPan||!1,o.maxWidth=t.maxWidth||0,o.pixelOffset=t.pixelOffset||new google.maps.Size(0,0),o.position=t.position||new google.maps.LatLng(0,0),o.zIndex=t.zIndex||null,o.boxClass=t.boxClass||"infoBox",o.boxStyle=t.boxStyle||{},o.closeBoxMargin=t.closeBoxMargin||"2px",o.closeBoxURL=t.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",""===t.closeBoxURL&&(o.closeBoxURL=""),o.infoBoxClearance=t.infoBoxClearance||new google.maps.Size(1,1),void 0===t.visible&&(void 0===t.isHidden?t.visible=!0:t.visible=!t.isHidden),o.isHidden=!t.visible,o.alignBottom=t.alignBottom||!1,o.pane=t.pane||"floatPane",o.enableEventPropagation=t.enableEventPropagation||!1,o.div=null,o.closeListener=null,o.moveListener=null,o.mapListener=null,o.contextListener=null,o.eventListeners=null,o.fixedWidthSet=null,o}return function(i,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=i}t(i,e),i.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}(e,i),e.prototype.createInfoBoxDiv=function(){var t=this;function i(t){t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}if(!this.div){this.div=document.createElement("div"),this.setBoxStyle(),"string"==typeof this.content?this.div.innerHTML=this.getCloseBoxImg()+this.content:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(this.content));var e=this.getPanes();if(null!==e&&e[this.pane].appendChild(this.div),this.addClickHandler(),this.div.style.width)this.fixedWidthSet=!0;else if(0!==this.maxWidth&&this.div.offsetWidth>this.maxWidth)this.div.style.width=this.maxWidth+"px",this.fixedWidthSet=!0;else{var o=this.getBoxWidths();this.div.style.width=this.div.offsetWidth-o.left-o.right+"px",this.fixedWidthSet=!1}if(this.panBox(this.disableAutoPan),!this.enableEventPropagation){this.eventListeners=[];for(var s=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove"],n=0;n<s.length;n++)this.eventListeners.push(google.maps.event.addListener(this.div,s[n],i));this.eventListeners.push(google.maps.event.addListener(this.div,"mouseover",(function(){t.div&&(t.div.style.cursor="default")})))}this.contextListener=google.maps.event.addListener(this.div,"contextmenu",(function(e){e.returnValue=!1,e.preventDefault&&e.preventDefault(),t.enableEventPropagation||i(e)})),google.maps.event.trigger(this,"domready")}},e.prototype.getCloseBoxImg=function(){var t="";return""!==this.closeBoxURL&&(t='<img alt=""',t+=' aria-hidden="true"',t+=" src='"+this.closeBoxURL+"'",t+=" align=right",t+=" style='",t+=" position: relative;",t+=" cursor: pointer;",t+=" margin: "+this.closeBoxMargin+";",t+="'>"),t},e.prototype.addClickHandler=function(){if(this.div&&this.div.firstChild&&""!==this.closeBoxURL){var t=this.div.firstChild;this.closeListener=google.maps.event.addListener(t,"click",this.getCloseClickHandler())}else this.closeListener=null},e.prototype.getCloseClickHandler=function(){var t=this;return function(i){i.cancelBubble=!0,i.stopPropagation&&i.stopPropagation(),google.maps.event.trigger(t,"closeclick"),t.close()}},e.prototype.panBox=function(t){if(this.div&&!t){var i=this.getMap();if(i instanceof google.maps.Map){var e=0,o=0,s=i.getBounds();s&&!s.contains(this.position)&&i.setCenter(this.position);var n=i.getDiv(),r=n.offsetWidth,l=n.offsetHeight,h=this.pixelOffset.width,d=this.pixelOffset.height,a=this.div.offsetWidth,p=this.div.offsetHeight,v=this.infoBoxClearance.width,c=this.infoBoxClearance.height,g=this.getProjection().fromLatLngToContainerPixel(this.position);null!==g&&(g.x<-h+v?e=g.x+h-v:g.x+a+h+v>r&&(e=g.x+a+h+v-r),this.alignBottom?g.y<-d+c+p?o=g.y+d-c-p:g.y+d+c>l&&(o=g.y+d+c-l):g.y<-d+c?o=g.y+d-c:g.y+p+d+c>l&&(o=g.y+p+d+c-l)),0===e&&0===o||i.panBy(e,o)}}},e.prototype.setBoxStyle=function(){if(this.div){this.div.className=this.boxClass,this.div.style.cssText="";var t=this.boxStyle;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(this.div.style[i]=t[i]);if(this.div.style.webkitTransform="translateZ(0)",void 0!==this.div.style.opacity&&""!==this.div.style.opacity){var e=parseFloat(this.div.style.opacity||"");this.div.style.msFilter='"progid:DXImageTransform.Microsoft.Alpha(Opacity='+100*e+')"',this.div.style.filter="alpha(opacity="+100*e+")"}this.div.style.position="absolute",this.div.style.visibility="hidden",null!==this.zIndex&&(this.div.style.zIndex=this.zIndex+""),this.div.style.overflow||(this.div.style.overflow="auto")}},e.prototype.getBoxWidths=function(){var t={top:0,bottom:0,left:0,right:0};if(!this.div)return t;if(document.defaultView){var i=this.div.ownerDocument,e=i&&i.defaultView?i.defaultView.getComputedStyle(this.div,""):null;e&&(t.top=parseInt(e.borderTopWidth||"",10)||0,t.bottom=parseInt(e.borderBottomWidth||"",10)||0,t.left=parseInt(e.borderLeftWidth||"",10)||0,t.right=parseInt(e.borderRightWidth||"",10)||0)}else if(document.documentElement.currentStyle){var o=this.div.currentStyle;o&&(t.top=parseInt(o.borderTopWidth||"",10)||0,t.bottom=parseInt(o.borderBottomWidth||"",10)||0,t.left=parseInt(o.borderLeftWidth||"",10)||0,t.right=parseInt(o.borderRightWidth||"",10)||0)}return t},e.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.div.parentNode.removeChild(this.div),this.div=null)},e.prototype.draw=function(){if(this.createInfoBoxDiv(),this.div){var t=this.getProjection().fromLatLngToDivPixel(this.position);null!==t&&(this.div.style.left=t.x+this.pixelOffset.width+"px",this.alignBottom?this.div.style.bottom=-(t.y+this.pixelOffset.height)+"px":this.div.style.top=t.y+this.pixelOffset.height+"px"),this.isHidden?this.div.style.visibility="hidden":this.div.style.visibility="visible"}},e.prototype.setOptions=function(t){void 0===t&&(t={}),void 0!==t.boxClass&&(this.boxClass=t.boxClass,this.setBoxStyle()),void 0!==t.boxStyle&&(this.boxStyle=t.boxStyle,this.setBoxStyle()),void 0!==t.content&&this.setContent(t.content),void 0!==t.disableAutoPan&&(this.disableAutoPan=t.disableAutoPan),void 0!==t.maxWidth&&(this.maxWidth=t.maxWidth),void 0!==t.pixelOffset&&(this.pixelOffset=t.pixelOffset),void 0!==t.alignBottom&&(this.alignBottom=t.alignBottom),void 0!==t.position&&this.setPosition(t.position),void 0!==t.zIndex&&this.setZIndex(t.zIndex),void 0!==t.closeBoxMargin&&(this.closeBoxMargin=t.closeBoxMargin),void 0!==t.closeBoxURL&&(this.closeBoxURL=t.closeBoxURL),void 0!==t.infoBoxClearance&&(this.infoBoxClearance=t.infoBoxClearance),void 0!==t.isHidden&&(this.isHidden=t.isHidden),void 0!==t.visible&&(this.isHidden=!t.visible),void 0!==t.enableEventPropagation&&(this.enableEventPropagation=t.enableEventPropagation),this.div&&this.draw()},e.prototype.setContent=function(t){this.content=t,this.div&&(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.fixedWidthSet||(this.div.style.width=""),"string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t)),this.fixedWidthSet||(this.div.style.width=this.div.offsetWidth+"px","string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t))),this.addClickHandler()),google.maps.event.trigger(this,"content_changed")},e.prototype.setPosition=function(t){this.position=t,this.div&&this.draw(),google.maps.event.trigger(this,"position_changed")},e.prototype.setVisible=function(t){this.isHidden=!t,this.div&&(this.div.style.visibility=this.isHidden?"hidden":"visible")},e.prototype.setZIndex=function(t){this.zIndex=t,this.div&&(this.div.style.zIndex=t+""),google.maps.event.trigger(this,"zindex_changed")},e.prototype.getContent=function(){return this.content},e.prototype.getPosition=function(){return this.position},e.prototype.getZIndex=function(){return this.zIndex},e.prototype.getVisible=function(){var t=this.getMap();return null!=t&&!this.isHidden},e.prototype.show=function(){this.isHidden=!1,this.div&&(this.div.style.visibility="visible")},e.prototype.hide=function(){this.isHidden=!0,this.div&&(this.div.style.visibility="hidden")},e.prototype.open=function(t,i){var e=this;i&&(this.position=i.getPosition(),this.moveListener=google.maps.event.addListener(i,"position_changed",(function(){var t=i.getPosition();e.setPosition(t)})),this.mapListener=google.maps.event.addListener(i,"map_changed",(function(){e.setMap(i.map)}))),this.setMap(t),this.div&&this.panBox()},e.prototype.close=function(){if(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.eventListeners){for(var t=0;t<this.eventListeners.length;t++)google.maps.event.removeListener(this.eventListeners[t]);this.eventListeners=null}this.moveListener&&(google.maps.event.removeListener(this.moveListener),this.moveListener=null),this.mapListener&&(google.maps.event.removeListener(this.mapListener),this.mapListener=null),this.contextListener&&(google.maps.event.removeListener(this.contextListener),this.contextListener=null),this.setMap(null)},e.prototype.extend=function(t,i){return function(t){for(var i in t.prototype)Object.prototype.hasOwnProperty.call(this,i)||this.prototype.set(i,t.prototype.get(i));return this}.apply(t,[i])},e}(google.maps.OverlayView);exports.InfoBox=i; | ||
//# sourceMappingURL=cjs.min.js.map |
101
dist/esm.js
@@ -1,21 +0,54 @@ | ||
var InfoBox = /** @class */ (function () { | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
var InfoBox = /** @class */ (function (_super) { | ||
__extends(InfoBox, _super); | ||
function InfoBox(options) { | ||
if (options === void 0) { options = {}; } | ||
this.extend(InfoBox, google.maps.OverlayView); | ||
var _this = _super.call(this) || this; | ||
_this.extend(InfoBox, google.maps.OverlayView); | ||
// Standard options (in common with google.maps.InfoWindow): | ||
this.content = options.content || ''; | ||
this.disableAutoPan = options.disableAutoPan || false; | ||
this.maxWidth = options.maxWidth || 0; | ||
this.pixelOffset = options.pixelOffset || new google.maps.Size(0, 0); | ||
this.position = options.position || new google.maps.LatLng(0, 0); | ||
this.zIndex = options.zIndex || null; | ||
_this.content = options.content || ''; | ||
_this.disableAutoPan = options.disableAutoPan || false; | ||
_this.maxWidth = options.maxWidth || 0; | ||
_this.pixelOffset = options.pixelOffset || new google.maps.Size(0, 0); | ||
_this.position = options.position || new google.maps.LatLng(0, 0); | ||
_this.zIndex = options.zIndex || null; | ||
// Additional options (unique to InfoBox): | ||
this.boxClass = options.boxClass || 'infoBox'; | ||
this.boxStyle = options.boxStyle || {}; | ||
this.closeBoxMargin = options.closeBoxMargin || '2px'; | ||
this.closeBoxURL = options.closeBoxURL || 'http://www.google.com/intl/en_us/mapfiles/close.gif'; | ||
_this.boxClass = options.boxClass || 'infoBox'; | ||
_this.boxStyle = options.boxStyle || {}; | ||
_this.closeBoxMargin = options.closeBoxMargin || '2px'; | ||
_this.closeBoxURL = options.closeBoxURL || 'http://www.google.com/intl/en_us/mapfiles/close.gif'; | ||
if (options.closeBoxURL === '') { | ||
this.closeBoxURL = ''; | ||
_this.closeBoxURL = ''; | ||
} | ||
this.infoBoxClearance = options.infoBoxClearance || new google.maps.Size(1, 1); | ||
_this.infoBoxClearance = options.infoBoxClearance || new google.maps.Size(1, 1); | ||
if (typeof options.visible === 'undefined') { | ||
@@ -29,13 +62,14 @@ if (typeof options.isHidden === 'undefined') { | ||
} | ||
this.isHidden = !options.visible; | ||
this.alignBottom = options.alignBottom || false; | ||
this.pane = options.pane || 'floatPane'; | ||
this.enableEventPropagation = options.enableEventPropagation || false; | ||
this.div = null; | ||
this.closeListener = null; | ||
this.moveListener = null; | ||
this.mapListener = null; | ||
this.contextListener = null; | ||
this.eventListeners = null; | ||
this.fixedWidthSet = null; | ||
_this.isHidden = !options.visible; | ||
_this.alignBottom = options.alignBottom || false; | ||
_this.pane = options.pane || 'floatPane'; | ||
_this.enableEventPropagation = options.enableEventPropagation || false; | ||
_this.div = null; | ||
_this.closeListener = null; | ||
_this.moveListener = null; | ||
_this.mapListener = null; | ||
_this.contextListener = null; | ||
_this.eventListeners = null; | ||
_this.fixedWidthSet = null; | ||
return _this; | ||
} | ||
@@ -72,6 +106,6 @@ InfoBox.prototype.createInfoBoxDiv = function () { | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
var panes = this.getPanes(); | ||
panes[this.pane].appendChild(this.div); // Add the InfoBox div to the DOM | ||
if (panes !== null) { | ||
panes[this.pane].appendChild(this.div); // Add the InfoBox div to the DOM | ||
} | ||
this.addClickHandler(); | ||
@@ -550,14 +584,7 @@ if (this.div.style.width) { | ||
return function applyExtend(object) { | ||
// eslint-disable-next-line guard-for-in | ||
for (var property in object.prototype) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
if (!Object.prototype.hasOwnProperty.call(this, property)) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.prototype[property] = object.prototype[property]; | ||
this.prototype.set(property, object.prototype.get(property)); | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return this; | ||
@@ -567,5 +594,5 @@ }.apply(obj1, [obj2]); | ||
return InfoBox; | ||
}()); | ||
}(google.maps.OverlayView)); | ||
export { InfoBox }; | ||
//# sourceMappingURL=esm.js.map |
@@ -1,2 +0,2 @@ | ||
var t=function(){function t(i){void 0===i&&(i={}),this.extend(t,google.maps.OverlayView),this.content=i.content||"",this.disableAutoPan=i.disableAutoPan||!1,this.maxWidth=i.maxWidth||0,this.pixelOffset=i.pixelOffset||new google.maps.Size(0,0),this.position=i.position||new google.maps.LatLng(0,0),this.zIndex=i.zIndex||null,this.boxClass=i.boxClass||"infoBox",this.boxStyle=i.boxStyle||{},this.closeBoxMargin=i.closeBoxMargin||"2px",this.closeBoxURL=i.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",""===i.closeBoxURL&&(this.closeBoxURL=""),this.infoBoxClearance=i.infoBoxClearance||new google.maps.Size(1,1),void 0===i.visible&&(void 0===i.isHidden?i.visible=!0:i.visible=!i.isHidden),this.isHidden=!i.visible,this.alignBottom=i.alignBottom||!1,this.pane=i.pane||"floatPane",this.enableEventPropagation=i.enableEventPropagation||!1,this.div=null,this.closeListener=null,this.moveListener=null,this.mapListener=null,this.contextListener=null,this.eventListeners=null,this.fixedWidthSet=null}return t.prototype.createInfoBoxDiv=function(){var t=this;function i(t){t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}if(!this.div){if(this.div=document.createElement("div"),this.setBoxStyle(),"string"==typeof this.content?this.div.innerHTML=this.getCloseBoxImg()+this.content:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(this.content)),this.getPanes()[this.pane].appendChild(this.div),this.addClickHandler(),this.div.style.width)this.fixedWidthSet=!0;else if(0!==this.maxWidth&&this.div.offsetWidth>this.maxWidth)this.div.style.width=this.maxWidth+"px",this.fixedWidthSet=!0;else{var e=this.getBoxWidths();this.div.style.width=this.div.offsetWidth-e.left-e.right+"px",this.fixedWidthSet=!1}if(this.panBox(this.disableAutoPan),!this.enableEventPropagation){this.eventListeners=[];for(var s=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove"],o=0;o<s.length;o++)this.eventListeners.push(google.maps.event.addListener(this.div,s[o],i));this.eventListeners.push(google.maps.event.addListener(this.div,"mouseover",(function(){t.div&&(t.div.style.cursor="default")})))}this.contextListener=google.maps.event.addListener(this.div,"contextmenu",(function(e){e.returnValue=!1,e.preventDefault&&e.preventDefault(),t.enableEventPropagation||i(e)})),google.maps.event.trigger(this,"domready")}},t.prototype.getCloseBoxImg=function(){var t="";return""!==this.closeBoxURL&&(t='<img alt=""',t+=' aria-hidden="true"',t+=" src='"+this.closeBoxURL+"'",t+=" align=right",t+=" style='",t+=" position: relative;",t+=" cursor: pointer;",t+=" margin: "+this.closeBoxMargin+";",t+="'>"),t},t.prototype.addClickHandler=function(){if(this.div&&this.div.firstChild&&""!==this.closeBoxURL){var t=this.div.firstChild;this.closeListener=google.maps.event.addListener(t,"click",this.getCloseClickHandler())}else this.closeListener=null},t.prototype.getCloseClickHandler=function(){var t=this;return function(i){i.cancelBubble=!0,i.stopPropagation&&i.stopPropagation(),google.maps.event.trigger(t,"closeclick"),t.close()}},t.prototype.panBox=function(t){if(this.div&&!t){var i=this.getMap();if(i instanceof google.maps.Map){var e=0,s=0,o=i.getBounds();o&&!o.contains(this.position)&&i.setCenter(this.position);var n=i.getDiv(),h=n.offsetWidth,l=n.offsetHeight,d=this.pixelOffset.width,r=this.pixelOffset.height,a=this.div.offsetWidth,p=this.div.offsetHeight,v=this.infoBoxClearance.width,g=this.infoBoxClearance.height,c=this.getProjection().fromLatLngToContainerPixel(this.position);null!==c&&(c.x<-d+v?e=c.x+d-v:c.x+a+d+v>h&&(e=c.x+a+d+v-h),this.alignBottom?c.y<-r+g+p?s=c.y+r-g-p:c.y+r+g>l&&(s=c.y+r+g-l):c.y<-r+g?s=c.y+r-g:c.y+p+r+g>l&&(s=c.y+p+r+g-l)),0===e&&0===s||i.panBy(e,s)}}},t.prototype.setBoxStyle=function(){if(this.div){this.div.className=this.boxClass,this.div.style.cssText="";var t=this.boxStyle;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(this.div.style[i]=t[i]);if(this.div.style.webkitTransform="translateZ(0)",void 0!==this.div.style.opacity&&""!==this.div.style.opacity){var e=parseFloat(this.div.style.opacity||"");this.div.style.msFilter='"progid:DXImageTransform.Microsoft.Alpha(Opacity='+100*e+')"',this.div.style.filter="alpha(opacity="+100*e+")"}this.div.style.position="absolute",this.div.style.visibility="hidden",null!==this.zIndex&&(this.div.style.zIndex=this.zIndex+""),this.div.style.overflow||(this.div.style.overflow="auto")}},t.prototype.getBoxWidths=function(){var t={top:0,bottom:0,left:0,right:0};if(!this.div)return t;if(document.defaultView){var i=this.div.ownerDocument,e=i&&i.defaultView?i.defaultView.getComputedStyle(this.div,""):null;e&&(t.top=parseInt(e.borderTopWidth||"",10)||0,t.bottom=parseInt(e.borderBottomWidth||"",10)||0,t.left=parseInt(e.borderLeftWidth||"",10)||0,t.right=parseInt(e.borderRightWidth||"",10)||0)}else if(document.documentElement.currentStyle){var s=this.div.currentStyle;s&&(t.top=parseInt(s.borderTopWidth||"",10)||0,t.bottom=parseInt(s.borderBottomWidth||"",10)||0,t.left=parseInt(s.borderLeftWidth||"",10)||0,t.right=parseInt(s.borderRightWidth||"",10)||0)}return t},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.div.parentNode.removeChild(this.div),this.div=null)},t.prototype.draw=function(){if(this.createInfoBoxDiv(),this.div){var t=this.getProjection().fromLatLngToDivPixel(this.position);null!==t&&(this.div.style.left=t.x+this.pixelOffset.width+"px",this.alignBottom?this.div.style.bottom=-(t.y+this.pixelOffset.height)+"px":this.div.style.top=t.y+this.pixelOffset.height+"px"),this.isHidden?this.div.style.visibility="hidden":this.div.style.visibility="visible"}},t.prototype.setOptions=function(t){void 0===t&&(t={}),void 0!==t.boxClass&&(this.boxClass=t.boxClass,this.setBoxStyle()),void 0!==t.boxStyle&&(this.boxStyle=t.boxStyle,this.setBoxStyle()),void 0!==t.content&&this.setContent(t.content),void 0!==t.disableAutoPan&&(this.disableAutoPan=t.disableAutoPan),void 0!==t.maxWidth&&(this.maxWidth=t.maxWidth),void 0!==t.pixelOffset&&(this.pixelOffset=t.pixelOffset),void 0!==t.alignBottom&&(this.alignBottom=t.alignBottom),void 0!==t.position&&this.setPosition(t.position),void 0!==t.zIndex&&this.setZIndex(t.zIndex),void 0!==t.closeBoxMargin&&(this.closeBoxMargin=t.closeBoxMargin),void 0!==t.closeBoxURL&&(this.closeBoxURL=t.closeBoxURL),void 0!==t.infoBoxClearance&&(this.infoBoxClearance=t.infoBoxClearance),void 0!==t.isHidden&&(this.isHidden=t.isHidden),void 0!==t.visible&&(this.isHidden=!t.visible),void 0!==t.enableEventPropagation&&(this.enableEventPropagation=t.enableEventPropagation),this.div&&this.draw()},t.prototype.setContent=function(t){this.content=t,this.div&&(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.fixedWidthSet||(this.div.style.width=""),"string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t)),this.fixedWidthSet||(this.div.style.width=this.div.offsetWidth+"px","string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t))),this.addClickHandler()),google.maps.event.trigger(this,"content_changed")},t.prototype.setPosition=function(t){this.position=t,this.div&&this.draw(),google.maps.event.trigger(this,"position_changed")},t.prototype.setVisible=function(t){this.isHidden=!t,this.div&&(this.div.style.visibility=this.isHidden?"hidden":"visible")},t.prototype.setZIndex=function(t){this.zIndex=t,this.div&&(this.div.style.zIndex=t+""),google.maps.event.trigger(this,"zindex_changed")},t.prototype.getContent=function(){return this.content},t.prototype.getPosition=function(){return this.position},t.prototype.getZIndex=function(){return this.zIndex},t.prototype.getVisible=function(){var t=this.getMap();return null!=t&&!this.isHidden},t.prototype.show=function(){this.isHidden=!1,this.div&&(this.div.style.visibility="visible")},t.prototype.hide=function(){this.isHidden=!0,this.div&&(this.div.style.visibility="hidden")},t.prototype.open=function(t,i){var e=this;i&&(this.position=i.getPosition(),this.moveListener=google.maps.event.addListener(i,"position_changed",(function(){var t=i.getPosition();e.setPosition(t)})),this.mapListener=google.maps.event.addListener(i,"map_changed",(function(){e.setMap(i.map)}))),this.setMap(t),this.div&&this.panBox()},t.prototype.close=function(){if(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.eventListeners){for(var t=0;t<this.eventListeners.length;t++)google.maps.event.removeListener(this.eventListeners[t]);this.eventListeners=null}this.moveListener&&(google.maps.event.removeListener(this.moveListener),this.moveListener=null),this.mapListener&&(google.maps.event.removeListener(this.mapListener),this.mapListener=null),this.contextListener&&(google.maps.event.removeListener(this.contextListener),this.contextListener=null),this.setMap(null)},t.prototype.extend=function(t,i){return function(t){for(var i in t.prototype)Object.prototype.hasOwnProperty.call(this,i)||(this.prototype[i]=t.prototype[i]);return this}.apply(t,[i])},t}();export{t as InfoBox}; | ||
var t=function(i,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])},t(i,e)};var i=function(i){function e(t){void 0===t&&(t={});var o=i.call(this)||this;return o.extend(e,google.maps.OverlayView),o.content=t.content||"",o.disableAutoPan=t.disableAutoPan||!1,o.maxWidth=t.maxWidth||0,o.pixelOffset=t.pixelOffset||new google.maps.Size(0,0),o.position=t.position||new google.maps.LatLng(0,0),o.zIndex=t.zIndex||null,o.boxClass=t.boxClass||"infoBox",o.boxStyle=t.boxStyle||{},o.closeBoxMargin=t.closeBoxMargin||"2px",o.closeBoxURL=t.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",""===t.closeBoxURL&&(o.closeBoxURL=""),o.infoBoxClearance=t.infoBoxClearance||new google.maps.Size(1,1),void 0===t.visible&&(void 0===t.isHidden?t.visible=!0:t.visible=!t.isHidden),o.isHidden=!t.visible,o.alignBottom=t.alignBottom||!1,o.pane=t.pane||"floatPane",o.enableEventPropagation=t.enableEventPropagation||!1,o.div=null,o.closeListener=null,o.moveListener=null,o.mapListener=null,o.contextListener=null,o.eventListeners=null,o.fixedWidthSet=null,o}return function(i,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=i}t(i,e),i.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}(e,i),e.prototype.createInfoBoxDiv=function(){var t=this;function i(t){t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}if(!this.div){this.div=document.createElement("div"),this.setBoxStyle(),"string"==typeof this.content?this.div.innerHTML=this.getCloseBoxImg()+this.content:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(this.content));var e=this.getPanes();if(null!==e&&e[this.pane].appendChild(this.div),this.addClickHandler(),this.div.style.width)this.fixedWidthSet=!0;else if(0!==this.maxWidth&&this.div.offsetWidth>this.maxWidth)this.div.style.width=this.maxWidth+"px",this.fixedWidthSet=!0;else{var o=this.getBoxWidths();this.div.style.width=this.div.offsetWidth-o.left-o.right+"px",this.fixedWidthSet=!1}if(this.panBox(this.disableAutoPan),!this.enableEventPropagation){this.eventListeners=[];for(var s=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove"],n=0;n<s.length;n++)this.eventListeners.push(google.maps.event.addListener(this.div,s[n],i));this.eventListeners.push(google.maps.event.addListener(this.div,"mouseover",(function(){t.div&&(t.div.style.cursor="default")})))}this.contextListener=google.maps.event.addListener(this.div,"contextmenu",(function(e){e.returnValue=!1,e.preventDefault&&e.preventDefault(),t.enableEventPropagation||i(e)})),google.maps.event.trigger(this,"domready")}},e.prototype.getCloseBoxImg=function(){var t="";return""!==this.closeBoxURL&&(t='<img alt=""',t+=' aria-hidden="true"',t+=" src='"+this.closeBoxURL+"'",t+=" align=right",t+=" style='",t+=" position: relative;",t+=" cursor: pointer;",t+=" margin: "+this.closeBoxMargin+";",t+="'>"),t},e.prototype.addClickHandler=function(){if(this.div&&this.div.firstChild&&""!==this.closeBoxURL){var t=this.div.firstChild;this.closeListener=google.maps.event.addListener(t,"click",this.getCloseClickHandler())}else this.closeListener=null},e.prototype.getCloseClickHandler=function(){var t=this;return function(i){i.cancelBubble=!0,i.stopPropagation&&i.stopPropagation(),google.maps.event.trigger(t,"closeclick"),t.close()}},e.prototype.panBox=function(t){if(this.div&&!t){var i=this.getMap();if(i instanceof google.maps.Map){var e=0,o=0,s=i.getBounds();s&&!s.contains(this.position)&&i.setCenter(this.position);var n=i.getDiv(),l=n.offsetWidth,r=n.offsetHeight,h=this.pixelOffset.width,d=this.pixelOffset.height,a=this.div.offsetWidth,p=this.div.offsetHeight,v=this.infoBoxClearance.width,c=this.infoBoxClearance.height,g=this.getProjection().fromLatLngToContainerPixel(this.position);null!==g&&(g.x<-h+v?e=g.x+h-v:g.x+a+h+v>l&&(e=g.x+a+h+v-l),this.alignBottom?g.y<-d+c+p?o=g.y+d-c-p:g.y+d+c>r&&(o=g.y+d+c-r):g.y<-d+c?o=g.y+d-c:g.y+p+d+c>r&&(o=g.y+p+d+c-r)),0===e&&0===o||i.panBy(e,o)}}},e.prototype.setBoxStyle=function(){if(this.div){this.div.className=this.boxClass,this.div.style.cssText="";var t=this.boxStyle;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(this.div.style[i]=t[i]);if(this.div.style.webkitTransform="translateZ(0)",void 0!==this.div.style.opacity&&""!==this.div.style.opacity){var e=parseFloat(this.div.style.opacity||"");this.div.style.msFilter='"progid:DXImageTransform.Microsoft.Alpha(Opacity='+100*e+')"',this.div.style.filter="alpha(opacity="+100*e+")"}this.div.style.position="absolute",this.div.style.visibility="hidden",null!==this.zIndex&&(this.div.style.zIndex=this.zIndex+""),this.div.style.overflow||(this.div.style.overflow="auto")}},e.prototype.getBoxWidths=function(){var t={top:0,bottom:0,left:0,right:0};if(!this.div)return t;if(document.defaultView){var i=this.div.ownerDocument,e=i&&i.defaultView?i.defaultView.getComputedStyle(this.div,""):null;e&&(t.top=parseInt(e.borderTopWidth||"",10)||0,t.bottom=parseInt(e.borderBottomWidth||"",10)||0,t.left=parseInt(e.borderLeftWidth||"",10)||0,t.right=parseInt(e.borderRightWidth||"",10)||0)}else if(document.documentElement.currentStyle){var o=this.div.currentStyle;o&&(t.top=parseInt(o.borderTopWidth||"",10)||0,t.bottom=parseInt(o.borderBottomWidth||"",10)||0,t.left=parseInt(o.borderLeftWidth||"",10)||0,t.right=parseInt(o.borderRightWidth||"",10)||0)}return t},e.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.div.parentNode.removeChild(this.div),this.div=null)},e.prototype.draw=function(){if(this.createInfoBoxDiv(),this.div){var t=this.getProjection().fromLatLngToDivPixel(this.position);null!==t&&(this.div.style.left=t.x+this.pixelOffset.width+"px",this.alignBottom?this.div.style.bottom=-(t.y+this.pixelOffset.height)+"px":this.div.style.top=t.y+this.pixelOffset.height+"px"),this.isHidden?this.div.style.visibility="hidden":this.div.style.visibility="visible"}},e.prototype.setOptions=function(t){void 0===t&&(t={}),void 0!==t.boxClass&&(this.boxClass=t.boxClass,this.setBoxStyle()),void 0!==t.boxStyle&&(this.boxStyle=t.boxStyle,this.setBoxStyle()),void 0!==t.content&&this.setContent(t.content),void 0!==t.disableAutoPan&&(this.disableAutoPan=t.disableAutoPan),void 0!==t.maxWidth&&(this.maxWidth=t.maxWidth),void 0!==t.pixelOffset&&(this.pixelOffset=t.pixelOffset),void 0!==t.alignBottom&&(this.alignBottom=t.alignBottom),void 0!==t.position&&this.setPosition(t.position),void 0!==t.zIndex&&this.setZIndex(t.zIndex),void 0!==t.closeBoxMargin&&(this.closeBoxMargin=t.closeBoxMargin),void 0!==t.closeBoxURL&&(this.closeBoxURL=t.closeBoxURL),void 0!==t.infoBoxClearance&&(this.infoBoxClearance=t.infoBoxClearance),void 0!==t.isHidden&&(this.isHidden=t.isHidden),void 0!==t.visible&&(this.isHidden=!t.visible),void 0!==t.enableEventPropagation&&(this.enableEventPropagation=t.enableEventPropagation),this.div&&this.draw()},e.prototype.setContent=function(t){this.content=t,this.div&&(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.fixedWidthSet||(this.div.style.width=""),"string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t)),this.fixedWidthSet||(this.div.style.width=this.div.offsetWidth+"px","string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t))),this.addClickHandler()),google.maps.event.trigger(this,"content_changed")},e.prototype.setPosition=function(t){this.position=t,this.div&&this.draw(),google.maps.event.trigger(this,"position_changed")},e.prototype.setVisible=function(t){this.isHidden=!t,this.div&&(this.div.style.visibility=this.isHidden?"hidden":"visible")},e.prototype.setZIndex=function(t){this.zIndex=t,this.div&&(this.div.style.zIndex=t+""),google.maps.event.trigger(this,"zindex_changed")},e.prototype.getContent=function(){return this.content},e.prototype.getPosition=function(){return this.position},e.prototype.getZIndex=function(){return this.zIndex},e.prototype.getVisible=function(){var t=this.getMap();return null!=t&&!this.isHidden},e.prototype.show=function(){this.isHidden=!1,this.div&&(this.div.style.visibility="visible")},e.prototype.hide=function(){this.isHidden=!0,this.div&&(this.div.style.visibility="hidden")},e.prototype.open=function(t,i){var e=this;i&&(this.position=i.getPosition(),this.moveListener=google.maps.event.addListener(i,"position_changed",(function(){var t=i.getPosition();e.setPosition(t)})),this.mapListener=google.maps.event.addListener(i,"map_changed",(function(){e.setMap(i.map)}))),this.setMap(t),this.div&&this.panBox()},e.prototype.close=function(){if(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.eventListeners){for(var t=0;t<this.eventListeners.length;t++)google.maps.event.removeListener(this.eventListeners[t]);this.eventListeners=null}this.moveListener&&(google.maps.event.removeListener(this.moveListener),this.moveListener=null),this.mapListener&&(google.maps.event.removeListener(this.mapListener),this.mapListener=null),this.contextListener&&(google.maps.event.removeListener(this.contextListener),this.contextListener=null),this.setMap(null)},e.prototype.extend=function(t,i){return function(t){for(var i in t.prototype)Object.prototype.hasOwnProperty.call(this,i)||this.prototype.set(i,t.prototype.get(i));return this}.apply(t,[i])},e}(google.maps.OverlayView);export{i as InfoBox}; | ||
//# sourceMappingURL=esm.min.js.map |
interface InfoBoxOptions { | ||
alignBottom?: boolean; | ||
boxClass?: string; | ||
alignBottom?: boolean | undefined; | ||
boxClass?: string | undefined; | ||
boxStyle?: { | ||
[key: string]: any; | ||
}; | ||
closeBoxMargin?: string; | ||
closeBoxURL?: string; | ||
content?: string | Node; | ||
disableAutoPan?: boolean; | ||
enableEventPropagation?: boolean; | ||
infoBoxClearance?: google.maps.Size; | ||
isHidden?: boolean; | ||
maxWidth?: number; | ||
pixelOffset?: google.maps.Size; | ||
position?: google.maps.LatLng; | ||
pane?: string; | ||
visible?: boolean; | ||
zIndex?: number; | ||
} | undefined; | ||
closeBoxMargin?: string | undefined; | ||
closeBoxURL?: string | undefined; | ||
content?: string | Node | undefined; | ||
disableAutoPan?: boolean | undefined; | ||
enableEventPropagation?: boolean | undefined; | ||
infoBoxClearance?: google.maps.Size | undefined; | ||
isHidden?: boolean | undefined; | ||
maxWidth?: number | undefined; | ||
pixelOffset?: google.maps.Size | undefined; | ||
position?: google.maps.LatLng | undefined; | ||
pane?: keyof google.maps.MapPanes | undefined; | ||
visible?: boolean | undefined; | ||
zIndex?: number | undefined; | ||
} | ||
declare class InfoBox { | ||
declare class InfoBox extends google.maps.OverlayView { | ||
content: string | Node; | ||
@@ -38,3 +38,3 @@ disableAutoPan: boolean; | ||
alignBottom: boolean; | ||
pane: string; | ||
pane: keyof google.maps.MapPanes; | ||
enableEventPropagation: boolean; | ||
@@ -53,3 +53,3 @@ div: HTMLDivElement | null; | ||
getCloseClickHandler(): (event: Event) => void; | ||
panBox(disablePan?: boolean): void; | ||
panBox(disablePan?: boolean | undefined): void; | ||
setBoxStyle(): void; | ||
@@ -77,5 +77,5 @@ getBoxWidths(): { | ||
close(): void; | ||
extend(obj1: any, obj2: any): any; | ||
extend<A extends typeof InfoBox>(obj1: A, obj2: typeof google.maps.OverlayView): A; | ||
} | ||
export { InfoBox, InfoBoxOptions }; |
101
dist/umd.js
@@ -7,22 +7,55 @@ (function (global, factory) { | ||
var InfoBox = /** @class */ (function () { | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
var InfoBox = /** @class */ (function (_super) { | ||
__extends(InfoBox, _super); | ||
function InfoBox(options) { | ||
if (options === void 0) { options = {}; } | ||
this.extend(InfoBox, google.maps.OverlayView); | ||
var _this = _super.call(this) || this; | ||
_this.extend(InfoBox, google.maps.OverlayView); | ||
// Standard options (in common with google.maps.InfoWindow): | ||
this.content = options.content || ''; | ||
this.disableAutoPan = options.disableAutoPan || false; | ||
this.maxWidth = options.maxWidth || 0; | ||
this.pixelOffset = options.pixelOffset || new google.maps.Size(0, 0); | ||
this.position = options.position || new google.maps.LatLng(0, 0); | ||
this.zIndex = options.zIndex || null; | ||
_this.content = options.content || ''; | ||
_this.disableAutoPan = options.disableAutoPan || false; | ||
_this.maxWidth = options.maxWidth || 0; | ||
_this.pixelOffset = options.pixelOffset || new google.maps.Size(0, 0); | ||
_this.position = options.position || new google.maps.LatLng(0, 0); | ||
_this.zIndex = options.zIndex || null; | ||
// Additional options (unique to InfoBox): | ||
this.boxClass = options.boxClass || 'infoBox'; | ||
this.boxStyle = options.boxStyle || {}; | ||
this.closeBoxMargin = options.closeBoxMargin || '2px'; | ||
this.closeBoxURL = options.closeBoxURL || 'http://www.google.com/intl/en_us/mapfiles/close.gif'; | ||
_this.boxClass = options.boxClass || 'infoBox'; | ||
_this.boxStyle = options.boxStyle || {}; | ||
_this.closeBoxMargin = options.closeBoxMargin || '2px'; | ||
_this.closeBoxURL = options.closeBoxURL || 'http://www.google.com/intl/en_us/mapfiles/close.gif'; | ||
if (options.closeBoxURL === '') { | ||
this.closeBoxURL = ''; | ||
_this.closeBoxURL = ''; | ||
} | ||
this.infoBoxClearance = options.infoBoxClearance || new google.maps.Size(1, 1); | ||
_this.infoBoxClearance = options.infoBoxClearance || new google.maps.Size(1, 1); | ||
if (typeof options.visible === 'undefined') { | ||
@@ -36,13 +69,14 @@ if (typeof options.isHidden === 'undefined') { | ||
} | ||
this.isHidden = !options.visible; | ||
this.alignBottom = options.alignBottom || false; | ||
this.pane = options.pane || 'floatPane'; | ||
this.enableEventPropagation = options.enableEventPropagation || false; | ||
this.div = null; | ||
this.closeListener = null; | ||
this.moveListener = null; | ||
this.mapListener = null; | ||
this.contextListener = null; | ||
this.eventListeners = null; | ||
this.fixedWidthSet = null; | ||
_this.isHidden = !options.visible; | ||
_this.alignBottom = options.alignBottom || false; | ||
_this.pane = options.pane || 'floatPane'; | ||
_this.enableEventPropagation = options.enableEventPropagation || false; | ||
_this.div = null; | ||
_this.closeListener = null; | ||
_this.moveListener = null; | ||
_this.mapListener = null; | ||
_this.contextListener = null; | ||
_this.eventListeners = null; | ||
_this.fixedWidthSet = null; | ||
return _this; | ||
} | ||
@@ -79,6 +113,6 @@ InfoBox.prototype.createInfoBoxDiv = function () { | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
var panes = this.getPanes(); | ||
panes[this.pane].appendChild(this.div); // Add the InfoBox div to the DOM | ||
if (panes !== null) { | ||
panes[this.pane].appendChild(this.div); // Add the InfoBox div to the DOM | ||
} | ||
this.addClickHandler(); | ||
@@ -557,14 +591,7 @@ if (this.div.style.width) { | ||
return function applyExtend(object) { | ||
// eslint-disable-next-line guard-for-in | ||
for (var property in object.prototype) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
if (!Object.prototype.hasOwnProperty.call(this, property)) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.prototype[property] = object.prototype[property]; | ||
this.prototype.set(property, object.prototype.get(property)); | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return this; | ||
@@ -574,3 +601,3 @@ }.apply(obj1, [obj2]); | ||
return InfoBox; | ||
}()); | ||
}(google.maps.OverlayView)); | ||
@@ -577,0 +604,0 @@ exports.InfoBox = InfoBox; |
@@ -1,2 +0,2 @@ | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).infoBox={})}(this,(function(t){"use strict";var i=function(){function t(i){void 0===i&&(i={}),this.extend(t,google.maps.OverlayView),this.content=i.content||"",this.disableAutoPan=i.disableAutoPan||!1,this.maxWidth=i.maxWidth||0,this.pixelOffset=i.pixelOffset||new google.maps.Size(0,0),this.position=i.position||new google.maps.LatLng(0,0),this.zIndex=i.zIndex||null,this.boxClass=i.boxClass||"infoBox",this.boxStyle=i.boxStyle||{},this.closeBoxMargin=i.closeBoxMargin||"2px",this.closeBoxURL=i.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",""===i.closeBoxURL&&(this.closeBoxURL=""),this.infoBoxClearance=i.infoBoxClearance||new google.maps.Size(1,1),void 0===i.visible&&(void 0===i.isHidden?i.visible=!0:i.visible=!i.isHidden),this.isHidden=!i.visible,this.alignBottom=i.alignBottom||!1,this.pane=i.pane||"floatPane",this.enableEventPropagation=i.enableEventPropagation||!1,this.div=null,this.closeListener=null,this.moveListener=null,this.mapListener=null,this.contextListener=null,this.eventListeners=null,this.fixedWidthSet=null}return t.prototype.createInfoBoxDiv=function(){var t=this;function i(t){t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}if(!this.div){if(this.div=document.createElement("div"),this.setBoxStyle(),"string"==typeof this.content?this.div.innerHTML=this.getCloseBoxImg()+this.content:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(this.content)),this.getPanes()[this.pane].appendChild(this.div),this.addClickHandler(),this.div.style.width)this.fixedWidthSet=!0;else if(0!==this.maxWidth&&this.div.offsetWidth>this.maxWidth)this.div.style.width=this.maxWidth+"px",this.fixedWidthSet=!0;else{var e=this.getBoxWidths();this.div.style.width=this.div.offsetWidth-e.left-e.right+"px",this.fixedWidthSet=!1}if(this.panBox(this.disableAutoPan),!this.enableEventPropagation){this.eventListeners=[];for(var s=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove"],o=0;o<s.length;o++)this.eventListeners.push(google.maps.event.addListener(this.div,s[o],i));this.eventListeners.push(google.maps.event.addListener(this.div,"mouseover",(function(){t.div&&(t.div.style.cursor="default")})))}this.contextListener=google.maps.event.addListener(this.div,"contextmenu",(function(e){e.returnValue=!1,e.preventDefault&&e.preventDefault(),t.enableEventPropagation||i(e)})),google.maps.event.trigger(this,"domready")}},t.prototype.getCloseBoxImg=function(){var t="";return""!==this.closeBoxURL&&(t='<img alt=""',t+=' aria-hidden="true"',t+=" src='"+this.closeBoxURL+"'",t+=" align=right",t+=" style='",t+=" position: relative;",t+=" cursor: pointer;",t+=" margin: "+this.closeBoxMargin+";",t+="'>"),t},t.prototype.addClickHandler=function(){if(this.div&&this.div.firstChild&&""!==this.closeBoxURL){var t=this.div.firstChild;this.closeListener=google.maps.event.addListener(t,"click",this.getCloseClickHandler())}else this.closeListener=null},t.prototype.getCloseClickHandler=function(){var t=this;return function(i){i.cancelBubble=!0,i.stopPropagation&&i.stopPropagation(),google.maps.event.trigger(t,"closeclick"),t.close()}},t.prototype.panBox=function(t){if(this.div&&!t){var i=this.getMap();if(i instanceof google.maps.Map){var e=0,s=0,o=i.getBounds();o&&!o.contains(this.position)&&i.setCenter(this.position);var n=i.getDiv(),h=n.offsetWidth,l=n.offsetHeight,d=this.pixelOffset.width,r=this.pixelOffset.height,a=this.div.offsetWidth,p=this.div.offsetHeight,v=this.infoBoxClearance.width,f=this.infoBoxClearance.height,g=this.getProjection().fromLatLngToContainerPixel(this.position);null!==g&&(g.x<-d+v?e=g.x+d-v:g.x+a+d+v>h&&(e=g.x+a+d+v-h),this.alignBottom?g.y<-r+f+p?s=g.y+r-f-p:g.y+r+f>l&&(s=g.y+r+f-l):g.y<-r+f?s=g.y+r-f:g.y+p+r+f>l&&(s=g.y+p+r+f-l)),0===e&&0===s||i.panBy(e,s)}}},t.prototype.setBoxStyle=function(){if(this.div){this.div.className=this.boxClass,this.div.style.cssText="";var t=this.boxStyle;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(this.div.style[i]=t[i]);if(this.div.style.webkitTransform="translateZ(0)",void 0!==this.div.style.opacity&&""!==this.div.style.opacity){var e=parseFloat(this.div.style.opacity||"");this.div.style.msFilter='"progid:DXImageTransform.Microsoft.Alpha(Opacity='+100*e+')"',this.div.style.filter="alpha(opacity="+100*e+")"}this.div.style.position="absolute",this.div.style.visibility="hidden",null!==this.zIndex&&(this.div.style.zIndex=this.zIndex+""),this.div.style.overflow||(this.div.style.overflow="auto")}},t.prototype.getBoxWidths=function(){var t={top:0,bottom:0,left:0,right:0};if(!this.div)return t;if(document.defaultView){var i=this.div.ownerDocument,e=i&&i.defaultView?i.defaultView.getComputedStyle(this.div,""):null;e&&(t.top=parseInt(e.borderTopWidth||"",10)||0,t.bottom=parseInt(e.borderBottomWidth||"",10)||0,t.left=parseInt(e.borderLeftWidth||"",10)||0,t.right=parseInt(e.borderRightWidth||"",10)||0)}else if(document.documentElement.currentStyle){var s=this.div.currentStyle;s&&(t.top=parseInt(s.borderTopWidth||"",10)||0,t.bottom=parseInt(s.borderBottomWidth||"",10)||0,t.left=parseInt(s.borderLeftWidth||"",10)||0,t.right=parseInt(s.borderRightWidth||"",10)||0)}return t},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.div.parentNode.removeChild(this.div),this.div=null)},t.prototype.draw=function(){if(this.createInfoBoxDiv(),this.div){var t=this.getProjection().fromLatLngToDivPixel(this.position);null!==t&&(this.div.style.left=t.x+this.pixelOffset.width+"px",this.alignBottom?this.div.style.bottom=-(t.y+this.pixelOffset.height)+"px":this.div.style.top=t.y+this.pixelOffset.height+"px"),this.isHidden?this.div.style.visibility="hidden":this.div.style.visibility="visible"}},t.prototype.setOptions=function(t){void 0===t&&(t={}),void 0!==t.boxClass&&(this.boxClass=t.boxClass,this.setBoxStyle()),void 0!==t.boxStyle&&(this.boxStyle=t.boxStyle,this.setBoxStyle()),void 0!==t.content&&this.setContent(t.content),void 0!==t.disableAutoPan&&(this.disableAutoPan=t.disableAutoPan),void 0!==t.maxWidth&&(this.maxWidth=t.maxWidth),void 0!==t.pixelOffset&&(this.pixelOffset=t.pixelOffset),void 0!==t.alignBottom&&(this.alignBottom=t.alignBottom),void 0!==t.position&&this.setPosition(t.position),void 0!==t.zIndex&&this.setZIndex(t.zIndex),void 0!==t.closeBoxMargin&&(this.closeBoxMargin=t.closeBoxMargin),void 0!==t.closeBoxURL&&(this.closeBoxURL=t.closeBoxURL),void 0!==t.infoBoxClearance&&(this.infoBoxClearance=t.infoBoxClearance),void 0!==t.isHidden&&(this.isHidden=t.isHidden),void 0!==t.visible&&(this.isHidden=!t.visible),void 0!==t.enableEventPropagation&&(this.enableEventPropagation=t.enableEventPropagation),this.div&&this.draw()},t.prototype.setContent=function(t){this.content=t,this.div&&(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.fixedWidthSet||(this.div.style.width=""),"string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t)),this.fixedWidthSet||(this.div.style.width=this.div.offsetWidth+"px","string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t))),this.addClickHandler()),google.maps.event.trigger(this,"content_changed")},t.prototype.setPosition=function(t){this.position=t,this.div&&this.draw(),google.maps.event.trigger(this,"position_changed")},t.prototype.setVisible=function(t){this.isHidden=!t,this.div&&(this.div.style.visibility=this.isHidden?"hidden":"visible")},t.prototype.setZIndex=function(t){this.zIndex=t,this.div&&(this.div.style.zIndex=t+""),google.maps.event.trigger(this,"zindex_changed")},t.prototype.getContent=function(){return this.content},t.prototype.getPosition=function(){return this.position},t.prototype.getZIndex=function(){return this.zIndex},t.prototype.getVisible=function(){var t=this.getMap();return null!=t&&!this.isHidden},t.prototype.show=function(){this.isHidden=!1,this.div&&(this.div.style.visibility="visible")},t.prototype.hide=function(){this.isHidden=!0,this.div&&(this.div.style.visibility="hidden")},t.prototype.open=function(t,i){var e=this;i&&(this.position=i.getPosition(),this.moveListener=google.maps.event.addListener(i,"position_changed",(function(){var t=i.getPosition();e.setPosition(t)})),this.mapListener=google.maps.event.addListener(i,"map_changed",(function(){e.setMap(i.map)}))),this.setMap(t),this.div&&this.panBox()},t.prototype.close=function(){if(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.eventListeners){for(var t=0;t<this.eventListeners.length;t++)google.maps.event.removeListener(this.eventListeners[t]);this.eventListeners=null}this.moveListener&&(google.maps.event.removeListener(this.moveListener),this.moveListener=null),this.mapListener&&(google.maps.event.removeListener(this.mapListener),this.mapListener=null),this.contextListener&&(google.maps.event.removeListener(this.contextListener),this.contextListener=null),this.setMap(null)},t.prototype.extend=function(t,i){return function(t){for(var i in t.prototype)Object.prototype.hasOwnProperty.call(this,i)||(this.prototype[i]=t.prototype[i]);return this}.apply(t,[i])},t}();t.InfoBox=i,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).infoBox={})}(this,(function(t){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},e(t,i)};var i=function(t){function i(e){void 0===e&&(e={});var o=t.call(this)||this;return o.extend(i,google.maps.OverlayView),o.content=e.content||"",o.disableAutoPan=e.disableAutoPan||!1,o.maxWidth=e.maxWidth||0,o.pixelOffset=e.pixelOffset||new google.maps.Size(0,0),o.position=e.position||new google.maps.LatLng(0,0),o.zIndex=e.zIndex||null,o.boxClass=e.boxClass||"infoBox",o.boxStyle=e.boxStyle||{},o.closeBoxMargin=e.closeBoxMargin||"2px",o.closeBoxURL=e.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",""===e.closeBoxURL&&(o.closeBoxURL=""),o.infoBoxClearance=e.infoBoxClearance||new google.maps.Size(1,1),void 0===e.visible&&(void 0===e.isHidden?e.visible=!0:e.visible=!e.isHidden),o.isHidden=!e.visible,o.alignBottom=e.alignBottom||!1,o.pane=e.pane||"floatPane",o.enableEventPropagation=e.enableEventPropagation||!1,o.div=null,o.closeListener=null,o.moveListener=null,o.mapListener=null,o.contextListener=null,o.eventListeners=null,o.fixedWidthSet=null,o}return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}(i,t),i.prototype.createInfoBoxDiv=function(){var t=this;function e(t){t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}if(!this.div){this.div=document.createElement("div"),this.setBoxStyle(),"string"==typeof this.content?this.div.innerHTML=this.getCloseBoxImg()+this.content:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(this.content));var i=this.getPanes();if(null!==i&&i[this.pane].appendChild(this.div),this.addClickHandler(),this.div.style.width)this.fixedWidthSet=!0;else if(0!==this.maxWidth&&this.div.offsetWidth>this.maxWidth)this.div.style.width=this.maxWidth+"px",this.fixedWidthSet=!0;else{var o=this.getBoxWidths();this.div.style.width=this.div.offsetWidth-o.left-o.right+"px",this.fixedWidthSet=!1}if(this.panBox(this.disableAutoPan),!this.enableEventPropagation){this.eventListeners=[];for(var s=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove"],n=0;n<s.length;n++)this.eventListeners.push(google.maps.event.addListener(this.div,s[n],e));this.eventListeners.push(google.maps.event.addListener(this.div,"mouseover",(function(){t.div&&(t.div.style.cursor="default")})))}this.contextListener=google.maps.event.addListener(this.div,"contextmenu",(function(i){i.returnValue=!1,i.preventDefault&&i.preventDefault(),t.enableEventPropagation||e(i)})),google.maps.event.trigger(this,"domready")}},i.prototype.getCloseBoxImg=function(){var t="";return""!==this.closeBoxURL&&(t='<img alt=""',t+=' aria-hidden="true"',t+=" src='"+this.closeBoxURL+"'",t+=" align=right",t+=" style='",t+=" position: relative;",t+=" cursor: pointer;",t+=" margin: "+this.closeBoxMargin+";",t+="'>"),t},i.prototype.addClickHandler=function(){if(this.div&&this.div.firstChild&&""!==this.closeBoxURL){var t=this.div.firstChild;this.closeListener=google.maps.event.addListener(t,"click",this.getCloseClickHandler())}else this.closeListener=null},i.prototype.getCloseClickHandler=function(){var t=this;return function(e){e.cancelBubble=!0,e.stopPropagation&&e.stopPropagation(),google.maps.event.trigger(t,"closeclick"),t.close()}},i.prototype.panBox=function(t){if(this.div&&!t){var e=this.getMap();if(e instanceof google.maps.Map){var i=0,o=0,s=e.getBounds();s&&!s.contains(this.position)&&e.setCenter(this.position);var n=e.getDiv(),l=n.offsetWidth,r=n.offsetHeight,h=this.pixelOffset.width,d=this.pixelOffset.height,a=this.div.offsetWidth,p=this.div.offsetHeight,v=this.infoBoxClearance.width,c=this.infoBoxClearance.height,f=this.getProjection().fromLatLngToContainerPixel(this.position);null!==f&&(f.x<-h+v?i=f.x+h-v:f.x+a+h+v>l&&(i=f.x+a+h+v-l),this.alignBottom?f.y<-d+c+p?o=f.y+d-c-p:f.y+d+c>r&&(o=f.y+d+c-r):f.y<-d+c?o=f.y+d-c:f.y+p+d+c>r&&(o=f.y+p+d+c-r)),0===i&&0===o||e.panBy(i,o)}}},i.prototype.setBoxStyle=function(){if(this.div){this.div.className=this.boxClass,this.div.style.cssText="";var t=this.boxStyle;for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.div.style[e]=t[e]);if(this.div.style.webkitTransform="translateZ(0)",void 0!==this.div.style.opacity&&""!==this.div.style.opacity){var i=parseFloat(this.div.style.opacity||"");this.div.style.msFilter='"progid:DXImageTransform.Microsoft.Alpha(Opacity='+100*i+')"',this.div.style.filter="alpha(opacity="+100*i+")"}this.div.style.position="absolute",this.div.style.visibility="hidden",null!==this.zIndex&&(this.div.style.zIndex=this.zIndex+""),this.div.style.overflow||(this.div.style.overflow="auto")}},i.prototype.getBoxWidths=function(){var t={top:0,bottom:0,left:0,right:0};if(!this.div)return t;if(document.defaultView){var e=this.div.ownerDocument,i=e&&e.defaultView?e.defaultView.getComputedStyle(this.div,""):null;i&&(t.top=parseInt(i.borderTopWidth||"",10)||0,t.bottom=parseInt(i.borderBottomWidth||"",10)||0,t.left=parseInt(i.borderLeftWidth||"",10)||0,t.right=parseInt(i.borderRightWidth||"",10)||0)}else if(document.documentElement.currentStyle){var o=this.div.currentStyle;o&&(t.top=parseInt(o.borderTopWidth||"",10)||0,t.bottom=parseInt(o.borderBottomWidth||"",10)||0,t.left=parseInt(o.borderLeftWidth||"",10)||0,t.right=parseInt(o.borderRightWidth||"",10)||0)}return t},i.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.div.parentNode.removeChild(this.div),this.div=null)},i.prototype.draw=function(){if(this.createInfoBoxDiv(),this.div){var t=this.getProjection().fromLatLngToDivPixel(this.position);null!==t&&(this.div.style.left=t.x+this.pixelOffset.width+"px",this.alignBottom?this.div.style.bottom=-(t.y+this.pixelOffset.height)+"px":this.div.style.top=t.y+this.pixelOffset.height+"px"),this.isHidden?this.div.style.visibility="hidden":this.div.style.visibility="visible"}},i.prototype.setOptions=function(t){void 0===t&&(t={}),void 0!==t.boxClass&&(this.boxClass=t.boxClass,this.setBoxStyle()),void 0!==t.boxStyle&&(this.boxStyle=t.boxStyle,this.setBoxStyle()),void 0!==t.content&&this.setContent(t.content),void 0!==t.disableAutoPan&&(this.disableAutoPan=t.disableAutoPan),void 0!==t.maxWidth&&(this.maxWidth=t.maxWidth),void 0!==t.pixelOffset&&(this.pixelOffset=t.pixelOffset),void 0!==t.alignBottom&&(this.alignBottom=t.alignBottom),void 0!==t.position&&this.setPosition(t.position),void 0!==t.zIndex&&this.setZIndex(t.zIndex),void 0!==t.closeBoxMargin&&(this.closeBoxMargin=t.closeBoxMargin),void 0!==t.closeBoxURL&&(this.closeBoxURL=t.closeBoxURL),void 0!==t.infoBoxClearance&&(this.infoBoxClearance=t.infoBoxClearance),void 0!==t.isHidden&&(this.isHidden=t.isHidden),void 0!==t.visible&&(this.isHidden=!t.visible),void 0!==t.enableEventPropagation&&(this.enableEventPropagation=t.enableEventPropagation),this.div&&this.draw()},i.prototype.setContent=function(t){this.content=t,this.div&&(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.fixedWidthSet||(this.div.style.width=""),"string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t)),this.fixedWidthSet||(this.div.style.width=this.div.offsetWidth+"px","string"==typeof t?this.div.innerHTML=this.getCloseBoxImg()+t:(this.div.innerHTML=this.getCloseBoxImg(),this.div.appendChild(t))),this.addClickHandler()),google.maps.event.trigger(this,"content_changed")},i.prototype.setPosition=function(t){this.position=t,this.div&&this.draw(),google.maps.event.trigger(this,"position_changed")},i.prototype.setVisible=function(t){this.isHidden=!t,this.div&&(this.div.style.visibility=this.isHidden?"hidden":"visible")},i.prototype.setZIndex=function(t){this.zIndex=t,this.div&&(this.div.style.zIndex=t+""),google.maps.event.trigger(this,"zindex_changed")},i.prototype.getContent=function(){return this.content},i.prototype.getPosition=function(){return this.position},i.prototype.getZIndex=function(){return this.zIndex},i.prototype.getVisible=function(){var t=this.getMap();return null!=t&&!this.isHidden},i.prototype.show=function(){this.isHidden=!1,this.div&&(this.div.style.visibility="visible")},i.prototype.hide=function(){this.isHidden=!0,this.div&&(this.div.style.visibility="hidden")},i.prototype.open=function(t,e){var i=this;e&&(this.position=e.getPosition(),this.moveListener=google.maps.event.addListener(e,"position_changed",(function(){var t=e.getPosition();i.setPosition(t)})),this.mapListener=google.maps.event.addListener(e,"map_changed",(function(){i.setMap(e.map)}))),this.setMap(t),this.div&&this.panBox()},i.prototype.close=function(){if(this.closeListener&&(google.maps.event.removeListener(this.closeListener),this.closeListener=null),this.eventListeners){for(var t=0;t<this.eventListeners.length;t++)google.maps.event.removeListener(this.eventListeners[t]);this.eventListeners=null}this.moveListener&&(google.maps.event.removeListener(this.moveListener),this.moveListener=null),this.mapListener&&(google.maps.event.removeListener(this.mapListener),this.mapListener=null),this.contextListener&&(google.maps.event.removeListener(this.contextListener),this.contextListener=null),this.setMap(null)},i.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)Object.prototype.hasOwnProperty.call(this,e)||this.prototype.set(e,t.prototype.get(e));return this}.apply(t,[e])},i}(google.maps.OverlayView);t.InfoBox=i,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=umd.min.js.map |
{ | ||
"name": "@react-google-maps/infobox", | ||
"sideEffects": false, | ||
"version": "2.10.1", | ||
"version": "2.11.1", | ||
"description": "InfoBox for React.js Google Maps API", | ||
@@ -59,3 +59,3 @@ "license": "MIT", | ||
"rimraf": "3.0.2", | ||
"rollup": "2.73.0", | ||
"rollup": "2.74.1", | ||
"rollup-plugin-dts": "4.2.1", | ||
@@ -62,0 +62,0 @@ "rollup-plugin-terser": "7.0.2" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
437262
2608