UNPKG

@react-google-maps/api

Version:
3 lines (2 loc) 40.7 kB
import{useContext as t,createContext as e,createElement as n,Fragment as o,PureComponent as s,createRef as r,useRef as i,useState as a,useEffect as p,memo as l,Children as c}from"react";import u from"invariant";import{Clusterer as d}from"@react-google-maps/marker-clusterer";import{createPortal as h}from"react-dom";function g(){return(g=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function f(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var m=e(null);function v(){t||u(!1);var e=t(m);return e||u(!1),e}var y=function(t,e,n){return Object.keys(t).reduce(function(n,o){return e(n,t[o],o)},n)},M=function(t,e,n,o){var s,r,i={};return s=t,r=function(t,s){var r=n[s];r!==e[s]&&(i[s]=r,t(o,r))},Object.keys(s).forEach(function(t){return r(s[t],t)}),i};function C(t){google.maps.event.removeListener(t)}function E(t){void 0===t&&(t=[]),t.map(C)}function k(t){var e=t.eventMap,n=t.nextProps,o=t.instance;return M(t.updaterMap,t.prevProps,n,o),function(t,e,n){return y(n,function(n,o,s){return"function"==typeof t[s]&&n.push(google.maps.event.addListener(e,o,t[s])),n},[])}(n,o,e)}var b={onDblClick:"dblclick",onDragEnd:"dragend",onDragStart:"dragstart",onMapTypeIdChanged:"maptypeid_changed",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseDown:"mousedown",onMouseUp:"mouseup",onRightClick:"rightclick",onTilesLoaded:"tilesloaded",onBoundsChanged:"bounds_changed",onCenterChanged:"center_changed",onClick:"click",onDrag:"drag",onHeadingChanged:"heading_changed",onIdle:"idle",onProjectionChanged:"projection_changed",onResize:"resize",onTiltChanged:"tilt_changed",onZoomChanged:"zoom_changed"},w={extraMapTypes:function(t,e){e.forEach(function(e,n){t.mapTypes.set(String(n),e)})},center:function(t,e){t.setCenter(e)},clickableIcons:function(t,e){t.setClickableIcons(e)},heading:function(t,e){t.setHeading(e)},mapTypeId:function(t,e){t.setMapTypeId(e)},options:function(t,e){t.setOptions(e)},streetView:function(t,e){t.setStreetView(e)},tilt:function(t,e){t.setTilt(e)},zoom:function(t,e){t.setZoom(e)}},P=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state={map:null},e.registeredEvents=[],e.mapRef=null,e.getInstance=function(){return new google.maps.Map(e.mapRef,e.props.options)},e.setMapCallback=function(){null!==e.state.map&&e.props.onLoad&&e.props.onLoad(e.state.map)},e.getRef=function(t){e.mapRef=t},e}f(e,t);var s=e.prototype;return s.componentDidMount=function(){var t=this.getInstance();this.registeredEvents=k({updaterMap:w,eventMap:b,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{map:t}},this.setMapCallback)},s.componentDidUpdate=function(t){null!==this.state.map&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:w,eventMap:b,prevProps:t,nextProps:this.props,instance:this.state.map}))},s.componentWillUnmount=function(){null!==this.state.map&&(this.props.onUnmount&&this.props.onUnmount(this.state.map),E(this.registeredEvents))},s.render=function(){return n("div",{id:this.props.id,ref:this.getRef,style:this.props.mapContainerStyle,className:this.props.mapContainerClassName},n(m.Provider,{value:this.state.map},null!==this.state.map?this.props.children:n(o,null)))},e}(s),x="undefined"!=typeof document,L=function(t){var e=t.url,n=t.id;return x?new Promise(function(t,o){if(document.getElementById(n))return t(n);var s=document.createElement("script");s.type="text/javascript",s.src=e,s.id=n,s.async=!0,s.onload=function(){t(n)},s.onerror=o,document.head.appendChild(s)}).catch(function(t){console.error("injectScript error: ",t)}):Promise.reject(new Error("document is undefined"))},D=function(t){return!((!t.href||0!==t.href.indexOf("https://fonts.googleapis.com/css?family=Roboto"))&&("style"===t.tagName.toLowerCase()&&t.styleSheet&&t.styleSheet.cssText&&0===t.styleSheet.cssText.replace("\r\n","").indexOf(".gm-style")?(t.styleSheet.cssText="",0):"style"===t.tagName.toLowerCase()&&t.innerHTML&&0===t.innerHTML.replace("\r\n","").indexOf(".gm-style")?(t.innerHTML="",0):"style"!==t.tagName.toLowerCase()||t.styleSheet||t.innerHTML))},U=function(){console.log("preventGoogleFonts run");var t=document.getElementsByTagName("head")[0],e=t.insertBefore.bind(t);t.insertBefore=function(n,o){D(n)||Reflect.apply(e,t,[n,o])};var n=t.appendChild.bind(t);t.appendChild=function(e){D(e)||Reflect.apply(n,t,[e])}};function S(t){var e=t.googleMapsApiKey,n=t.googleMapsClientId,o=t.version,s=void 0===o?"weekly":o,r=t.language,i=t.region,a=t.libraries,p=[];return e&&n||!e||!n||u(!1),e?p.push("key="+e):n&&p.push("client="+n),s&&p.push("v="+s),r&&p.push("language="+r),i&&p.push("region="+i),a&&a.length&&p.push("libraries="+a.join(",")),"https://maps.googleapis.com/maps/api/js?"+p.join("&")}var O=!1;function T(){return n("div",null,"Loading...")}var R,V={id:"script-loader",version:"weekly"},_=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).check=r(),e.state={loaded:!1},e.cleanupCallback=function(){delete window.google,e.injectScript()},e.isCleaningUp=function(){try{return Promise.resolve(new Promise(function(t){if(O){if(x)var e=window.setInterval(function(){O||(window.clearInterval(e),t())},1)}else t()}))}catch(t){return Promise.reject(t)}},e.cleanup=function(){O=!0;var t=document.getElementById(e.props.id);t&&t.parentNode&&t.parentNode.removeChild(t),Array.prototype.slice.call(document.getElementsByTagName("script")).filter(function(t){return t.src.includes("maps.googleapis")}).forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)}),Array.prototype.slice.call(document.getElementsByTagName("link")).filter(function(t){return"https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Google+Sans"===t.href}).forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)}),Array.prototype.slice.call(document.getElementsByTagName("style")).filter(function(t){return t.innerText.length>0&&t.innerText.includes(".gm-")}).forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})},e.injectScript=function(){e.props.preventGoogleFontsLoading&&U(),"string"!=typeof e.props.id&&u(!1);var t={id:e.props.id,url:S(e.props)};L(t).then(function(){e.props.onLoad&&e.props.onLoad(),e.setState(function(){return{loaded:!0}})}).catch(function(t){e.props.onError&&e.props.onError(t),console.error("\n There has been an Error with loading Google Maps API script, please check that you provided correct google API key ("+(e.props.googleMapsApiKey||"-")+") or Client ID ("+(e.props.googleMapsClientId||"-")+") to <LoadScript />\n Otherwise it is a Network issue.\n ")})},e}f(e,t);var s=e.prototype;return s.componentDidMount=function(){if(x){if(window.google&&!O)return void console.error("google api is already presented");this.isCleaningUp().then(this.injectScript)}},s.componentDidUpdate=function(t){this.props.libraries!==t.libraries&&console.warn("Performance warning! Loadscript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable ounside of component, or somwhere in config files or ENV variables"),x&&t.language!==this.props.language&&(this.cleanup(),this.setState(function(){return{loaded:!1}},this.cleanupCallback))},s.componentWillUnmount=function(){var t=this;x&&(this.cleanup(),setTimeout(function(){t.check.current||(delete window.google,O=!1)},1),this.props.onUnmount&&this.props.onUnmount())},s.render=function(){return n(o,null,n("div",{ref:this.check}),this.state.loaded?this.props.children:this.props.loadingElement||n(T,null))},e}(s);function I(t){var e=t.id,n=void 0===e?V.id:e,o=t.version,s=void 0===o?V.version:o,r=t.googleMapsApiKey,l=t.googleMapsClientId,c=t.language,d=t.region,h=t.libraries,g=t.preventGoogleFontsLoading,f=i(!1),m=a(!1),v=m[0],y=m[1],M=a(void 0),C=M[0],E=M[1];p(function(){return f.current=!0,function(){f.current=!1}},[]),p(function(){x&&g&&U()},[g]),p(function(){v&&(window.google||u(!1))},[v]);var k=S({version:s,googleMapsApiKey:r,googleMapsClientId:l,language:c,region:d,libraries:h});p(function(){function t(){f.current&&(y(!0),R=k)}x&&(window.google&&R===k?t():L({id:n,url:k}).then(t).catch(function(t){f.current&&E(t),console.warn("\n There has been an Error with loading Google Maps API script, please check that you provided correct google API key ("+(r||"-")+") or Client ID ("+(l||"-")+")\n Otherwise it is a Network issue.\n "),console.error(t)}))},[n,k]);var b=i();return p(function(){b.current&&h!==b.current&&console.warn("Performance warning! Loadscript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables"),b.current=h},[h]),{isLoaded:v,loadError:C,url:k}}_.defaultProps=V;var W=n(T,null);function A(t){var e=t.loadingElement,n=t.onLoad,o=t.onError,s=t.onUnmount,r=t.children,i=I(function(t,e){if(null==t)return{};var n,o,s={},r=Object.keys(t);for(o=0;o<r.length;o++)e.indexOf(n=r[o])>=0||(s[n]=t[n]);return s}(t,["loadingElement","onLoad","onError","onUnmount","children"])),a=i.isLoaded,l=i.loadError;return p(function(){a&&"function"==typeof n&&n()},[a,n]),p(function(){l&&"function"==typeof o&&o(l)},[l,o]),p(function(){return function(){s&&s()}},[s]),a?r:e||W}var B=l(A),N={},j={options:function(t,e){t.setOptions(e)}},z=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state={trafficLayer:null},e.setTrafficLayerCallback=function(){null!==e.state.trafficLayer&&e.props.onLoad&&e.props.onLoad(e.state.trafficLayer)},e.registeredEvents=[],e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=new google.maps.TrafficLayer(g({},this.props.options||{},{map:this.context}));this.registeredEvents=k({updaterMap:j,eventMap:N,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{trafficLayer:t}},this.setTrafficLayerCallback)},n.componentDidUpdate=function(t){null!==this.state.trafficLayer&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:j,eventMap:N,prevProps:t,nextProps:this.props,instance:this.state.trafficLayer}))},n.componentWillUnmount=function(){null!==this.state.trafficLayer&&(this.props.onUnmount&&this.props.onUnmount(this.state.trafficLayer),E(this.registeredEvents),this.state.trafficLayer.setMap(null))},n.render=function(){return null},e}(s);z.contextType=m;var G=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state={bicyclingLayer:null},e.setBicyclingLayerCallback=function(){null!==e.state.bicyclingLayer&&(e.state.bicyclingLayer.setMap(e.context),e.props.onLoad&&e.props.onLoad(e.state.bicyclingLayer))},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=new google.maps.BicyclingLayer;this.setState(function(){return{bicyclingLayer:t}},this.setBicyclingLayerCallback)},n.componentWillUnmount=function(){null!==this.state.bicyclingLayer&&(this.props.onUnmount&&this.props.onUnmount(this.state.bicyclingLayer),this.state.bicyclingLayer.setMap(null))},n.render=function(){return null},e}(s);G.contextType=m;var H={onCircleComplete:"circlecomplete",onMarkerComplete:"markercomplete",onOverlayComplete:"overlaycomplete",onPolygonComplete:"polygoncomplete",onPolylineComplete:"polylinecomplete",onRectangleComplete:"rectanglecomplete"},Z={drawingMode:function(t,e){t.setDrawingMode(e)},options:function(t,e){t.setOptions(e)}},F=function(t){function e(e){var n;return(n=t.call(this,e)||this).registeredEvents=[],n.state={drawingManager:null},n.setDrawingManagerCallback=function(){null!==n.state.drawingManager&&n.props.onLoad&&n.props.onLoad(n.state.drawingManager)},google.maps.drawing||u(!1),n}f(e,t);var s=e.prototype;return s.componentDidMount=function(){var t=new google.maps.drawing.DrawingManager(g({},this.props.options||{},{map:this.context}));this.registeredEvents=k({updaterMap:Z,eventMap:H,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{drawingManager:t}},this.setDrawingManagerCallback)},s.componentDidUpdate=function(t){null!==this.state.drawingManager&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:Z,eventMap:H,prevProps:t,nextProps:this.props,instance:this.state.drawingManager}))},s.componentWillUnmount=function(){null!==this.state.drawingManager&&(this.props.onUnmount&&this.props.onUnmount(this.state.drawingManager),E(this.registeredEvents),this.state.drawingManager.setMap(null))},s.render=function(){return n(o,null)},e}(s);F.contextType=m;var K={onAnimationChanged:"animation_changed",onClick:"click",onClickableChanged:"clickable_changed",onCursorChanged:"cursor_changed",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDraggableChanged:"draggable_changed",onDragStart:"dragstart",onFlatChanged:"flat_changed",onIconChanged:"icon_changed",onMouseDown:"mousedown",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onPositionChanged:"position_changed",onRightClick:"rightclick",onShapeChanged:"shape_changed",onTitleChanged:"title_changed",onVisibleChanged:"visible_changed",onZindexChanged:"zindex_changed"},Y={animation:function(t,e){t.setAnimation(e)},clickable:function(t,e){t.setClickable(e)},cursor:function(t,e){t.setCursor(e)},draggable:function(t,e){t.setDraggable(e)},icon:function(t,e){t.setIcon(e)},label:function(t,e){t.setLabel(e)},map:function(t,e){t.setMap(e)},opacity:function(t,e){t.setOpacity(e)},options:function(t,e){t.setOptions(e)},position:function(t,e){t.setPosition(e)},shape:function(t,e){t.setShape(e)},title:function(t,e){t.setTitle(e)},visible:function(t,e){t.setVisible(e)},zIndex:function(t,e){t.setZIndex(e)}},J=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={marker:null},e.setMarkerCallback=function(){null!==e.state.marker&&e.props.onLoad&&e.props.onLoad(e.state.marker)},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=g({},this.props.options||{},this.props.clusterer?{}:{map:this.context},{position:this.props.position}),e=new google.maps.Marker(t);this.props.clusterer?this.props.clusterer.addMarker(e,!!this.props.noClustererRedraw):e.setMap(this.context),this.registeredEvents=k({updaterMap:Y,eventMap:K,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{marker:e}},this.setMarkerCallback)},n.componentDidUpdate=function(t){null!==this.state.marker&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:Y,eventMap:K,prevProps:t,nextProps:this.props,instance:this.state.marker}))},n.componentWillUnmount=function(){null!==this.state.marker&&(this.props.onUnmount&&this.props.onUnmount(this.state.marker),E(this.registeredEvents),this.props.clusterer?this.props.clusterer.removeMarker(this.state.marker,!!this.props.noClustererRedraw):this.state.marker&&this.state.marker.setMap(null))},n.render=function(){return this.props.children||null},e}(s);J.contextType=m;var q={onClick:"click",onClusteringBegin:"clusteringbegin",onClusteringEnd:"clusteringend",onMouseOut:"mouseout",onMouseOver:"mouseover"},Q={averageCenter:function(t,e){t.setAverageCenter(e)},batchSizeIE:function(t,e){t.setBatchSizeIE(e)},calculator:function(t,e){t.setCalculator(e)},clusterClass:function(t,e){t.setClusterClass(e)},enableRetinaIcons:function(t,e){t.setEnableRetinaIcons(e)},gridSize:function(t,e){t.setGridSize(e)},ignoreHidden:function(t,e){t.setIgnoreHidden(e)},imageExtension:function(t,e){t.setImageExtension(e)},imagePath:function(t,e){t.setImagePath(e)},imageSizes:function(t,e){t.setImageSizes(e)},maxZoom:function(t,e){t.setMaxZoom(e)},minimumClusterSize:function(t,e){t.setMinimumClusterSize(e)},styles:function(t,e){t.setStyles(e)},title:function(t,e){t.setTitle(e)},zoomOnClick:function(t,e){t.setZoomOnClick(e)}},X=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={markerClusterer:null},e.setClustererCallback=function(){null!==e.state.markerClusterer&&e.props.onLoad&&e.props.onLoad(e.state.markerClusterer)},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){if(this.context){var t=new d(this.context,[],this.props.options);this.registeredEvents=k({updaterMap:Q,eventMap:q,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{markerClusterer:t}},this.setClustererCallback)}},n.componentDidUpdate=function(t){this.state.markerClusterer&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:Q,eventMap:q,prevProps:t,nextProps:this.props,instance:this.state.markerClusterer}))},n.componentWillUnmount=function(){null!==this.state.markerClusterer&&(this.props.onUnmount&&this.props.onUnmount(this.state.markerClusterer),E(this.registeredEvents),this.state.markerClusterer.setMap(null))},n.render=function(){return null!==this.state.markerClusterer?this.props.children(this.state.markerClusterer):null},e}(s);X.contextType=m;var $={onCloseClick:"closeclick",onContentChanged:"content_changed",onDomReady:"domready",onPositionChanged:"position_changed",onZindexChanged:"zindex_changed"},tt={options:function(t,e){t.setOptions(e)},position:function(t,e){t.setPosition(e)},zIndex:function(t,e){t.setZIndex(e)}},et=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.containerElement=null,e.state={infoWindow:null},e.open=function(t,n){n?t.open(e.context,n):t.getPosition()?t.open(e.context):u(!1)},e.setInfowindowCallback=function(){null!==e.state.infoWindow&&null!==e.containerElement&&(e.state.infoWindow.setContent(e.containerElement),e.open(e.state.infoWindow,e.props.anchor),e.props.onLoad&&e.props.onLoad(e.state.infoWindow))},e}f(e,t);var s=e.prototype;return s.componentDidMount=function(){var t=new google.maps.InfoWindow(g({},this.props.options||{}));this.containerElement=document.createElement("div"),this.registeredEvents=k({updaterMap:tt,eventMap:$,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{infoWindow:t}},this.setInfowindowCallback)},s.componentDidUpdate=function(t){null!==this.state.infoWindow&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:tt,eventMap:$,prevProps:t,nextProps:this.props,instance:this.state.infoWindow}))},s.componentWillUnmount=function(){null!==this.state.infoWindow&&(E(this.registeredEvents),this.state.infoWindow.close())},s.render=function(){return this.containerElement?h(c.only(this.props.children),this.containerElement):n(o,null)},e}(s);et.contextType=m;var nt={onClick:"click",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragStart:"dragstart",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRightClick:"rightclick"},ot={draggable:function(t,e){t.setDraggable(e)},editable:function(t,e){t.setEditable(e)},map:function(t,e){t.setMap(e)},options:function(t,e){t.setOptions(e)},path:function(t,e){t.setPath(e)},visible:function(t,e){t.setVisible(e)}},st=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={polyline:null},e.setPolylineCallback=function(){null!==e.state.polyline&&e.props.onLoad&&e.props.onLoad(e.state.polyline)},e}f(e,t);var s=e.prototype;return s.componentDidMount=function(){var t=new google.maps.Polyline(g({},this.props.options||{},{map:this.context}));this.registeredEvents=k({updaterMap:ot,eventMap:nt,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{polyline:t}},this.setPolylineCallback)},s.componentDidUpdate=function(t){null!==this.state.polyline&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:ot,eventMap:nt,prevProps:t,nextProps:this.props,instance:this.state.polyline}))},s.componentWillUnmount=function(){null!==this.state.polyline&&(this.props.onUnmount&&this.props.onUnmount(this.state.polyline),E(this.registeredEvents),this.state.polyline.setMap(null))},s.render=function(){return n(o,null)},e}(s);st.contextType=m;var rt={onClick:"click",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragStart:"dragstart",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRightClick:"rightclick"},it={draggable:function(t,e){t.setDraggable(e)},editable:function(t,e){t.setEditable(e)},map:function(t,e){t.setMap(e)},options:function(t,e){t.setOptions(e)},path:function(t,e){t.setPath(e)},paths:function(t,e){t.setPaths(e)},visible:function(t,e){t.setVisible(e)}},at=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={polygon:null},e.setPolygonCallback=function(){null!==e.state.polygon&&e.props.onLoad&&e.props.onLoad(e.state.polygon)},e.render=function(){return null},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=new google.maps.Polygon(g({},this.props.options||{},{map:this.context}));this.registeredEvents=k({updaterMap:it,eventMap:rt,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{polygon:t}},this.setPolygonCallback)},n.componentDidUpdate=function(t){null!==this.state.polygon&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:it,eventMap:rt,prevProps:t,nextProps:this.props,instance:this.state.polygon}))},n.componentWillUnmount=function(){null!==this.state.polygon&&(this.props.onUnmount&&this.props.onUnmount(this.state.polygon),E(this.registeredEvents),this.state.polygon&&this.state.polygon.setMap(null))},e}(s);at.contextType=m;var pt={onBoundsChanged:"bounds_changed",onClick:"click",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragStart:"dragstart",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRightClick:"rightclick"},lt={bounds:function(t,e){t.setBounds(e)},draggable:function(t,e){t.setDraggable(e)},editable:function(t,e){t.setEditable(e)},map:function(t,e){t.setMap(e)},options:function(t,e){t.setOptions(e)},visible:function(t,e){t.setVisible(e)}},ct=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={rectangle:null},e.setRectangleCallback=function(){null!==e.state.rectangle&&e.props.onLoad&&e.props.onLoad(e.state.rectangle)},e}f(e,t);var s=e.prototype;return s.componentDidMount=function(){var t=new google.maps.Rectangle(g({},this.props.options||{},{map:this.context}));this.registeredEvents=k({updaterMap:lt,eventMap:pt,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{rectangle:t}},this.setRectangleCallback)},s.componentDidUpdate=function(t){null!==this.state.rectangle&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:lt,eventMap:pt,prevProps:t,nextProps:this.props,instance:this.state.rectangle}))},s.componentWillUnmount=function(){null!==this.state.rectangle&&(this.props.onUnmount&&this.props.onUnmount(this.state.rectangle),E(this.registeredEvents),this.state.rectangle.setMap(null))},s.render=function(){return n(o,null)},e}(s);ct.contextType=m;var ut={onCenterChanged:"center_changed",onClick:"click",onDblClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragStart:"dragstart",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRadiusChanged:"radius_changed",onRightClick:"rightclick"},dt={center:function(t,e){t.setCenter(e)},draggable:function(t,e){t.setDraggable(e)},editable:function(t,e){t.setEditable(e)},map:function(t,e){t.setMap(e)},options:function(t,e){t.setOptions(e)},radius:function(t,e){t.setRadius(e)},visible:function(t,e){t.setVisible(e)}},ht=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={circle:null},e.setCircleCallback=function(){null!==e.state.circle&&e.props.onLoad&&e.props.onLoad(e.state.circle)},e}f(e,t);var s=e.prototype;return s.componentDidMount=function(){var t=new google.maps.Circle(g({},this.props.options||{},{map:this.context}));this.registeredEvents=k({updaterMap:dt,eventMap:ut,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{circle:t}},this.setCircleCallback)},s.componentDidUpdate=function(t){null!==this.state.circle&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:dt,eventMap:ut,prevProps:t,nextProps:this.props,instance:this.state.circle}))},s.componentWillUnmount=function(){null!==this.state.circle&&(this.props.onUnmount&&this.props.onUnmount(this.state.circle),E(this.registeredEvents),this.state.circle&&this.state.circle.setMap(null))},s.render=function(){return n(o,null)},e}(s);ht.contextType=m;var gt={onAddFeature:"addfeature",onClick:"click",onDblClick:"dblclick",onMouseDown:"mousedown",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onRemoveFeature:"removefeature",onRemoveProperty:"removeproperty",onRightClick:"rightclick",onSetGeometry:"setgeometry",onSetProperty:"setproperty"},ft={add:function(t,e){t.add(e)},addgeojson:function(t,e,n){t.addGeoJson(e,n)},contains:function(t,e){t.contains(e)},foreach:function(t,e){t.forEach(e)},loadgeojson:function(t,e,n,o){t.loadGeoJson(e,n,o)},overridestyle:function(t,e,n){t.overrideStyle(e,n)},remove:function(t,e){t.remove(e)},revertstyle:function(t,e){t.revertStyle(e)},controlposition:function(t,e){t.setControlPosition(e)},controls:function(t,e){t.setControls(e)},drawingmode:function(t,e){t.setDrawingMode(e)},map:function(t,e){t.setMap(e)},style:function(t,e){t.setStyle(e)},togeojson:function(t,e){t.toGeoJson(e)}},mt=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={data:null},e.setDataCallback=function(){null!==e.state.data&&e.props.onLoad&&e.props.onLoad(e.state.data)},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=new google.maps.Data(g({},this.props.options||{},{map:this.context}));this.registeredEvents=k({updaterMap:ft,eventMap:gt,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{data:t}},this.setDataCallback)},n.componentDidUpdate=function(t){null!==this.state.data&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:ft,eventMap:gt,prevProps:t,nextProps:this.props,instance:this.state.data}))},n.componentWillUnmount=function(){null!==this.state.data&&(this.props.onUnmount&&this.props.onUnmount(this.state.data),E(this.registeredEvents),this.state.data&&this.state.data.setMap(null))},n.render=function(){return null},e}(s);mt.contextType=m;var vt={onClick:"click",onDefaultViewportChanged:"defaultviewport_changed",onStatusChanged:"status_changed"},yt={options:function(t,e){t.setOptions(e)},url:function(t,e){console.log({instance:t,url:e}),t.setUrl(e)},zIndex:function(t,e){t.setZIndex(e)}},Mt=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={kmlLayer:null},e.setKmlLayerCallback=function(){null!==e.state.kmlLayer&&e.props.onLoad&&e.props.onLoad(e.state.kmlLayer)},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=new google.maps.KmlLayer(g({},this.props.options,{map:this.context}));this.registeredEvents=k({updaterMap:yt,eventMap:vt,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{kmlLayer:t}},this.setKmlLayerCallback)},n.componentDidUpdate=function(t){null!==this.state.kmlLayer&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:yt,eventMap:vt,prevProps:t,nextProps:this.props,instance:this.state.kmlLayer}))},n.componentWillUnmount=function(){null!==this.state.kmlLayer&&(this.props.onUnmount&&this.props.onUnmount(this.state.kmlLayer),E(this.registeredEvents),this.state.kmlLayer.setMap(null))},n.render=function(){return null},e}(s);Mt.contextType=m;var Ct=function(t,e){return new e(t.lat,t.lng)},Et=function(t,e){return new e(new google.maps.LatLng(t.ne.lat,t.ne.lng),new google.maps.LatLng(t.sw.lat,t.sw.lng))},kt=function(t,e,n){return t instanceof e?t:n(t,e)},bt=function(t,e,n,o){return void 0!==n?function(t,e,n){var o=t.fromLatLngToDivPixel(n.getNorthEast()),s=t.fromLatLngToDivPixel(n.getSouthWest());return o&&s?{left:s.x+e.x+"px",top:o.y+e.y+"px",width:o.x-s.x-e.x+"px",height:s.y-o.y-e.y+"px"}:{left:"-9999px",top:"-9999px"}}(t,e,kt(n,google.maps.LatLngBounds,Et)):function(t,e,n){var o=t.fromLatLngToDivPixel(n);return o?{left:o.x+e.x+"px",top:o.y+e.y+"px"}:{left:"-9999px",top:"-9999px"}}(t,e,kt(o,google.maps.LatLng,Ct))},wt=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state={overlayView:null},e.containerElement=null,e.setOverlayViewCallback=function(){null!==e.state.overlayView&&e.props.onLoad&&e.props.onLoad(e.state.overlayView)},e.onAdd=function(){e.containerElement=document.createElement("div"),e.containerElement.style.position="absolute"},e.onPositionElement=function(){if(null!==e.state.overlayView&&null!==e.containerElement){var t=e.state.overlayView.getProjection(),n=g({x:0,y:0},(s=e.containerElement,"function"==typeof(r=e.props.getPixelPositionOffset)?r(s.offsetWidth,s.offsetHeight):{})),o=bt(t,n,e.props.bounds,e.props.position);Object.assign(e.containerElement.style,o)}var s,r},e.draw=function(){e.props.mapPaneName||u(!1);var t=e.state.overlayView;if(null!==t){var n=t.getPanes();n&&(e.containerElement&&n[e.props.mapPaneName].appendChild(e.containerElement),e.onPositionElement(),e.forceUpdate())}},e.onRemove=function(){null!==e.containerElement&&e.containerElement.parentNode&&(e.containerElement.parentNode.removeChild(e.containerElement),delete e.containerElement)},e}f(e,t);var s=e.prototype;return s.componentDidMount=function(){var t=new google.maps.OverlayView;t.onAdd=this.onAdd,t.draw=this.draw,t.onRemove=this.onRemove,t.setMap(this.context),this.setState(function(){return{overlayView:t}},this.setOverlayViewCallback)},s.componentDidUpdate=function(t){var e=this;t.position===this.props.position&&t.bounds===this.props.bounds||setTimeout(function(){null!==e.state.overlayView&&e.state.overlayView.draw()},0)},s.componentWillUnmount=function(){null!==this.state.overlayView&&(this.props.onUnmount&&this.props.onUnmount(this.state.overlayView),this.state.overlayView.setMap(null))},s.render=function(){return null!==this.containerElement?h(c.only(this.props.children),this.containerElement):n(o,null)},e}(s);wt.FLOAT_PANE="floatPane",wt.MAP_PANE="mapPane",wt.MARKER_LAYER="markerLayer",wt.OVERLAY_LAYER="overlayLayer",wt.OVERLAY_MOUSE_TARGET="overlayMouseTarget",wt.contextType=m;var Pt={onDblClick:"dblclick",onClick:"click"},xt={opacity:function(t,e){t.setOpacity(e)}},Lt=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={groundOverlay:null},e.setGroundOverlayCallback=function(){null!==e.state.groundOverlay&&e.props.onLoad&&e.props.onLoad(e.state.groundOverlay)},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){console.log("this.props.url: ",this.props.url),console.log("this.props.bounds: ",this.props.bounds),this.props.url||this.props.bounds||u(!1);var t=new google.maps.GroundOverlay(this.props.url,this.props.bounds,g({},this.props.options,{map:this.context}));this.registeredEvents=k({updaterMap:xt,eventMap:Pt,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{groundOverlay:t}},this.setGroundOverlayCallback)},n.componentDidUpdate=function(t){null!==this.state.groundOverlay&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:xt,eventMap:Pt,prevProps:t,nextProps:this.props,instance:this.state.groundOverlay}))},n.componentWillUnmount=function(){this.state.groundOverlay&&(this.props.onUnmount&&this.props.onUnmount(this.state.groundOverlay),this.state.groundOverlay.setMap(null))},n.render=function(){return null},e}(s);Lt.defaultProps={onLoad:function(){}},Lt.contextType=m;var Dt={},Ut={data:function(t,e){t.setData(e)},map:function(t,e){t.setMap(e)},options:function(t,e){t.setOptions(e)}},St=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={heatmapLayer:null},e.setHeatmapLayerCallback=function(){null!==e.state.heatmapLayer&&e.props.onLoad&&e.props.onLoad(e.state.heatmapLayer)},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){google.maps.visualization||u(!1),this.props.data||u(!1);var t=new google.maps.visualization.HeatmapLayer(g({data:this.props.data},this.props.options||{},{map:this.context}));this.registeredEvents=k({updaterMap:Ut,eventMap:Dt,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{heatmapLayer:t}},this.setHeatmapLayerCallback)},n.componentDidUpdate=function(t){E(this.registeredEvents),this.registeredEvents=k({updaterMap:Ut,eventMap:Dt,prevProps:t,nextProps:this.props,instance:this.state.heatmapLayer})},n.componentWillUnmount=function(){null!==this.state.heatmapLayer&&(this.props.onUnmount&&this.props.onUnmount(this.state.heatmapLayer),E(this.registeredEvents),this.state.heatmapLayer.setMap(null))},n.render=function(){return null},e}(s);St.contextType=m;var Ot={onCloseClick:"closeclick",onPanoChanged:"pano_changed",onPositionChanged:"position_changed",onPovChanged:"pov_changed",onResize:"resize",onStatusChanged:"status_changed",onVisibleChanged:"visible_changed",onZoomChanged:"zoom_changed"},Tt={register:function(t,e,n){t.registerPanoProvider(e,n)},links:function(t,e){t.setLinks(e)},motionTracking:function(t,e){t.setMotionTracking(e)},options:function(t,e){t.setOptions(e)},pano:function(t,e){t.setPano(e)},position:function(t,e){t.setPosition(e)},pov:function(t,e){t.setPov(e)},visible:function(t,e){t.setVisible(e)},zoom:function(t,e){t.setZoom(e)}},Rt=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={streetViewPanorama:null},e.setStreetViewPanoramaCallback=function(){null!==e.state.streetViewPanorama&&e.props.onLoad&&e.props.onLoad(e.state.streetViewPanorama)},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=this.context.getStreetView();this.registeredEvents=k({updaterMap:Tt,eventMap:Ot,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{streetViewPanorama:t}},this.setStreetViewPanoramaCallback)},n.componentDidUpdate=function(t){null!==this.state.streetViewPanorama&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:Tt,eventMap:Ot,prevProps:t,nextProps:this.props,instance:this.state.streetViewPanorama}))},n.componentWillUnmount=function(){null!==this.state.streetViewPanorama&&(this.props.onUnmount&&this.props.onUnmount(this.state.streetViewPanorama),E(this.registeredEvents),this.state.streetViewPanorama.setVisible(!1))},n.render=function(){return null},e}(s);Rt.contextType=m;var Vt=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state={streetViewService:null},e.setStreetViewServiceCallback=function(){null!==e.state.streetViewService&&e.props.onLoad&&e.props.onLoad(e.state.streetViewService)},e}f(e,t);var n=e.prototype;return n.componentDidMount=function(){var t=new google.maps.StreetViewService;this.setState(function(){return{streetViewService:t}})},n.componentWillUnmount=function(){null!==this.state.streetViewService&&this.props.onUnmount&&this.props.onUnmount(this.state.streetViewService)},n.render=function(){return null},e}(s);Vt.contextType=m;var _t=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state={directionsService:null},e.setDirectionsServiceCallback=function(){null!==e.state.directionsService&&e.props.onLoad&&e.props.onLoad(e.state.directionsService)},e}f(e,t);var s=e.prototype;return s.componentDidMount=function(){this.props.options||u(!1);var t=new google.maps.DirectionsService;this.setState(function(){return{directionsService:t}},this.setDirectionsServiceCallback)},s.componentDidUpdate=function(){null!==this.state.directionsService&&this.state.directionsService.route(this.props.options,this.props.callback)},s.componentWillUnmount=function(){null!==this.state.directionsService&&this.props.onUnmount&&this.props.onUnmount(this.state.directionsService)},s.render=function(){return n(o,null)},e}(s),It={onDirectionsChanged:"directions_changed"},Wt={directions:function(t,e){t.setDirections(e)},map:function(t,e){t.setMap(e)},options:function(t,e){t.setOptions(e)},panel:function(t,e){t.setPanel(e)},routeIndex:function(t,e){t.setRouteIndex(e)}},At=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.state={directionsRenderer:null},e.setDirectionsRendererCallback=function(){null!==e.state.directionsRenderer&&(e.state.directionsRenderer.setMap(e.context),e.props.onLoad&&e.props.onLoad(e.state.directionsRenderer))},e}f(e,t);var s=e.prototype;return s.componentDidMount=function(){var t=new google.maps.DirectionsRenderer(this.props.options);this.registeredEvents=k({updaterMap:Wt,eventMap:It,prevProps:{},nextProps:this.props,instance:t}),this.setState(function(){return{directionsRenderer:t}},this.setDirectionsRendererCallback)},s.componentDidUpdate=function(t){null!==this.state.directionsRenderer&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:Wt,eventMap:It,prevProps:t,nextProps:this.props,instance:this.state.directionsRenderer}))},s.componentWillUnmount=function(){null!==this.state.directionsRenderer&&(this.props.onUnmount&&this.props.onUnmount(this.state.directionsRenderer),E(this.registeredEvents),this.state.directionsRenderer&&this.state.directionsRenderer.setMap(null))},s.render=function(){return n(o,null)},e}(s);At.contextType=m;var Bt={onPlacesChanged:"places_changed"},Nt={bounds:function(t,e){t.setBounds(e)}},jt=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.containerElement=r(),e.state={searchBox:null},e.setSearchBoxCallback=function(){null!==e.state.searchBox&&e.props.onLoad&&e.props.onLoad(e.state.searchBox)},e}f(e,t);var o=e.prototype;return o.componentDidMount=function(){if(google.maps.places||u(!1),null!==this.containerElement&&null!==this.containerElement.current){var t=this.containerElement.current.querySelector("input");if(t){var e=new google.maps.places.SearchBox(t,this.props.options);this.registeredEvents=k({updaterMap:Nt,eventMap:Bt,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{searchBox:e}},this.setSearchBoxCallback)}}},o.componentDidUpdate=function(t){null!==this.state.searchBox&&(E(this.registeredEvents),this.registeredEvents=k({updaterMap:Nt,eventMap:Bt,prevProps:t,nextProps:this.props,instance:this.state.searchBox}))},o.componentWillUnmount=function(){null!==this.state.searchBox&&(this.props.onUnmount&&this.props.onUnmount(this.state.searchBox),E(this.registeredEvents))},o.render=function(){return n("div",{ref:this.containerElement},c.only(this.props.children))},e}(s);jt.contextType=m;var zt={onPlaceChanged:"place_changed"},Gt={bounds:function(t,e){t.setBounds(e)},restrictions:function(t,e){t.setComponentRestrictions(e)},fields:function(t,e){t.setFields(e)},options:function(t,e){t.setOptions(e)},types:function(t,e){t.setTypes(e)}},Ht=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).registeredEvents=[],e.containerElement=r(),e.state={autocomplete:null},e.setAutocompleteCallback=function(){null!==e.state.autocomplete&&e.props.onLoad&&e.props.onLoad(e.state.autocomplete)},e}f(e,t);var o=e.prototype;return o.componentDidMount=function(){google.maps.places||u(!1);var t=this.containerElement.current.querySelector("input");if(t){var e=new google.maps.places.Autocomplete(t,this.props.options);this.registeredEvents=k({updaterMap:Gt,eventMap:zt,prevProps:{},nextProps:this.props,instance:e}),this.setState(function(){return{autocomplete:e}},this.setAutocompleteCallback)}},o.componentDidUpdate=function(t){E(this.registeredEvents),this.registeredEvents=k({updaterMap:Gt,eventMap:zt,prevProps:t,nextProps:this.props,instance:this.state.autocomplete})},o.componentWillUnmount=function(){null!==this.state.autocomplete&&E(this.registeredEvents)},o.render=function(){return n("div",{ref:this.containerElement},c.only(this.props.children))},e}(s);Ht.contextType=m;export{Ht as Autocomplete,G as BicyclingLayer,ht as Circle,mt as Data,At as DirectionsRenderer,_t as DirectionsService,F as DrawingManager,P as GoogleMap,Lt as GroundOverlay,St as HeatmapLayer,et as InfoWindow,Mt as KmlLayer,_ as LoadScript,B as LoadScriptNext,J as Marker,X as MarkerClusterer,wt as OverlayView,at as Polygon,st as Polyline,ct as Rectangle,jt as StandaloneSearchBox,Rt as StreetViewPanorama,Vt as StreetViewService,z as TrafficLayer,v as useGoogleMap,I as useLoadScript}; //# sourceMappingURL=reactgooglemapsapi.es.production.js.map