diff --git a/.eslintrc.json b/.eslintrc.json index 79da11d..4175034 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,7 +17,6 @@ "react/react-in-jsx-scope": "off", "react-hooks/rules-of-hooks": "error", "react-hooks/exhaustive-deps": "warn", - "react/no-unknown-property": ["warn", { "ignore": ["jsx"] }], "react/prop-types": "warn" }, "env": { diff --git a/README.md b/README.md index 05da9eb..9c17006 100644 --- a/README.md +++ b/README.md @@ -28,40 +28,40 @@ npm install --save google-maps-react-markers ```jsx const App = () => { - const mapRef = useRef(null); - const [mapReady, setMapReady] = useState(false); - - /** - * @description This function is called when the map is ready - * @param {Object} map - reference to the map instance - * @param {Object} maps - reference to the maps library - */ - const onGoogleApiLoaded = ({ map, maps }) => { - mapRef.current = map; - setMapReady(true); - }; - - const onMarkerClick = (markerId) => { - console.log("This is ->", markerId); - }; - - return ( - <> - {mapReady &&
Map is ready. See for logs in developer console.
} - console.log("Map moved", map)} - > - {coordinates.map(({ lat, lng, name }, index) => ( - - ))} - - - ); + const mapRef = useRef(null); + const [mapReady, setMapReady] = useState(false); + + /** + * @description This function is called when the map is ready + * @param {Object} map - reference to the map instance + * @param {Object} maps - reference to the maps library + */ + const onGoogleApiLoaded = ({ map, maps }) => { + mapRef.current = map; + setMapReady(true); + }; + + const onMarkerClick = (markerId) => { + console.log("This is ->", markerId); + }; + + return ( + <> + {mapReady &&
Map is ready. See for logs in developer console.
} + console.log("Map moved", map)} + > + {coordinates.map(({ lat, lng, name }, index) => ( + + ))} + + + ); }; export default App; @@ -93,8 +93,17 @@ For clustering, follow this [guide](https://www.leighhalliday.com/google-maps-cl const onMapChange = ({ bounds, zoom }) => { const ne = bounds.getNorthEast(); const sw = bounds.getSouthWest(); - // useSupercluster accepts bounds in the form of [westLng, southLat, eastLng, northLat] + /** + * useSupercluster accepts bounds in the form of [westLng, southLat, eastLng, northLat] + * const { clusters, supercluster } = useSupercluster({ + * points: points, + * bounds: mapBounds.bounds, + * zoom: mapBounds.zoom, + * }) + */ setMapBounds({ ...mapBounds, bounds: [sw.lng(), sw.lat(), ne.lng(), ne.lat()], zoom }); + + console.log("New bounds and zoom -> ", { bounds, zoom }); }; ``` diff --git a/dist/google-map.d.ts b/dist/google-map.d.ts new file mode 100644 index 0000000..fc05f7b --- /dev/null +++ b/dist/google-map.d.ts @@ -0,0 +1,3 @@ +export default GoogleMap; +declare const GoogleMap: any; +//# sourceMappingURL=google-map.d.ts.map \ No newline at end of file diff --git a/dist/google-map.d.ts.map b/dist/google-map.d.ts.map new file mode 100644 index 0000000..53603af --- /dev/null +++ b/dist/google-map.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"google-map.d.ts","sourceRoot":"","sources":["../src/google-map.js"],"names":[],"mappings":";AAKA,6BAsBE"} \ No newline at end of file diff --git a/dist/hooks/useGoogleMaps.d.ts b/dist/hooks/useGoogleMaps.d.ts new file mode 100644 index 0000000..036e400 --- /dev/null +++ b/dist/hooks/useGoogleMaps.d.ts @@ -0,0 +1,5 @@ +export function useGoogleMaps({ apiKey, libraries }: { + apiKey: any; + libraries?: any[]; +}): "idle" | "loading" | "ready" | "error"; +//# sourceMappingURL=useGoogleMaps.d.ts.map \ No newline at end of file diff --git a/dist/hooks/useGoogleMaps.d.ts.map b/dist/hooks/useGoogleMaps.d.ts.map new file mode 100644 index 0000000..e924f61 --- /dev/null +++ b/dist/hooks/useGoogleMaps.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"useGoogleMaps.d.ts","sourceRoot":"","sources":["../../src/hooks/useGoogleMaps.js"],"names":[],"mappings":"AAKO;;;IAFM,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAclD"} \ No newline at end of file diff --git a/dist/hooks/useMemoCompare.d.ts b/dist/hooks/useMemoCompare.d.ts new file mode 100644 index 0000000..9da0aa6 --- /dev/null +++ b/dist/hooks/useMemoCompare.d.ts @@ -0,0 +1,10 @@ +export default useMemoCompare; +/** + * A hook that compares the previous and current values of a reference. + * @param {any} value - the current value of the reference + * @param {function} compare - a function that compares the previous and current values + * @returns {any} the previous value of the reference + * @ref https://usehooks.com/useMemoCompare/ + */ +declare function useMemoCompare(next: any, compare: Function): any; +//# sourceMappingURL=useMemoCompare.d.ts.map \ No newline at end of file diff --git a/dist/hooks/useMemoCompare.d.ts.map b/dist/hooks/useMemoCompare.d.ts.map new file mode 100644 index 0000000..18f5571 --- /dev/null +++ b/dist/hooks/useMemoCompare.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"useMemoCompare.d.ts","sourceRoot":"","sources":["../../src/hooks/useMemoCompare.js"],"names":[],"mappings":";AAEA;;;;;;GAMG;AACH,+DAHa,GAAG,CAoBf"} \ No newline at end of file diff --git a/dist/hooks/useScript.d.ts b/dist/hooks/useScript.d.ts new file mode 100644 index 0000000..0c422e5 --- /dev/null +++ b/dist/hooks/useScript.d.ts @@ -0,0 +1,10 @@ +export function useScript(script?: { + src: string; + attributes?: any; + callbacks?: { + onLoadCallback?: Function; + onErrorCallback?: Function; + }; + elementIdToAppend?: string; +}): "idle" | "loading" | "ready" | "error"; +//# sourceMappingURL=useScript.d.ts.map \ No newline at end of file diff --git a/dist/hooks/useScript.d.ts.map b/dist/hooks/useScript.d.ts.map new file mode 100644 index 0000000..5b3661e --- /dev/null +++ b/dist/hooks/useScript.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"useScript.d.ts","sourceRoot":"","sources":["../../src/hooks/useScript.js"],"names":[],"mappings":"AA0BO;IApBmB,GAAG,EAAlB,MAAM;IACU,UAAU;IACV,SAAS;QACG,cAAc;QACd,eAAe;;IAC3B,iBAAiB,GAAjC,MAAM;IACJ,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAwGlD"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..9c6b17d --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,2 @@ +export { default } from "./google-map"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map new file mode 100644 index 0000000..6e08bd5 --- /dev/null +++ b/dist/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/index.modern.js b/dist/index.modern.js index 2545f5b..55170c3 100644 --- a/dist/index.modern.js +++ b/dist/index.modern.js @@ -2,89 +2,41 @@ import { element, string, shape, number, object, node, oneOfType, arrayOf, func import React, { useState, useEffect, useRef, useMemo, Children, isValidElement, useCallback, forwardRef } from 'react'; import { createPortal } from 'react-dom'; -function _extends() { - _extends = Object.assign ? Object.assign.bind() : function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - return target; - }; - return _extends.apply(this, arguments); -} -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - _setPrototypeOf(subClass, superClass); -} -function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - return _setPrototypeOf(o, p); -} -function _objectWithoutPropertiesLoose(source, excluded) { - if (source == null) return {}; - var target = {}; - var sourceKeys = Object.keys(source); - var key, i; - for (i = 0; i < sourceKeys.length; i++) { - key = sourceKeys[i]; - if (excluded.indexOf(key) >= 0) continue; - target[key] = source[key]; - } - return target; -} - -var useScript = function useScript(script) { - if (script === void 0) { - script = { - src: '', - attributes: {}, - callbacks: { - onLoadCallback: null, - onErrorCallback: null - }, - elementIdToAppend: null - }; - } - var _useState = useState(script.src ? 'loading' : 'idle'), - status = _useState[0], - setStatus = _useState[1]; - useEffect(function () { +const useScript = (script = { + src: '', + attributes: {}, + callbacks: { + onLoadCallback: null, + onErrorCallback: null + }, + elementIdToAppend: null +}) => { + const [status, setStatus] = useState(script.src ? 'loading' : 'idle'); + useEffect(() => { var _script$callbacks, _script$callbacks2; if (!script.src) { setStatus('idle'); return; } - var scriptToAdd = document.querySelector("script[src=\"" + script.src + "\"]"); + let scriptToAdd = document.querySelector(`script[src="${script.src}"]`); if (!scriptToAdd) { scriptToAdd = document.createElement('script'); scriptToAdd.src = script.src; scriptToAdd.async = true; scriptToAdd.setAttribute('data-status', 'loading'); - script.attributes && Object.entries(script.attributes).length > 0 ? Object.entries(script.attributes).map(function (_ref) { - var key = _ref[0], - value = _ref[1]; - return scriptToAdd.setAttribute(key, value); - }) : null; + script.attributes && Object.entries(script.attributes).length > 0 ? Object.entries(script.attributes).map(([key, value]) => scriptToAdd.setAttribute(key, value)) : null; if (script.elementIdToAppend && document.getElementById(script.elementIdToAppend)) { document.getElementById(script.elementIdToAppend).appendChild(scriptToAdd); } else { document.body.appendChild(scriptToAdd); } - var setAttributeFromEvent = function setAttributeFromEvent(event) { + const setAttributeFromEvent = event => { scriptToAdd.setAttribute('data-status', event.type === 'load' ? 'ready' : 'error'); }; scriptToAdd.addEventListener('load', setAttributeFromEvent); scriptToAdd.addEventListener('error', setAttributeFromEvent); } else { - var currentScriptStatus = scriptToAdd.getAttribute('data-status'); + const currentScriptStatus = scriptToAdd.getAttribute('data-status'); switch (currentScriptStatus) { case 'load': case 'ready': @@ -96,14 +48,14 @@ var useScript = function useScript(script) { } setStatus(currentScriptStatus); } - var setStateFromEvent = function setStateFromEvent(event) { + const setStateFromEvent = event => { var _script$callbacks3, _script$callbacks4; event.type === 'load' ? (_script$callbacks3 = script.callbacks) !== null && _script$callbacks3 !== void 0 && _script$callbacks3.onLoadCallback ? script.callbacks.onLoadCallback() : null : (_script$callbacks4 = script.callbacks) !== null && _script$callbacks4 !== void 0 && _script$callbacks4.onErrorCallback ? script.callbacks.onErrorCallback() : null; setStatus(event.type === 'load' ? 'ready' : 'error'); }; scriptToAdd.addEventListener('load', setStateFromEvent); scriptToAdd.addEventListener('error', setStateFromEvent); - return function () { + return () => { if (scriptToAdd) { scriptToAdd.removeEventListener('load', setStateFromEvent); scriptToAdd.removeEventListener('error', setStateFromEvent); @@ -114,17 +66,17 @@ var useScript = function useScript(script) { return status; }; -var useGoogleMaps = function useGoogleMaps(_ref) { - var apiKey = _ref.apiKey, - _ref$libraries = _ref.libraries, - libraries = _ref$libraries === void 0 ? [] : _ref$libraries; - var script = apiKey ? { - src: "https://maps.googleapis.com/maps/api/js?key=" + apiKey + "&libraries=" + (libraries === null || libraries === void 0 ? void 0 : libraries.join(",")), +const useGoogleMaps = ({ + apiKey, + libraries: _libraries = [] +}) => { + const script = apiKey ? { + src: `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${_libraries === null || _libraries === void 0 ? void 0 : _libraries.join(",")}`, attributes: { id: "googleMapsApi" } } : { - src: "https://maps.googleapis.com/maps/api/js?libraries=" + (libraries === null || libraries === void 0 ? void 0 : libraries.join(",")), + src: `https://maps.googleapis.com/maps/api/js?libraries=${_libraries === null || _libraries === void 0 ? void 0 : _libraries.join(",")}`, attributes: { id: "googleMapsApi" } @@ -132,9 +84,9 @@ var useGoogleMaps = function useGoogleMaps(_ref) { return useScript(script); }; -var isArraysEqualEps = function isArraysEqualEps(arrayA, arrayB, eps) { +const isArraysEqualEps = (arrayA, arrayB, eps) => { if (arrayA && arrayB) { - for (var i = 0; i !== arrayA.length; ++i) { + for (let i = 0; i !== arrayA.length; ++i) { if (Math.abs(arrayA[i] - arrayB[i]) > eps) { return false; } @@ -144,11 +96,11 @@ var isArraysEqualEps = function isArraysEqualEps(arrayA, arrayB, eps) { return false; }; -var useMemoCompare = function useMemoCompare(next, compare) { - var previousRef = useRef(); - var previous = previousRef.current; - var isEqual = compare(previous, next); - useEffect(function () { +const useMemoCompare = (next, compare) => { + const previousRef = useRef(); + const previous = previousRef.current; + const isEqual = compare(previous, next); + useEffect(() => { if (!isEqual) { previousRef.current = next; } @@ -156,40 +108,38 @@ var useMemoCompare = function useMemoCompare(next, compare) { return isEqual ? previous : next; }; -var createOverlay = function createOverlay(_ref) { - var container = _ref.container, - pane = _ref.pane, - position = _ref.position, - maps = _ref.maps; - var Overlay = /*#__PURE__*/function (_maps$OverlayView) { - _inheritsLoose(Overlay, _maps$OverlayView); - function Overlay(container, _pane, position) { - var _this; - _this = _maps$OverlayView.call(this) || this; - _this.onAdd = function () { - var pane = _this.getPanes()[_this.pane]; +const createOverlay = ({ + container, + pane, + position, + maps +}) => { + class Overlay extends maps.OverlayView { + constructor(container, _pane, position) { + super(); + this.onAdd = () => { + const pane = this.getPanes()[this.pane]; pane === null || pane === void 0 ? void 0 : pane.classList.add('google-map-markers-overlay'); - pane === null || pane === void 0 ? void 0 : pane.appendChild(_this.container); + pane === null || pane === void 0 ? void 0 : pane.appendChild(this.container); }; - _this.draw = function () { - var projection = _this.getProjection(); - var point = projection.fromLatLngToDivPixel(_this.position); + this.draw = () => { + const projection = this.getProjection(); + const point = projection.fromLatLngToDivPixel(this.position); if (point === null) return; - _this.container.style.transform = "translate(" + point.x + "px, " + point.y + "px)"; + this.container.style.transform = `translate(${point.x}px, ${point.y}px)`; }; - _this.onRemove = function () { - if (_this.container.parentNode !== null) { - _this.container.parentNode.removeChild(_this.container); + this.onRemove = () => { + if (this.container.parentNode !== null) { + this.container.parentNode.removeChild(this.container); } }; - _this.container = container; - _this.pane = _pane; - _this.position = position; - return _this; + this.container = container; + this.pane = _pane; + this.position = position; } - return Overlay; - }(maps.OverlayView); + } + return new Overlay(container, pane, position); }; createOverlay.propTypes = { @@ -202,42 +152,42 @@ createOverlay.propTypes = { maps: object.isRequired }; -var OverlayView = function OverlayView(_ref) { - var position = _ref.position, - _ref$pane = _ref.pane, - pane = _ref$pane === void 0 ? 'floatPane' : _ref$pane, - map = _ref.map, - maps = _ref.maps, - zIndex = _ref.zIndex, - children = _ref.children; - var container = useMemo(function () { - var div = document.createElement('div'); +const OverlayView = ({ + position, + pane: _pane = 'floatPane', + map, + maps, + zIndex, + children +}) => { + const container = useMemo(() => { + const div = document.createElement('div'); div.style.position = 'absolute'; return div; }, []); - var overlay = useMemo(function () { + const overlay = useMemo(() => { return createOverlay({ - container: container, - pane: pane, - position: position, - maps: maps + container, + pane: _pane, + position, + maps }); - }, [container, maps, pane, position]); + }, [container, maps, _pane, position]); - var childrenProps = useMemoCompare(children === null || children === void 0 ? void 0 : children.props, function (prev, next) { + const childrenProps = useMemoCompare(children === null || children === void 0 ? void 0 : children.props, (prev, next) => { return prev && prev.lat === next.lat && prev.lng === next.lng; }); - useEffect(function () { + useEffect(() => { if (!overlay.map) { overlay === null || overlay === void 0 ? void 0 : overlay.setMap(map); - return function () { + return () => { overlay === null || overlay === void 0 ? void 0 : overlay.setMap(null); }; } }, [map, childrenProps]); - useEffect(function () { - container.style.zIndex = "" + zIndex; + useEffect(() => { + container.style.zIndex = `${zIndex}`; }, [zIndex, container]); return /*#__PURE__*/createPortal(children, container); }; @@ -256,15 +206,16 @@ OverlayView.propTypes = { children: node.isRequired }; -var MapMarkers = function MapMarkers(_ref) { - var children = _ref.children, - map = _ref.map, - maps = _ref.maps; - var markers = useMemo(function () { +const MapMarkers = ({ + children, + map, + maps +}) => { + const markers = useMemo(() => { if (!map || !maps) return []; - return Children.map(children, function (child) { + return Children.map(children, child => { if ( /*#__PURE__*/isValidElement(child)) { - var latLng = { + const latLng = { lat: child.props.lat, lng: child.props.lng }; @@ -284,60 +235,55 @@ MapMarkers.propTypes = { maps: object.isRequired }; -var _excluded = ["children", "style", "defaultCenter", "defaultZoom", "onGoogleApiLoaded", "onChange"]; -var EPS = 0.00001; -var MapComponent = function MapComponent(_ref) { - var children = _ref.children, - style = _ref.style, - defaultCenter = _ref.defaultCenter, - defaultZoom = _ref.defaultZoom, - onGoogleApiLoaded = _ref.onGoogleApiLoaded, - onChange = _ref.onChange, - props = _objectWithoutPropertiesLoose(_ref, _excluded); - var mapRef = useRef(null); - var prevBoundsRef = useRef(null); - var _useState = useState(null), - map = _useState[0], - setMap = _useState[1]; - var _useState2 = useState(null), - maps = _useState2[0], - setMaps = _useState2[1]; - var _useState3 = useState(false), - googleApiCalled = _useState3[0], - setGoogleApiCalled = _useState3[1]; - var onIdle = useCallback(function () { - var zoom = map.getZoom(); - var bounds = map.getBounds(); - var centerLatLng = map.getCenter(); - var ne = bounds.getNorthEast(); - var sw = bounds.getSouthWest(); - var boundsArray = [sw.lng(), sw.lat(), ne.lng(), ne.lat()]; +const EPS = 0.00001; +const MapComponent = ({ + children, + style, + defaultCenter, + defaultZoom, + onGoogleApiLoaded, + onChange, + ...props +}) => { + const mapRef = useRef(null); + const prevBoundsRef = useRef(null); + const [map, setMap] = useState(null); + const [maps, setMaps] = useState(null); + const [googleApiCalled, setGoogleApiCalled] = useState(false); + const onIdle = useCallback(() => { + const zoom = map.getZoom(); + const bounds = map.getBounds(); + const centerLatLng = map.getCenter(); + const ne = bounds.getNorthEast(); + const sw = bounds.getSouthWest(); + const boundsArray = [sw.lng(), sw.lat(), ne.lng(), ne.lat()]; if (!isArraysEqualEps(boundsArray, prevBoundsRef.current, EPS)) { if (onChange) { onChange({ - zoom: zoom, + zoom, center: [centerLatLng.lng(), centerLatLng.lat()], - bounds: bounds + bounds }); } prevBoundsRef.current = boundsArray; } }, [map, onChange]); - useEffect(function () { + useEffect(() => { if (mapRef.current && !map) { - setMap(new window.google.maps.Map(mapRef.current, _extends({ + setMap(new window.google.maps.Map(mapRef.current, { center: defaultCenter, - zoom: defaultZoom - }, props))); + zoom: defaultZoom, + ...props + })); setMaps(window.google.maps); } }, [defaultCenter, defaultZoom, map, mapRef, props]); - useEffect(function () { + useEffect(() => { if (map) { if (!googleApiCalled) { onGoogleApiLoaded({ - map: map, - maps: maps, + map, + maps, ref: mapRef.current }); setGoogleApiCalled(true); @@ -346,8 +292,8 @@ var MapComponent = function MapComponent(_ref) { window.google.maps.event.addListener(map, 'idle', onIdle); } }, [googleApiCalled, map, maps, onChange, onGoogleApiLoaded, onIdle]); - useEffect(function () { - return function () { + useEffect(() => { + return () => { if (map) { window.google.maps.event.clearListeners(map, 'idle'); } @@ -372,8 +318,8 @@ MapComponent.defaultProps = { padding: 0, position: 'absolute' }, - onGoogleApiLoaded: function onGoogleApiLoaded() {}, - onChange: function onChange() {} + onGoogleApiLoaded: () => {}, + onChange: () => {} }; MapComponent.propTypes = { children: oneOfType([arrayOf(node), node]), @@ -384,22 +330,22 @@ MapComponent.propTypes = { onChange: func }; -var _excluded$1 = ["apiKey", "libraries", "children", "loadingContent", "idleContent", "errorContent", "mapMinHeight", "containerProps"]; -var GoogleMap = /*#__PURE__*/forwardRef(function GoogleMap(_ref, ref) { - var apiKey = _ref.apiKey, - libraries = _ref.libraries, - children = _ref.children, - loadingContent = _ref.loadingContent, - idleContent = _ref.idleContent, - errorContent = _ref.errorContent, - mapMinHeight = _ref.mapMinHeight, - containerProps = _ref.containerProps, - props = _objectWithoutPropertiesLoose(_ref, _excluded$1); - var status = useGoogleMaps({ - apiKey: apiKey, - libraries: libraries +const GoogleMap = /*#__PURE__*/forwardRef(function GoogleMap({ + apiKey, + libraries, + children, + loadingContent, + idleContent, + errorContent, + mapMinHeight, + containerProps, + ...props +}, ref) { + const status = useGoogleMaps({ + apiKey, + libraries }); - return /*#__PURE__*/React.createElement("div", _extends({ + return /*#__PURE__*/React.createElement("div", Object.assign({ style: { height: '100%', width: '100%', @@ -410,22 +356,24 @@ var GoogleMap = /*#__PURE__*/forwardRef(function GoogleMap(_ref, ref) { ref: ref }, containerProps), status === 'ready' ? /*#__PURE__*/React.createElement(MapComponent, props, children) : status === 'loading' ? loadingContent : status === 'idle' ? idleContent : status === 'error' ? errorContent : null); }); -GoogleMap.defaultProps = _extends({}, MapComponent.defaultProps, { +GoogleMap.defaultProps = { + ...MapComponent.defaultProps, loadingContent: 'Google Maps is loading', idleContent: 'Google Maps is on idle', errorContent: 'Google Maps is on error', mapMinHeight: 'unset', apiKey: '', libraries: ['places', 'geometry'] -}); -GoogleMap.propTypes = _extends({}, MapComponent.propTypes, { +}; +GoogleMap.propTypes = { + ...MapComponent.propTypes, children: oneOfType([node, arrayOf(node)]), loadingContent: node, idleContent: node, errorContent: node, mapMinHeight: oneOfType([number, string]), containerProps: object -}); +}; export default GoogleMap; //# sourceMappingURL=index.modern.js.map diff --git a/dist/index.modern.js.map b/dist/index.modern.js.map index 404295d..42057c4 100644 --- a/dist/index.modern.js.map +++ b/dist/index.modern.js.map @@ -1 +1 @@ -{"version":3,"file":"index.modern.js","sources":["../src/hooks/useScript.js","../src/hooks/useGoogleMaps.js","../src/utils/utils.js","../src/hooks/useMemoCompare.js","../src/map/overlay.js","../src/map/overlay-view.js","../src/map/markers.js","../src/map/map.js","../src/google-map.js"],"sourcesContent":["/* eslint-disable no-unused-expressions */\nimport { useState, useEffect } from 'react'\n\n/**\n * @description Hook to load external script.\n * @param {Object} script - Script to load.\n * @param {string} script.src - Script source.\n * @param {Object} [script.attributes] - Attributes to add to the script tag.\n * @param {Object} [script.callbacks] - Callbacks executed on completion.\n * @param {Function} [script.callbacks.onLoadCallback] - Callback executed on completion in case of success.\n * @param {Function} [script.callbacks.onErrorCallback] - Callbacks executed on completion in case of error.\n * @param {string} [script.elementIdToAppend] - HTML element id to append the script to. Default is HTML HEAD.\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n *\n * @example\n * const status = useScript({\n * \t\tsrc: \"https://script-to-load.js\",\n * \t\tattributes: { id: \"scriptId\", class: \"script-class\" },\n * \t\tcallbacks: {\n * \t\t\tonLoadCallback: onLoadFunc,\n * \t\t\tonErrorCallback: onErrorFunc,\n * \t\t},\n * \t\telementIdToAppend: \"script-container\"\n * })\n */\n\nexport const useScript = (\n\tscript = {\n\t\tsrc: '',\n\t\tattributes: {},\n\t\tcallbacks: { onLoadCallback: null, onErrorCallback: null },\n\t\telementIdToAppend: null,\n\t}\n) => {\n\t// Keep track of script status (\"idle\", \"loading\", \"ready\", \"error\")\n\tconst [status, setStatus] = useState(script.src ? 'loading' : 'idle')\n\n\tuseEffect(\n\t\t() => {\n\t\t\t// Allow falsy src value if waiting on other data needed for\n\t\t\t// constructing the script URL passed to this hook.\n\t\t\tif (!script.src) {\n\t\t\t\tsetStatus('idle')\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Fetch existing script element by src\n\t\t\t// It may have been added by another instance of this hook\n\t\t\tlet scriptToAdd = document.querySelector(`script[src=\"${script.src}\"]`)\n\t\t\tif (!scriptToAdd) {\n\t\t\t\t// Create script\n\t\t\t\tscriptToAdd = document.createElement('script')\n\t\t\t\tscriptToAdd.src = script.src\n\t\t\t\tscriptToAdd.async = true\n\t\t\t\tscriptToAdd.setAttribute('data-status', 'loading')\n\t\t\t\t// Add other script attributes, if they exist\n\t\t\t\tscript.attributes && Object.entries(script.attributes).length > 0\n\t\t\t\t\t? Object.entries(script.attributes).map(([key, value]) => scriptToAdd.setAttribute(key, value))\n\t\t\t\t\t: null\n\t\t\t\t// Add script to document body\n\t\t\t\tif (script.elementIdToAppend && document.getElementById(script.elementIdToAppend)) {\n\t\t\t\t\tdocument.getElementById(script.elementIdToAppend).appendChild(scriptToAdd)\n\t\t\t\t} else {\n\t\t\t\t\tdocument.body.appendChild(scriptToAdd)\n\t\t\t\t}\n\t\t\t\t// Store status in attribute on script\n\t\t\t\t// This can be read by other instances of this hook\n\t\t\t\tconst setAttributeFromEvent = (event) => {\n\t\t\t\t\tscriptToAdd.setAttribute('data-status', event.type === 'load' ? 'ready' : 'error')\n\t\t\t\t}\n\t\t\t\tscriptToAdd.addEventListener('load', setAttributeFromEvent)\n\t\t\t\tscriptToAdd.addEventListener('error', setAttributeFromEvent)\n\t\t\t} else {\n\t\t\t\t// Grab existing script status from attribute and set to state.\n\t\t\t\tconst currentScriptStatus = scriptToAdd.getAttribute('data-status')\n\t\t\t\tswitch (currentScriptStatus) {\n\t\t\t\t\tcase 'load':\n\t\t\t\t\tcase 'ready':\n\t\t\t\t\t\tscript.callbacks?.onLoadCallback ? script.callbacks.onLoadCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\tscript.callbacks?.onErrorCallback ? script.callbacks.onErrorCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// loading: do nothing\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tsetStatus(currentScriptStatus)\n\t\t\t}\n\t\t\t// Script event handler to update status in state\n\t\t\t// Note: Even if the script already exists we still need to add\n\t\t\t// event handlers to update the state for this hook instance.\n\t\t\tconst setStateFromEvent = (event) => {\n\t\t\t\tevent.type === 'load'\n\t\t\t\t\t? script.callbacks?.onLoadCallback\n\t\t\t\t\t\t? script.callbacks.onLoadCallback()\n\t\t\t\t\t\t: null\n\t\t\t\t\t: script.callbacks?.onErrorCallback\n\t\t\t\t\t? script.callbacks.onErrorCallback()\n\t\t\t\t\t: null\n\t\t\t\tsetStatus(event.type === 'load' ? 'ready' : 'error')\n\t\t\t}\n\t\t\t// Add event listeners\n\t\t\tscriptToAdd.addEventListener('load', setStateFromEvent)\n\t\t\tscriptToAdd.addEventListener('error', setStateFromEvent)\n\t\t\t// Remove event listeners on cleanup\n\t\t\treturn () => {\n\t\t\t\tif (scriptToAdd) {\n\t\t\t\t\tscriptToAdd.removeEventListener('load', setStateFromEvent)\n\t\t\t\t\tscriptToAdd.removeEventListener('error', setStateFromEvent)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Re-run useEffect if script changes\n\t\t[script]\n\t)\n\treturn status\n}\n","import { useScript } from \"./useScript\";\n\n/**\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n */\nexport const useGoogleMaps = ({ apiKey, libraries = [] }) => {\n\tconst script = apiKey\n\t\t? {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${libraries?.join(\",\")}`,\n\t\t\t\tattributes: { id: \"googleMapsApi\" },\n\t\t }\n\t\t: {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?libraries=${libraries?.join(\",\")}`,\n\t\t\t\tattributes: { id: \"googleMapsApi\" },\n\t\t};\n\n\treturn useScript(script);\n};\n","export const isArraysEqualEps = (arrayA, arrayB, eps) => {\n\tif (arrayA && arrayB) {\n\t\tfor (let i = 0; i !== arrayA.length; ++i) {\n\t\t\tif (Math.abs(arrayA[i] - arrayB[i]) > eps) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn false\n}\n","import { useEffect, useRef } from 'react'\n\n/**\n * A hook that compares the previous and current values of a reference.\n * @param {any} value - the current value of the reference\n * @param {function} compare - a function that compares the previous and current values\n * @returns {any} the previous value of the reference\n * @ref https://usehooks.com/useMemoCompare/\n */\nconst useMemoCompare = (next, compare) => {\n\t// Ref for storing previous value\n\tconst previousRef = useRef()\n\tconst previous = previousRef.current\n\t// Pass previous and next value to compare function\n\t// to determine whether to consider them equal.\n\tconst isEqual = compare(previous, next)\n\t// If not equal update previousRef to next value.\n\t// We only update if not equal so that this hook continues to return\n\t// the same old value if compare keeps returning true.\n\tuseEffect(() => {\n\t\tif (!isEqual) {\n\t\t\tpreviousRef.current = next\n\t\t}\n\t})\n\t// Finally, if equal then return the previous value\n\treturn isEqual ? previous : next\n}\n\nexport default useMemoCompare\n","import { element, number, object, shape, string } from 'prop-types'\n\n/**\n * @param {HTMLElement} container\n * @param {google.maps.MapPanes} pane\n * @param {google.maps.LatLng | google.maps.LatLngLiteral} position\n * @param {google.maps} maps\n * @returns {void}\n */\nconst createOverlay = ({ container, pane, position, maps }) => {\n\tclass Overlay extends maps.OverlayView {\n\t\tconstructor(container, pane, position) {\n\t\t\tsuper()\n\t\t\tthis.container = container\n\t\t\tthis.pane = pane\n\t\t\tthis.position = position\n\t\t}\n\n\t\t/**\n\t\t * onAdd is called when the map's panes are ready and the overlay has been\n\t\t * added to the map.\n\t\t */\n\t\tonAdd = () => {\n\t\t\t// Add the element to the pane.\n\t\t\tconst pane = this.getPanes()[this.pane]\n\t\t\tpane?.classList.add('google-map-markers-overlay')\n\t\t\tpane?.appendChild(this.container)\n\t\t}\n\n\t\tdraw = () => {\n\t\t\tconst projection = this.getProjection()\n\t\t\t// Computes the pixel coordinates of the given geographical location in the DOM element that holds the draggable map.\n\t\t\tconst point = projection.fromLatLngToDivPixel(this.position)\n\t\t\tif (point === null) return\n\t\t\tthis.container.style.transform = `translate(${point.x}px, ${point.y}px)`\n\t\t}\n\n\t\t/**\n\t\t * The onRemove() method will be called automatically from the API if\n\t\t * we ever set the overlay's map property to 'null'.\n\t\t */\n\t\tonRemove = () => {\n\t\t\tif (this.container.parentNode !== null) {\n\t\t\t\tthis.container.parentNode.removeChild(this.container)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn new Overlay(container, pane, position)\n}\n\ncreateOverlay.propTypes = {\n\t/**\n\t * The HTML container element for the overlay.\n\t */\n\tcontainer: element.isRequired,\n\t/**\n\t * The HTML container element for the overlay.\n\t * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)\n\t * @default 'floatPane'\n\t * @type {google.maps.MapPanes}\n\t * @required\n\t */\n\tpane: string.isRequired,\n\t/**\n\t * The geographical location of the overlay.\n\t * @type {google.maps.LatLng | google.maps.LatLngLiteral}\n\t * @required\n\t * @ref [LatLng](https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLng)\n\t */\n\tposition: shape({\n\t\tlat: number.isRequired,\n\t\tlng: number.isRequired,\n\t}).isRequired,\n\t/**\n\t * The Google Maps API.\n\t */\n\tmaps: object.isRequired,\n}\n\nexport default createOverlay\n","import { node, number, object, shape, string } from 'prop-types'\nimport { useEffect, useMemo } from 'react'\nimport { createPortal } from 'react-dom'\nimport useMemoCompare from '../hooks/useMemoCompare'\nimport createOverlay from './overlay'\n\n/**\n * @param {HTMLElement} container\n * @param {google.maps.MapPanes} pane - The pane on which to display the overlay. This is the Pane name, not the Pane itself. Defaults to floatPane.\n * @param {google.maps.LatLng | google.maps.LatLngLiteral} position\n * @returns {void}\n * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)\n */\nconst OverlayView = ({ position, pane = 'floatPane', map, maps, zIndex, children }) => {\n\tconst container = useMemo(() => {\n\t\t// eslint-disable-next-line no-undef\n\t\tconst div = document.createElement('div')\n\t\tdiv.style.position = 'absolute'\n\t\treturn div\n\t}, [])\n\n\tconst overlay = useMemo(() => {\n\t\treturn createOverlay({ container, pane, position, maps })\n\t}, [container, maps, pane, position])\n\n\t// Because React does not do deep comparisons, a custom hook is used.\n\t// This fixes the issue where the overlay is not updated when the position changes.\n\tconst childrenProps = useMemoCompare(children?.props, (prev, next) => {\n\t\treturn prev && prev.lat === next.lat && prev.lng === next.lng\n\t})\n\n\tuseEffect(() => {\n\t\tif (!overlay.map) {\n\t\t\toverlay?.setMap(map)\n\t\t\treturn () => {\n\t\t\t\toverlay?.setMap(null)\n\t\t\t}\n\t\t}\n\t\t// overlay depends on map, so we don't need to add it to the dependency array\n\t\t// otherwise, it will re-render the overlay every time the map changes\n\t\t//? added childrenProps to the dependency array to re-render the overlay when the children props change.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [map, childrenProps])\n\n\t// to move the container to the foreground and background\n\tuseEffect(() => {\n\t\tcontainer.style.zIndex = `${zIndex}`\n\t}, [zIndex, container])\n\n\treturn createPortal(children, container)\n}\n\nOverlayView.defaultProps = {\n\tzIndex: 0,\n}\n\nOverlayView.propTypes = {\n\t/**\n\t * The HTML container element for the overlay.\n\t * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)\n\t * @default 'floatPane'\n\t * @type {google.maps.MapPanes}\n\t */\n\tpane: string,\n\t/**\n\t * The geographical location of the overlay.\n\t * @type {google.maps.LatLng | google.maps.LatLngLiteral}\n\t * @required\n\t * @ref [LatLng](https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLng)\n\t */\n\tposition: shape({\n\t\tlat: number.isRequired,\n\t\tlng: number.isRequired,\n\t}).isRequired,\n\t/**\n\t * The map on which to display the overlay.\n\t * @type {google.maps.Map}\n\t * @required\n\t * @ref [Map](https://developers.google.com/maps/documentation/javascript/reference/map#Map)\n\t */\n\tmap: object.isRequired,\n\t/**\n\t * The Google Maps API.\n\t * @type {object}\n\t * @required\n\t * @ref [Google Maps API](https://developers.google.com/maps/documentation/javascript/reference)\n\t */\n\tmaps: object.isRequired,\n\t/**\n\t * The z-index of the overlay.\n\t * @type {number}\n\t * @default 0\n\t */\n\tzIndex: number,\n\t/**\n\t * The children of the OverlayView.\n\t * @type {ReactNode}\n\t * @required\n\t * @ref [ReactNode](https://reactjs.org/docs/react-api.html#reactnode)\n\t */\n\tchildren: node.isRequired,\n}\n\nexport default OverlayView\n","import { node, object } from 'prop-types'\nimport React, { Children, isValidElement, useMemo } from 'react'\nimport OverlayView from './overlay-view'\n\nconst MapMarkers = ({ children, map, maps }) => {\n\tconst markers = useMemo(() => {\n\t\tif (!map || !maps) return []\n\n\t\treturn Children.map(children, (child) => {\n\t\t\tif (isValidElement(child)) {\n\t\t\t\tconst latLng = { lat: child.props.lat, lng: child.props.lng }\n\t\t\t\t// set the map prop on the child component\n\t\t\t\treturn (\n\t\t\t\t\t\n\t\t\t\t\t\t{child}\n\t\t\t\t\t\n\t\t\t\t)\n\t\t\t}\n\t\t})\n\t}, [children, map, maps])\n\n\treturn
{markers}
\n}\n\nMapMarkers.propTypes = {\n\t/**\n\t * The Markers on the Map.\n\t * @type {ReactNode}\n\t * @required\n\t */\n\tchildren: node.isRequired,\n\t/**\n\t * The Google Maps instance.\n\t * @type {object}\n\t * @required\n\t */\n\tmap: object,\n\t/**\n\t * The Google Maps API.\n\t * @type {object}\n\t * @required\n\t */\n\tmaps: object.isRequired,\n}\n\nexport default MapMarkers\n","import { arrayOf, func, node, number, object, oneOfType } from 'prop-types'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { isArraysEqualEps } from '../utils/utils'\nimport MapMarkers from './markers'\n\nconst EPS = 0.00001\n\nconst MapComponent = ({ children, style, defaultCenter, defaultZoom, onGoogleApiLoaded, onChange, ...props }) => {\n\tconst mapRef = useRef(null)\n\tconst prevBoundsRef = useRef(null)\n\tconst [map, setMap] = useState(null)\n\tconst [maps, setMaps] = useState(null)\n\tconst [googleApiCalled, setGoogleApiCalled] = useState(false)\n\n\tconst onIdle = useCallback(() => {\n\t\tconst zoom = map.getZoom()\n\t\tconst bounds = map.getBounds()\n\t\tconst centerLatLng = map.getCenter()\n\n\t\tconst ne = bounds.getNorthEast()\n\t\tconst sw = bounds.getSouthWest()\n\t\tconst boundsArray = [sw.lng(), sw.lat(), ne.lng(), ne.lat()]\n\n\t\tif (!isArraysEqualEps(boundsArray, prevBoundsRef.current, EPS)) {\n\t\t\tif (onChange) {\n\t\t\t\tonChange({\n\t\t\t\t\tzoom,\n\t\t\t\t\tcenter: [centerLatLng.lng(), centerLatLng.lat()],\n\t\t\t\t\tbounds,\n\t\t\t\t})\n\t\t\t}\n\t\t\tprevBoundsRef.current = boundsArray\n\t\t}\n\t}, [map, onChange])\n\n\tuseEffect(() => {\n\t\tif (mapRef.current && !map) {\n\t\t\tsetMap(\n\t\t\t\tnew window.google.maps.Map(mapRef.current, {\n\t\t\t\t\tcenter: defaultCenter,\n\t\t\t\t\tzoom: defaultZoom,\n\t\t\t\t\t...props,\n\t\t\t\t})\n\t\t\t)\n\t\t\tsetMaps(window.google.maps)\n\t\t}\n\t}, [defaultCenter, defaultZoom, map, mapRef, props])\n\n\tuseEffect(() => {\n\t\tif (map) {\n\t\t\tif (!googleApiCalled) {\n\t\t\t\tonGoogleApiLoaded({ map, maps, ref: mapRef.current })\n\t\t\t\tsetGoogleApiCalled(true)\n\t\t\t}\n\n\t\t\twindow.google.maps.event.clearListeners(map, 'idle')\n\t\t\t// Idle event is fired when the map becomes idle after panning or zooming.\n\t\t\twindow.google.maps.event.addListener(map, 'idle', onIdle)\n\t\t}\n\t}, [googleApiCalled, map, maps, onChange, onGoogleApiLoaded, onIdle])\n\n\tuseEffect(() => {\n\t\t// clear listeners on unmount\n\t\treturn () => {\n\t\t\tif (map) {\n\t\t\t\twindow.google.maps.event.clearListeners(map, 'idle')\n\t\t\t}\n\t\t}\n\t}, [map])\n\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t{children && map && maps && (\n\t\t\t\t\n\t\t\t\t\t{children}\n\t\t\t\t\n\t\t\t)}\n\t\t\n\t)\n}\n\nMapComponent.defaultProps = {\n\tstyle: {\n\t\twidth: '100%',\n\t\theight: '100%',\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tmargin: 0,\n\t\tpadding: 0,\n\t\tposition: 'absolute',\n\t},\n\tonGoogleApiLoaded: () => {},\n\tonChange: () => {},\n}\n\nMapComponent.propTypes = {\n\t/**\n\t * The Markers on the Map.\n\t */\n\tchildren: oneOfType([arrayOf(node), node]),\n\tstyle: object,\n\tdefaultCenter: object.isRequired,\n\tdefaultZoom: number.isRequired,\n\tonGoogleApiLoaded: func,\n\tonChange: func,\n}\n\nexport default MapComponent\n","import { arrayOf, node, number, object, oneOfType, string } from 'prop-types'\nimport React, { forwardRef } from 'react'\nimport { useGoogleMaps } from './hooks/useGoogleMaps'\nimport MapComponent from './map/map'\n\nconst GoogleMap = forwardRef(function GoogleMap(\n\t{ apiKey, libraries, children, loadingContent, idleContent, errorContent, mapMinHeight, containerProps, ...props },\n\tref\n) {\n\tconst status = useGoogleMaps({ apiKey, libraries })\n\treturn (\n\t\t\n\t\t\t{status === 'ready' ? (\n\t\t\t\t{children}\n\t\t\t) : status === 'loading' ? (\n\t\t\t\tloadingContent\n\t\t\t) : status === 'idle' ? (\n\t\t\t\tidleContent\n\t\t\t) : status === 'error' ? (\n\t\t\t\terrorContent\n\t\t\t) : null}\n\t\t
\n\t)\n})\n\nGoogleMap.defaultProps = {\n\t...MapComponent.defaultProps,\n\tloadingContent: 'Google Maps is loading',\n\tidleContent: 'Google Maps is on idle',\n\terrorContent: 'Google Maps is on error',\n\tmapMinHeight: 'unset',\n\tapiKey: '',\n\tlibraries: ['places', 'geometry'],\n}\n\nGoogleMap.propTypes = {\n\t...MapComponent.propTypes,\n\t/**\n\t * The Markers on the Map.\n\t */\n\tchildren: oneOfType([node, arrayOf(node)]),\n\t/**\n\t * Content to be displayed while the map is loading.\n\t */\n\tloadingContent: node,\n\t/**\n\t * Content to be displayed while the map is idle.\n\t */\n\tidleContent: node,\n\t/**\n\t * Content to be displayed when there is an error loading the map.\n\t */\n\terrorContent: node,\n\t/**\n\t * The minimum height of the map.\n\t */\n\tmapMinHeight: oneOfType([number, string]),\n\t/**\n\t * Props to be passed to the container div.\n\t */\n\tcontainerProps: object,\n}\n\nexport default GoogleMap\n"],"names":["useScript","script","src","attributes","callbacks","onLoadCallback","onErrorCallback","elementIdToAppend","useState","status","setStatus","useEffect","scriptToAdd","document","querySelector","createElement","async","setAttribute","Object","entries","length","map","key","value","getElementById","appendChild","body","setAttributeFromEvent","event","type","addEventListener","currentScriptStatus","getAttribute","setStateFromEvent","removeEventListener","useGoogleMaps","apiKey","libraries","join","id","isArraysEqualEps","arrayA","arrayB","eps","i","Math","abs","useMemoCompare","next","compare","previousRef","useRef","previous","current","isEqual","createOverlay","container","pane","position","maps","Overlay","onAdd","getPanes","classList","add","draw","projection","getProjection","point","fromLatLngToDivPixel","style","transform","x","y","onRemove","parentNode","removeChild","OverlayView","propTypes","element","isRequired","string","shape","lat","number","lng","object","zIndex","children","useMemo","div","overlay","childrenProps","props","prev","setMap","createPortal","defaultProps","node","MapMarkers","markers","Children","child","isValidElement","latLng","EPS","MapComponent","defaultCenter","defaultZoom","onGoogleApiLoaded","onChange","mapRef","prevBoundsRef","setMaps","googleApiCalled","setGoogleApiCalled","onIdle","useCallback","zoom","getZoom","bounds","getBounds","centerLatLng","getCenter","ne","getNorthEast","sw","getSouthWest","boundsArray","center","window","google","Map","ref","clearListeners","addListener","width","height","left","top","margin","padding","oneOfType","arrayOf","func","GoogleMap","forwardRef","loadingContent","idleContent","errorContent","mapMinHeight","containerProps","overflow","minHeight"],"mapp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Ac,EAAEjE;AAAM,EACtB;;;;"} \ No newline at end of file +{"version":3,"file":"index.modern.js","sources":["../src/hooks/useScript.js","../src/hooks/useGoogleMaps.js","../src/utils/utils.js","../src/hooks/useMemoCompare.js","../src/map/overlay.js","../src/map/overlay-view.js","../src/map/markers.js","../src/map/map.js","../src/google-map.js"],"sourcesContent":["/* eslint-disable no-unused-expressions */\nimport { useState, useEffect } from 'react'\n\n/**\n * @description Hook to load external script.\n * @param {Object} script - Script to load.\n * @param {string} script.src - Script source.\n * @param {Object} [script.attributes] - Attributes to add to the script tag.\n * @param {Object} [script.callbacks] - Callbacks executed on completion.\n * @param {Function} [script.callbacks.onLoadCallback] - Callback executed on completion in case of success.\n * @param {Function} [script.callbacks.onErrorCallback] - Callbacks executed on completion in case of error.\n * @param {string} [script.elementIdToAppend] - HTML element id to append the script to. Default is HTML HEAD.\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n *\n * @example\n * const status = useScript({\n * \t\tsrc: \"https://script-to-load.js\",\n * \t\tattributes: { id: \"scriptId\", class: \"script-class\" },\n * \t\tcallbacks: {\n * \t\t\tonLoadCallback: onLoadFunc,\n * \t\t\tonErrorCallback: onErrorFunc,\n * \t\t},\n * \t\telementIdToAppend: \"script-container\"\n * })\n */\n\nexport const useScript = (\n\tscript = {\n\t\tsrc: '',\n\t\tattributes: {},\n\t\tcallbacks: { onLoadCallback: null, onErrorCallback: null },\n\t\telementIdToAppend: null,\n\t}\n) => {\n\t// Keep track of script status (\"idle\", \"loading\", \"ready\", \"error\")\n\tconst [status, setStatus] = useState(script.src ? 'loading' : 'idle')\n\n\tuseEffect(\n\t\t() => {\n\t\t\t// Allow falsy src value if waiting on other data needed for\n\t\t\t// constructing the script URL passed to this hook.\n\t\t\tif (!script.src) {\n\t\t\t\tsetStatus('idle')\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Fetch existing script element by src\n\t\t\t// It may have been added by another instance of this hook\n\t\t\tlet scriptToAdd = document.querySelector(`script[src=\"${script.src}\"]`)\n\t\t\tif (!scriptToAdd) {\n\t\t\t\t// Create script\n\t\t\t\tscriptToAdd = document.createElement('script')\n\t\t\t\tscriptToAdd.src = script.src\n\t\t\t\tscriptToAdd.async = true\n\t\t\t\tscriptToAdd.setAttribute('data-status', 'loading')\n\t\t\t\t// Add other script attributes, if they exist\n\t\t\t\tscript.attributes && Object.entries(script.attributes).length > 0\n\t\t\t\t\t? Object.entries(script.attributes).map(([key, value]) => scriptToAdd.setAttribute(key, value))\n\t\t\t\t\t: null\n\t\t\t\t// Add script to document body\n\t\t\t\tif (script.elementIdToAppend && document.getElementById(script.elementIdToAppend)) {\n\t\t\t\t\tdocument.getElementById(script.elementIdToAppend).appendChild(scriptToAdd)\n\t\t\t\t} else {\n\t\t\t\t\tdocument.body.appendChild(scriptToAdd)\n\t\t\t\t}\n\t\t\t\t// Store status in attribute on script\n\t\t\t\t// This can be read by other instances of this hook\n\t\t\t\tconst setAttributeFromEvent = (event) => {\n\t\t\t\t\tscriptToAdd.setAttribute('data-status', event.type === 'load' ? 'ready' : 'error')\n\t\t\t\t}\n\t\t\t\tscriptToAdd.addEventListener('load', setAttributeFromEvent)\n\t\t\t\tscriptToAdd.addEventListener('error', setAttributeFromEvent)\n\t\t\t} else {\n\t\t\t\t// Grab existing script status from attribute and set to state.\n\t\t\t\tconst currentScriptStatus = scriptToAdd.getAttribute('data-status')\n\t\t\t\tswitch (currentScriptStatus) {\n\t\t\t\t\tcase 'load':\n\t\t\t\t\tcase 'ready':\n\t\t\t\t\t\tscript.callbacks?.onLoadCallback ? script.callbacks.onLoadCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\tscript.callbacks?.onErrorCallback ? script.callbacks.onErrorCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// loading: do nothing\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tsetStatus(currentScriptStatus)\n\t\t\t}\n\t\t\t// Script event handler to update status in state\n\t\t\t// Note: Even if the script already exists we still need to add\n\t\t\t// event handlers to update the state for this hook instance.\n\t\t\tconst setStateFromEvent = (event) => {\n\t\t\t\tevent.type === 'load'\n\t\t\t\t\t? script.callbacks?.onLoadCallback\n\t\t\t\t\t\t? script.callbacks.onLoadCallback()\n\t\t\t\t\t\t: null\n\t\t\t\t\t: script.callbacks?.onErrorCallback\n\t\t\t\t\t? script.callbacks.onErrorCallback()\n\t\t\t\t\t: null\n\t\t\t\tsetStatus(event.type === 'load' ? 'ready' : 'error')\n\t\t\t}\n\t\t\t// Add event listeners\n\t\t\tscriptToAdd.addEventListener('load', setStateFromEvent)\n\t\t\tscriptToAdd.addEventListener('error', setStateFromEvent)\n\t\t\t// Remove event listeners on cleanup\n\t\t\treturn () => {\n\t\t\t\tif (scriptToAdd) {\n\t\t\t\t\tscriptToAdd.removeEventListener('load', setStateFromEvent)\n\t\t\t\t\tscriptToAdd.removeEventListener('error', setStateFromEvent)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Re-run useEffect if script changes\n\t\t[script]\n\t)\n\treturn status\n}\n","import { useScript } from \"./useScript\";\n\n/**\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n */\nexport const useGoogleMaps = ({ apiKey, libraries = [] }) => {\n\tconst script = apiKey\n\t\t? {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${libraries?.join(\",\")}`,\n\t\t\t\tattributes: { id: \"googleMapsApi\" },\n\t\t }\n\t\t: {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?libraries=${libraries?.join(\",\")}`,\n\t\t\t\tattributes: { id: \"googleMapsApi\" },\n\t\t};\n\n\treturn useScript(script);\n};\n","export const isArraysEqualEps = (arrayA, arrayB, eps) => {\n\tif (arrayA && arrayB) {\n\t\tfor (let i = 0; i !== arrayA.length; ++i) {\n\t\t\tif (Math.abs(arrayA[i] - arrayB[i]) > eps) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn false\n}\n","import { useEffect, useRef } from 'react'\n\n/**\n * A hook that compares the previous and current values of a reference.\n * @param {any} value - the current value of the reference\n * @param {function} compare - a function that compares the previous and current values\n * @returns {any} the previous value of the reference\n * @ref https://usehooks.com/useMemoCompare/\n */\nconst useMemoCompare = (next, compare) => {\n\t// Ref for storing previous value\n\tconst previousRef = useRef()\n\tconst previous = previousRef.current\n\t// Pass previous and next value to compare function\n\t// to determine whether to consider them equal.\n\tconst isEqual = compare(previous, next)\n\t// If not equal update previousRef to next value.\n\t// We only update if not equal so that this hook continues to return\n\t// the same old value if compare keeps returning true.\n\tuseEffect(() => {\n\t\tif (!isEqual) {\n\t\t\tpreviousRef.current = next\n\t\t}\n\t})\n\t// Finally, if equal then return the previous value\n\treturn isEqual ? previous : next\n}\n\nexport default useMemoCompare\n","import { element, number, object, shape, string } from 'prop-types'\n\n/**\n * @param {HTMLElement} container\n * @param {google.maps.MapPanes} pane\n * @param {google.maps.LatLng | google.maps.LatLngLiteral} position\n * @param {google.maps} maps\n * @returns {void}\n */\nconst createOverlay = ({ container, pane, position, maps }) => {\n\tclass Overlay extends maps.OverlayView {\n\t\tconstructor(container, pane, position) {\n\t\t\tsuper()\n\t\t\tthis.container = container\n\t\t\tthis.pane = pane\n\t\t\tthis.position = position\n\t\t}\n\n\t\t/**\n\t\t * onAdd is called when the map's panes are ready and the overlay has been\n\t\t * added to the map.\n\t\t */\n\t\tonAdd = () => {\n\t\t\t// Add the element to the pane.\n\t\t\tconst pane = this.getPanes()[this.pane]\n\t\t\tpane?.classList.add('google-map-markers-overlay')\n\t\t\tpane?.appendChild(this.container)\n\t\t}\n\n\t\tdraw = () => {\n\t\t\tconst projection = this.getProjection()\n\t\t\t// Computes the pixel coordinates of the given geographical location in the DOM element that holds the draggable map.\n\t\t\tconst point = projection.fromLatLngToDivPixel(this.position)\n\t\t\tif (point === null) return\n\t\t\tthis.container.style.transform = `translate(${point.x}px, ${point.y}px)`\n\t\t}\n\n\t\t/**\n\t\t * The onRemove() method will be called automatically from the API if\n\t\t * we ever set the overlay's map property to 'null'.\n\t\t */\n\t\tonRemove = () => {\n\t\t\tif (this.container.parentNode !== null) {\n\t\t\t\tthis.container.parentNode.removeChild(this.container)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn new Overlay(container, pane, position)\n}\n\ncreateOverlay.propTypes = {\n\t/**\n\t * The HTML container element for the overlay.\n\t */\n\tcontainer: element.isRequired,\n\t/**\n\t * The HTML container element for the overlay.\n\t * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)\n\t * @default 'floatPane'\n\t * @type {google.maps.MapPanes}\n\t * @required\n\t */\n\tpane: string.isRequired,\n\t/**\n\t * The geographical location of the overlay.\n\t * @type {google.maps.LatLng | google.maps.LatLngLiteral}\n\t * @required\n\t * @ref [LatLng](https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLng)\n\t */\n\tposition: shape({\n\t\tlat: number.isRequired,\n\t\tlng: number.isRequired,\n\t}).isRequired,\n\t/**\n\t * The Google Maps API.\n\t */\n\tmaps: object.isRequired,\n}\n\nexport default createOverlay\n","import { node, number, object, shape, string } from 'prop-types'\nimport { useEffect, useMemo } from 'react'\nimport { createPortal } from 'react-dom'\nimport useMemoCompare from '../hooks/useMemoCompare'\nimport createOverlay from './overlay'\n\n/**\n * @param {HTMLElement} container\n * @param {google.maps.MapPanes} pane - The pane on which to display the overlay. This is the Pane name, not the Pane itself. Defaults to floatPane.\n * @param {google.maps.LatLng | google.maps.LatLngLiteral} position\n * @returns {void}\n * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)\n */\nconst OverlayView = ({ position, pane = 'floatPane', map, maps, zIndex, children }) => {\n\tconst container = useMemo(() => {\n\t\t// eslint-disable-next-line no-undef\n\t\tconst div = document.createElement('div')\n\t\tdiv.style.position = 'absolute'\n\t\treturn div\n\t}, [])\n\n\tconst overlay = useMemo(() => {\n\t\treturn createOverlay({ container, pane, position, maps })\n\t}, [container, maps, pane, position])\n\n\t// Because React does not do deep comparisons, a custom hook is used.\n\t// This fixes the issue where the overlay is not updated when the position changes.\n\tconst childrenProps = useMemoCompare(children?.props, (prev, next) => {\n\t\treturn prev && prev.lat === next.lat && prev.lng === next.lng\n\t})\n\n\tuseEffect(() => {\n\t\tif (!overlay.map) {\n\t\t\toverlay?.setMap(map)\n\t\t\treturn () => {\n\t\t\t\toverlay?.setMap(null)\n\t\t\t}\n\t\t}\n\t\t// overlay depends on map, so we don't need to add it to the dependency array\n\t\t// otherwise, it will re-render the overlay every time the map changes\n\t\t//? added childrenProps to the dependency array to re-render the overlay when the children props change.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [map, childrenProps])\n\n\t// to move the container to the foreground and background\n\tuseEffect(() => {\n\t\tcontainer.style.zIndex = `${zIndex}`\n\t}, [zIndex, container])\n\n\treturn createPortal(children, container)\n}\n\nOverlayView.defaultProps = {\n\tzIndex: 0,\n}\n\nOverlayView.propTypes = {\n\t/**\n\t * The HTML container element for the overlay.\n\t * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)\n\t * @default 'floatPane'\n\t * @type {google.maps.MapPanes}\n\t */\n\tpane: string,\n\t/**\n\t * The geographical location of the overlay.\n\t * @type {google.maps.LatLng | google.maps.LatLngLiteral}\n\t * @required\n\t * @ref [LatLng](https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLng)\n\t */\n\tposition: shape({\n\t\tlat: number.isRequired,\n\t\tlng: number.isRequired,\n\t}).isRequired,\n\t/**\n\t * The map on which to display the overlay.\n\t * @type {google.maps.Map}\n\t * @required\n\t * @ref [Map](https://developers.google.com/maps/documentation/javascript/reference/map#Map)\n\t */\n\tmap: object.isRequired,\n\t/**\n\t * The Google Maps API.\n\t * @type {object}\n\t * @required\n\t * @ref [Google Maps API](https://developers.google.com/maps/documentation/javascript/reference)\n\t */\n\tmaps: object.isRequired,\n\t/**\n\t * The z-index of the overlay.\n\t * @type {number}\n\t * @default 0\n\t */\n\tzIndex: number,\n\t/**\n\t * The children of the OverlayView.\n\t * @type {ReactNode}\n\t * @required\n\t * @ref [ReactNode](https://reactjs.org/docs/react-api.html#reactnode)\n\t */\n\tchildren: node.isRequired,\n}\n\nexport default OverlayView\n","import { node, object } from 'prop-types'\nimport React, { Children, isValidElement, useMemo } from 'react'\nimport OverlayView from './overlay-view'\n\nconst MapMarkers = ({ children, map, maps }) => {\n\tconst markers = useMemo(() => {\n\t\tif (!map || !maps) return []\n\n\t\treturn Children.map(children, (child) => {\n\t\t\tif (isValidElement(child)) {\n\t\t\t\tconst latLng = { lat: child.props.lat, lng: child.props.lng }\n\t\t\t\t// set the map prop on the child component\n\t\t\t\treturn (\n\t\t\t\t\t\n\t\t\t\t\t\t{child}\n\t\t\t\t\t\n\t\t\t\t)\n\t\t\t}\n\t\t})\n\t}, [children, map, maps])\n\n\treturn
{markers}
\n}\n\nMapMarkers.propTypes = {\n\t/**\n\t * The Markers on the Map.\n\t * @type {ReactNode}\n\t * @required\n\t */\n\tchildren: node.isRequired,\n\t/**\n\t * The Google Maps instance.\n\t * @type {object}\n\t * @required\n\t */\n\tmap: object,\n\t/**\n\t * The Google Maps API.\n\t * @type {object}\n\t * @required\n\t */\n\tmaps: object.isRequired,\n}\n\nexport default MapMarkers\n","import { arrayOf, func, node, number, object, oneOfType } from 'prop-types'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { isArraysEqualEps } from '../utils/utils'\nimport MapMarkers from './markers'\n\nconst EPS = 0.00001\n\nconst MapComponent = ({ children, style, defaultCenter, defaultZoom, onGoogleApiLoaded, onChange, ...props }) => {\n\tconst mapRef = useRef(null)\n\tconst prevBoundsRef = useRef(null)\n\tconst [map, setMap] = useState(null)\n\tconst [maps, setMaps] = useState(null)\n\tconst [googleApiCalled, setGoogleApiCalled] = useState(false)\n\n\tconst onIdle = useCallback(() => {\n\t\tconst zoom = map.getZoom()\n\t\tconst bounds = map.getBounds()\n\t\tconst centerLatLng = map.getCenter()\n\n\t\tconst ne = bounds.getNorthEast()\n\t\tconst sw = bounds.getSouthWest()\n\t\tconst boundsArray = [sw.lng(), sw.lat(), ne.lng(), ne.lat()]\n\n\t\tif (!isArraysEqualEps(boundsArray, prevBoundsRef.current, EPS)) {\n\t\t\tif (onChange) {\n\t\t\t\tonChange({\n\t\t\t\t\tzoom,\n\t\t\t\t\tcenter: [centerLatLng.lng(), centerLatLng.lat()],\n\t\t\t\t\tbounds,\n\t\t\t\t})\n\t\t\t}\n\t\t\tprevBoundsRef.current = boundsArray\n\t\t}\n\t}, [map, onChange])\n\n\tuseEffect(() => {\n\t\tif (mapRef.current && !map) {\n\t\t\tsetMap(\n\t\t\t\tnew window.google.maps.Map(mapRef.current, {\n\t\t\t\t\tcenter: defaultCenter,\n\t\t\t\t\tzoom: defaultZoom,\n\t\t\t\t\t...props,\n\t\t\t\t})\n\t\t\t)\n\t\t\tsetMaps(window.google.maps)\n\t\t}\n\t}, [defaultCenter, defaultZoom, map, mapRef, props])\n\n\tuseEffect(() => {\n\t\tif (map) {\n\t\t\tif (!googleApiCalled) {\n\t\t\t\tonGoogleApiLoaded({ map, maps, ref: mapRef.current })\n\t\t\t\tsetGoogleApiCalled(true)\n\t\t\t}\n\n\t\t\twindow.google.maps.event.clearListeners(map, 'idle')\n\t\t\t// Idle event is fired when the map becomes idle after panning or zooming.\n\t\t\twindow.google.maps.event.addListener(map, 'idle', onIdle)\n\t\t}\n\t}, [googleApiCalled, map, maps, onChange, onGoogleApiLoaded, onIdle])\n\n\tuseEffect(() => {\n\t\t// clear listeners on unmount\n\t\treturn () => {\n\t\t\tif (map) {\n\t\t\t\twindow.google.maps.event.clearListeners(map, 'idle')\n\t\t\t}\n\t\t}\n\t}, [map])\n\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t{children && map && maps && (\n\t\t\t\t\n\t\t\t\t\t{children}\n\t\t\t\t\n\t\t\t)}\n\t\t\n\t)\n}\n\nMapComponent.defaultProps = {\n\tstyle: {\n\t\twidth: '100%',\n\t\theight: '100%',\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tmargin: 0,\n\t\tpadding: 0,\n\t\tposition: 'absolute',\n\t},\n\tonGoogleApiLoaded: () => {},\n\tonChange: () => {},\n}\n\nMapComponent.propTypes = {\n\t/**\n\t * The Markers on the Map.\n\t */\n\tchildren: oneOfType([arrayOf(node), node]),\n\tstyle: object,\n\tdefaultCenter: object.isRequired,\n\tdefaultZoom: number.isRequired,\n\tonGoogleApiLoaded: func,\n\tonChange: func,\n}\n\nexport default MapComponent\n","import { arrayOf, node, number, object, oneOfType, string } from 'prop-types'\nimport React, { forwardRef } from 'react'\nimport { useGoogleMaps } from './hooks/useGoogleMaps'\nimport MapComponent from './map/map'\n\nconst GoogleMap = forwardRef(function GoogleMap(\n\t{ apiKey, libraries, children, loadingContent, idleContent, errorContent, mapMinHeight, containerProps, ...props },\n\tref\n) {\n\tconst status = useGoogleMaps({ apiKey, libraries })\n\treturn (\n\t\t\n\t\t\t{status === 'ready' ? (\n\t\t\t\t{children}\n\t\t\t) : status === 'loading' ? (\n\t\t\t\tloadingContent\n\t\t\t) : status === 'idle' ? (\n\t\t\t\tidleContent\n\t\t\t) : status === 'error' ? (\n\t\t\t\terrorContent\n\t\t\t) : null}\n\t\t
\n\t)\n})\n\nGoogleMap.defaultProps = {\n\t...MapComponent.defaultProps,\n\tloadingContent: 'Google Maps is loading',\n\tidleContent: 'Google Maps is on idle',\n\terrorContent: 'Google Maps is on error',\n\tmapMinHeight: 'unset',\n\tapiKey: '',\n\tlibraries: ['places', 'geometry'],\n}\n\nGoogleMap.propTypes = {\n\t...MapComponent.propTypes,\n\t/**\n\t * The Markers on the Map.\n\t */\n\tchildren: oneOfType([node, arrayOf(node)]),\n\t/**\n\t * Content to be displayed while the map is loading.\n\t */\n\tloadingContent: node,\n\t/**\n\t * Content to be displayed while the map is idle.\n\t */\n\tidleContent: node,\n\t/**\n\t * Content to be displayed when there is an error loading the map.\n\t */\n\terrorContent: node,\n\t/**\n\t * The minimum height of the map.\n\t */\n\tmapMinHeight: oneOfType([number, string]),\n\t/**\n\t * Props to be passed to the container div.\n\t */\n\tcontainerProps: object,\n}\n\nexport default GoogleMap\n"],"names":["useScript","script","src","attributes","callbacks","onLoadCallback","onErrorCallback","elementIdToAppend","status","setStatus","useState","useEffect","scriptToAdd","document","querySelector","createElement","async","setAttribute","Object","entries","length","map","key","value","getElementById","appendChild","body","setAttributeFromEvent","event","type","addEventListener","currentScriptStatus","getAttribute","setStateFromEvent","removeEventListener","useGoogleMaps","apiKey","libraries","join","id","isArraysEqualEps","arrayA","arrayB","eps","i","Math","abs","useMemoCompare","next","compare","previousRef","useRef","previous","current","isEqual","createOverlay","container","pane","position","maps","Overlay","OverlayView","constructor","onAdd","getPanes","classList","add","draw","projection","getProjection","point","fromLatLngToDivPixel","style","transform","x","y","onRemove","parentNode","removeChild","propTypes","element","isRequired","string","shape","lat","number","lng","object","zIndex","children","useMemo","div","overlay","childrenProps","props","prev","setMap","createPortal","defaultProps","node","MapMarkers","markers","Children","child","isValidElement","latLng","EPS","MapComponent","defaultCenter","defaultZoom","onGoogleApiLoaded","onChange","mapRef","prevBoundsRef","setMaps","googleApiCalled","setGoogleApiCalled","onIdle","useCallback","zoom","getZoom","bounds","getBounds","centerLatLng","getCenter","ne","getNorthEast","sw","getSouthWest","boundsArray","center","window","google","Map","ref","clearListeners","addListener","width","height","left","top","margin","padding","oneOfType","arrayOf","func","GoogleMap","forwardRef","loadingContent","idleContent","errorContent","mapMinHeight","containerProps","overflow","minHeight"],"mappings":";;;;AA0BO,MAAMA,SAAS,GAAG,CACxBC,MAAM,GAAG;EACRC,GAAG,EAAE,EAAE;EACPC,UAAU,EAAE,EAAE;EACdC,SAAS,EAAE;IAAEC,cAAc,EAAE,IAAI;IAAEC,eAAe,EAAE;GAAM;EAC1DC,iBAAiB,EAAE;A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wB;EACrCC,YAAY,EAAE,yBAAyB;EACvCC,YAAY,EAAE,OAAO;EACrBnH,MAAM,EAAE,EAAE;EACVC,SAAS,EAAE,CAAC,QAAQ,EAAE,UAAU;AACjC,CAAC;AAED6G,SAAS,CAACnE,SAAS,GAAG;EACrB,GAAG4B,YAAY,CAAC5B,SAAS;EAIzBU,QAAQ,EAAEsD,SAAS,CAAC,CAAC5C,IAAI,EAAE6C,OAAO,CAAC7C,IAAI,CAAC,CAAC,CAAC;EAI1CiD,cAAc,EAAEjD,IAAI;EAIpBkD,WAAW,EAAElD,IAAI;EAIjBmD,YAAY,EAAEnD,IAAI;EAIlBoD,YAAY,EAAER,SAAS,CAAC,CAAC1D,MAAM,EAAEH,MAAM,CAAC,CAAC;EAIzCsE,cAAc,EAAEjE;AACjB,CAAC;;;;"} \ No newline at end of file diff --git a/dist/map/map.d.ts b/dist/map/map.d.ts new file mode 100644 index 0000000..fb50cfd --- /dev/null +++ b/dist/map/map.d.ts @@ -0,0 +1,34 @@ +export default MapComponent; +declare function MapComponent({ children, style, defaultCenter, defaultZoom, onGoogleApiLoaded, onChange, ...props }: { + [x: string]: any; + children: any; + style: any; + defaultCenter: any; + defaultZoom: any; + onGoogleApiLoaded: any; + onChange: any; +}): any; +declare namespace MapComponent { + namespace defaultProps { + namespace style { + const width: string; + const height: string; + const left: number; + const top: number; + const margin: number; + const padding: number; + const position: string; + } + function onGoogleApiLoaded(): void; + function onChange(): void; + } + namespace propTypes { + export const children: any; + export { object as style }; + export const defaultCenter: any; + export const defaultZoom: any; + export { func as onGoogleApiLoaded }; + export { func as onChange }; + } +} +//# sourceMappingURL=map.d.ts.map \ No newline at end of file diff --git a/dist/map/map.d.ts.map b/dist/map/map.d.ts.map new file mode 100644 index 0000000..d432d9b --- /dev/null +++ b/dist/map/map.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/map/map.js"],"names":[],"mappings":";AAOA;;;;;;;;QAyEC;;;;;;;;;;;;QAYmB,mCAAQ;QACjB,0BAAQ"} \ No newline at end of file diff --git a/dist/map/markers.d.ts b/dist/map/markers.d.ts new file mode 100644 index 0000000..ecb2d69 --- /dev/null +++ b/dist/map/markers.d.ts @@ -0,0 +1,14 @@ +export default MapMarkers; +declare function MapMarkers({ children, map, maps }: { + children: any; + map: any; + maps: any; +}): any; +declare namespace MapMarkers { + namespace propTypes { + export const children: ReactNode; + export { object as map }; + export const maps: object; + } +} +//# sourceMappingURL=markers.d.ts.map \ No newline at end of file diff --git a/dist/map/markers.d.ts.map b/dist/map/markers.d.ts.map new file mode 100644 index 0000000..9fda3a5 --- /dev/null +++ b/dist/map/markers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../src/map/markers.js"],"names":[],"mappings":";AAIA;;;;QAkBC;;;;;2BAiBU,MAAM"} \ No newline at end of file diff --git a/dist/map/overlay-view.d.ts b/dist/map/overlay-view.d.ts new file mode 100644 index 0000000..8d797b8 --- /dev/null +++ b/dist/map/overlay-view.d.ts @@ -0,0 +1,23 @@ +export default OverlayView; +/** + * @param {HTMLElement} container + * @param {google.maps.MapPanes} pane - The pane on which to display the overlay. This is the Pane name, not the Pane itself. Defaults to floatPane. + * @param {google.maps.LatLng | google.maps.LatLngLiteral} position + * @returns {void} + * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes) + */ +declare function OverlayView({ position, pane, map, maps, zIndex, children }: HTMLElement): void; +declare namespace OverlayView { + namespace defaultProps { + const zIndex: number; + } + namespace propTypes { + export { string as pane }; + export const position: google.maps.LatLng | google.maps.LatLngLiteral; + export const map: google.maps.Map; + export const maps: object; + export { number as zIndex }; + export const children: ReactNode; + } +} +//# sourceMappingURL=overlay-view.d.ts.map \ No newline at end of file diff --git a/dist/map/overlay-view.d.ts.map b/dist/map/overlay-view.d.ts.map new file mode 100644 index 0000000..f619134 --- /dev/null +++ b/dist/map/overlay-view.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"overlay-view.d.ts","sourceRoot":"","sources":["../../src/map/overlay-view.js"],"names":[],"mappings":";AAMA;;;;;;GAMG;AACH,8EANW,WAAW,GAGT,IAAI,CAwChB;;;;;;;+BAgBU,8CAA8C;;2BAiB9C,MAAM"} \ No newline at end of file diff --git a/dist/map/overlay.d.ts b/dist/map/overlay.d.ts new file mode 100644 index 0000000..1d4c2d9 --- /dev/null +++ b/dist/map/overlay.d.ts @@ -0,0 +1,18 @@ +export default createOverlay; +/** + * @param {HTMLElement} container + * @param {google.maps.MapPanes} pane + * @param {google.maps.LatLng | google.maps.LatLngLiteral} position + * @param {google.maps} maps + * @returns {void} + */ +declare function createOverlay({ container, pane, position, maps }: HTMLElement): void; +declare namespace createOverlay { + namespace propTypes { + const container: any; + const pane: google.maps.MapPanes; + const position: google.maps.LatLng | google.maps.LatLngLiteral; + const maps: any; + } +} +//# sourceMappingURL=overlay.d.ts.map \ No newline at end of file diff --git a/dist/map/overlay.d.ts.map b/dist/map/overlay.d.ts.map new file mode 100644 index 0000000..45f1ade --- /dev/null +++ b/dist/map/overlay.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/map/overlay.js"],"names":[],"mappings":";AAEA;;;;;;GAMG;AACH,oEANW,WAAW,GAIT,IAAI,CA0ChB;;;;;wBAiBU,8CAA8C"} \ No newline at end of file diff --git a/dist/utils/utils.d.ts b/dist/utils/utils.d.ts new file mode 100644 index 0000000..f729f6e --- /dev/null +++ b/dist/utils/utils.d.ts @@ -0,0 +1,2 @@ +export function isArraysEqualEps(arrayA: any, arrayB: any, eps: any): boolean; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/dist/utils/utils.d.ts.map b/dist/utils/utils.d.ts.map new file mode 100644 index 0000000..76c9e5a --- /dev/null +++ b/dist/utils/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.js"],"names":[],"mappings":"AAAO,8EAUN"} \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 87a9a0b..9c17006 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,7 +15,7 @@ The library implements [Google Maps Custom Overlays](https://developers.google.c ## Install ```bash -yarn add -D google-maps-react-markers +yarn add google-maps-react-markers ``` or @@ -28,40 +28,40 @@ npm install --save google-maps-react-markers ```jsx const App = () => { - const mapRef = useRef(null); - const [mapReady, setMapReady] = useState(false); - - /** - * @description This function is called when the map is ready - * @param {Object} map - reference to the map instance - * @param {Object} maps - reference to the maps library - */ - const onGoogleApiLoaded = ({ map, maps }) => { - mapRef.current = map; - setMapReady(true); - }; - - const onMarkerClick = (markerId) => { - console.log("This is ->", markerId); - }; - - return ( - <> - {mapReady &&
Map is ready. See for logs in developer console.
} - console.log("Map moved", map)} - > - {coordinates.map(({ lat, lng, name }, index) => ( - - ))} - - - ); + const mapRef = useRef(null); + const [mapReady, setMapReady] = useState(false); + + /** + * @description This function is called when the map is ready + * @param {Object} map - reference to the map instance + * @param {Object} maps - reference to the maps library + */ + const onGoogleApiLoaded = ({ map, maps }) => { + mapRef.current = map; + setMapReady(true); + }; + + const onMarkerClick = (markerId) => { + console.log("This is ->", markerId); + }; + + return ( + <> + {mapReady &&
Map is ready. See for logs in developer console.
} + console.log("Map moved", map)} + > + {coordinates.map(({ lat, lng, name }, index) => ( + + ))} + + + ); }; export default App; @@ -93,8 +93,17 @@ For clustering, follow this [guide](https://www.leighhalliday.com/google-maps-cl const onMapChange = ({ bounds, zoom }) => { const ne = bounds.getNorthEast(); const sw = bounds.getSouthWest(); - // useSupercluster accepts bounds in the form of [westLng, southLat, eastLng, northLat] + /** + * useSupercluster accepts bounds in the form of [westLng, southLat, eastLng, northLat] + * const { clusters, supercluster } = useSupercluster({ + * points: points, + * bounds: mapBounds.bounds, + * zoom: mapBounds.zoom, + * }) + */ setMapBounds({ ...mapBounds, bounds: [sw.lng(), sw.lat(), ne.lng(), ne.lat()], zoom }); + + console.log("New bounds and zoom -> ", { bounds, zoom }); }; ``` diff --git a/docs/build/asset-manifest.json b/docs/build/asset-manifest.json index 00eb51b..8f62adc 100644 --- a/docs/build/asset-manifest.json +++ b/docs/build/asset-manifest.json @@ -1,13 +1,13 @@ { "files": { - "main.css": "./static/css/main.23f87a87.css", - "main.js": "./static/js/main.e1d97e2f.js", + "main.css": "./static/css/main.d964f5a5.css", + "main.js": "./static/js/main.2feec936.js", "index.html": "./index.html", - "main.23f87a87.css.map": "./static/css/main.23f87a87.css.map", - "main.e1d97e2f.js.map": "./static/js/main.e1d97e2f.js.map" + "main.d964f5a5.css.map": "./static/css/main.d964f5a5.css.map", + "main.2feec936.js.map": "./static/js/main.2feec936.js.map" }, "entrypoints": [ - "static/css/main.23f87a87.css", - "static/js/main.e1d97e2f.js" + "static/css/main.d964f5a5.css", + "static/js/main.2feec936.js" ] } \ No newline at end of file diff --git a/docs/build/index.html b/docs/build/index.html index 4e133fe..644dfa9 100644 --- a/docs/build/index.html +++ b/docs/build/index.html @@ -1 +1 @@ -google-maps-react-markers
\ No newline at end of file +google-maps-react-markers
\ No newline at end of file diff --git a/docs/build/static/css/main.23f87a87.css b/docs/build/static/css/main.23f87a87.css deleted file mode 100644 index 4e58610..0000000 --- a/docs/build/static/css/main.23f87a87.css +++ /dev/null @@ -1,2 +0,0 @@ -body{background-color:#191919;color:#fff;font-family:Roboto Mono,monospace;font-size:1rem}#root{display:flex;flex-direction:column;justify-content:space-around;min-height:100vh}button{background:#000;border:0;color:#fff;cursor:pointer;font-weight:700;margin:5px 0;padding:10px}.container{align-items:center;display:flex;justify-content:space-between;padding:10px}.marker{-webkit-animation:reveal .4s forwards;animation:reveal .4s forwards;-webkit-transform:scale(0);transform:scale(0)}@-webkit-keyframes reveal{to{-webkit-transform:scale(1);transform:scale(1)}}@keyframes reveal{to{-webkit-transform:scale(1);transform:scale(1)}} -/*# sourceMappingURL=main.23f87a87.css.map*/ \ No newline at end of file diff --git a/docs/build/static/css/main.23f87a87.css.map b/docs/build/static/css/main.23f87a87.css.map deleted file mode 100644 index 4be97f4..0000000 --- a/docs/build/static/css/main.23f87a87.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"static/css/main.23f87a87.css","mappings":"AAAA,KACC,wBAAyB,CACzB,UAAW,CACX,iCAAmC,CACnC,cACD,CAEA,MACC,YAAa,CACb,qBAAsB,CACtB,4BAA6B,CAC7B,gBACD,CAEA,OAEC,eAAgB,CAChB,QAAS,CAFT,UAAW,CAKX,cAAe,CACf,eAAiB,CAFjB,YAAa,CADb,YAID,CAEA,WAGC,kBAAmB,CAFnB,YAAa,CACb,6BAA8B,CAE9B,YACD,CAEA,QAEC,qCAAgC,CAAhC,6BAAgC,CADhC,0BAAmB,CAAnB,kBAED,CACA,0BACC,GACC,0BAAmB,CAAnB,kBACD,CACD,CAJA,kBACC,GACC,0BAAmB,CAAnB,kBACD,CACD","sources":["style.css"],"sourcesContent":["body {\n\tbackground-color: #191919;\n\tcolor: #fff;\n\tfont-family: Roboto Mono, monospace;\n\tfont-size: 1rem;\n}\n\n#root {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-around;\n\tmin-height: 100vh;\n}\n\nbutton {\n\tcolor: #fff;\n\tbackground: #000;\n\tborder: 0;\n\tpadding: 10px;\n\tmargin: 5px 0;\n\tcursor: pointer;\n\tfont-weight: bold;\n}\n\n.container {\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tpadding: 10px;\n}\n\n.marker {\n\ttransform: scale(0);\n\tanimation: 400ms reveal forwards;\n}\n@keyframes reveal {\n\tto {\n\t\ttransform: scale(1);\n\t}\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/docs/build/static/css/main.d964f5a5.css b/docs/build/static/css/main.d964f5a5.css new file mode 100644 index 0000000..79887a9 --- /dev/null +++ b/docs/build/static/css/main.d964f5a5.css @@ -0,0 +1,2 @@ +body{background-color:#191919;color:#fff;font-family:Roboto Mono,monospace;font-size:14px}#root{display:flex;flex-direction:column;justify-content:space-around;min-height:100vh}button{background:#000;border:0;color:#fff;cursor:pointer;font-weight:700;margin:5px 0;padding:10px}.container{align-items:center;display:flex;justify-content:space-between;padding:10px}.container h1,.container h2,.container h3{color:#ffff6b}.left{align-items:flex-start;display:flex}.left>div:not(.info){padding-left:25px}.right a{background-color:#000;display:block;padding:10px}.marker{-webkit-animation:reveal .4s forwards;animation:reveal .4s forwards;-webkit-transform:scale(0);transform:scale(0)}@-webkit-keyframes reveal{to{-webkit-transform:scale(1);transform:scale(1)}}@keyframes reveal{to{-webkit-transform:scale(1);transform:scale(1)}}@media screen and (max-width:767px){.container{align-items:flex-start}.container,.left{flex-direction:column}.left>div:not(.info){padding-left:0}} +/*# sourceMappingURL=main.d964f5a5.css.map*/ \ No newline at end of file diff --git a/docs/build/static/css/main.d964f5a5.css.map b/docs/build/static/css/main.d964f5a5.css.map new file mode 100644 index 0000000..7b61ad5 --- /dev/null +++ b/docs/build/static/css/main.d964f5a5.css.map @@ -0,0 +1 @@ +{"version":3,"file":"static/css/main.d964f5a5.css","mappings":"AAAA,KACC,wBAAyB,CACzB,UAAW,CACX,iCAAmC,CACnC,cACD,CAEA,MACC,YAAa,CACb,qBAAsB,CACtB,4BAA6B,CAC7B,gBACD,CAEA,OAEC,eAAgB,CAChB,QAAS,CAFT,UAAW,CAKX,cAAe,CACf,eAAiB,CAFjB,YAAa,CADb,YAID,CAEA,WAGC,kBAAmB,CAFnB,YAAa,CACb,6BAA8B,CAE9B,YACD,CAEA,0CACC,aACD,CAEA,MAEC,sBAAuB,CADvB,YAED,CAEA,qBACC,iBACD,CAEA,SAGC,qBAAsB,CAFtB,aAAc,CACd,YAED,CAEA,QAEC,qCAAgC,CAAhC,6BAAgC,CADhC,0BAAmB,CAAnB,kBAED,CACA,0BACC,GACC,0BAAmB,CAAnB,kBACD,CACD,CAJA,kBACC,GACC,0BAAmB,CAAnB,kBACD,CACD,CAEA,oCACC,WAEC,sBACD,CACA,iBAHC,qBAKD,CACA,qBACC,cACD,CACD","sources":["style.css"],"sourcesContent":["body {\n\tbackground-color: #191919;\n\tcolor: #fff;\n\tfont-family: Roboto Mono, monospace;\n\tfont-size: 14px;\n}\n\n#root {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-around;\n\tmin-height: 100vh;\n}\n\nbutton {\n\tcolor: #fff;\n\tbackground: #000;\n\tborder: 0;\n\tpadding: 10px;\n\tmargin: 5px 0;\n\tcursor: pointer;\n\tfont-weight: bold;\n}\n\n.container {\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tpadding: 10px;\n}\n\n.container h1, .container h2, .container h3 {\n\tcolor: rgb(255, 255, 107);\n}\n\n.left {\n\tdisplay: flex;\n\talign-items: flex-start;\n}\n\n.left > div:not(.info) {\n\tpadding-left: 25px;\n}\n\n.right a {\n\tdisplay: block;\n\tpadding: 10px;\n\tbackground-color: #000;\n}\n\n.marker {\n\ttransform: scale(0);\n\tanimation: 400ms reveal forwards;\n}\n@keyframes reveal {\n\tto {\n\t\ttransform: scale(1);\n\t}\n}\n\n@media screen and (max-width: 767px) {\n\t.container {\n\t\tflex-direction: column;\n\t\talign-items: flex-start;\n\t}\n\t.left {\n\t\tflex-direction: column;\n\t}\n\t.left > div:not(.info) {\n\t\tpadding-left: 0;\n\t}\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/docs/build/static/js/main.e1d97e2f.js b/docs/build/static/js/main.2feec936.js similarity index 56% rename from docs/build/static/js/main.e1d97e2f.js rename to docs/build/static/js/main.2feec936.js index 534fe35..3d28846 100644 --- a/docs/build/static/js/main.e1d97e2f.js +++ b/docs/build/static/js/main.2feec936.js @@ -1,3 +1,3 @@ -/*! For license information please see main.e1d97e2f.js.LICENSE.txt */ -!function(){var e={241:function(e,n,t){"use strict";var r=t(71);function l(){}function a(){}a.resetWarningCache=l,e.exports=function(){function e(e,n,t,l,a,o){if(o!==r){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function n(){return e}e.isRequired=e;var t={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,elementType:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:a,resetWarningCache:l};return t.PropTypes=t,t}},630:function(e,n,t){e.exports=t(241)()},71:function(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},839:function(e,n,t){"use strict";var r=t(167),l=t(704);function a(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,t=1;t