{"version":3,"file":"overlay-popup-c560448893.js","sources":["overlay-popup-c560448893.js"],"sourcesContent":["const createPopup = function() {\r\n\r\n\tfunction Popup(position, template, type) {\r\n\t\tthis.popupType = type;\r\n\t\tthis.position = new window.google.maps.LatLng(position.lat, position.lng);\r\n\t\tthis.containerDiv = document.createElement('div');\r\n\t\tthis.containerDiv.className = \"c-search-map__fullscreen-wrapper\";\r\n\t\tthis.containerDiv.innerHTML = template;\r\n\t\tconst close = this.containerDiv.querySelector('.js-overlay-close');\r\n\r\n\t\tif (close) {\r\n\t\t\t$(close).click(function() {\r\n\t\t\t\twindow.site.body.trigger({\r\n\t\t\t\t\ttype: 'closeMapOverlay'\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\twindow.google.maps.OverlayView.preventMapHitsAndGesturesFrom(this.containerDiv);\r\n\t}\r\n\r\n\tPopup.prototype = Object.create(window.google.maps.OverlayView.prototype);\r\n\r\n\tPopup.prototype.onAdd = function() {\r\n\t\tthis.getPanes().floatPane.appendChild(this.containerDiv);\r\n\t};\r\n\r\n\tPopup.prototype.onRemove = function() {\r\n\t\tif (this.containerDiv.parentElement) {\r\n\t\t\tthis.containerDiv.parentElement.removeChild(this.containerDiv);\r\n\t\t}\r\n\t};\r\n\r\n\tPopup.prototype.draw = function() {\r\n\t\tconst divPosition = this.getProjection().fromLatLngToDivPixel(this.position);\r\n\r\n\t\t// Hide the popup when it is far out of view.\r\n\t\tconst display = Math.abs(divPosition.x) < 4000 && Math.abs(divPosition.y) < 4000 ? 'block' : 'none';\r\n\r\n\t\tif (display === 'block') {\r\n\t\t\tthis.containerDiv.style.left = divPosition.x + 'px';\r\n\t\t\tthis.containerDiv.style.top = divPosition.y + 'px';\r\n\t\t}\r\n\t\tif (this.containerDiv.style.display !== display) {\r\n\t\t\tthis.containerDiv.style.display = display;\r\n\t\t}\r\n\t};\r\n\r\n\tPopup.prototype.panToOverlayCenter = function(markerLatLng, map) {\r\n\t\tmarkerLatLng = new window.google.maps.LatLng(markerLatLng.lat, markerLatLng.lng);\r\n\t\tconst overlayInfo = this.containerDiv.getBoundingClientRect();\r\n\r\n\t\tconst width = (overlayInfo.width - (overlayInfo.width / 10)) / 2;\r\n\t\tconst height = (overlayInfo.height / 2) - 12;\r\n\r\n\t\tconst location = offset(markerLatLng, -width, height);\r\n\r\n\t\tmap.panTo(location);\r\n\r\n\t\tfunction offset(markerPosition, offsetx, offsety) {\r\n\r\n\t\t\tconst scale = Math.pow(2, map.zoom);\r\n\t\t\tconst worldCoordinateCenter = map.getProjection().fromLatLngToPoint(markerPosition);\r\n\t\t\tconst pixelOffset = new window.google.maps.Point((offsetx / scale) || 0, (offsety / scale) || 0);\r\n\t\t\tconst worldCoordinateNewCenter = new window.google.maps.Point(\r\n\t\t\t\tworldCoordinateCenter.x - pixelOffset.x,\r\n\t\t\t\tworldCoordinateCenter.y + pixelOffset.y\r\n\t\t\t);\r\n\r\n\t\t\treturn map.getProjection().fromPointToLatLng(worldCoordinateNewCenter);\r\n\t\t};\r\n\t};\r\n\r\n\treturn Popup;\r\n};\r\n\r\n\r\nexport default createPopup \r\n"],"names":["createPopup","Popup","position","template","type","this","popupType","window","google","maps","LatLng","lat","lng","containerDiv","document","createElement","className","innerHTML","close","querySelector","$","click","site","body","trigger","OverlayView","preventMapHitsAndGesturesFrom","prototype","Object","create","onAdd","getPanes","floatPane","appendChild","onRemove","parentElement","removeChild","draw","divPosition","getProjection","fromLatLngToDivPixel","display","Math","abs","x","y","style","left","top","panToOverlayCenter","markerLatLng","map","overlayInfo","getBoundingClientRect","width","height","location","markerPosition","offsetx","offsety","scale","pow","zoom","worldCoordinateCenter","fromLatLngToPoint","pixelOffset","Point","worldCoordinateNewCenter","fromPointToLatLng","panTo"],"mappings":"AAAA,MAAMA,YAAc,WAEnB,SAASC,EAAMC,EAAUC,EAAUC,GAClCC,KAAKC,UAAYF,EACjBC,KAAKH,SAAW,IAAIK,OAAOC,OAAOC,KAAKC,OAAOR,EAASS,IAA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