google-maps-js-api-react
Advanced tools
Comparing version 1.2.4 to 1.3.0
/// <reference types="google.maps" /> | ||
/** | ||
* @param startLoading - if `true`, starts loading if {@link google.maps} not loaded yet, overwise just waited for loading if it not done yet | ||
* @throws error if `places` not included to libraries in loader {@link Loader.options options} | ||
*/ | ||
declare const useAutocompleteService: (startLoading?: boolean) => google.maps.places.AutocompleteService | undefined; | ||
declare const useAutocompleteService: () => import("../utils/handleService").Service<google.maps.places.AutocompleteService>; | ||
export default useAutocompleteService; |
/// <reference types="google.maps" /> | ||
/** | ||
* @param startLoading - if `true`, starts loading if {@link google.maps} not loaded yet, overwise just waited for loading if it not done yet | ||
* @throws error if `places` not included to libraries in loader {@link Loader.options options} | ||
*/ | ||
declare const usePlacesService: (startLoading?: boolean, container?: null | (() => HTMLDivElement) | HTMLDivElement | google.maps.Map) => google.maps.places.PlacesService | undefined; | ||
import { Service } from '../utils/handleService'; | ||
declare type UsePlacesService = { | ||
(container?: null | HTMLElement | google.maps.Map): Service<google.maps.places.PlacesService>; | ||
(getContainer: () => HTMLElement): Service<google.maps.places.PlacesService> | undefined; | ||
}; | ||
declare const usePlacesService: UsePlacesService; | ||
export default usePlacesService; |
@@ -10,1 +10,2 @@ export { default as createGoogleMapComponent, GoogleMapsBaseProps, GoogleMapsHandlers, } from './createComponents/createGoogleMap'; | ||
export { default as usePlacesService } from './hooks/usePlacesService'; | ||
export { default as useGeocoder } from './hooks/useGeocoder'; |
@@ -1,2 +0,2 @@ | ||
var e=require("react"),n=require("fast-deep-equal"),t=require("google-maps-js-api-loader"),o=require("react-dom"),r=require("marker-cluster");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=/*#__PURE__*/a(e),i=/*#__PURE__*/a(n),l=/*#__PURE__*/a(t),c=/*#__PURE__*/a(r);function s(){return s=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},s.apply(this,arguments)}function d(e,n){return d=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},d(e,n)}function f(e,n){if(null==e)return{};var t,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)n.indexOf(t=a[o])>=0||(r[t]=e[t]);return r}var g,p=e.createContext(null),C=function(){return e.useContext(p)};!function(e){e.CLICK="click",e.CONTEXT_MENU="contextmenu",e.DOUBLE_CLICK="dblclick",e.DRAG="drag",e.DRAG_END="dragend",e.DRAG_START="dragstart",e.MOUSE_MOVE="mousemove",e.MOUSE_OUT="mouseout",e.MOUSE_OVER="mouseover",e.RIGHT_CLICK="rightclick",e.BOUNDS_CHANGED="bounds_changed",e.CENTER_CHANGED="center_changed",e.HEADING_CHANGED="heading_changed",e.IDLE="idle",e.MAP_TYPE_ID_CHANGED="maptypeid_changed",e.PROJECTION_CHANGED="projection_changed",e.RESIZE="resize",e.TILES_LOADED="tilesloaded",e.TILT_CHANGED="tilt_changed",e.ZOOM_CHANGED="zoom_changed",e.ANIMATION_CHANGED="animation_changed",e.CLICKABLE_CHANGED="clickable_changed",e.CURSOR_CHANGED="cursor_changed",e.DRAGGABLE_CHANGED="draggable_changed",e.FLAT_CHANGED="flat_changed",e.ICON_CHANGED="icon_changed",e.MOUSE_DOWN="mousedown",e.MOUSE_UP="mouseup",e.POSITION_CHANGED="position_changed",e.SHAPE_CHANGED="shape_changed",e.TITLE_CHANGED="title_changed",e.VISIBLE_CHANGED="visible_changed",e.Z_INDEX_CHANGED="zindex_changed"}(g||(g={}));var v=Object.freeze({onClick:g.CLICK,onDoubleClick:g.DOUBLE_CLICK,onDrag:g.DRAG,onDragEnd:g.DRAG_END,onDragStart:g.DRAG_START,onContextMenu:g.CONTEXT_MENU,onMouseMove:g.MOUSE_MOVE,onMouseOut:g.MOUSE_OUT,onMouseOver:g.MOUSE_OVER,onRightClick:g.RIGHT_CLICK,onBoundsChanged:g.BOUNDS_CHANGED,onCenterChanged:g.CENTER_CHANGED,onHeadingChanged:g.HEADING_CHANGED,onIdle:g.IDLE,onMapTypeIdChanged:g.MAP_TYPE_ID_CHANGED,onProjectionChanged:g.PROJECTION_CHANGED,onResize:g.RESIZE,onTilesLoaded:g.TILES_LOADED,onTiltChanged:g.TILT_CHANGED,onZoomChanged:g.ZOOM_CHANGED,onAnimationChanged:g.ANIMATION_CHANGED,onClickableChanged:g.CLICKABLE_CHANGED,onCursorChanged:g.CURSOR_CHANGED,onDraggableChanged:g.DRAGGABLE_CHANGED,onFlatChanged:g.FLAT_CHANGED,onIconChanged:g.ICON_CHANGED,onMouseDown:g.MOUSE_DOWN,onMouseUp:g.MOUSE_UP,onPositionChanged:g.POSITION_CHANGED,onShapeChanged:g.SHAPE_CHANGED,onTitleChanged:g.TITLE_CHANGED,onVisibleChanged:g.VISIBLE_CHANGED,onZIndexChanged:g.Z_INDEX_CHANGED}),E=function(){};function h(n,t){return void 0===t&&(t={}),function(o,r){return n(function(n,t,o){if(0===t.length&&0===n.length)return E;n=Array.from(new Set(n)).reverse();var r=(t=Array.from(new Set(t)).reverse()).length,a=function(n,o){var a=e.useRef([]);e.useEffect(function(){var e=n.current;if(e){var u=a.current;if(u.length)for(var l=r;l--;){var c=t[l],s=o[c];i.default(s,u[l])||(e.set(c,s),u[l]=s)}else for(var d=r;d--;)u[d]=o[t[d]]}})};if(0===n.length)return a;var u=function(t,r){for(var a=function(a){var u=n[a],i=r[u];e.useEffect(function(){var e=t.current;if(e&&i){var n=o[u],r=e.addListener(v[u],n?function(){i.apply(void 0,[this.get(n)].concat([].slice.call(arguments),[this]))}:function(){i.apply(void 0,[].slice.call(arguments).concat([this]))});return function(){return r.remove()}}},[i])},u=n.length;u--;)a(u)};if(0===r)return u;for(var l=[],c=n.length;c--;){var s=n[c],d=o[s];d&&t.includes(d)&&(l.push(s),n.splice(c,1))}var f=l.length;return 0===f?function(e,n){u(e,n),a(e,n)}:(0===n.length&&(u=E),function(n,a){var c=e.useRef({isTriggeredBySetStateMap:new Map,prevStateArr:[]});u(n,a);for(var s=c.current.isTriggeredBySetStateMap,d=function(t){var r=l[t],u=a[r];e.useEffect(function(){var e=n.current;if(e&&u){var t=o[r],a=e.addListener(v[r],function(){s.has(t)?s.delete(t):u.apply(void 0,[this.get(t)].concat([].slice.call(arguments),[this]))});return function(){return a.remove()}}},[u])},g=f;g--;)d(g);e.useEffect(function(){var e=n.current;if(e){var o=c.current.prevStateArr;if(o.length)for(var u=r;u--;){var l=t[u],d=a[l];i.default(d,o[u])||(s.set(l,!0),e.set(l,d),o[u]=d)}else for(var f=r;f--;)o[f]=a[t[f]]}})})}(o,r,t))}}var _,D=["children","className","style","defaultOptions","onMount","onUnmount"],A=h(function(n){return function(t){var o=t.children,r=t.className,a=t.style,i=t.defaultOptions,l=t.onMount,c=t.onUnmount,d=f(t,D),g=e.useRef(null),C=e.useRef(),v=e.useState(),h=v[0],_=v[1];return e.useEffect(function(){var e=new google.maps.Map(g.current,s({},i,d));return C.current=e,google.maps.event.addListenerOnce(e,"idle",function(){_(e),(l||E)(e)}),c},[]),n(C,d),u.default.createElement("div",{ref:g,className:r,style:a},o&&h&&u.default.createElement(p.Provider,{value:h},"function"==typeof o?o(h):o))}},{onCenterChanged:"center",onHeadingChanged:"heading",onMapTypeIdChanged:"mapTypeId",onTiltChanged:"tilt",onZoomChanged:"zoom",onBoundsChanged:"bounds"}),O=["defaultOptions","onMount","onUnmount"],N=h(function(n){return function(t){var o=t.defaultOptions,r=t.onMount,a=t.onUnmount,u=f(t,O),i=C(),l=e.useRef();return e.useEffect(function(){var e=new google.maps.Marker(s({map:i},o,u));return l.current=e,(r||E)(e),function(){e.setMap(null),(a||E)()}},[]),n(l,u),null}},{onAnimationChanged:"animation",onCursorChanged:"cursor",onDraggableChanged:"draggable",onIconChanged:"icon",onPositionChanged:"position",onShapeChanged:"shape",onTitleChanged:"title",onVisibleChanged:"visible",onZIndexChanged:"zIndex"}),m=function(n){void 0===n&&(n={});var o=e.useState(l.default.status),r=o[0],a=o[1];return e.useEffect(function(){r!==t.LoaderStatus.LOADED&&l.default.load().then(function(){a(t.LoaderStatus.LOADED),(n.onLoaded||E)()},function(e){a(t.LoaderStatus.ERROR),(n.onError||E)(e)})},[]),r},L=e.createContext(l.default.status),G=["lat","lng","onAdd","onDraw","onRemove","component","mapPaneLayer","preventMapDragging"];l.default.completion.then(function(){_=/*#__PURE__*/function(e){var n,t;function o(n,t,o){var r;return(r=e.call(this)||this)._style=void 0,r._latLng=void 0,r._onDraw=void 0,r._style=n,r._latLng=new google.maps.LatLng(t[0],t[1]),r.setCallbacks(o),r}t=e,(n=o).prototype=Object.create(t.prototype),n.prototype.constructor=n,d(n,t);var r=o.prototype;return r.setCallbacks=function(e){this.onAdd=e[0]||E,this._onDraw=e[1]||E,this.onRemove=e[2]||E},r.setCoords=function(e){this._latLng=new google.maps.LatLng(e[0],e[1]),this.draw()},r.draw=function(){var e=this.getProjection().fromLatLngToDivPixel(this._latLng);if(e){var n=e.x,t=e.y,o=this._style;o.left=n+"px",o.top=t+"px",this._onDraw(n,t)}},o}(google.maps.OverlayView)});var S=e.forwardRef(function(n,t){var r=n.lat,a=n.lng,i=n.onAdd,l=n.onDraw,c=n.onRemove,d=n.component,g=void 0===d?"div":d,p=n.mapPaneLayer,v=void 0===p?"overlayMouseTarget":p,E=n.preventMapDragging,h=f(n,G),D=C(),A=e.useRef({}),O=[r,a],N=[i,l,c],m=e.useCallback(function(e){var n=A.current;if(e){if(n.el!==e){var o;null==(o=n.overlay)||o.setMap(null),n.el=e,E&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(e);var r=e.style;r.position="absolute";var a=new _(r,O,N);n.overlay=a,a.setMap(D)}}else n.overlay&&(n.overlay.setMap(null),delete n.el,delete n.overlay);!function(e,n){e&&("object"==typeof e?e.current=n:e(n))}(t,e)},[t]);return e.useEffect(function(){var e=A.current,n=e.overlay;e.isNotFirstRender&&n&&n.setCallbacks(N)},N),e.useEffect(function(){var e,n=A.current;n.isNotFirstRender?null==(e=n.overlay)||e.setCoords(O):n.isNotFirstRender=!0},O),o.createPortal(u.default.createElement(g,s({ref:m},h)),D.__gm.panes[v])}),y=function(){var e;if(null!=(e=l.default.options.libraries)&&e.includes("places"))return new google.maps.places.AutocompleteService;throw Error("Places library not loaded")},M=function(e){var n;if(void 0===e&&(e=null),null!=(n=l.default.options.libraries)&&n.includes("places"))return new google.maps.places.PlacesService(e);throw Error("Places library not loaded")};Object.defineProperty(exports,"Loader",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(exports,"LoaderStatus",{enumerable:!0,get:function(){return t.LoaderStatus}}),exports.GoogleMapLoader=function(e){var n=m(e),t=e.children;return t?u.default.createElement(L.Provider,{value:n},t):null},exports.OverlayView=S,exports.createGoogleMapComponent=A,exports.createMarkerComponent=N,exports.useAutocompleteService=function(n){var o=e.useState(function(){return l.default.status===t.LoaderStatus.LOADED?y():void 0}),r=o[0],a=o[1];return e.useEffect(function(){r||(n?l.default.load():l.default.completion).then(function(){return a(y())})},[]),r},exports.useGoogleMap=C,exports.useGoogleMapLoader=m,exports.useGoogleMapStatus=function(){return e.useContext(L)},exports.useMarkerCluster=function(n,t,o){var r,a,u=(r=function(){return new c.default(t,o)},(a=e.useRef()).current||(a.current=r())),i=e.useState([]),l=i[0][0],s=i[1],d=e.useRef();return e.useEffect(function(){return function(){return u.cleanUp()}},[]),e.useEffect(function(){var e=function(){var e=d.current;e&&s([function(){return u.getPoints.apply(u,e.concat([].slice.call(arguments)))}])};if(null!=o&&o.asyncMode)return u.loadAsync(n).then(e),function(){var e;n!==u.points&&(null==(e=u.worker)||e.terminate(),u.worker=void 0)};u.load(n),e()},[n]),{handleBoundsChange:function(e,n){var t=e.getSouthWest(),o=e.getNorthEast(),r=[n.getZoom(),t.lng(),t.lat(),o.lng(),o.lat()];d.current=r,u.points&&s([function(e,n,t){return u.getPoints.apply(u,r.concat([e,n,t]))}])},getPoints:l,markerCluster:u}},exports.usePlacesService=function(n,o){void 0===o&&(o=null);var r=e.useState(function(){return"function"!=typeof o&&l.default.status===t.LoaderStatus.LOADED?M(o):void 0}),a=r[0],u=r[1];return e.useEffect(function(){a||(n?l.default.load():l.default.completion).then(function(){return u(M("function"!=typeof o?o:o()))})},[]),a}; | ||
var e=require("react"),n=require("fast-deep-equal"),t=require("google-maps-js-api-loader"),r=require("react-dom"),o=require("marker-cluster");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=/*#__PURE__*/a(e),i=/*#__PURE__*/a(n),c=/*#__PURE__*/a(t),l=/*#__PURE__*/a(o);function s(){return s=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},s.apply(this,arguments)}function f(e,n){return f=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},f(e,n)}function d(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n.indexOf(t=a[r])>=0||(o[t]=e[t]);return o}var g,p=e.createContext(null),v=function(){return e.useContext(p)};!function(e){e.CLICK="click",e.CONTEXT_MENU="contextmenu",e.DOUBLE_CLICK="dblclick",e.DRAG="drag",e.DRAG_END="dragend",e.DRAG_START="dragstart",e.MOUSE_MOVE="mousemove",e.MOUSE_OUT="mouseout",e.MOUSE_OVER="mouseover",e.RIGHT_CLICK="rightclick",e.BOUNDS_CHANGED="bounds_changed",e.CENTER_CHANGED="center_changed",e.HEADING_CHANGED="heading_changed",e.IDLE="idle",e.MAP_TYPE_ID_CHANGED="maptypeid_changed",e.PROJECTION_CHANGED="projection_changed",e.RESIZE="resize",e.TILES_LOADED="tilesloaded",e.TILT_CHANGED="tilt_changed",e.ZOOM_CHANGED="zoom_changed",e.ANIMATION_CHANGED="animation_changed",e.CLICKABLE_CHANGED="clickable_changed",e.CURSOR_CHANGED="cursor_changed",e.DRAGGABLE_CHANGED="draggable_changed",e.FLAT_CHANGED="flat_changed",e.ICON_CHANGED="icon_changed",e.MOUSE_DOWN="mousedown",e.MOUSE_UP="mouseup",e.POSITION_CHANGED="position_changed",e.SHAPE_CHANGED="shape_changed",e.TITLE_CHANGED="title_changed",e.VISIBLE_CHANGED="visible_changed",e.Z_INDEX_CHANGED="zindex_changed"}(g||(g={}));var C=Object.freeze({onClick:g.CLICK,onDoubleClick:g.DOUBLE_CLICK,onDrag:g.DRAG,onDragEnd:g.DRAG_END,onDragStart:g.DRAG_START,onContextMenu:g.CONTEXT_MENU,onMouseMove:g.MOUSE_MOVE,onMouseOut:g.MOUSE_OUT,onMouseOver:g.MOUSE_OVER,onRightClick:g.RIGHT_CLICK,onBoundsChanged:g.BOUNDS_CHANGED,onCenterChanged:g.CENTER_CHANGED,onHeadingChanged:g.HEADING_CHANGED,onIdle:g.IDLE,onMapTypeIdChanged:g.MAP_TYPE_ID_CHANGED,onProjectionChanged:g.PROJECTION_CHANGED,onResize:g.RESIZE,onTilesLoaded:g.TILES_LOADED,onTiltChanged:g.TILT_CHANGED,onZoomChanged:g.ZOOM_CHANGED,onAnimationChanged:g.ANIMATION_CHANGED,onClickableChanged:g.CLICKABLE_CHANGED,onCursorChanged:g.CURSOR_CHANGED,onDraggableChanged:g.DRAGGABLE_CHANGED,onFlatChanged:g.FLAT_CHANGED,onIconChanged:g.ICON_CHANGED,onMouseDown:g.MOUSE_DOWN,onMouseUp:g.MOUSE_UP,onPositionChanged:g.POSITION_CHANGED,onShapeChanged:g.SHAPE_CHANGED,onTitleChanged:g.TITLE_CHANGED,onVisibleChanged:g.VISIBLE_CHANGED,onZIndexChanged:g.Z_INDEX_CHANGED}),E=function(){};function h(n,t){return void 0===t&&(t={}),function(r,o){return n(function(n,t,r){if(0===t.length&&0===n.length)return E;n=Array.from(new Set(n)).reverse();var o=(t=Array.from(new Set(t)).reverse()).length,a=function(n,r){var a=e.useRef([]);e.useEffect(function(){var e=n.current;if(e){var u=a.current;if(u.length)for(var c=o;c--;){var l=t[c],s=r[l];i.default(s,u[c])||(e.set(l,s),u[c]=s)}else for(var f=o;f--;)u[f]=r[t[f]]}})};if(0===n.length)return a;var u=function(t,o){for(var a=function(a){var u=n[a],i=o[u];e.useEffect(function(){var e=t.current;if(e&&i){var n=r[u],o=e.addListener(C[u],n?function(){i.apply(void 0,[this.get(n)].concat([].slice.call(arguments),[this]))}:function(){i.apply(void 0,[].slice.call(arguments).concat([this]))});return function(){return o.remove()}}},[i])},u=n.length;u--;)a(u)};if(0===o)return u;for(var c=[],l=n.length;l--;){var s=n[l],f=r[s];f&&t.includes(f)&&(c.push(s),n.splice(l,1))}var d=c.length;return 0===d?function(e,n){u(e,n),a(e,n)}:(0===n.length&&(u=E),function(n,a){var l=e.useRef({isTriggeredBySetStateMap:new Map,prevStateArr:[]});u(n,a);for(var s=l.current.isTriggeredBySetStateMap,f=function(t){var o=c[t],u=a[o];e.useEffect(function(){var e=n.current;if(e&&u){var t=r[o],a=e.addListener(C[o],function(){s.has(t)?s.delete(t):u.apply(void 0,[this.get(t)].concat([].slice.call(arguments),[this]))});return function(){return a.remove()}}},[u])},g=d;g--;)f(g);e.useEffect(function(){var e=n.current;if(e){var r=l.current.prevStateArr;if(r.length)for(var u=o;u--;){var c=t[u],f=a[c];i.default(f,r[u])||(s.set(c,!0),e.set(c,f),r[u]=f)}else for(var d=o;d--;)r[d]=a[t[d]]}})})}(r,o,t))}}var _,D=["children","className","style","defaultOptions","onMount","onUnmount"],A=h(function(n){return function(t){var r=t.children,o=t.className,a=t.style,i=t.defaultOptions,c=t.onMount,l=t.onUnmount,f=d(t,D),g=e.useRef(null),v=e.useRef(),C=e.useState(),h=C[0],_=C[1];return e.useEffect(function(){var e=new google.maps.Map(g.current,s({},i,f));return v.current=e,google.maps.event.addListenerOnce(e,"idle",function(){_(e),(c||E)(e)}),l},[]),n(v,f),u.default.createElement("div",{ref:g,className:o,style:a},r&&h&&u.default.createElement(p.Provider,{value:h},"function"==typeof r?r(h):r))}},{onCenterChanged:"center",onHeadingChanged:"heading",onMapTypeIdChanged:"mapTypeId",onTiltChanged:"tilt",onZoomChanged:"zoom",onBoundsChanged:"bounds"}),m=["defaultOptions","onMount","onUnmount"],O=h(function(n){return function(t){var r=t.defaultOptions,o=t.onMount,a=t.onUnmount,u=d(t,m),i=v(),c=e.useRef();return e.useEffect(function(){var e=new google.maps.Marker(s({map:i},r,u));return c.current=e,(o||E)(e),function(){e.setMap(null),(a||E)()}},[]),n(c,u),null}},{onAnimationChanged:"animation",onCursorChanged:"cursor",onDraggableChanged:"draggable",onIconChanged:"icon",onPositionChanged:"position",onShapeChanged:"shape",onTitleChanged:"title",onVisibleChanged:"visible",onZIndexChanged:"zIndex"}),N=function(n){void 0===n&&(n={});var r=e.useState(c.default.status),o=r[0],a=r[1];return e.useEffect(function(){o!==t.LoaderStatus.LOADED&&c.default.load().then(function(){a(t.LoaderStatus.LOADED),(n.onLoaded||E)()},function(e){a(t.LoaderStatus.ERROR),(n.onError||E)(e)})},[]),o},y=e.createContext(c.default.status),G=["lat","lng","onAdd","onDraw","onRemove","component","mapPaneLayer","preventMapDragging"];c.default.completion.then(function(){_=/*#__PURE__*/function(e){var n,t;function r(n,t,r){var o;return(o=e.call(this)||this)._style=void 0,o._latLng=void 0,o._onDraw=void 0,o._style=n,o._latLng=new google.maps.LatLng(t[0],t[1]),o.setCallbacks(r),o}t=e,(n=r).prototype=Object.create(t.prototype),n.prototype.constructor=n,f(n,t);var o=r.prototype;return o.setCallbacks=function(e){this.onAdd=e[0]||E,this._onDraw=e[1]||E,this.onRemove=e[2]||E},o.setCoords=function(e){this._latLng=new google.maps.LatLng(e[0],e[1]),this.draw()},o.draw=function(){var e=this.getProjection().fromLatLngToDivPixel(this._latLng);if(e){var n=e.x,t=e.y,r=this._style;r.left=n+"px",r.top=t+"px",this._onDraw(n,t)}},r}(google.maps.OverlayView)});var L=e.forwardRef(function(n,t){var o=n.lat,a=n.lng,i=n.onAdd,c=n.onDraw,l=n.onRemove,f=n.component,g=void 0===f?"div":f,p=n.mapPaneLayer,C=void 0===p?"overlayMouseTarget":p,E=n.preventMapDragging,h=d(n,G),D=v(),A=e.useRef({}),m=[o,a],O=[i,c,l],N=e.useCallback(function(e){var n=A.current;if(e){if(n.el!==e){var r;null==(r=n.overlay)||r.setMap(null),n.el=e,E&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(e);var o=e.style;o.position="absolute";var a=new _(o,m,O);n.overlay=a,a.setMap(D)}}else n.overlay&&(n.overlay.setMap(null),delete n.el,delete n.overlay);!function(e,n){e&&("object"==typeof e?e.current=n:e(n))}(t,e)},[t]);return e.useEffect(function(){var e=A.current,n=e.overlay;e.isNotFirstRender&&n&&n.setCallbacks(O)},O),e.useEffect(function(){var e,n=A.current;n.isNotFirstRender?null==(e=n.overlay)||e.setCoords(m):n.isNotFirstRender=!0},m),r.createPortal(u.default.createElement(g,s({ref:N},h)),D.__gm.panes[C])}),M=function(n){var t=e.useRef();return t.current||(t.current=n())},S=function(e,n,t){var r=e[n].bind(e);return Object.defineProperty(t,n,{value:r,writable:!1,configurable:!1}),r},I=function(e,n){for(var r,o,a={},u=function(u){var i=n[u];Object.defineProperty(a,i,{get:function(){if(c.default.status===t.LoaderStatus.LOADED)return r||(r=e()),S(r,i,a);var n;o||(o=c.default.completion.then(function(){return r=e()}));var u=function(){try{var e=function(){return n.apply(void 0,[].slice.call(t))},t=arguments,r=function(){if(!n)return Promise.resolve(o).then(function(e){n=S(e,i,a)})}();return Promise.resolve(r&&r.then?r.then(e):e(r))}catch(e){return Promise.reject(e)}};return Object.defineProperty(a,i,{value:u,configurable:!0}),u},configurable:!0})},i=n.length;i--;)u(i);return a};Object.defineProperty(exports,"Loader",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(exports,"LoaderStatus",{enumerable:!0,get:function(){return t.LoaderStatus}}),exports.GoogleMapLoader=function(e){var n=N(e),t=e.children;return t?u.default.createElement(y.Provider,{value:n},t):null},exports.OverlayView=L,exports.createGoogleMapComponent=A,exports.createMarkerComponent=O,exports.useAutocompleteService=function(){return M(function(){return I(function(){return new google.maps.places.AutocompleteService},["getPlacePredictions","getQueryPredictions"])})},exports.useGeocoder=function(){return M(function(){return I(function(){return new google.maps.Geocoder},["geocode"])})},exports.useGoogleMap=v,exports.useGoogleMapLoader=N,exports.useGoogleMapStatus=function(){return e.useContext(y)},exports.useMarkerCluster=function(n,t,r){var o=M(function(){return new l.default(t,r)}),a=e.useState([]),u=a[0][0],i=a[1],c=e.useRef();return e.useEffect(function(){return function(){return o.cleanUp()}},[]),e.useEffect(function(){var e=function(){var e=c.current;e&&i([function(){return o.getPoints.apply(o,e.concat([].slice.call(arguments)))}])};if(null!=r&&r.asyncMode)return o.loadAsync(n).then(e),function(){var e;n!==o.points&&(null==(e=o.worker)||e.terminate(),o.worker=void 0)};o.load(n),e()},[n]),{handleBoundsChange:function(e,n){var t=e.getSouthWest(),r=e.getNorthEast(),a=[n.getZoom(),t.lng(),t.lat(),r.lng(),r.lat()];c.current=a,o.points&&i([function(e,n,t){return o.getPoints.apply(o,a.concat([e,n,t]))}])},getPoints:u,markerCluster:o}},exports.usePlacesService=function(n){void 0===n&&(n=null);var t=function(){return I(function(){return new google.maps.places.PlacesService(n)},["findPlaceFromPhoneNumber","findPlaceFromQuery","getDetails","nearbySearch","textSearch"])};if("function"!=typeof n)return e.useMemo(t,[n]);var r=e.useState(),o=r[0],a=r[1],u=e.useRef();return e.useEffect(function(){var e=n();u.current!==e&&(u.current=e,a(t()))}),o}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import n,{createContext as e,useContext as t,useRef as o,useEffect as r,useState as a,forwardRef as i,useCallback as l}from"react";import u from"fast-deep-equal";import c,{LoaderStatus as s}from"google-maps-js-api-loader";export{default as Loader,LoaderStatus}from"google-maps-js-api-loader";import{createPortal as d}from"react-dom";import g from"marker-cluster";function f(){return f=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},f.apply(this,arguments)}function v(n,e){return v=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n},v(n,e)}function p(n,e){if(null==n)return{};var t,o,r={},a=Object.keys(n);for(o=0;o<a.length;o++)e.indexOf(t=a[o])>=0||(r[t]=n[t]);return r}var C,h=e(null),E=function(){return t(h)};!function(n){n.CLICK="click",n.CONTEXT_MENU="contextmenu",n.DOUBLE_CLICK="dblclick",n.DRAG="drag",n.DRAG_END="dragend",n.DRAG_START="dragstart",n.MOUSE_MOVE="mousemove",n.MOUSE_OUT="mouseout",n.MOUSE_OVER="mouseover",n.RIGHT_CLICK="rightclick",n.BOUNDS_CHANGED="bounds_changed",n.CENTER_CHANGED="center_changed",n.HEADING_CHANGED="heading_changed",n.IDLE="idle",n.MAP_TYPE_ID_CHANGED="maptypeid_changed",n.PROJECTION_CHANGED="projection_changed",n.RESIZE="resize",n.TILES_LOADED="tilesloaded",n.TILT_CHANGED="tilt_changed",n.ZOOM_CHANGED="zoom_changed",n.ANIMATION_CHANGED="animation_changed",n.CLICKABLE_CHANGED="clickable_changed",n.CURSOR_CHANGED="cursor_changed",n.DRAGGABLE_CHANGED="draggable_changed",n.FLAT_CHANGED="flat_changed",n.ICON_CHANGED="icon_changed",n.MOUSE_DOWN="mousedown",n.MOUSE_UP="mouseup",n.POSITION_CHANGED="position_changed",n.SHAPE_CHANGED="shape_changed",n.TITLE_CHANGED="title_changed",n.VISIBLE_CHANGED="visible_changed",n.Z_INDEX_CHANGED="zindex_changed"}(C||(C={}));var _=Object.freeze({onClick:C.CLICK,onDoubleClick:C.DOUBLE_CLICK,onDrag:C.DRAG,onDragEnd:C.DRAG_END,onDragStart:C.DRAG_START,onContextMenu:C.CONTEXT_MENU,onMouseMove:C.MOUSE_MOVE,onMouseOut:C.MOUSE_OUT,onMouseOver:C.MOUSE_OVER,onRightClick:C.RIGHT_CLICK,onBoundsChanged:C.BOUNDS_CHANGED,onCenterChanged:C.CENTER_CHANGED,onHeadingChanged:C.HEADING_CHANGED,onIdle:C.IDLE,onMapTypeIdChanged:C.MAP_TYPE_ID_CHANGED,onProjectionChanged:C.PROJECTION_CHANGED,onResize:C.RESIZE,onTilesLoaded:C.TILES_LOADED,onTiltChanged:C.TILT_CHANGED,onZoomChanged:C.ZOOM_CHANGED,onAnimationChanged:C.ANIMATION_CHANGED,onClickableChanged:C.CLICKABLE_CHANGED,onCursorChanged:C.CURSOR_CHANGED,onDraggableChanged:C.DRAGGABLE_CHANGED,onFlatChanged:C.FLAT_CHANGED,onIconChanged:C.ICON_CHANGED,onMouseDown:C.MOUSE_DOWN,onMouseUp:C.MOUSE_UP,onPositionChanged:C.POSITION_CHANGED,onShapeChanged:C.SHAPE_CHANGED,onTitleChanged:C.TITLE_CHANGED,onVisibleChanged:C.VISIBLE_CHANGED,onZIndexChanged:C.Z_INDEX_CHANGED}),D=function(){};function A(n,e){return void 0===e&&(e={}),function(t,a){return n(function(n,e,t){if(0===e.length&&0===n.length)return D;n=Array.from(new Set(n)).reverse();var a=(e=Array.from(new Set(e)).reverse()).length,i=function(n,t){var i=o([]);r(function(){var o=n.current;if(o){var r=i.current;if(r.length)for(var l=a;l--;){var c=e[l],s=t[c];u(s,r[l])||(o.set(c,s),r[l]=s)}else for(var d=a;d--;)r[d]=t[e[d]]}})};if(0===n.length)return i;var l=function(e,o){for(var a=function(a){var i=n[a],l=o[i];r(function(){var n=e.current;if(n&&l){var o=t[i],r=n.addListener(_[i],o?function(){l.apply(void 0,[this.get(o)].concat([].slice.call(arguments),[this]))}:function(){l.apply(void 0,[].slice.call(arguments).concat([this]))});return function(){return r.remove()}}},[l])},i=n.length;i--;)a(i)};if(0===a)return l;for(var c=[],s=n.length;s--;){var d=n[s],g=t[d];g&&e.includes(g)&&(c.push(d),n.splice(s,1))}var f=c.length;return 0===f?function(n,e){l(n,e),i(n,e)}:(0===n.length&&(l=D),function(n,i){var s=o({isTriggeredBySetStateMap:new Map,prevStateArr:[]});l(n,i);for(var d=s.current.isTriggeredBySetStateMap,g=function(e){var o=c[e],a=i[o];r(function(){var e=n.current;if(e&&a){var r=t[o],i=e.addListener(_[o],function(){d.has(r)?d.delete(r):a.apply(void 0,[this.get(r)].concat([].slice.call(arguments),[this]))});return function(){return i.remove()}}},[a])},v=f;v--;)g(v);r(function(){var t=n.current;if(t){var o=s.current.prevStateArr;if(o.length)for(var r=a;r--;){var l=e[r],c=i[l];u(c,o[r])||(d.set(l,!0),t.set(l,c),o[r]=c)}else for(var g=a;g--;)o[g]=i[e[g]]}})})}(t,a,e))}}var m,N=["children","className","style","defaultOptions","onMount","onUnmount"],O=A(function(e){return function(t){var i=t.children,l=t.className,u=t.style,c=t.defaultOptions,s=t.onMount,d=t.onUnmount,g=p(t,N),v=o(null),C=o(),E=a(),_=E[0],A=E[1];return r(function(){var n=new google.maps.Map(v.current,f({},c,g));return C.current=n,google.maps.event.addListenerOnce(n,"idle",function(){A(n),(s||D)(n)}),d},[]),e(C,g),n.createElement("div",{ref:v,className:l,style:u},i&&_&&n.createElement(h.Provider,{value:_},"function"==typeof i?i(_):i))}},{onCenterChanged:"center",onHeadingChanged:"heading",onMapTypeIdChanged:"mapTypeId",onTiltChanged:"tilt",onZoomChanged:"zoom",onBoundsChanged:"bounds"}),G=["defaultOptions","onMount","onUnmount"],I=A(function(n){return function(e){var t=e.defaultOptions,a=e.onMount,i=e.onUnmount,l=p(e,G),u=E(),c=o();return r(function(){var n=new google.maps.Marker(f({map:u},t,l));return c.current=n,(a||D)(n),function(){n.setMap(null),(i||D)()}},[]),n(c,l),null}},{onAnimationChanged:"animation",onCursorChanged:"cursor",onDraggableChanged:"draggable",onIconChanged:"icon",onPositionChanged:"position",onShapeChanged:"shape",onTitleChanged:"title",onVisibleChanged:"visible",onZIndexChanged:"zIndex"}),L=function(n){void 0===n&&(n={});var e=a(c.status),t=e[0],o=e[1];return r(function(){t!==s.LOADED&&c.load().then(function(){o(s.LOADED),(n.onLoaded||D)()},function(e){o(s.ERROR),(n.onError||D)(e)})},[]),t},y=e(c.status),M=function(){return t(y)},T=function(e){var t=L(e),o=e.children;return o?n.createElement(y.Provider,{value:t},o):null},H=["lat","lng","onAdd","onDraw","onRemove","component","mapPaneLayer","preventMapDragging"];c.completion.then(function(){m=/*#__PURE__*/function(n){var e,t;function o(e,t,o){var r;return(r=n.call(this)||this)._style=void 0,r._latLng=void 0,r._onDraw=void 0,r._style=e,r._latLng=new google.maps.LatLng(t[0],t[1]),r.setCallbacks(o),r}t=n,(e=o).prototype=Object.create(t.prototype),e.prototype.constructor=e,v(e,t);var r=o.prototype;return r.setCallbacks=function(n){this.onAdd=n[0]||D,this._onDraw=n[1]||D,this.onRemove=n[2]||D},r.setCoords=function(n){this._latLng=new google.maps.LatLng(n[0],n[1]),this.draw()},r.draw=function(){var n=this.getProjection().fromLatLngToDivPixel(this._latLng);if(n){var e=n.x,t=n.y,o=this._style;o.left=e+"px",o.top=t+"px",this._onDraw(e,t)}},o}(google.maps.OverlayView)});var S=i(function(e,t){var a=e.lat,i=e.lng,u=e.onAdd,c=e.onDraw,s=e.onRemove,g=e.component,v=void 0===g?"div":g,C=e.mapPaneLayer,h=void 0===C?"overlayMouseTarget":C,_=e.preventMapDragging,D=p(e,H),A=E(),N=o({}),O=[a,i],G=[u,c,s],I=l(function(n){var e=N.current;if(n){if(e.el!==n){var o;null==(o=e.overlay)||o.setMap(null),e.el=n,_&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(n);var r=n.style;r.position="absolute";var a=new m(r,O,G);e.overlay=a,a.setMap(A)}}else e.overlay&&(e.overlay.setMap(null),delete e.el,delete e.overlay);!function(n,e){n&&("object"==typeof n?n.current=e:n(e))}(t,n)},[t]);return r(function(){var n=N.current,e=n.overlay;n.isNotFirstRender&&e&&e.setCallbacks(G)},G),r(function(){var n,e=N.current;e.isNotFirstRender?null==(n=e.overlay)||n.setCoords(O):e.isNotFirstRender=!0},O),d(n.createElement(v,f({ref:I},D)),A.__gm.panes[h])}),R=function(n,e,t){var i,l,u=(i=function(){return new g(e,t)},(l=o()).current||(l.current=i())),c=a([]),s=c[0][0],d=c[1],f=o();return r(function(){return function(){return u.cleanUp()}},[]),r(function(){var e=function(){var n=f.current;n&&d([function(){return u.getPoints.apply(u,n.concat([].slice.call(arguments)))}])};if(null!=t&&t.asyncMode)return u.loadAsync(n).then(e),function(){var e;n!==u.points&&(null==(e=u.worker)||e.terminate(),u.worker=void 0)};u.load(n),e()},[n]),{handleBoundsChange:function(n,e){var t=n.getSouthWest(),o=n.getNorthEast(),r=[e.getZoom(),t.lng(),t.lat(),o.lng(),o.lat()];f.current=r,u.points&&d([function(n,e,t){return u.getPoints.apply(u,r.concat([n,e,t]))}])},getPoints:s,markerCluster:u}},b=function(){var n;if(null!=(n=c.options.libraries)&&n.includes("places"))return new google.maps.places.AutocompleteService;throw Error("Places library not loaded")},P=function(n){var e=a(function(){return c.status===s.LOADED?b():void 0}),t=e[0],o=e[1];return r(function(){t||(n?c.load():c.completion).then(function(){return o(b())})},[]),t},U=function(n){var e;if(void 0===n&&(n=null),null!=(e=c.options.libraries)&&e.includes("places"))return new google.maps.places.PlacesService(n);throw Error("Places library not loaded")},w=function(n,e){void 0===e&&(e=null);var t=a(function(){return"function"!=typeof e&&c.status===s.LOADED?U(e):void 0}),o=t[0],i=t[1];return r(function(){o||(n?c.load():c.completion).then(function(){return i(U("function"!=typeof e?e:e()))})},[]),o};export{T as GoogleMapLoader,S as OverlayView,O as createGoogleMapComponent,I as createMarkerComponent,P as useAutocompleteService,E as useGoogleMap,L as useGoogleMapLoader,M as useGoogleMapStatus,R as useMarkerCluster,w as usePlacesService}; | ||
import n,{createContext as e,useContext as t,useRef as r,useEffect as o,useState as a,forwardRef as i,useCallback as u,useMemo as c}from"react";import l from"fast-deep-equal";import s,{LoaderStatus as d}from"google-maps-js-api-loader";export{default as Loader,LoaderStatus}from"google-maps-js-api-loader";import{createPortal as g}from"react-dom";import f from"marker-cluster";function v(){return v=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},v.apply(this,arguments)}function p(n,e){return p=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n},p(n,e)}function C(n,e){if(null==n)return{};var t,r,o={},a=Object.keys(n);for(r=0;r<a.length;r++)e.indexOf(t=a[r])>=0||(o[t]=n[t]);return o}var h,E=e(null),_=function(){return t(E)};!function(n){n.CLICK="click",n.CONTEXT_MENU="contextmenu",n.DOUBLE_CLICK="dblclick",n.DRAG="drag",n.DRAG_END="dragend",n.DRAG_START="dragstart",n.MOUSE_MOVE="mousemove",n.MOUSE_OUT="mouseout",n.MOUSE_OVER="mouseover",n.RIGHT_CLICK="rightclick",n.BOUNDS_CHANGED="bounds_changed",n.CENTER_CHANGED="center_changed",n.HEADING_CHANGED="heading_changed",n.IDLE="idle",n.MAP_TYPE_ID_CHANGED="maptypeid_changed",n.PROJECTION_CHANGED="projection_changed",n.RESIZE="resize",n.TILES_LOADED="tilesloaded",n.TILT_CHANGED="tilt_changed",n.ZOOM_CHANGED="zoom_changed",n.ANIMATION_CHANGED="animation_changed",n.CLICKABLE_CHANGED="clickable_changed",n.CURSOR_CHANGED="cursor_changed",n.DRAGGABLE_CHANGED="draggable_changed",n.FLAT_CHANGED="flat_changed",n.ICON_CHANGED="icon_changed",n.MOUSE_DOWN="mousedown",n.MOUSE_UP="mouseup",n.POSITION_CHANGED="position_changed",n.SHAPE_CHANGED="shape_changed",n.TITLE_CHANGED="title_changed",n.VISIBLE_CHANGED="visible_changed",n.Z_INDEX_CHANGED="zindex_changed"}(h||(h={}));var D=Object.freeze({onClick:h.CLICK,onDoubleClick:h.DOUBLE_CLICK,onDrag:h.DRAG,onDragEnd:h.DRAG_END,onDragStart:h.DRAG_START,onContextMenu:h.CONTEXT_MENU,onMouseMove:h.MOUSE_MOVE,onMouseOut:h.MOUSE_OUT,onMouseOver:h.MOUSE_OVER,onRightClick:h.RIGHT_CLICK,onBoundsChanged:h.BOUNDS_CHANGED,onCenterChanged:h.CENTER_CHANGED,onHeadingChanged:h.HEADING_CHANGED,onIdle:h.IDLE,onMapTypeIdChanged:h.MAP_TYPE_ID_CHANGED,onProjectionChanged:h.PROJECTION_CHANGED,onResize:h.RESIZE,onTilesLoaded:h.TILES_LOADED,onTiltChanged:h.TILT_CHANGED,onZoomChanged:h.ZOOM_CHANGED,onAnimationChanged:h.ANIMATION_CHANGED,onClickableChanged:h.CLICKABLE_CHANGED,onCursorChanged:h.CURSOR_CHANGED,onDraggableChanged:h.DRAGGABLE_CHANGED,onFlatChanged:h.FLAT_CHANGED,onIconChanged:h.ICON_CHANGED,onMouseDown:h.MOUSE_DOWN,onMouseUp:h.MOUSE_UP,onPositionChanged:h.POSITION_CHANGED,onShapeChanged:h.SHAPE_CHANGED,onTitleChanged:h.TITLE_CHANGED,onVisibleChanged:h.VISIBLE_CHANGED,onZIndexChanged:h.Z_INDEX_CHANGED}),m=function(){};function A(n,e){return void 0===e&&(e={}),function(t,a){return n(function(n,e,t){if(0===e.length&&0===n.length)return m;n=Array.from(new Set(n)).reverse();var a=(e=Array.from(new Set(e)).reverse()).length,i=function(n,t){var i=r([]);o(function(){var r=n.current;if(r){var o=i.current;if(o.length)for(var u=a;u--;){var c=e[u],s=t[c];l(s,o[u])||(r.set(c,s),o[u]=s)}else for(var d=a;d--;)o[d]=t[e[d]]}})};if(0===n.length)return i;var u=function(e,r){for(var a=function(a){var i=n[a],u=r[i];o(function(){var n=e.current;if(n&&u){var r=t[i],o=n.addListener(D[i],r?function(){u.apply(void 0,[this.get(r)].concat([].slice.call(arguments),[this]))}:function(){u.apply(void 0,[].slice.call(arguments).concat([this]))});return function(){return o.remove()}}},[u])},i=n.length;i--;)a(i)};if(0===a)return u;for(var c=[],s=n.length;s--;){var d=n[s],g=t[d];g&&e.includes(g)&&(c.push(d),n.splice(s,1))}var f=c.length;return 0===f?function(n,e){u(n,e),i(n,e)}:(0===n.length&&(u=m),function(n,i){var s=r({isTriggeredBySetStateMap:new Map,prevStateArr:[]});u(n,i);for(var d=s.current.isTriggeredBySetStateMap,g=function(e){var r=c[e],a=i[r];o(function(){var e=n.current;if(e&&a){var o=t[r],i=e.addListener(D[r],function(){d.has(o)?d.delete(o):a.apply(void 0,[this.get(o)].concat([].slice.call(arguments),[this]))});return function(){return i.remove()}}},[a])},v=f;v--;)g(v);o(function(){var t=n.current;if(t){var r=s.current.prevStateArr;if(r.length)for(var o=a;o--;){var u=e[o],c=i[u];l(c,r[o])||(d.set(u,!0),t.set(u,c),r[o]=c)}else for(var g=a;g--;)r[g]=i[e[g]]}})})}(t,a,e))}}var N,O=["children","className","style","defaultOptions","onMount","onUnmount"],y=A(function(e){return function(t){var i=t.children,u=t.className,c=t.style,l=t.defaultOptions,s=t.onMount,d=t.onUnmount,g=C(t,O),f=r(null),p=r(),h=a(),_=h[0],D=h[1];return o(function(){var n=new google.maps.Map(f.current,v({},l,g));return p.current=n,google.maps.event.addListenerOnce(n,"idle",function(){D(n),(s||m)(n)}),d},[]),e(p,g),n.createElement("div",{ref:f,className:u,style:c},i&&_&&n.createElement(E.Provider,{value:_},"function"==typeof i?i(_):i))}},{onCenterChanged:"center",onHeadingChanged:"heading",onMapTypeIdChanged:"mapTypeId",onTiltChanged:"tilt",onZoomChanged:"zoom",onBoundsChanged:"bounds"}),G=["defaultOptions","onMount","onUnmount"],I=A(function(n){return function(e){var t=e.defaultOptions,a=e.onMount,i=e.onUnmount,u=C(e,G),c=_(),l=r();return o(function(){var n=new google.maps.Marker(v({map:c},t,u));return l.current=n,(a||m)(n),function(){n.setMap(null),(i||m)()}},[]),n(l,u),null}},{onAnimationChanged:"animation",onCursorChanged:"cursor",onDraggableChanged:"draggable",onIconChanged:"icon",onPositionChanged:"position",onShapeChanged:"shape",onTitleChanged:"title",onVisibleChanged:"visible",onZIndexChanged:"zIndex"}),L=function(n){void 0===n&&(n={});var e=a(s.status),t=e[0],r=e[1];return o(function(){t!==d.LOADED&&s.load().then(function(){r(d.LOADED),(n.onLoaded||m)()},function(e){r(d.ERROR),(n.onError||m)(e)})},[]),t},M=e(s.status),T=function(){return t(M)},H=function(e){var t=L(e),r=e.children;return r?n.createElement(M.Provider,{value:t},r):null},S=["lat","lng","onAdd","onDraw","onRemove","component","mapPaneLayer","preventMapDragging"];s.completion.then(function(){N=/*#__PURE__*/function(n){var e,t;function r(e,t,r){var o;return(o=n.call(this)||this)._style=void 0,o._latLng=void 0,o._onDraw=void 0,o._style=e,o._latLng=new google.maps.LatLng(t[0],t[1]),o.setCallbacks(r),o}t=n,(e=r).prototype=Object.create(t.prototype),e.prototype.constructor=e,p(e,t);var o=r.prototype;return o.setCallbacks=function(n){this.onAdd=n[0]||m,this._onDraw=n[1]||m,this.onRemove=n[2]||m},o.setCoords=function(n){this._latLng=new google.maps.LatLng(n[0],n[1]),this.draw()},o.draw=function(){var n=this.getProjection().fromLatLngToDivPixel(this._latLng);if(n){var e=n.x,t=n.y,r=this._style;r.left=e+"px",r.top=t+"px",this._onDraw(e,t)}},r}(google.maps.OverlayView)});var P=i(function(e,t){var a=e.lat,i=e.lng,c=e.onAdd,l=e.onDraw,s=e.onRemove,d=e.component,f=void 0===d?"div":d,p=e.mapPaneLayer,h=void 0===p?"overlayMouseTarget":p,E=e.preventMapDragging,D=C(e,S),m=_(),A=r({}),O=[a,i],y=[c,l,s],G=u(function(n){var e=A.current;if(n){if(e.el!==n){var r;null==(r=e.overlay)||r.setMap(null),e.el=n,E&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(n);var o=n.style;o.position="absolute";var a=new N(o,O,y);e.overlay=a,a.setMap(m)}}else e.overlay&&(e.overlay.setMap(null),delete e.el,delete e.overlay);!function(n,e){n&&("object"==typeof n?n.current=e:n(e))}(t,n)},[t]);return o(function(){var n=A.current,e=n.overlay;n.isNotFirstRender&&e&&e.setCallbacks(y)},y),o(function(){var n,e=A.current;e.isNotFirstRender?null==(n=e.overlay)||n.setCoords(O):e.isNotFirstRender=!0},O),g(n.createElement(f,v({ref:G},D)),m.__gm.panes[h])}),b=function(n){var e=r();return e.current||(e.current=n())},R=function(n,e,t){var i=b(function(){return new f(e,t)}),u=a([]),c=u[0][0],l=u[1],s=r();return o(function(){return function(){return i.cleanUp()}},[]),o(function(){var e=function(){var n=s.current;n&&l([function(){return i.getPoints.apply(i,n.concat([].slice.call(arguments)))}])};if(null!=t&&t.asyncMode)return i.loadAsync(n).then(e),function(){var e;n!==i.points&&(null==(e=i.worker)||e.terminate(),i.worker=void 0)};i.load(n),e()},[n]),{handleBoundsChange:function(n,e){var t=n.getSouthWest(),r=n.getNorthEast(),o=[e.getZoom(),t.lng(),t.lat(),r.lng(),r.lat()];s.current=o,i.points&&l([function(n,e,t){return i.getPoints.apply(i,o.concat([n,e,t]))}])},getPoints:c,markerCluster:i}},U=function(n,e,t){var r=n[e].bind(n);return Object.defineProperty(t,e,{value:r,writable:!1,configurable:!1}),r},w=function(n,e){for(var t,r,o={},a=function(a){var i=e[a];Object.defineProperty(o,i,{get:function(){if(s.status===d.LOADED)return t||(t=n()),U(t,i,o);var e;r||(r=s.completion.then(function(){return t=n()}));var a=function(){try{var n=function(){return e.apply(void 0,[].slice.call(t))},t=arguments,a=function(){if(!e)return Promise.resolve(r).then(function(n){e=U(n,i,o)})}();return Promise.resolve(a&&a.then?a.then(n):n(a))}catch(n){return Promise.reject(n)}};return Object.defineProperty(o,i,{value:a,configurable:!0}),a},configurable:!0})},i=e.length;i--;)a(i);return o},k=function(){return b(function(){return w(function(){return new google.maps.places.AutocompleteService},["getPlacePredictions","getQueryPredictions"])})},j=function(n){void 0===n&&(n=null);var e=function(){return w(function(){return new google.maps.places.PlacesService(n)},["findPlaceFromPhoneNumber","findPlaceFromQuery","getDetails","nearbySearch","textSearch"])};if("function"!=typeof n)return c(e,[n]);var t=a(),i=t[0],u=t[1],l=r();return o(function(){var t=n();l.current!==t&&(l.current=t,u(e()))}),i},B=function(){return b(function(){return w(function(){return new google.maps.Geocoder},["geocode"])})};export{H as GoogleMapLoader,P as OverlayView,y as createGoogleMapComponent,I as createMarkerComponent,k as useAutocompleteService,B as useGeocoder,_ as useGoogleMap,L as useGoogleMapLoader,T as useGoogleMapStatus,R as useMarkerCluster,j as usePlacesService}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("fast-deep-equal"),require("google-maps-js-api-loader"),require("react-dom"),require("marker-cluster")):"function"==typeof define&&define.amd?define(["exports","react","fast-deep-equal","google-maps-js-api-loader","react-dom","marker-cluster"],n):n((e||self).googleMapsJsApiReact={},e.react,e.fastDeepEqual,e.googleMapsJsApiLoader,e.reactDom,e.markerCluster)}(this,function(e,n,t,o,r,a){function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/u(n),l=/*#__PURE__*/u(t),c=/*#__PURE__*/u(o),s=/*#__PURE__*/u(a);function d(){return d=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},d.apply(this,arguments)}function f(e,n){return f=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},f(e,n)}function g(e,n){if(null==e)return{};var t,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)n.indexOf(t=a[o])>=0||(r[t]=e[t]);return r}var p,C=n.createContext(null),E=function(){return n.useContext(C)};!function(e){e.CLICK="click",e.CONTEXT_MENU="contextmenu",e.DOUBLE_CLICK="dblclick",e.DRAG="drag",e.DRAG_END="dragend",e.DRAG_START="dragstart",e.MOUSE_MOVE="mousemove",e.MOUSE_OUT="mouseout",e.MOUSE_OVER="mouseover",e.RIGHT_CLICK="rightclick",e.BOUNDS_CHANGED="bounds_changed",e.CENTER_CHANGED="center_changed",e.HEADING_CHANGED="heading_changed",e.IDLE="idle",e.MAP_TYPE_ID_CHANGED="maptypeid_changed",e.PROJECTION_CHANGED="projection_changed",e.RESIZE="resize",e.TILES_LOADED="tilesloaded",e.TILT_CHANGED="tilt_changed",e.ZOOM_CHANGED="zoom_changed",e.ANIMATION_CHANGED="animation_changed",e.CLICKABLE_CHANGED="clickable_changed",e.CURSOR_CHANGED="cursor_changed",e.DRAGGABLE_CHANGED="draggable_changed",e.FLAT_CHANGED="flat_changed",e.ICON_CHANGED="icon_changed",e.MOUSE_DOWN="mousedown",e.MOUSE_UP="mouseup",e.POSITION_CHANGED="position_changed",e.SHAPE_CHANGED="shape_changed",e.TITLE_CHANGED="title_changed",e.VISIBLE_CHANGED="visible_changed",e.Z_INDEX_CHANGED="zindex_changed"}(p||(p={}));var v=Object.freeze({onClick:p.CLICK,onDoubleClick:p.DOUBLE_CLICK,onDrag:p.DRAG,onDragEnd:p.DRAG_END,onDragStart:p.DRAG_START,onContextMenu:p.CONTEXT_MENU,onMouseMove:p.MOUSE_MOVE,onMouseOut:p.MOUSE_OUT,onMouseOver:p.MOUSE_OVER,onRightClick:p.RIGHT_CLICK,onBoundsChanged:p.BOUNDS_CHANGED,onCenterChanged:p.CENTER_CHANGED,onHeadingChanged:p.HEADING_CHANGED,onIdle:p.IDLE,onMapTypeIdChanged:p.MAP_TYPE_ID_CHANGED,onProjectionChanged:p.PROJECTION_CHANGED,onResize:p.RESIZE,onTilesLoaded:p.TILES_LOADED,onTiltChanged:p.TILT_CHANGED,onZoomChanged:p.ZOOM_CHANGED,onAnimationChanged:p.ANIMATION_CHANGED,onClickableChanged:p.CLICKABLE_CHANGED,onCursorChanged:p.CURSOR_CHANGED,onDraggableChanged:p.DRAGGABLE_CHANGED,onFlatChanged:p.FLAT_CHANGED,onIconChanged:p.ICON_CHANGED,onMouseDown:p.MOUSE_DOWN,onMouseUp:p.MOUSE_UP,onPositionChanged:p.POSITION_CHANGED,onShapeChanged:p.SHAPE_CHANGED,onTitleChanged:p.TITLE_CHANGED,onVisibleChanged:p.VISIBLE_CHANGED,onZIndexChanged:p.Z_INDEX_CHANGED}),h=function(){};function _(e,t){return void 0===t&&(t={}),function(o,r){return e(function(e,t,o){if(0===t.length&&0===e.length)return h;e=Array.from(new Set(e)).reverse();var r=(t=Array.from(new Set(t)).reverse()).length,a=function(e,o){var a=n.useRef([]);n.useEffect(function(){var n=e.current;if(n){var u=a.current;if(u.length)for(var i=r;i--;){var c=t[i],s=o[c];l.default(s,u[i])||(n.set(c,s),u[i]=s)}else for(var d=r;d--;)u[d]=o[t[d]]}})};if(0===e.length)return a;var u=function(t,r){for(var a=function(a){var u=e[a],i=r[u];n.useEffect(function(){var e=t.current;if(e&&i){var n=o[u],r=e.addListener(v[u],n?function(){i.apply(void 0,[this.get(n)].concat([].slice.call(arguments),[this]))}:function(){i.apply(void 0,[].slice.call(arguments).concat([this]))});return function(){return r.remove()}}},[i])},u=e.length;u--;)a(u)};if(0===r)return u;for(var i=[],c=e.length;c--;){var s=e[c],d=o[s];d&&t.includes(d)&&(i.push(s),e.splice(c,1))}var f=i.length;return 0===f?function(e,n){u(e,n),a(e,n)}:(0===e.length&&(u=h),function(e,a){var c=n.useRef({isTriggeredBySetStateMap:new Map,prevStateArr:[]});u(e,a);for(var s=c.current.isTriggeredBySetStateMap,d=function(t){var r=i[t],u=a[r];n.useEffect(function(){var n=e.current;if(n&&u){var t=o[r],a=n.addListener(v[r],function(){s.has(t)?s.delete(t):u.apply(void 0,[this.get(t)].concat([].slice.call(arguments),[this]))});return function(){return a.remove()}}},[u])},g=f;g--;)d(g);n.useEffect(function(){var n=e.current;if(n){var o=c.current.prevStateArr;if(o.length)for(var u=r;u--;){var i=t[u],d=a[i];l.default(d,o[u])||(s.set(i,!0),n.set(i,d),o[u]=d)}else for(var f=r;f--;)o[f]=a[t[f]]}})})}(o,r,t))}}var D,A=["children","className","style","defaultOptions","onMount","onUnmount"],m=_(function(e){return function(t){var o=t.children,r=t.className,a=t.style,u=t.defaultOptions,l=t.onMount,c=t.onUnmount,s=g(t,A),f=n.useRef(null),p=n.useRef(),E=n.useState(),v=E[0],_=E[1];return n.useEffect(function(){var e=new google.maps.Map(f.current,d({},u,s));return p.current=e,google.maps.event.addListenerOnce(e,"idle",function(){_(e),(l||h)(e)}),c},[]),e(p,s),i.default.createElement("div",{ref:f,className:r,style:a},o&&v&&i.default.createElement(C.Provider,{value:v},"function"==typeof o?o(v):o))}},{onCenterChanged:"center",onHeadingChanged:"heading",onMapTypeIdChanged:"mapTypeId",onTiltChanged:"tilt",onZoomChanged:"zoom",onBoundsChanged:"bounds"}),O=["defaultOptions","onMount","onUnmount"],N=_(function(e){return function(t){var o=t.defaultOptions,r=t.onMount,a=t.onUnmount,u=g(t,O),i=E(),l=n.useRef();return n.useEffect(function(){var e=new google.maps.Marker(d({map:i},o,u));return l.current=e,(r||h)(e),function(){e.setMap(null),(a||h)()}},[]),e(l,u),null}},{onAnimationChanged:"animation",onCursorChanged:"cursor",onDraggableChanged:"draggable",onIconChanged:"icon",onPositionChanged:"position",onShapeChanged:"shape",onTitleChanged:"title",onVisibleChanged:"visible",onZIndexChanged:"zIndex"}),L=function(e){void 0===e&&(e={});var t=n.useState(c.default.status),r=t[0],a=t[1];return n.useEffect(function(){r!==o.LoaderStatus.LOADED&&c.default.load().then(function(){a(o.LoaderStatus.LOADED),(e.onLoaded||h)()},function(n){a(o.LoaderStatus.ERROR),(e.onError||h)(n)})},[]),r},y=n.createContext(c.default.status),G=["lat","lng","onAdd","onDraw","onRemove","component","mapPaneLayer","preventMapDragging"];c.default.completion.then(function(){D=/*#__PURE__*/function(e){var n,t;function o(n,t,o){var r;return(r=e.call(this)||this)._style=void 0,r._latLng=void 0,r._onDraw=void 0,r._style=n,r._latLng=new google.maps.LatLng(t[0],t[1]),r.setCallbacks(o),r}t=e,(n=o).prototype=Object.create(t.prototype),n.prototype.constructor=n,f(n,t);var r=o.prototype;return r.setCallbacks=function(e){this.onAdd=e[0]||h,this._onDraw=e[1]||h,this.onRemove=e[2]||h},r.setCoords=function(e){this._latLng=new google.maps.LatLng(e[0],e[1]),this.draw()},r.draw=function(){var e=this.getProjection().fromLatLngToDivPixel(this._latLng);if(e){var n=e.x,t=e.y,o=this._style;o.left=n+"px",o.top=t+"px",this._onDraw(n,t)}},o}(google.maps.OverlayView)});var M=n.forwardRef(function(e,t){var o=e.lat,a=e.lng,u=e.onAdd,l=e.onDraw,c=e.onRemove,s=e.component,f=void 0===s?"div":s,p=e.mapPaneLayer,C=void 0===p?"overlayMouseTarget":p,v=e.preventMapDragging,h=g(e,G),_=E(),A=n.useRef({}),m=[o,a],O=[u,l,c],N=n.useCallback(function(e){var n=A.current;if(e){if(n.el!==e){var o;null==(o=n.overlay)||o.setMap(null),n.el=e,v&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(e);var r=e.style;r.position="absolute";var a=new D(r,m,O);n.overlay=a,a.setMap(_)}}else n.overlay&&(n.overlay.setMap(null),delete n.el,delete n.overlay);!function(e,n){e&&("object"==typeof e?e.current=n:e(n))}(t,e)},[t]);return n.useEffect(function(){var e=A.current,n=e.overlay;e.isNotFirstRender&&n&&n.setCallbacks(O)},O),n.useEffect(function(){var e,n=A.current;n.isNotFirstRender?null==(e=n.overlay)||e.setCoords(m):n.isNotFirstRender=!0},m),r.createPortal(i.default.createElement(f,d({ref:N},h)),_.__gm.panes[C])}),S=function(){var e;if(null!=(e=c.default.options.libraries)&&e.includes("places"))return new google.maps.places.AutocompleteService;throw Error("Places library not loaded")},I=function(e){var n;if(void 0===e&&(e=null),null!=(n=c.default.options.libraries)&&n.includes("places"))return new google.maps.places.PlacesService(e);throw Error("Places library not loaded")};Object.defineProperty(e,"Loader",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(e,"LoaderStatus",{enumerable:!0,get:function(){return o.LoaderStatus}}),e.GoogleMapLoader=function(e){var n=L(e),t=e.children;return t?i.default.createElement(y.Provider,{value:n},t):null},e.OverlayView=M,e.createGoogleMapComponent=m,e.createMarkerComponent=N,e.useAutocompleteService=function(e){var t=n.useState(function(){return c.default.status===o.LoaderStatus.LOADED?S():void 0}),r=t[0],a=t[1];return n.useEffect(function(){r||(e?c.default.load():c.default.completion).then(function(){return a(S())})},[]),r},e.useGoogleMap=E,e.useGoogleMapLoader=L,e.useGoogleMapStatus=function(){return n.useContext(y)},e.useMarkerCluster=function(e,t,o){var r,a,u=(r=function(){return new s.default(t,o)},(a=n.useRef()).current||(a.current=r())),i=n.useState([]),l=i[0][0],c=i[1],d=n.useRef();return n.useEffect(function(){return function(){return u.cleanUp()}},[]),n.useEffect(function(){var n=function(){var e=d.current;e&&c([function(){return u.getPoints.apply(u,e.concat([].slice.call(arguments)))}])};if(null!=o&&o.asyncMode)return u.loadAsync(e).then(n),function(){var n;e!==u.points&&(null==(n=u.worker)||n.terminate(),u.worker=void 0)};u.load(e),n()},[e]),{handleBoundsChange:function(e,n){var t=e.getSouthWest(),o=e.getNorthEast(),r=[n.getZoom(),t.lng(),t.lat(),o.lng(),o.lat()];d.current=r,u.points&&c([function(e,n,t){return u.getPoints.apply(u,r.concat([e,n,t]))}])},getPoints:l,markerCluster:u}},e.usePlacesService=function(e,t){void 0===t&&(t=null);var r=n.useState(function(){return"function"!=typeof t&&c.default.status===o.LoaderStatus.LOADED?I(t):void 0}),a=r[0],u=r[1];return n.useEffect(function(){a||(e?c.default.load():c.default.completion).then(function(){return u(I("function"!=typeof t?t:t()))})},[]),a}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("fast-deep-equal"),require("google-maps-js-api-loader"),require("react-dom"),require("marker-cluster")):"function"==typeof define&&define.amd?define(["exports","react","fast-deep-equal","google-maps-js-api-loader","react-dom","marker-cluster"],n):n((e||self).googleMapsJsApiReact={},e.react,e.fastDeepEqual,e.googleMapsJsApiLoader,e.reactDom,e.markerCluster)}(this,function(e,n,t,r,o,a){function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/u(n),c=/*#__PURE__*/u(t),l=/*#__PURE__*/u(r),s=/*#__PURE__*/u(a);function f(){return f=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},f.apply(this,arguments)}function d(e,n){return d=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},d(e,n)}function g(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n.indexOf(t=a[r])>=0||(o[t]=e[t]);return o}var p,v=n.createContext(null),C=function(){return n.useContext(v)};!function(e){e.CLICK="click",e.CONTEXT_MENU="contextmenu",e.DOUBLE_CLICK="dblclick",e.DRAG="drag",e.DRAG_END="dragend",e.DRAG_START="dragstart",e.MOUSE_MOVE="mousemove",e.MOUSE_OUT="mouseout",e.MOUSE_OVER="mouseover",e.RIGHT_CLICK="rightclick",e.BOUNDS_CHANGED="bounds_changed",e.CENTER_CHANGED="center_changed",e.HEADING_CHANGED="heading_changed",e.IDLE="idle",e.MAP_TYPE_ID_CHANGED="maptypeid_changed",e.PROJECTION_CHANGED="projection_changed",e.RESIZE="resize",e.TILES_LOADED="tilesloaded",e.TILT_CHANGED="tilt_changed",e.ZOOM_CHANGED="zoom_changed",e.ANIMATION_CHANGED="animation_changed",e.CLICKABLE_CHANGED="clickable_changed",e.CURSOR_CHANGED="cursor_changed",e.DRAGGABLE_CHANGED="draggable_changed",e.FLAT_CHANGED="flat_changed",e.ICON_CHANGED="icon_changed",e.MOUSE_DOWN="mousedown",e.MOUSE_UP="mouseup",e.POSITION_CHANGED="position_changed",e.SHAPE_CHANGED="shape_changed",e.TITLE_CHANGED="title_changed",e.VISIBLE_CHANGED="visible_changed",e.Z_INDEX_CHANGED="zindex_changed"}(p||(p={}));var E=Object.freeze({onClick:p.CLICK,onDoubleClick:p.DOUBLE_CLICK,onDrag:p.DRAG,onDragEnd:p.DRAG_END,onDragStart:p.DRAG_START,onContextMenu:p.CONTEXT_MENU,onMouseMove:p.MOUSE_MOVE,onMouseOut:p.MOUSE_OUT,onMouseOver:p.MOUSE_OVER,onRightClick:p.RIGHT_CLICK,onBoundsChanged:p.BOUNDS_CHANGED,onCenterChanged:p.CENTER_CHANGED,onHeadingChanged:p.HEADING_CHANGED,onIdle:p.IDLE,onMapTypeIdChanged:p.MAP_TYPE_ID_CHANGED,onProjectionChanged:p.PROJECTION_CHANGED,onResize:p.RESIZE,onTilesLoaded:p.TILES_LOADED,onTiltChanged:p.TILT_CHANGED,onZoomChanged:p.ZOOM_CHANGED,onAnimationChanged:p.ANIMATION_CHANGED,onClickableChanged:p.CLICKABLE_CHANGED,onCursorChanged:p.CURSOR_CHANGED,onDraggableChanged:p.DRAGGABLE_CHANGED,onFlatChanged:p.FLAT_CHANGED,onIconChanged:p.ICON_CHANGED,onMouseDown:p.MOUSE_DOWN,onMouseUp:p.MOUSE_UP,onPositionChanged:p.POSITION_CHANGED,onShapeChanged:p.SHAPE_CHANGED,onTitleChanged:p.TITLE_CHANGED,onVisibleChanged:p.VISIBLE_CHANGED,onZIndexChanged:p.Z_INDEX_CHANGED}),h=function(){};function _(e,t){return void 0===t&&(t={}),function(r,o){return e(function(e,t,r){if(0===t.length&&0===e.length)return h;e=Array.from(new Set(e)).reverse();var o=(t=Array.from(new Set(t)).reverse()).length,a=function(e,r){var a=n.useRef([]);n.useEffect(function(){var n=e.current;if(n){var u=a.current;if(u.length)for(var i=o;i--;){var l=t[i],s=r[l];c.default(s,u[i])||(n.set(l,s),u[i]=s)}else for(var f=o;f--;)u[f]=r[t[f]]}})};if(0===e.length)return a;var u=function(t,o){for(var a=function(a){var u=e[a],i=o[u];n.useEffect(function(){var e=t.current;if(e&&i){var n=r[u],o=e.addListener(E[u],n?function(){i.apply(void 0,[this.get(n)].concat([].slice.call(arguments),[this]))}:function(){i.apply(void 0,[].slice.call(arguments).concat([this]))});return function(){return o.remove()}}},[i])},u=e.length;u--;)a(u)};if(0===o)return u;for(var i=[],l=e.length;l--;){var s=e[l],f=r[s];f&&t.includes(f)&&(i.push(s),e.splice(l,1))}var d=i.length;return 0===d?function(e,n){u(e,n),a(e,n)}:(0===e.length&&(u=h),function(e,a){var l=n.useRef({isTriggeredBySetStateMap:new Map,prevStateArr:[]});u(e,a);for(var s=l.current.isTriggeredBySetStateMap,f=function(t){var o=i[t],u=a[o];n.useEffect(function(){var n=e.current;if(n&&u){var t=r[o],a=n.addListener(E[o],function(){s.has(t)?s.delete(t):u.apply(void 0,[this.get(t)].concat([].slice.call(arguments),[this]))});return function(){return a.remove()}}},[u])},g=d;g--;)f(g);n.useEffect(function(){var n=e.current;if(n){var r=l.current.prevStateArr;if(r.length)for(var u=o;u--;){var i=t[u],f=a[i];c.default(f,r[u])||(s.set(i,!0),n.set(i,f),r[u]=f)}else for(var d=o;d--;)r[d]=a[t[d]]}})})}(r,o,t))}}var D,A=["children","className","style","defaultOptions","onMount","onUnmount"],m=_(function(e){return function(t){var r=t.children,o=t.className,a=t.style,u=t.defaultOptions,c=t.onMount,l=t.onUnmount,s=g(t,A),d=n.useRef(null),p=n.useRef(),C=n.useState(),E=C[0],_=C[1];return n.useEffect(function(){var e=new google.maps.Map(d.current,f({},u,s));return p.current=e,google.maps.event.addListenerOnce(e,"idle",function(){_(e),(c||h)(e)}),l},[]),e(p,s),i.default.createElement("div",{ref:d,className:o,style:a},r&&E&&i.default.createElement(v.Provider,{value:E},"function"==typeof r?r(E):r))}},{onCenterChanged:"center",onHeadingChanged:"heading",onMapTypeIdChanged:"mapTypeId",onTiltChanged:"tilt",onZoomChanged:"zoom",onBoundsChanged:"bounds"}),O=["defaultOptions","onMount","onUnmount"],N=_(function(e){return function(t){var r=t.defaultOptions,o=t.onMount,a=t.onUnmount,u=g(t,O),i=C(),c=n.useRef();return n.useEffect(function(){var e=new google.maps.Marker(f({map:i},r,u));return c.current=e,(o||h)(e),function(){e.setMap(null),(a||h)()}},[]),e(c,u),null}},{onAnimationChanged:"animation",onCursorChanged:"cursor",onDraggableChanged:"draggable",onIconChanged:"icon",onPositionChanged:"position",onShapeChanged:"shape",onTitleChanged:"title",onVisibleChanged:"visible",onZIndexChanged:"zIndex"}),y=function(e){void 0===e&&(e={});var t=n.useState(l.default.status),o=t[0],a=t[1];return n.useEffect(function(){o!==r.LoaderStatus.LOADED&&l.default.load().then(function(){a(r.LoaderStatus.LOADED),(e.onLoaded||h)()},function(n){a(r.LoaderStatus.ERROR),(e.onError||h)(n)})},[]),o},G=n.createContext(l.default.status),L=["lat","lng","onAdd","onDraw","onRemove","component","mapPaneLayer","preventMapDragging"];l.default.completion.then(function(){D=/*#__PURE__*/function(e){var n,t;function r(n,t,r){var o;return(o=e.call(this)||this)._style=void 0,o._latLng=void 0,o._onDraw=void 0,o._style=n,o._latLng=new google.maps.LatLng(t[0],t[1]),o.setCallbacks(r),o}t=e,(n=r).prototype=Object.create(t.prototype),n.prototype.constructor=n,d(n,t);var o=r.prototype;return o.setCallbacks=function(e){this.onAdd=e[0]||h,this._onDraw=e[1]||h,this.onRemove=e[2]||h},o.setCoords=function(e){this._latLng=new google.maps.LatLng(e[0],e[1]),this.draw()},o.draw=function(){var e=this.getProjection().fromLatLngToDivPixel(this._latLng);if(e){var n=e.x,t=e.y,r=this._style;r.left=n+"px",r.top=t+"px",this._onDraw(n,t)}},r}(google.maps.OverlayView)});var M=n.forwardRef(function(e,t){var r=e.lat,a=e.lng,u=e.onAdd,c=e.onDraw,l=e.onRemove,s=e.component,d=void 0===s?"div":s,p=e.mapPaneLayer,v=void 0===p?"overlayMouseTarget":p,E=e.preventMapDragging,h=g(e,L),_=C(),A=n.useRef({}),m=[r,a],O=[u,c,l],N=n.useCallback(function(e){var n=A.current;if(e){if(n.el!==e){var r;null==(r=n.overlay)||r.setMap(null),n.el=e,E&&google.maps.OverlayView.preventMapHitsAndGesturesFrom(e);var o=e.style;o.position="absolute";var a=new D(o,m,O);n.overlay=a,a.setMap(_)}}else n.overlay&&(n.overlay.setMap(null),delete n.el,delete n.overlay);!function(e,n){e&&("object"==typeof e?e.current=n:e(n))}(t,e)},[t]);return n.useEffect(function(){var e=A.current,n=e.overlay;e.isNotFirstRender&&n&&n.setCallbacks(O)},O),n.useEffect(function(){var e,n=A.current;n.isNotFirstRender?null==(e=n.overlay)||e.setCoords(m):n.isNotFirstRender=!0},m),o.createPortal(i.default.createElement(d,f({ref:N},h)),_.__gm.panes[v])}),S=function(e){var t=n.useRef();return t.current||(t.current=e())},I=function(e,n,t){var r=e[n].bind(e);return Object.defineProperty(t,n,{value:r,writable:!1,configurable:!1}),r},T=function(e,n){for(var t,o,a={},u=function(u){var i=n[u];Object.defineProperty(a,i,{get:function(){if(l.default.status===r.LoaderStatus.LOADED)return t||(t=e()),I(t,i,a);var n;o||(o=l.default.completion.then(function(){return t=e()}));var u=function(){try{var e=function(){return n.apply(void 0,[].slice.call(t))},t=arguments,r=function(){if(!n)return Promise.resolve(o).then(function(e){n=I(e,i,a)})}();return Promise.resolve(r&&r.then?r.then(e):e(r))}catch(e){return Promise.reject(e)}};return Object.defineProperty(a,i,{value:u,configurable:!0}),u},configurable:!0})},i=n.length;i--;)u(i);return a};Object.defineProperty(e,"Loader",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(e,"LoaderStatus",{enumerable:!0,get:function(){return r.LoaderStatus}}),e.GoogleMapLoader=function(e){var n=y(e),t=e.children;return t?i.default.createElement(G.Provider,{value:n},t):null},e.OverlayView=M,e.createGoogleMapComponent=m,e.createMarkerComponent=N,e.useAutocompleteService=function(){return S(function(){return T(function(){return new google.maps.places.AutocompleteService},["getPlacePredictions","getQueryPredictions"])})},e.useGeocoder=function(){return S(function(){return T(function(){return new google.maps.Geocoder},["geocode"])})},e.useGoogleMap=C,e.useGoogleMapLoader=y,e.useGoogleMapStatus=function(){return n.useContext(G)},e.useMarkerCluster=function(e,t,r){var o=S(function(){return new s.default(t,r)}),a=n.useState([]),u=a[0][0],i=a[1],c=n.useRef();return n.useEffect(function(){return function(){return o.cleanUp()}},[]),n.useEffect(function(){var n=function(){var e=c.current;e&&i([function(){return o.getPoints.apply(o,e.concat([].slice.call(arguments)))}])};if(null!=r&&r.asyncMode)return o.loadAsync(e).then(n),function(){var n;e!==o.points&&(null==(n=o.worker)||n.terminate(),o.worker=void 0)};o.load(e),n()},[e]),{handleBoundsChange:function(e,n){var t=e.getSouthWest(),r=e.getNorthEast(),a=[n.getZoom(),t.lng(),t.lat(),r.lng(),r.lat()];c.current=a,o.points&&i([function(e,n,t){return o.getPoints.apply(o,a.concat([e,n,t]))}])},getPoints:u,markerCluster:o}},e.usePlacesService=function(e){void 0===e&&(e=null);var t=function(){return T(function(){return new google.maps.places.PlacesService(e)},["findPlaceFromPhoneNumber","findPlaceFromQuery","getDetails","nearbySearch","textSearch"])};if("function"!=typeof e)return n.useMemo(t,[e]);var r=n.useState(),o=r[0],a=r[1],u=n.useRef();return n.useEffect(function(){var n=e();u.current!==n&&(u.current=n,a(t()))}),o}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "google-maps-js-api-react", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "Library for convenient work of Google Maps JavaScript API with React", | ||
@@ -32,3 +32,3 @@ "author": "Krombik", | ||
"@types/google.maps": "^3.49.2", | ||
"@types/react": "^18.0.12", | ||
"@types/react": "^18.0.14", | ||
"@types/react-dom": "^18.0.5", | ||
@@ -40,3 +40,3 @@ "cross-env": "^7.0.3", | ||
"prettier": "^2.7.0", | ||
"typescript": "^4.7.3" | ||
"typescript": "^4.7.4" | ||
}, | ||
@@ -43,0 +43,0 @@ "files": [ |
@@ -19,3 +19,3 @@ # google-maps-js-api-react | ||
Loader.options = { apiKey: API_KEY }; | ||
Loader.options = { apiKey: API_KEY, defer: true }; | ||
@@ -46,2 +46,4 @@ const GoogleMap = createGoogleMapComponent([], []); | ||
style={{ background: 'red' }} | ||
preventMapDragging | ||
onClick={() => console.log('clicked')} | ||
> | ||
@@ -61,3 +63,3 @@ dot | ||
> Note: if you use createGoogleMapComponent([], ['zoom']), it not means that `map zoom` can be only the value which will be provided by `zoom` prop (like `value` prop in `input` component), it means that if `zoom` prop was changed, `map zoom` will be changed to | ||
> Note: if you use createGoogleMapComponent([], ['zoom']), it not means that `map zoom` can be only the value which will be provided by `zoom` prop (like `value` prop in `input` component), it means that if `zoom` prop was changed, `map zoom` will be changed to, but not vice versa | ||
@@ -302,2 +304,3 @@ ## API | ||
onRemove?: () => void; | ||
preventMapDragging?: boolean; | ||
component?: C; | ||
@@ -313,6 +316,7 @@ } & google.maps.LatLngLiteral; | ||
| Name | Description | Default | | ||
| :-------------- | :------------------------------------------------------------------------------------------------- | :------------------- | | ||
| `mapPaneLayer?` | [see](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes) | 'overlayMouseTarget' | | ||
| `component?` | same to [material-ui component props](https://mui.com/guides/composition/#component-prop) | 'div' | | ||
| Name | Description | Default | | ||
| :-------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------- | | ||
| `mapPaneLayer?` | [see](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes) | 'overlayMouseTarget' | | ||
| `component?` | same to [material-ui component props](https://mui.com/guides/composition/#component-prop) | 'div' | | ||
| `preventMapDragging?` | Stops click, tap, drag, and wheel events on the element from bubbling up to the map. Use this to prevent map dragging and zooming, as well as map "click" events. | false | | ||
@@ -342,19 +346,35 @@ > Note: if you pass functional component to `component` prop, you should wrap it in forwardRef like in example below | ||
```ts | ||
const useAutocompleteService: () => | ||
| google.maps.places.AutocompleteService | ||
| undefined; | ||
useAutocompleteService(): google.maps.places.AutocompleteService; | ||
``` | ||
returns `undefined` if google.maps is not loaded yet, throws error if `places` not included to libraries in loader options | ||
Returns service even if `map api` not loaded yet, in this case all methods are async (first waiting for `map api` loading and then call method from service), after `map api` loaded went back to normal behavior | ||
This hook don't provokes re-renders. | ||
--- | ||
### useAutocompleteService | ||
### useGeocoder | ||
```ts | ||
const usePlacesService: ( | ||
container?: null | (() => HTMLDivElement) | HTMLDivElement | google.maps.Map | ||
) => google.maps.places.PlacesService | undefined; | ||
useGeocoder(): google.maps.Geocoder; | ||
``` | ||
Returns service even if `map api` not loaded yet, in this case all methods are async (first waiting for `map api` loading and then call method from service), after `map api` loaded went back to normal behavior | ||
This hook don't provokes re-renders. | ||
--- | ||
### usePlacesService | ||
```ts | ||
usePlacesService( | ||
container?: null | HTMLElement | google.maps.Map | ||
): Service<google.maps.places.PlacesService>; | ||
usePlacesService(getContainer: () => HTMLElement): | ||
| Service<google.maps.places.PlacesService> | ||
| undefined; | ||
``` | ||
| Name | Description | Default | | ||
@@ -364,4 +384,8 @@ | :----------- | :------------------------------------------------------------------------------------------------------------------------------------------ | :------ | | ||
returns `undefined` if google.maps is not loaded yet, throws error if `places` not included to libraries in loader options | ||
Returns service even if `map api` not loaded yet, in this case all methods are async (first waiting for `map api` loading and then call method from service), after `map api` loaded went back to normal behavior | ||
This hook provokes re-renders only if `container` is function. | ||
> Note: don't switch between overloads, this will provoke react errors | ||
--- | ||
@@ -368,0 +392,0 @@ |
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
243765
30
423
428