UNPKG

94.5 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7var React = require('react');
8var invariant = _interopDefault(require('invariant'));
9var markerClusterer = require('@react-google-maps/marker-clusterer');
10var ReactDOM = require('react-dom');
11var infobox = require('@react-google-maps/infobox');
12
13function _extends() {
14 _extends = Object.assign || function (target) {
15 for (var i = 1; i < arguments.length; i++) {
16 var source = arguments[i];
17
18 for (var key in source) {
19 if (Object.prototype.hasOwnProperty.call(source, key)) {
20 target[key] = source[key];
21 }
22 }
23 }
24
25 return target;
26 };
27
28 return _extends.apply(this, arguments);
29}
30
31function _inheritsLoose(subClass, superClass) {
32 subClass.prototype = Object.create(superClass.prototype);
33 subClass.prototype.constructor = subClass;
34 subClass.__proto__ = superClass;
35}
36
37function _objectWithoutPropertiesLoose(source, excluded) {
38 if (source == null) return {};
39 var target = {};
40 var sourceKeys = Object.keys(source);
41 var key, i;
42
43 for (i = 0; i < sourceKeys.length; i++) {
44 key = sourceKeys[i];
45 if (excluded.indexOf(key) >= 0) continue;
46 target[key] = source[key];
47 }
48
49 return target;
50}
51
52var MapContext =
53/*#__PURE__*/
54React.createContext(null);
55function useGoogleMap() {
56 !!!React.useContext ? invariant(false, 'useGoogleMap is React hook and requires React version 16.8+') : void 0;
57 var map = React.useContext(MapContext);
58 !!!map ? invariant(false, 'useGoogleMap needs a GoogleMap available up in the tree') : void 0;
59 return map;
60}
61
62// eslint-disable-next-line @typescript-eslint/no-explicit-any
63var reduce = function reduce(obj, fn, acc) {
64 return Object.keys(obj).reduce(function reducer(newAcc, key) {
65 return fn(newAcc, obj[key], key);
66 }, acc);
67};
68
69// eslint-disable-next-line @typescript-eslint/no-explicit-any
70function forEach(obj, fn) {
71 Object.keys(obj).forEach(function iterator(key) {
72 return fn(obj[key], key);
73 });
74}
75
76/* global google */
77var applyUpdaterToNextProps = function applyUpdaterToNextProps( // eslint-disable-next-line @typescript-eslint/no-explicit-any
78updaterMap, // eslint-disable-next-line @typescript-eslint/no-explicit-any
79prevProps, // eslint-disable-next-line @typescript-eslint/no-explicit-any
80nextProps, // eslint-disable-next-line @typescript-eslint/no-explicit-any
81instance // eslint-disable-next-line @typescript-eslint/no-explicit-any
82) {
83 // eslint-disable-next-line @typescript-eslint/no-explicit-any
84 var map = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
86 var iter = function iter(fn, key) {
87 var nextValue = nextProps[key];
88
89 if (nextValue !== prevProps[key]) {
90 map[key] = nextValue;
91 fn(instance, nextValue);
92 }
93 };
94
95 forEach(updaterMap, iter);
96 return map;
97};
98function registerEvents( // eslint-disable-next-line @typescript-eslint/no-explicit-any
99props, // eslint-disable-next-line @typescript-eslint/no-explicit-any
100instance, eventMap) {
101 var registeredList = reduce(eventMap, function reducer(acc, googleEventName, // eslint-disable-next-line @typescript-eslint/no-explicit-any
102 onEventName) {
103 if (typeof props[onEventName] === 'function') {
104 acc.push(google.maps.event.addListener(instance, googleEventName, props[onEventName]));
105 }
106
107 return acc;
108 }, []);
109 return registeredList;
110}
111
112function unregisterEvent(registered) {
113 google.maps.event.removeListener(registered);
114}
115
116function unregisterEvents(events) {
117 if (events === void 0) {
118 events = [];
119 }
120
121 events.forEach(unregisterEvent);
122}
123function applyUpdatersToPropsAndRegisterEvents(_ref) {
124 var updaterMap = _ref.updaterMap,
125 eventMap = _ref.eventMap,
126 prevProps = _ref.prevProps,
127 nextProps = _ref.nextProps,
128 instance = _ref.instance;
129 var registeredEvents = registerEvents(nextProps, instance, eventMap);
130 applyUpdaterToNextProps(updaterMap, prevProps, nextProps, instance);
131 return registeredEvents;
132}
133
134var eventMap = {
135 onDblClick: 'dblclick',
136 onDragEnd: 'dragend',
137 onDragStart: 'dragstart',
138 onMapTypeIdChanged: 'maptypeid_changed',
139 onMouseMove: 'mousemove',
140 onMouseOut: 'mouseout',
141 onMouseOver: 'mouseover',
142 onMouseDown: 'mousedown',
143 onMouseUp: 'mouseup',
144 onRightClick: 'rightclick',
145 onTilesLoaded: 'tilesloaded',
146 onBoundsChanged: 'bounds_changed',
147 onCenterChanged: 'center_changed',
148 onClick: 'click',
149 onDrag: 'drag',
150 onHeadingChanged: 'heading_changed',
151 onIdle: 'idle',
152 onProjectionChanged: 'projection_changed',
153 onResize: 'resize',
154 onTiltChanged: 'tilt_changed',
155 onZoomChanged: 'zoom_changed'
156};
157var updaterMap = {
158 extraMapTypes: function extraMapTypes(map, extra) {
159 extra.forEach(function forEachExtra(it, i) {
160 map.mapTypes.set(String(i), it);
161 });
162 },
163 center: function center(map, _center) {
164 map.setCenter(_center);
165 },
166 clickableIcons: function clickableIcons(map, clickable) {
167 map.setClickableIcons(clickable);
168 },
169 heading: function heading(map, _heading) {
170 map.setHeading(_heading);
171 },
172 mapTypeId: function mapTypeId(map, _mapTypeId) {
173 map.setMapTypeId(_mapTypeId);
174 },
175 options: function options(map, _options) {
176 map.setOptions(_options);
177 },
178 streetView: function streetView(map, _streetView) {
179 map.setStreetView(_streetView);
180 },
181 tilt: function tilt(map, _tilt) {
182 map.setTilt(_tilt);
183 },
184 zoom: function zoom(map, _zoom) {
185 map.setZoom(_zoom);
186 }
187};
188var GoogleMap =
189/*#__PURE__*/
190function (_React$PureComponent) {
191 _inheritsLoose(GoogleMap, _React$PureComponent);
192
193 function GoogleMap() {
194 var _this;
195
196 _this = _React$PureComponent.apply(this, arguments) || this;
197 _this.state = {
198 map: null
199 };
200 _this.registeredEvents = [];
201 _this.mapRef = null;
202
203 _this.getInstance = function () {
204 if (_this.mapRef === null) {
205 return null;
206 }
207
208 return new google.maps.Map(_this.mapRef, _this.props.options);
209 };
210
211 _this.panTo = function (latLng) {
212 var map = _this.getInstance();
213
214 if (map) {
215 map.panTo(latLng);
216 }
217 };
218
219 _this.setMapCallback = function () {
220 if (_this.state.map !== null) {
221 if (_this.props.onLoad) {
222 _this.props.onLoad(_this.state.map);
223 }
224 }
225 };
226
227 _this.getRef = function (ref) {
228 _this.mapRef = ref;
229 };
230
231 return _this;
232 }
233
234 var _proto = GoogleMap.prototype;
235
236 _proto.componentDidMount = function componentDidMount() {
237 var map = this.getInstance();
238 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
239 updaterMap: updaterMap,
240 eventMap: eventMap,
241 prevProps: {},
242 nextProps: this.props,
243 instance: map
244 });
245 this.setState(function setMap() {
246 return {
247 map: map
248 };
249 }, this.setMapCallback);
250 };
251
252 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
253 if (this.state.map !== null) {
254 unregisterEvents(this.registeredEvents);
255 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
256 updaterMap: updaterMap,
257 eventMap: eventMap,
258 prevProps: prevProps,
259 nextProps: this.props,
260 instance: this.state.map
261 });
262 }
263 };
264
265 _proto.componentWillUnmount = function componentWillUnmount() {
266 if (this.state.map !== null) {
267 if (this.props.onUnmount) {
268 this.props.onUnmount(this.state.map);
269 }
270
271 unregisterEvents(this.registeredEvents);
272 }
273 };
274
275 _proto.render = function render() {
276 return React.createElement("div", {
277 id: this.props.id,
278 ref: this.getRef,
279 style: this.props.mapContainerStyle,
280 className: this.props.mapContainerClassName
281 }, React.createElement(MapContext.Provider, {
282 value: this.state.map
283 }, this.state.map !== null ? this.props.children : React.createElement(React.Fragment, null)));
284 };
285
286 return GoogleMap;
287}(React.PureComponent);
288
289var isBrowser = typeof document !== 'undefined';
290
291var injectScript = function injectScript(_ref) {
292 var url = _ref.url,
293 id = _ref.id;
294
295 if (!isBrowser) {
296 return Promise.reject(new Error('document is undefined'));
297 }
298
299 return new Promise(function injectScriptCallback(resolve, reject) {
300 var existingScript = document.getElementById(id);
301 var windowWithGoogleMap = window;
302
303 if (existingScript) {
304 // Same script id/url: keep same script
305 var dataStateAttribute = existingScript.getAttribute('data-state');
306
307 if (existingScript.src === url && dataStateAttribute !== 'error') {
308 if (dataStateAttribute === 'ready') {
309 return resolve(id);
310 } else {
311 var originalInitMap = windowWithGoogleMap.initMap;
312 var originalErrorCallback = existingScript.onerror;
313
314 windowWithGoogleMap.initMap = function initMap() {
315 if (originalInitMap) {
316 originalInitMap();
317 }
318
319 resolve(id);
320 };
321
322 existingScript.onerror = function (err) {
323 if (originalErrorCallback) {
324 originalErrorCallback(err);
325 }
326
327 reject(err);
328 };
329
330 return;
331 }
332 } // Same script id, but either
333 // 1. requested URL is different
334 // 2. script failed to load
335 else {
336 existingScript.remove();
337 }
338 }
339
340 var script = document.createElement('script');
341 script.type = 'text/javascript';
342 script.src = url;
343 script.id = id;
344 script.async = true;
345
346 script.onerror = function onerror(err) {
347 script.setAttribute('data-state', 'error');
348 reject(err);
349 };
350
351 windowWithGoogleMap.initMap = function onload() {
352 script.setAttribute('data-state', 'ready');
353 resolve(id);
354 };
355
356 document.head.appendChild(script);
357 })["catch"](function (err) {
358 console.error('injectScript error: ', err);
359 throw err;
360 });
361};
362
363var isRobotoStyle = function isRobotoStyle(element) {
364 // roboto font download
365 if (element.href && element.href.indexOf('https://fonts.googleapis.com/css?family=Roboto') === 0) {
366 return true;
367 } // roboto style elements
368
369
370 if (element.tagName.toLowerCase() === 'style' && // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
371 // @ts-ignore
372 element.styleSheet && // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
373 // @ts-ignore
374 element.styleSheet.cssText && // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
375 // @ts-ignore
376 element.styleSheet.cssText.replace('\r\n', '').indexOf('.gm-style') === 0) {
377 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
378 // @ts-ignore
379 element.styleSheet.cssText = '';
380 return true;
381 } // roboto style elements for other browsers
382
383
384 if (element.tagName.toLowerCase() === 'style' && element.innerHTML && element.innerHTML.replace('\r\n', '').indexOf('.gm-style') === 0) {
385 element.innerHTML = '';
386 return true;
387 } // when google tries to add empty style
388
389
390 if (element.tagName.toLowerCase() === 'style' && // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
391 // @ts-ignore
392 !element.styleSheet && !element.innerHTML) {
393 return true;
394 }
395
396 return false;
397}; // Preventing the Google Maps library from downloading an extra font
398
399
400var preventGoogleFonts = function preventGoogleFonts() {
401 // we override these methods only for one particular head element
402 // default methods for other elements are not affected
403 var head = document.getElementsByTagName('head')[0];
404 var trueInsertBefore = head.insertBefore.bind(head); // TODO: adding return before reflect solves the TS issue
405 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
406 // @ts-ignore
407
408 head.insertBefore = function insertBefore(newElement, referenceElement) {
409 if (!isRobotoStyle(newElement)) {
410 Reflect.apply(trueInsertBefore, head, [newElement, referenceElement]);
411 }
412 };
413
414 var trueAppend = head.appendChild.bind(head); // TODO: adding return before reflect solves the TS issue
415 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
416 // @ts-ignore
417
418 head.appendChild = function appendChild(textNode) {
419 if (!isRobotoStyle(textNode)) {
420 Reflect.apply(trueAppend, head, [textNode]);
421 }
422 };
423};
424
425function makeLoadScriptUrl(_ref) {
426 var googleMapsApiKey = _ref.googleMapsApiKey,
427 googleMapsClientId = _ref.googleMapsClientId,
428 _ref$version = _ref.version,
429 version = _ref$version === void 0 ? 'weekly' : _ref$version,
430 language = _ref.language,
431 region = _ref.region,
432 libraries = _ref.libraries,
433 channel = _ref.channel;
434 var params = [];
435 !(googleMapsApiKey && googleMapsClientId || !(googleMapsApiKey && googleMapsClientId)) ? invariant(false, 'You need to specify either googleMapsApiKey or googleMapsClientId for @react-google-maps/api load script to work. You cannot use both at the same time.') : void 0;
436
437 if (googleMapsApiKey) {
438 params.push("key=" + googleMapsApiKey);
439 } else if (googleMapsClientId) {
440 params.push("client=" + googleMapsClientId);
441 }
442
443 if (version) {
444 params.push("v=" + version);
445 }
446
447 if (language) {
448 params.push("language=" + language);
449 }
450
451 if (region) {
452 params.push("region=" + region);
453 }
454
455 if (libraries && libraries.length) {
456 params.push("libraries=" + libraries.sort().join(','));
457 }
458
459 if (channel) {
460 params.push("channel=" + channel);
461 }
462
463 params.push('callback=initMap');
464 return "https://maps.googleapis.com/maps/api/js?" + params.join('&');
465}
466
467var cleaningUp = false;
468function DefaultLoadingElement() {
469 return React.createElement("div", null, "Loading...");
470}
471var defaultLoadScriptProps = {
472 id: 'script-loader',
473 version: 'weekly'
474};
475
476var LoadScript =
477/*#__PURE__*/
478function (_React$PureComponent) {
479 _inheritsLoose(LoadScript, _React$PureComponent);
480
481 function LoadScript() {
482 var _this;
483
484 _this = _React$PureComponent.apply(this, arguments) || this;
485 _this.check = React.createRef();
486 _this.state = {
487 loaded: false
488 };
489
490 _this.cleanupCallback = function () {
491 delete window.google;
492
493 _this.injectScript();
494 };
495
496 _this.isCleaningUp = function () {
497 try {
498 var promiseCallback = function promiseCallback(resolve) {
499 if (!cleaningUp) {
500 resolve();
501 } else {
502 if (isBrowser) {
503 var timer = window.setInterval(function interval() {
504 if (!cleaningUp) {
505 window.clearInterval(timer);
506 resolve();
507 }
508 }, 1);
509 }
510 }
511
512 return;
513 };
514
515 return Promise.resolve(new Promise(promiseCallback));
516 } catch (e) {
517 return Promise.reject(e);
518 }
519 };
520
521 _this.cleanup = function () {
522 cleaningUp = true;
523 var script = document.getElementById(_this.props.id);
524
525 if (script && script.parentNode) {
526 script.parentNode.removeChild(script);
527 }
528
529 Array.prototype.slice.call(document.getElementsByTagName('script')).filter(function filter(script) {
530 return script.src.includes('maps.googleapis');
531 }).forEach(function forEach(script) {
532 if (script.parentNode) {
533 script.parentNode.removeChild(script);
534 }
535 });
536 Array.prototype.slice.call(document.getElementsByTagName('link')).filter(function filter(link) {
537 return link.href === 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Google+Sans';
538 }).forEach(function forEach(link) {
539 if (link.parentNode) {
540 link.parentNode.removeChild(link);
541 }
542 });
543 Array.prototype.slice.call(document.getElementsByTagName('style')).filter(function filter(style) {
544 return style.innerText !== undefined && style.innerText.length > 0 && style.innerText.includes('.gm-');
545 }).forEach(function forEach(style) {
546 if (style.parentNode) {
547 style.parentNode.removeChild(style);
548 }
549 });
550 };
551
552 _this.injectScript = function () {
553 if (_this.props.preventGoogleFontsLoading) {
554 preventGoogleFonts();
555 }
556
557 !!!_this.props.id ? invariant(false, 'LoadScript requires "id" prop to be a string: %s', _this.props.id) : void 0;
558 var injectScriptOptions = {
559 id: _this.props.id,
560 url: makeLoadScriptUrl(_this.props)
561 };
562 injectScript(injectScriptOptions).then(function () {
563 if (_this.props.onLoad) {
564 _this.props.onLoad();
565 }
566
567 _this.setState(function setLoaded() {
568 return {
569 loaded: true
570 };
571 });
572
573 return;
574 })["catch"](function (err) {
575 if (_this.props.onError) {
576 _this.props.onError(err);
577 }
578
579 console.error("\n There has been an Error with loading Google Maps API script, please check that you provided correct google API key (" + (_this.props.googleMapsApiKey || '-') + ") or Client ID (" + (_this.props.googleMapsClientId || '-') + ") to <LoadScript />\n Otherwise it is a Network issue.\n ");
580 });
581 };
582
583 return _this;
584 }
585
586 var _proto = LoadScript.prototype;
587
588 _proto.componentDidMount = function componentDidMount() {
589 if (isBrowser) {
590 if (window.google && !cleaningUp) {
591 console.error('google api is already presented');
592 return;
593 }
594
595 this.isCleaningUp().then(this.injectScript)["catch"](function err(err) {
596 console.error('Error at injecting script after cleaning up: ', err);
597 });
598 }
599 };
600
601 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
602 if (this.props.libraries !== prevProps.libraries) {
603 console.warn('Performance warning! LoadScript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables');
604 }
605
606 if (isBrowser && prevProps.language !== this.props.language) {
607 this.cleanup(); // TODO: refactor to use gDSFP maybe... wait for hooks refactoring.
608 // eslint-disable-next-line react/no-did-update-set-state
609
610 this.setState(function setLoaded() {
611 return {
612 loaded: false
613 };
614 }, this.cleanupCallback);
615 }
616 };
617
618 _proto.componentWillUnmount = function componentWillUnmount() {
619 var _this2 = this;
620
621 if (isBrowser) {
622 this.cleanup();
623
624 var timeoutCallback = function timeoutCallback() {
625 if (!_this2.check.current) {
626 delete window.google;
627 cleaningUp = false;
628 }
629 };
630
631 window.setTimeout(timeoutCallback, 1);
632
633 if (this.props.onUnmount) {
634 this.props.onUnmount();
635 }
636 }
637 };
638
639 _proto.render = function render() {
640 return React.createElement(React.Fragment, null, React.createElement("div", {
641 ref: this.check
642 }), this.state.loaded ? this.props.children : this.props.loadingElement || React.createElement(DefaultLoadingElement, null));
643 };
644
645 return LoadScript;
646}(React.PureComponent);
647
648LoadScript.defaultProps = defaultLoadScriptProps;
649
650/* eslint-disable filenames/match-regex */
651var previouslyLoadedUrl;
652function useLoadScript(_ref) {
653 var _ref$id = _ref.id,
654 id = _ref$id === void 0 ? defaultLoadScriptProps.id : _ref$id,
655 _ref$version = _ref.version,
656 version = _ref$version === void 0 ? defaultLoadScriptProps.version : _ref$version,
657 googleMapsApiKey = _ref.googleMapsApiKey,
658 googleMapsClientId = _ref.googleMapsClientId,
659 language = _ref.language,
660 region = _ref.region,
661 libraries = _ref.libraries,
662 preventGoogleFontsLoading = _ref.preventGoogleFontsLoading,
663 channel = _ref.channel;
664 var isMounted = React.useRef(false);
665
666 var _React$useState = React.useState(false),
667 isLoaded = _React$useState[0],
668 setLoaded = _React$useState[1];
669
670 var _React$useState2 = React.useState(undefined),
671 loadError = _React$useState2[0],
672 setLoadError = _React$useState2[1];
673
674 React.useEffect(function trackMountedState() {
675 isMounted.current = true;
676 return function () {
677 isMounted.current = false;
678 };
679 }, []);
680 React.useEffect(function applyPreventGoogleFonts() {
681 if (isBrowser && preventGoogleFontsLoading) {
682 preventGoogleFonts();
683 }
684 }, [preventGoogleFontsLoading]);
685 React.useEffect(function validateLoadedState() {
686 if (isLoaded) {
687 !!!window.google ? invariant(false, 'useLoadScript was marked as loaded, but window.google is not present. Something went wrong.') : void 0;
688 }
689 }, [isLoaded]);
690 var url = makeLoadScriptUrl({
691 version: version,
692 googleMapsApiKey: googleMapsApiKey,
693 googleMapsClientId: googleMapsClientId,
694 language: language,
695 region: region,
696 libraries: libraries,
697 channel: channel
698 });
699 React.useEffect(function loadScriptAndModifyLoadedState() {
700 if (!isBrowser) {
701 return;
702 }
703
704 function setLoadedIfMounted() {
705 if (isMounted.current) {
706 setLoaded(true);
707 previouslyLoadedUrl = url;
708 }
709 }
710
711 if (window.google && previouslyLoadedUrl === url) {
712 setLoadedIfMounted();
713 return;
714 }
715
716 injectScript({
717 id: id,
718 url: url
719 }).then(setLoadedIfMounted)["catch"](function handleInjectError(err) {
720 if (isMounted.current) {
721 setLoadError(err);
722 }
723
724 console.warn("\n There has been an Error with loading Google Maps API script, please check that you provided correct google API key (" + (googleMapsApiKey || '-') + ") or Client ID (" + (googleMapsClientId || '-') + ")\n Otherwise it is a Network issue.\n ");
725 console.error(err);
726 });
727 }, [id, url]);
728 var prevLibraries = React.useRef();
729 React.useEffect(function checkPerformance() {
730 if (prevLibraries.current && libraries !== prevLibraries.current) {
731 console.warn('Performance warning! LoadScript has been reloaded unintentionally! You should not pass `libraries` prop as new array. Please keep an array of libraries as static class property for Components and PureComponents, or just a const variable outside of component, or somewhere in config files or ENV variables');
732 }
733
734 prevLibraries.current = libraries;
735 }, [libraries]);
736 return {
737 isLoaded: isLoaded,
738 loadError: loadError,
739 url: url
740 };
741}
742
743var defaultLoadingElement =
744/*#__PURE__*/
745React.createElement(DefaultLoadingElement, null);
746
747function LoadScriptNext(_ref) {
748 var loadingElement = _ref.loadingElement,
749 onLoad = _ref.onLoad,
750 onError = _ref.onError,
751 onUnmount = _ref.onUnmount,
752 children = _ref.children,
753 hookOptions = _objectWithoutPropertiesLoose(_ref, ["loadingElement", "onLoad", "onError", "onUnmount", "children"]);
754
755 var _useLoadScript = useLoadScript(hookOptions),
756 isLoaded = _useLoadScript.isLoaded,
757 loadError = _useLoadScript.loadError;
758
759 React.useEffect(function handleOnLoad() {
760 if (isLoaded && typeof onLoad === 'function') {
761 onLoad();
762 }
763 }, [isLoaded, onLoad]);
764 React.useEffect(function handleOnError() {
765 if (loadError && typeof onError === 'function') {
766 onError(loadError);
767 }
768 }, [loadError, onError]);
769 React.useEffect(function handleOnUnmount() {
770 return function () {
771 if (onUnmount) {
772 onUnmount();
773 }
774 };
775 }, [onUnmount]);
776 return isLoaded ? children : loadingElement || defaultLoadingElement;
777}
778
779var LoadScriptNext$1 = /*#__PURE__*/
780React.memo(LoadScriptNext);
781
782var eventMap$1 = {};
783var updaterMap$1 = {
784 options: function options(instance, _options) {
785 instance.setOptions(_options);
786 }
787};
788var TrafficLayer =
789/*#__PURE__*/
790function (_PureComponent) {
791 _inheritsLoose(TrafficLayer, _PureComponent);
792
793 function TrafficLayer() {
794 var _this;
795
796 _this = _PureComponent.apply(this, arguments) || this;
797 _this.state = {
798 trafficLayer: null
799 };
800
801 _this.setTrafficLayerCallback = function () {
802 if (_this.state.trafficLayer !== null) {
803 if (_this.props.onLoad) {
804 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
805 // @ts-ignore
806 _this.props.onLoad(_this.state.trafficLayer);
807 }
808 }
809 };
810
811 _this.registeredEvents = [];
812 return _this;
813 }
814
815 var _proto = TrafficLayer.prototype;
816
817 _proto.componentDidMount = function componentDidMount() {
818 var trafficLayer = new google.maps.TrafficLayer(_extends({}, this.props.options || {}, {
819 map: this.context
820 }));
821 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
822 updaterMap: updaterMap$1,
823 eventMap: eventMap$1,
824 prevProps: {},
825 nextProps: this.props,
826 instance: trafficLayer
827 });
828 this.setState(function setTrafficLayer() {
829 return {
830 trafficLayer: trafficLayer
831 };
832 }, this.setTrafficLayerCallback);
833 };
834
835 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
836 if (this.state.trafficLayer !== null) {
837 unregisterEvents(this.registeredEvents);
838 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
839 updaterMap: updaterMap$1,
840 eventMap: eventMap$1,
841 prevProps: prevProps,
842 nextProps: this.props,
843 instance: this.state.trafficLayer
844 });
845 }
846 };
847
848 _proto.componentWillUnmount = function componentWillUnmount() {
849 if (this.state.trafficLayer !== null) {
850 if (this.props.onUnmount) {
851 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
852 // @ts-ignore
853 this.props.onUnmount(this.state.trafficLayer);
854 }
855
856 unregisterEvents(this.registeredEvents); // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
857 // @ts-ignore
858
859 this.state.trafficLayer.setMap(null);
860 }
861 };
862
863 _proto.render = function render() {
864 return null;
865 };
866
867 return TrafficLayer;
868}(React.PureComponent);
869TrafficLayer.contextType = MapContext;
870
871var BicyclingLayer =
872/*#__PURE__*/
873function (_React$PureComponent) {
874 _inheritsLoose(BicyclingLayer, _React$PureComponent);
875
876 function BicyclingLayer() {
877 var _this;
878
879 _this = _React$PureComponent.apply(this, arguments) || this;
880 _this.state = {
881 bicyclingLayer: null
882 };
883
884 _this.setBicyclingLayerCallback = function () {
885 if (_this.state.bicyclingLayer !== null) {
886 // TODO: how is this possibly null if we're doing a null check
887 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
888 // @ts-ignore
889 _this.state.bicyclingLayer.setMap(_this.context);
890
891 if (_this.props.onLoad) {
892 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
893 // @ts-ignore
894 _this.props.onLoad(_this.state.bicyclingLayer);
895 }
896 }
897 };
898
899 return _this;
900 }
901
902 var _proto = BicyclingLayer.prototype;
903
904 _proto.componentDidMount = function componentDidMount() {
905 var bicyclingLayer = new google.maps.BicyclingLayer();
906 this.setState(function setBicyclingLayer() {
907 return {
908 bicyclingLayer: bicyclingLayer
909 };
910 }, this.setBicyclingLayerCallback);
911 };
912
913 _proto.componentWillUnmount = function componentWillUnmount() {
914 if (this.state.bicyclingLayer !== null) {
915 if (this.props.onUnmount) {
916 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
917 // @ts-ignore
918 this.props.onUnmount(this.state.bicyclingLayer);
919 } // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
920 // @ts-ignore
921
922
923 this.state.bicyclingLayer.setMap(null);
924 }
925 };
926
927 _proto.render = function render() {
928 return null;
929 };
930
931 return BicyclingLayer;
932}(React.PureComponent);
933BicyclingLayer.contextType = MapContext;
934
935var TransitLayer =
936/*#__PURE__*/
937function (_React$PureComponent) {
938 _inheritsLoose(TransitLayer, _React$PureComponent);
939
940 function TransitLayer() {
941 var _this;
942
943 _this = _React$PureComponent.apply(this, arguments) || this;
944 _this.state = {
945 transitLayer: null
946 };
947
948 _this.setTransitLayerCallback = function () {
949 if (_this.state.transitLayer !== null) {
950 // TODO: how is this possibly null if we're doing a null check
951 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
952 // @ts-ignore
953 _this.state.transitLayer.setMap(_this.context);
954
955 if (_this.props.onLoad) {
956 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
957 // @ts-ignore
958 _this.props.onLoad(_this.state.transitLayer);
959 }
960 }
961 };
962
963 return _this;
964 }
965
966 var _proto = TransitLayer.prototype;
967
968 _proto.componentDidMount = function componentDidMount() {
969 var transitLayer = new google.maps.TransitLayer();
970 this.setState(function setTransitLayer() {
971 return {
972 transitLayer: transitLayer
973 };
974 }, this.setTransitLayerCallback);
975 };
976
977 _proto.componentWillUnmount = function componentWillUnmount() {
978 if (this.state.transitLayer !== null) {
979 if (this.props.onUnmount) {
980 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
981 // @ts-ignore
982 this.props.onUnmount(this.state.transitLayer);
983 } // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
984 // @ts-ignore
985
986
987 this.state.transitLayer.setMap(null);
988 }
989 };
990
991 _proto.render = function render() {
992 return null;
993 };
994
995 return TransitLayer;
996}(React.PureComponent);
997TransitLayer.contextType = MapContext;
998
999var eventMap$2 = {
1000 onCircleComplete: 'circlecomplete',
1001 onMarkerComplete: 'markercomplete',
1002 onOverlayComplete: 'overlaycomplete',
1003 onPolygonComplete: 'polygoncomplete',
1004 onPolylineComplete: 'polylinecomplete',
1005 onRectangleComplete: 'rectanglecomplete'
1006};
1007var updaterMap$2 = {
1008 drawingMode: function drawingMode(instance, _drawingMode) {
1009 instance.setDrawingMode(_drawingMode);
1010 },
1011 options: function options(instance, _options) {
1012 instance.setOptions(_options);
1013 }
1014};
1015var DrawingManager =
1016/*#__PURE__*/
1017function (_React$PureComponent) {
1018 _inheritsLoose(DrawingManager, _React$PureComponent);
1019
1020 function DrawingManager(props) {
1021 var _this;
1022
1023 _this = _React$PureComponent.call(this, props) || this;
1024 _this.registeredEvents = [];
1025 _this.state = {
1026 drawingManager: null
1027 };
1028
1029 _this.setDrawingManagerCallback = function () {
1030 if (_this.state.drawingManager !== null && _this.props.onLoad) {
1031 _this.props.onLoad(_this.state.drawingManager);
1032 }
1033 };
1034
1035 !!!google.maps.drawing ? invariant(false, "Did you include prop libraries={['drawing']} in the URL? %s", google.maps.drawing) : void 0;
1036 return _this;
1037 }
1038
1039 var _proto = DrawingManager.prototype;
1040
1041 _proto.componentDidMount = function componentDidMount() {
1042 var drawingManager = new google.maps.drawing.DrawingManager(_extends({}, this.props.options || {}, {
1043 map: this.context
1044 }));
1045 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1046 updaterMap: updaterMap$2,
1047 eventMap: eventMap$2,
1048 prevProps: {},
1049 nextProps: this.props,
1050 instance: drawingManager
1051 });
1052 this.setState(function setDrawingManager() {
1053 return {
1054 drawingManager: drawingManager
1055 };
1056 }, this.setDrawingManagerCallback);
1057 };
1058
1059 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1060 if (this.state.drawingManager !== null) {
1061 unregisterEvents(this.registeredEvents);
1062 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1063 updaterMap: updaterMap$2,
1064 eventMap: eventMap$2,
1065 prevProps: prevProps,
1066 nextProps: this.props,
1067 instance: this.state.drawingManager
1068 });
1069 }
1070 };
1071
1072 _proto.componentWillUnmount = function componentWillUnmount() {
1073 if (this.state.drawingManager !== null) {
1074 if (this.props.onUnmount) {
1075 this.props.onUnmount(this.state.drawingManager);
1076 }
1077
1078 unregisterEvents(this.registeredEvents);
1079 this.state.drawingManager.setMap(null);
1080 }
1081 };
1082
1083 _proto.render = function render() {
1084 return React.createElement(React.Fragment, null);
1085 };
1086
1087 return DrawingManager;
1088}(React.PureComponent);
1089DrawingManager.contextType = MapContext;
1090
1091var eventMap$3 = {
1092 onAnimationChanged: 'animation_changed',
1093 onClick: 'click',
1094 onClickableChanged: 'clickable_changed',
1095 onCursorChanged: 'cursor_changed',
1096 onDblClick: 'dblclick',
1097 onDrag: 'drag',
1098 onDragEnd: 'dragend',
1099 onDraggableChanged: 'draggable_changed',
1100 onDragStart: 'dragstart',
1101 onFlatChanged: 'flat_changed',
1102 onIconChanged: 'icon_changed',
1103 onMouseDown: 'mousedown',
1104 onMouseOut: 'mouseout',
1105 onMouseOver: 'mouseover',
1106 onMouseUp: 'mouseup',
1107 onPositionChanged: 'position_changed',
1108 onRightClick: 'rightclick',
1109 onShapeChanged: 'shape_changed',
1110 onTitleChanged: 'title_changed',
1111 onVisibleChanged: 'visible_changed',
1112 onZindexChanged: 'zindex_changed'
1113};
1114var updaterMap$3 = {
1115 animation: function animation(instance, _animation) {
1116 instance.setAnimation(_animation);
1117 },
1118 clickable: function clickable(instance, _clickable) {
1119 instance.setClickable(_clickable);
1120 },
1121 cursor: function cursor(instance, _cursor) {
1122 instance.setCursor(_cursor);
1123 },
1124 draggable: function draggable(instance, _draggable) {
1125 instance.setDraggable(_draggable);
1126 },
1127 icon: function icon(instance, _icon) {
1128 instance.setIcon(_icon);
1129 },
1130 label: function label(instance, _label) {
1131 instance.setLabel(_label);
1132 },
1133 map: function map(instance, _map) {
1134 instance.setMap(_map);
1135 },
1136 opacity: function opacity(instance, _opacity) {
1137 instance.setOpacity(_opacity);
1138 },
1139 options: function options(instance, _options) {
1140 instance.setOptions(_options);
1141 },
1142 position: function position(instance, _position) {
1143 instance.setPosition(_position);
1144 },
1145 shape: function shape(instance, _shape) {
1146 instance.setShape(_shape);
1147 },
1148 title: function title(instance, _title) {
1149 instance.setTitle(_title);
1150 },
1151 visible: function visible(instance, _visible) {
1152 instance.setVisible(_visible);
1153 },
1154 zIndex: function zIndex(instance, _zIndex) {
1155 instance.setZIndex(_zIndex);
1156 }
1157};
1158var Marker =
1159/*#__PURE__*/
1160function (_React$PureComponent) {
1161 _inheritsLoose(Marker, _React$PureComponent);
1162
1163 function Marker() {
1164 var _this;
1165
1166 _this = _React$PureComponent.apply(this, arguments) || this;
1167 _this.registeredEvents = [];
1168 _this.state = {
1169 marker: null
1170 };
1171
1172 _this.setMarkerCallback = function () {
1173 if (_this.state.marker !== null && _this.props.onLoad) {
1174 _this.props.onLoad(_this.state.marker);
1175 }
1176 };
1177
1178 return _this;
1179 }
1180
1181 var _proto = Marker.prototype;
1182
1183 _proto.componentDidMount = function componentDidMount() {
1184 var markerOptions = _extends({}, this.props.options || {}, {}, this.props.clusterer ? {} : {
1185 map: this.context
1186 }, {
1187 position: this.props.position
1188 });
1189
1190 var marker = new google.maps.Marker(markerOptions);
1191
1192 if (this.props.clusterer) {
1193 this.props.clusterer.addMarker( // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
1194 // @ts-ignore
1195 marker, !!this.props.noClustererRedraw);
1196 } else {
1197 marker.setMap(this.context);
1198 }
1199
1200 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1201 updaterMap: updaterMap$3,
1202 eventMap: eventMap$3,
1203 prevProps: {},
1204 nextProps: this.props,
1205 instance: marker
1206 });
1207 this.setState(function setMarker() {
1208 return {
1209 marker: marker
1210 };
1211 }, this.setMarkerCallback);
1212 };
1213
1214 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1215 if (this.state.marker !== null) {
1216 unregisterEvents(this.registeredEvents);
1217 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1218 updaterMap: updaterMap$3,
1219 eventMap: eventMap$3,
1220 prevProps: prevProps,
1221 nextProps: this.props,
1222 instance: this.state.marker
1223 });
1224 }
1225 };
1226
1227 _proto.componentWillUnmount = function componentWillUnmount() {
1228 if (this.state.marker !== null) {
1229 if (this.props.onUnmount) {
1230 this.props.onUnmount(this.state.marker);
1231 }
1232
1233 unregisterEvents(this.registeredEvents);
1234
1235 if (this.props.clusterer) {
1236 this.props.clusterer.removeMarker( // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
1237 // @ts-ignore
1238 this.state.marker, !!this.props.noClustererRedraw);
1239 } else {
1240 this.state.marker && this.state.marker.setMap(null);
1241 }
1242 }
1243 };
1244
1245 _proto.render = function render() {
1246 return this.props.children || null;
1247 };
1248
1249 return Marker;
1250}(React.PureComponent);
1251Marker.contextType = MapContext;
1252
1253var eventMap$4 = {
1254 onClick: 'click',
1255 onClusteringBegin: 'clusteringbegin',
1256 onClusteringEnd: 'clusteringend',
1257 onMouseOut: 'mouseout',
1258 onMouseOver: 'mouseover'
1259};
1260var updaterMap$4 = {
1261 averageCenter: function averageCenter(instance, _averageCenter) {
1262 instance.setAverageCenter(_averageCenter);
1263 },
1264 batchSizeIE: function batchSizeIE(instance, _batchSizeIE) {
1265 instance.setBatchSizeIE(_batchSizeIE);
1266 },
1267 calculator: function calculator(instance, _calculator) {
1268 instance.setCalculator(_calculator);
1269 },
1270 clusterClass: function clusterClass(instance, _clusterClass) {
1271 instance.setClusterClass(_clusterClass);
1272 },
1273 enableRetinaIcons: function enableRetinaIcons(instance, _enableRetinaIcons) {
1274 instance.setEnableRetinaIcons(_enableRetinaIcons);
1275 },
1276 gridSize: function gridSize(instance, _gridSize) {
1277 instance.setGridSize(_gridSize);
1278 },
1279 ignoreHidden: function ignoreHidden(instance, _ignoreHidden) {
1280 instance.setIgnoreHidden(_ignoreHidden);
1281 },
1282 imageExtension: function imageExtension(instance, _imageExtension) {
1283 instance.setImageExtension(_imageExtension);
1284 },
1285 imagePath: function imagePath(instance, _imagePath) {
1286 instance.setImagePath(_imagePath);
1287 },
1288 imageSizes: function imageSizes(instance, _imageSizes) {
1289 instance.setImageSizes(_imageSizes);
1290 },
1291 maxZoom: function maxZoom(instance, _maxZoom) {
1292 instance.setMaxZoom(_maxZoom);
1293 },
1294 minimumClusterSize: function minimumClusterSize(instance, _minimumClusterSize) {
1295 instance.setMinimumClusterSize(_minimumClusterSize);
1296 },
1297 styles: function styles(instance, _styles) {
1298 instance.setStyles(_styles);
1299 },
1300 title: function title(instance, _title) {
1301 instance.setTitle(_title);
1302 },
1303 zoomOnClick: function zoomOnClick(instance, _zoomOnClick) {
1304 instance.setZoomOnClick(_zoomOnClick);
1305 }
1306};
1307var ClustererComponent =
1308/*#__PURE__*/
1309function (_React$PureComponent) {
1310 _inheritsLoose(ClustererComponent, _React$PureComponent);
1311
1312 function ClustererComponent() {
1313 var _this;
1314
1315 _this = _React$PureComponent.apply(this, arguments) || this;
1316 _this.registeredEvents = [];
1317 _this.state = {
1318 markerClusterer: null
1319 };
1320
1321 _this.setClustererCallback = function () {
1322 if (_this.state.markerClusterer !== null && _this.props.onLoad) {
1323 _this.props.onLoad(_this.state.markerClusterer);
1324 }
1325 };
1326
1327 return _this;
1328 }
1329
1330 var _proto = ClustererComponent.prototype;
1331
1332 _proto.componentDidMount = function componentDidMount() {
1333 if (this.context) {
1334 var markerClusterer$1 = new markerClusterer.Clusterer(this.context, [], this.props.options);
1335 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1336 updaterMap: updaterMap$4,
1337 eventMap: eventMap$4,
1338 prevProps: {},
1339 nextProps: this.props,
1340 instance: markerClusterer$1
1341 });
1342 this.setState(function setClusterer() {
1343 return {
1344 markerClusterer: markerClusterer$1
1345 };
1346 }, this.setClustererCallback);
1347 }
1348 };
1349
1350 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1351 if (this.state.markerClusterer) {
1352 unregisterEvents(this.registeredEvents);
1353 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1354 updaterMap: updaterMap$4,
1355 eventMap: eventMap$4,
1356 prevProps: prevProps,
1357 nextProps: this.props,
1358 instance: this.state.markerClusterer
1359 });
1360 }
1361 };
1362
1363 _proto.componentWillUnmount = function componentWillUnmount() {
1364 if (this.state.markerClusterer !== null) {
1365 if (this.props.onUnmount) {
1366 this.props.onUnmount(this.state.markerClusterer);
1367 }
1368
1369 unregisterEvents(this.registeredEvents); // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
1370 // @ts-ignore
1371
1372 this.state.markerClusterer.setMap(null);
1373 }
1374 };
1375
1376 _proto.render = function render() {
1377 return this.state.markerClusterer !== null ? this.props.children(this.state.markerClusterer) : null;
1378 };
1379
1380 return ClustererComponent;
1381}(React.PureComponent);
1382ClustererComponent.contextType = MapContext;
1383
1384var eventMap$5 = {
1385 onCloseClick: 'closeclick',
1386 onContentChanged: 'content_changed',
1387 onDomReady: 'domready',
1388 onPositionChanged: 'position_changed',
1389 onZindexChanged: 'zindex_changed'
1390};
1391var updaterMap$5 = {
1392 options: function options(instance, _options) {
1393 instance.setOptions(_options);
1394 },
1395 position: function position(instance, _position) {
1396 if (_position instanceof google.maps.LatLng) {
1397 instance.setPosition(_position);
1398 } else {
1399 instance.setPosition(new google.maps.LatLng(_position.lat, _position.lng));
1400 }
1401 },
1402 visible: function visible(instance, _visible) {
1403 instance.setVisible(_visible);
1404 },
1405 zIndex: function zIndex(instance, _zIndex) {
1406 instance.setZIndex(_zIndex);
1407 }
1408};
1409var InfoBoxComponent =
1410/*#__PURE__*/
1411function (_React$PureComponent) {
1412 _inheritsLoose(InfoBoxComponent, _React$PureComponent);
1413
1414 function InfoBoxComponent() {
1415 var _this;
1416
1417 _this = _React$PureComponent.apply(this, arguments) || this;
1418 _this.registeredEvents = [];
1419 _this.containerElement = null;
1420 _this.state = {
1421 infoBox: null
1422 };
1423
1424 _this.open = function (infoBox, anchor) {
1425 if (anchor) {
1426 infoBox.open(_this.context, anchor);
1427 } else if (infoBox.getPosition()) {
1428 infoBox.open(_this.context);
1429 } else {
1430 invariant(false, 'You must provide either an anchor or a position prop for <InfoBox>.') ;
1431 }
1432 };
1433
1434 _this.setInfoBoxCallback = function () {
1435 var _this$props = _this.props,
1436 anchor = _this$props.anchor,
1437 onLoad = _this$props.onLoad;
1438 var infoBox = _this.state.infoBox;
1439
1440 if (infoBox !== null && _this.containerElement !== null) {
1441 infoBox.setContent(_this.containerElement);
1442
1443 _this.open(infoBox, anchor);
1444
1445 if (onLoad) {
1446 onLoad(infoBox);
1447 }
1448 }
1449 };
1450
1451 return _this;
1452 }
1453
1454 var _proto = InfoBoxComponent.prototype;
1455
1456 _proto.componentDidMount = function componentDidMount() {
1457 var options = this.props.options;
1458
1459 var _ref = options || {},
1460 position = _ref.position,
1461 infoBoxOptions = _objectWithoutPropertiesLoose(_ref, ["position"]);
1462
1463 var positionLatLng;
1464
1465 if (position && !(position instanceof google.maps.LatLng)) {
1466 positionLatLng = new google.maps.LatLng(position.lat, position.lng);
1467 }
1468
1469 var infoBox = new infobox.InfoBox(_extends({}, infoBoxOptions, {}, positionLatLng ? {
1470 position: positionLatLng
1471 } : {}));
1472 this.containerElement = document.createElement('div');
1473 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1474 updaterMap: updaterMap$5,
1475 eventMap: eventMap$5,
1476 prevProps: {},
1477 nextProps: this.props,
1478 instance: infoBox
1479 });
1480 this.setState({
1481 infoBox: infoBox
1482 }, this.setInfoBoxCallback);
1483 };
1484
1485 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1486 var infoBox = this.state.infoBox;
1487
1488 if (infoBox !== null) {
1489 unregisterEvents(this.registeredEvents);
1490 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1491 updaterMap: updaterMap$5,
1492 eventMap: eventMap$5,
1493 prevProps: prevProps,
1494 nextProps: this.props,
1495 instance: infoBox
1496 });
1497 }
1498 };
1499
1500 _proto.componentWillUnmount = function componentWillUnmount() {
1501 var onUnmount = this.props.onUnmount;
1502 var infoBox = this.state.infoBox;
1503
1504 if (infoBox !== null) {
1505 if (onUnmount) {
1506 onUnmount(infoBox);
1507 }
1508
1509 unregisterEvents(this.registeredEvents);
1510 infoBox.close();
1511 }
1512 };
1513
1514 _proto.render = function render() {
1515 if (!this.containerElement) {
1516 return null;
1517 }
1518
1519 return ReactDOM.createPortal(React.Children.only(this.props.children), this.containerElement);
1520 };
1521
1522 return InfoBoxComponent;
1523}(React.PureComponent);
1524InfoBoxComponent.contextType = MapContext;
1525
1526var eventMap$6 = {
1527 onCloseClick: 'closeclick',
1528 onContentChanged: 'content_changed',
1529 onDomReady: 'domready',
1530 onPositionChanged: 'position_changed',
1531 onZindexChanged: 'zindex_changed'
1532};
1533var updaterMap$6 = {
1534 options: function options(instance, _options) {
1535 instance.setOptions(_options);
1536 },
1537 position: function position(instance, _position) {
1538 instance.setPosition(_position);
1539 },
1540 zIndex: function zIndex(instance, _zIndex) {
1541 instance.setZIndex(_zIndex);
1542 }
1543};
1544var InfoWindow =
1545/*#__PURE__*/
1546function (_React$PureComponent) {
1547 _inheritsLoose(InfoWindow, _React$PureComponent);
1548
1549 function InfoWindow() {
1550 var _this;
1551
1552 _this = _React$PureComponent.apply(this, arguments) || this;
1553 _this.registeredEvents = [];
1554 _this.containerElement = null;
1555 _this.state = {
1556 infoWindow: null
1557 };
1558
1559 _this.open = function (infoWindow, anchor) {
1560 if (anchor) {
1561 infoWindow.open(_this.context, anchor);
1562 } else if (infoWindow.getPosition()) {
1563 infoWindow.open(_this.context);
1564 } else {
1565 invariant(false, "You must provide either an anchor (typically render it inside a <Marker>) or a position props for <InfoWindow>.") ;
1566 }
1567 };
1568
1569 _this.setInfoWindowCallback = function () {
1570 if (_this.state.infoWindow !== null && _this.containerElement !== null) {
1571 _this.state.infoWindow.setContent(_this.containerElement);
1572
1573 _this.open(_this.state.infoWindow, _this.props.anchor);
1574
1575 if (_this.props.onLoad) {
1576 _this.props.onLoad(_this.state.infoWindow);
1577 }
1578 }
1579 };
1580
1581 return _this;
1582 }
1583
1584 var _proto = InfoWindow.prototype;
1585
1586 _proto.componentDidMount = function componentDidMount() {
1587 var infoWindow = new google.maps.InfoWindow(_extends({}, this.props.options || {}));
1588 this.containerElement = document.createElement('div');
1589 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1590 updaterMap: updaterMap$6,
1591 eventMap: eventMap$6,
1592 prevProps: {},
1593 nextProps: this.props,
1594 instance: infoWindow
1595 });
1596 this.setState(function setInfoWindow() {
1597 return {
1598 infoWindow: infoWindow
1599 };
1600 }, this.setInfoWindowCallback);
1601 };
1602
1603 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1604 if (this.state.infoWindow !== null) {
1605 unregisterEvents(this.registeredEvents);
1606 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1607 updaterMap: updaterMap$6,
1608 eventMap: eventMap$6,
1609 prevProps: prevProps,
1610 nextProps: this.props,
1611 instance: this.state.infoWindow
1612 });
1613 }
1614 };
1615
1616 _proto.componentWillUnmount = function componentWillUnmount() {
1617 if (this.state.infoWindow !== null) {
1618 unregisterEvents(this.registeredEvents);
1619 this.state.infoWindow.close();
1620 }
1621 };
1622
1623 _proto.render = function render() {
1624 return this.containerElement ? ReactDOM.createPortal(React.Children.only(this.props.children), this.containerElement) : React.createElement(React.Fragment, null);
1625 };
1626
1627 return InfoWindow;
1628}(React.PureComponent);
1629InfoWindow.contextType = MapContext;
1630
1631var eventMap$7 = {
1632 onClick: 'click',
1633 onDblClick: 'dblclick',
1634 onDrag: 'drag',
1635 onDragEnd: 'dragend',
1636 onDragStart: 'dragstart',
1637 onMouseDown: 'mousedown',
1638 onMouseMove: 'mousemove',
1639 onMouseOut: 'mouseout',
1640 onMouseOver: 'mouseover',
1641 onMouseUp: 'mouseup',
1642 onRightClick: 'rightclick'
1643};
1644var updaterMap$7 = {
1645 draggable: function draggable(instance, _draggable) {
1646 instance.setDraggable(_draggable);
1647 },
1648 editable: function editable(instance, _editable) {
1649 instance.setEditable(_editable);
1650 },
1651 map: function map(instance, _map) {
1652 instance.setMap(_map);
1653 },
1654 options: function options(instance, _options) {
1655 instance.setOptions(_options);
1656 },
1657 path: function path(instance, _path) {
1658 instance.setPath(_path);
1659 },
1660 visible: function visible(instance, _visible) {
1661 instance.setVisible(_visible);
1662 }
1663};
1664var Polyline =
1665/*#__PURE__*/
1666function (_React$PureComponent) {
1667 _inheritsLoose(Polyline, _React$PureComponent);
1668
1669 function Polyline() {
1670 var _this;
1671
1672 _this = _React$PureComponent.apply(this, arguments) || this;
1673 _this.registeredEvents = [];
1674 _this.state = {
1675 polyline: null
1676 };
1677
1678 _this.setPolylineCallback = function () {
1679 if (_this.state.polyline !== null && _this.props.onLoad) {
1680 _this.props.onLoad(_this.state.polyline);
1681 }
1682 };
1683
1684 return _this;
1685 }
1686
1687 var _proto = Polyline.prototype;
1688
1689 _proto.componentDidMount = function componentDidMount() {
1690 var polyline = new google.maps.Polyline(_extends({}, this.props.options || {}, {
1691 map: this.context
1692 }));
1693 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1694 updaterMap: updaterMap$7,
1695 eventMap: eventMap$7,
1696 prevProps: {},
1697 nextProps: this.props,
1698 instance: polyline
1699 });
1700 this.setState(function setPolyline() {
1701 return {
1702 polyline: polyline
1703 };
1704 }, this.setPolylineCallback);
1705 };
1706
1707 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1708 if (this.state.polyline !== null) {
1709 unregisterEvents(this.registeredEvents);
1710 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1711 updaterMap: updaterMap$7,
1712 eventMap: eventMap$7,
1713 prevProps: prevProps,
1714 nextProps: this.props,
1715 instance: this.state.polyline
1716 });
1717 }
1718 };
1719
1720 _proto.componentWillUnmount = function componentWillUnmount() {
1721 if (this.state.polyline !== null) {
1722 if (this.props.onUnmount) {
1723 this.props.onUnmount(this.state.polyline);
1724 }
1725
1726 unregisterEvents(this.registeredEvents);
1727 this.state.polyline.setMap(null);
1728 }
1729 };
1730
1731 _proto.render = function render() {
1732 return React.createElement(React.Fragment, null);
1733 };
1734
1735 return Polyline;
1736}(React.PureComponent);
1737Polyline.contextType = MapContext;
1738
1739var eventMap$8 = {
1740 onClick: 'click',
1741 onDblClick: 'dblclick',
1742 onDrag: 'drag',
1743 onDragEnd: 'dragend',
1744 onDragStart: 'dragstart',
1745 onMouseDown: 'mousedown',
1746 onMouseMove: 'mousemove',
1747 onMouseOut: 'mouseout',
1748 onMouseOver: 'mouseover',
1749 onMouseUp: 'mouseup',
1750 onRightClick: 'rightclick'
1751};
1752var updaterMap$8 = {
1753 draggable: function draggable(instance, _draggable) {
1754 instance.setDraggable(_draggable);
1755 },
1756 editable: function editable(instance, _editable) {
1757 instance.setEditable(_editable);
1758 },
1759 map: function map(instance, _map) {
1760 instance.setMap(_map);
1761 },
1762 options: function options(instance, _options) {
1763 instance.setOptions(_options);
1764 },
1765 path: function path(instance, _path) {
1766 instance.setPath(_path);
1767 },
1768 paths: function paths(instance, _paths) {
1769 instance.setPaths(_paths);
1770 },
1771 visible: function visible(instance, _visible) {
1772 instance.setVisible(_visible);
1773 }
1774};
1775var Polygon =
1776/*#__PURE__*/
1777function (_React$PureComponent) {
1778 _inheritsLoose(Polygon, _React$PureComponent);
1779
1780 function Polygon() {
1781 var _this;
1782
1783 _this = _React$PureComponent.apply(this, arguments) || this;
1784 _this.registeredEvents = [];
1785 _this.state = {
1786 polygon: null
1787 };
1788
1789 _this.setPolygonCallback = function () {
1790 if (_this.state.polygon !== null && _this.props.onLoad) {
1791 _this.props.onLoad(_this.state.polygon);
1792 }
1793 };
1794
1795 return _this;
1796 }
1797
1798 var _proto = Polygon.prototype;
1799
1800 _proto.componentDidMount = function componentDidMount() {
1801 var polygon = new google.maps.Polygon(_extends({}, this.props.options || {}, {
1802 map: this.context
1803 }));
1804 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1805 updaterMap: updaterMap$8,
1806 eventMap: eventMap$8,
1807 prevProps: {},
1808 nextProps: this.props,
1809 instance: polygon
1810 });
1811 this.setState(function setPolygon() {
1812 return {
1813 polygon: polygon
1814 };
1815 }, this.setPolygonCallback);
1816 };
1817
1818 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1819 if (this.state.polygon !== null) {
1820 unregisterEvents(this.registeredEvents);
1821 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1822 updaterMap: updaterMap$8,
1823 eventMap: eventMap$8,
1824 prevProps: prevProps,
1825 nextProps: this.props,
1826 instance: this.state.polygon
1827 });
1828 }
1829 };
1830
1831 _proto.componentWillUnmount = function componentWillUnmount() {
1832 if (this.state.polygon !== null) {
1833 if (this.props.onUnmount) {
1834 this.props.onUnmount(this.state.polygon);
1835 }
1836
1837 unregisterEvents(this.registeredEvents);
1838 this.state.polygon && this.state.polygon.setMap(null);
1839 }
1840 };
1841
1842 _proto.render = function render() {
1843 return null;
1844 };
1845
1846 return Polygon;
1847}(React.PureComponent);
1848Polygon.contextType = MapContext;
1849
1850var eventMap$9 = {
1851 onBoundsChanged: 'bounds_changed',
1852 onClick: 'click',
1853 onDblClick: 'dblclick',
1854 onDrag: 'drag',
1855 onDragEnd: 'dragend',
1856 onDragStart: 'dragstart',
1857 onMouseDown: 'mousedown',
1858 onMouseMove: 'mousemove',
1859 onMouseOut: 'mouseout',
1860 onMouseOver: 'mouseover',
1861 onMouseUp: 'mouseup',
1862 onRightClick: 'rightclick'
1863};
1864var updaterMap$9 = {
1865 bounds: function bounds(instance, _bounds) {
1866 instance.setBounds(_bounds);
1867 },
1868 draggable: function draggable(instance, _draggable) {
1869 instance.setDraggable(_draggable);
1870 },
1871 editable: function editable(instance, _editable) {
1872 instance.setEditable(_editable);
1873 },
1874 map: function map(instance, _map) {
1875 instance.setMap(_map);
1876 },
1877 options: function options(instance, _options) {
1878 instance.setOptions(_options);
1879 },
1880 visible: function visible(instance, _visible) {
1881 instance.setVisible(_visible);
1882 }
1883};
1884var Rectangle =
1885/*#__PURE__*/
1886function (_React$PureComponent) {
1887 _inheritsLoose(Rectangle, _React$PureComponent);
1888
1889 function Rectangle() {
1890 var _this;
1891
1892 _this = _React$PureComponent.apply(this, arguments) || this;
1893 _this.registeredEvents = [];
1894 _this.state = {
1895 rectangle: null
1896 };
1897
1898 _this.setRectangleCallback = function () {
1899 if (_this.state.rectangle !== null && _this.props.onLoad) {
1900 _this.props.onLoad(_this.state.rectangle);
1901 }
1902 };
1903
1904 return _this;
1905 }
1906
1907 var _proto = Rectangle.prototype;
1908
1909 _proto.componentDidMount = function componentDidMount() {
1910 var rectangle = new google.maps.Rectangle(_extends({}, this.props.options || {}, {
1911 map: this.context
1912 }));
1913 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1914 updaterMap: updaterMap$9,
1915 eventMap: eventMap$9,
1916 prevProps: {},
1917 nextProps: this.props,
1918 instance: rectangle
1919 });
1920 this.setState(function setRectangle() {
1921 return {
1922 rectangle: rectangle
1923 };
1924 }, this.setRectangleCallback);
1925 };
1926
1927 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1928 if (this.state.rectangle !== null) {
1929 unregisterEvents(this.registeredEvents);
1930 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
1931 updaterMap: updaterMap$9,
1932 eventMap: eventMap$9,
1933 prevProps: prevProps,
1934 nextProps: this.props,
1935 instance: this.state.rectangle
1936 });
1937 }
1938 };
1939
1940 _proto.componentWillUnmount = function componentWillUnmount() {
1941 if (this.state.rectangle !== null) {
1942 if (this.props.onUnmount) {
1943 this.props.onUnmount(this.state.rectangle);
1944 }
1945
1946 unregisterEvents(this.registeredEvents);
1947 this.state.rectangle.setMap(null);
1948 }
1949 };
1950
1951 _proto.render = function render() {
1952 return React.createElement(React.Fragment, null);
1953 };
1954
1955 return Rectangle;
1956}(React.PureComponent);
1957Rectangle.contextType = MapContext;
1958
1959var eventMap$a = {
1960 onCenterChanged: 'center_changed',
1961 onClick: 'click',
1962 onDblClick: 'dblclick',
1963 onDrag: 'drag',
1964 onDragEnd: 'dragend',
1965 onDragStart: 'dragstart',
1966 onMouseDown: 'mousedown',
1967 onMouseMove: 'mousemove',
1968 onMouseOut: 'mouseout',
1969 onMouseOver: 'mouseover',
1970 onMouseUp: 'mouseup',
1971 onRadiusChanged: 'radius_changed',
1972 onRightClick: 'rightclick'
1973};
1974var updaterMap$a = {
1975 center: function center(instance, _center) {
1976 instance.setCenter(_center);
1977 },
1978 draggable: function draggable(instance, _draggable) {
1979 instance.setDraggable(_draggable);
1980 },
1981 editable: function editable(instance, _editable) {
1982 instance.setEditable(_editable);
1983 },
1984 map: function map(instance, _map) {
1985 instance.setMap(_map);
1986 },
1987 options: function options(instance, _options) {
1988 instance.setOptions(_options);
1989 },
1990 radius: function radius(instance, _radius) {
1991 instance.setRadius(_radius);
1992 },
1993 visible: function visible(instance, _visible) {
1994 instance.setVisible(_visible);
1995 }
1996};
1997var Circle =
1998/*#__PURE__*/
1999function (_React$PureComponent) {
2000 _inheritsLoose(Circle, _React$PureComponent);
2001
2002 function Circle() {
2003 var _this;
2004
2005 _this = _React$PureComponent.apply(this, arguments) || this;
2006 _this.registeredEvents = [];
2007 _this.state = {
2008 circle: null
2009 };
2010
2011 _this.setCircleCallback = function () {
2012 if (_this.state.circle !== null && _this.props.onLoad) {
2013 _this.props.onLoad(_this.state.circle);
2014 }
2015 };
2016
2017 return _this;
2018 }
2019
2020 var _proto = Circle.prototype;
2021
2022 _proto.componentDidMount = function componentDidMount() {
2023 var circle = new google.maps.Circle(_extends({}, this.props.options || {}, {
2024 map: this.context
2025 }));
2026 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2027 updaterMap: updaterMap$a,
2028 eventMap: eventMap$a,
2029 prevProps: {},
2030 nextProps: this.props,
2031 instance: circle
2032 });
2033 this.setState(function setCircle() {
2034 return {
2035 circle: circle
2036 };
2037 }, this.setCircleCallback);
2038 };
2039
2040 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2041 if (this.state.circle !== null) {
2042 unregisterEvents(this.registeredEvents);
2043 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2044 updaterMap: updaterMap$a,
2045 eventMap: eventMap$a,
2046 prevProps: prevProps,
2047 nextProps: this.props,
2048 instance: this.state.circle
2049 });
2050 }
2051 };
2052
2053 _proto.componentWillUnmount = function componentWillUnmount() {
2054 if (this.state.circle !== null) {
2055 if (this.props.onUnmount) {
2056 this.props.onUnmount(this.state.circle);
2057 }
2058
2059 unregisterEvents(this.registeredEvents);
2060 this.state.circle && this.state.circle.setMap(null);
2061 }
2062 };
2063
2064 _proto.render = function render() {
2065 return React.createElement(React.Fragment, null);
2066 };
2067
2068 return Circle;
2069}(React.PureComponent);
2070Circle.contextType = MapContext;
2071
2072var eventMap$b = {
2073 onAddFeature: 'addfeature',
2074 onClick: 'click',
2075 onDblClick: 'dblclick',
2076 onMouseDown: 'mousedown',
2077 onMouseOut: 'mouseout',
2078 onMouseOver: 'mouseover',
2079 onMouseUp: 'mouseup',
2080 onRemoveFeature: 'removefeature',
2081 onRemoveProperty: 'removeproperty',
2082 onRightClick: 'rightclick',
2083 onSetGeometry: 'setgeometry',
2084 onSetProperty: 'setproperty'
2085};
2086var updaterMap$b = {
2087 add: function add(instance, features) {
2088 instance.add(features);
2089 },
2090 addgeojson: function addgeojson(instance, geojson, options) {
2091 instance.addGeoJson(geojson, options);
2092 },
2093 contains: function contains(instance, feature) {
2094 instance.contains(feature);
2095 },
2096 foreach: function foreach(instance, callback) {
2097 instance.forEach(callback);
2098 },
2099 loadgeojson: function loadgeojson(instance, url, options, callback) {
2100 instance.loadGeoJson(url, options, callback);
2101 },
2102 overridestyle: function overridestyle(instance, feature, style) {
2103 instance.overrideStyle(feature, style);
2104 },
2105 remove: function remove(instance, feature) {
2106 instance.remove(feature);
2107 },
2108 revertstyle: function revertstyle(instance, feature) {
2109 instance.revertStyle(feature);
2110 },
2111 controlposition: function controlposition(instance, controlPosition) {
2112 instance.setControlPosition(controlPosition);
2113 },
2114 controls: function controls(instance, _controls) {
2115 instance.setControls(_controls);
2116 },
2117 drawingmode: function drawingmode(instance, mode) {
2118 instance.setDrawingMode(mode);
2119 },
2120 map: function map(instance, _map) {
2121 instance.setMap(_map);
2122 },
2123 style: function style(instance, _style) {
2124 instance.setStyle(_style);
2125 },
2126 togeojson: function togeojson(instance, callback) {
2127 instance.toGeoJson(callback);
2128 }
2129};
2130var Data =
2131/*#__PURE__*/
2132function (_React$PureComponent) {
2133 _inheritsLoose(Data, _React$PureComponent);
2134
2135 function Data() {
2136 var _this;
2137
2138 _this = _React$PureComponent.apply(this, arguments) || this;
2139 _this.registeredEvents = [];
2140 _this.state = {
2141 data: null
2142 };
2143
2144 _this.setDataCallback = function () {
2145 if (_this.state.data !== null && _this.props.onLoad) {
2146 _this.props.onLoad(_this.state.data);
2147 }
2148 };
2149
2150 return _this;
2151 }
2152
2153 var _proto = Data.prototype;
2154
2155 _proto.componentDidMount = function componentDidMount() {
2156 var data = new google.maps.Data(_extends({}, this.props.options || {}, {
2157 map: this.context
2158 }));
2159 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2160 updaterMap: updaterMap$b,
2161 eventMap: eventMap$b,
2162 prevProps: {},
2163 nextProps: this.props,
2164 instance: data
2165 });
2166 this.setState(function setData() {
2167 return {
2168 data: data
2169 };
2170 }, this.setDataCallback);
2171 };
2172
2173 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2174 if (this.state.data !== null) {
2175 unregisterEvents(this.registeredEvents);
2176 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2177 updaterMap: updaterMap$b,
2178 eventMap: eventMap$b,
2179 prevProps: prevProps,
2180 nextProps: this.props,
2181 instance: this.state.data
2182 });
2183 }
2184 };
2185
2186 _proto.componentWillUnmount = function componentWillUnmount() {
2187 if (this.state.data !== null) {
2188 if (this.props.onUnmount) {
2189 this.props.onUnmount(this.state.data);
2190 }
2191
2192 unregisterEvents(this.registeredEvents);
2193
2194 if (this.state.data) {
2195 this.state.data.setMap(null);
2196 }
2197 }
2198 };
2199
2200 _proto.render = function render() {
2201 return null;
2202 };
2203
2204 return Data;
2205}(React.PureComponent);
2206Data.contextType = MapContext;
2207
2208var eventMap$c = {
2209 onClick: 'click',
2210 onDefaultViewportChanged: 'defaultviewport_changed',
2211 onStatusChanged: 'status_changed'
2212};
2213var updaterMap$c = {
2214 options: function options(instance, _options) {
2215 instance.setOptions(_options);
2216 },
2217 url: function url(instance, _url) {
2218 instance.setUrl(_url);
2219 },
2220 zIndex: function zIndex(instance, _zIndex) {
2221 instance.setZIndex(_zIndex);
2222 }
2223};
2224var KmlLayer =
2225/*#__PURE__*/
2226function (_PureComponent) {
2227 _inheritsLoose(KmlLayer, _PureComponent);
2228
2229 function KmlLayer() {
2230 var _this;
2231
2232 _this = _PureComponent.apply(this, arguments) || this;
2233 _this.registeredEvents = [];
2234 _this.state = {
2235 kmlLayer: null
2236 };
2237
2238 _this.setKmlLayerCallback = function () {
2239 if (_this.state.kmlLayer !== null && _this.props.onLoad) {
2240 _this.props.onLoad(_this.state.kmlLayer);
2241 }
2242 };
2243
2244 return _this;
2245 }
2246
2247 var _proto = KmlLayer.prototype;
2248
2249 _proto.componentDidMount = function componentDidMount() {
2250 var kmlLayer = new google.maps.KmlLayer(_extends({}, this.props.options, {
2251 map: this.context
2252 }));
2253 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2254 updaterMap: updaterMap$c,
2255 eventMap: eventMap$c,
2256 prevProps: {},
2257 nextProps: this.props,
2258 instance: kmlLayer
2259 });
2260 this.setState(function setLmlLayer() {
2261 return {
2262 kmlLayer: kmlLayer
2263 };
2264 }, this.setKmlLayerCallback);
2265 };
2266
2267 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2268 if (this.state.kmlLayer !== null) {
2269 unregisterEvents(this.registeredEvents);
2270 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2271 updaterMap: updaterMap$c,
2272 eventMap: eventMap$c,
2273 prevProps: prevProps,
2274 nextProps: this.props,
2275 instance: this.state.kmlLayer
2276 });
2277 }
2278 };
2279
2280 _proto.componentWillUnmount = function componentWillUnmount() {
2281 if (this.state.kmlLayer !== null) {
2282 if (this.props.onUnmount) {
2283 this.props.onUnmount(this.state.kmlLayer);
2284 }
2285
2286 unregisterEvents(this.registeredEvents);
2287 this.state.kmlLayer.setMap(null);
2288 }
2289 };
2290
2291 _proto.render = function render() {
2292 return null;
2293 };
2294
2295 return KmlLayer;
2296}(React.PureComponent);
2297KmlLayer.contextType = MapContext;
2298
2299/* eslint-disable filenames/match-regex */
2300function getOffsetOverride(containerElement, getPixelPositionOffset) {
2301 return typeof getPixelPositionOffset === 'function' ? getPixelPositionOffset(containerElement.offsetWidth, containerElement.offsetHeight) : {};
2302} // eslint-disable-next-line @typescript-eslint/no-explicit-any
2303
2304var createLatLng = function createLatLng(inst, Type) {
2305 return new Type(inst.lat, inst.lng);
2306}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
2307
2308
2309var createLatLngBounds = function createLatLngBounds(inst, Type) {
2310 return new Type(new google.maps.LatLng(inst.ne.lat, inst.ne.lng), new google.maps.LatLng(inst.sw.lat, inst.sw.lng));
2311}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
2312
2313
2314var ensureOfType = function ensureOfType(inst, type, factory) {
2315 return inst instanceof type ? inst : factory(inst, type);
2316};
2317
2318var getLayoutStylesByBounds = function getLayoutStylesByBounds(mapCanvasProjection, offset, bounds) {
2319 var ne = mapCanvasProjection.fromLatLngToDivPixel(bounds.getNorthEast());
2320 var sw = mapCanvasProjection.fromLatLngToDivPixel(bounds.getSouthWest());
2321
2322 if (ne && sw) {
2323 return {
2324 left: sw.x + offset.x + "px",
2325 top: ne.y + offset.y + "px",
2326 width: ne.x - sw.x - offset.x + "px",
2327 height: sw.y - ne.y - offset.y + "px"
2328 };
2329 }
2330
2331 return {
2332 left: '-9999px',
2333 top: '-9999px'
2334 };
2335};
2336
2337var getLayoutStylesByPosition = function getLayoutStylesByPosition(mapCanvasProjection, offset, position) {
2338 var point = mapCanvasProjection.fromLatLngToDivPixel(position);
2339
2340 if (point) {
2341 var x = point.x,
2342 y = point.y;
2343 return {
2344 left: x + offset.x + "px",
2345 top: y + offset.y + "px"
2346 };
2347 }
2348
2349 return {
2350 left: '-9999px',
2351 top: '-9999px'
2352 };
2353};
2354
2355var getLayoutStyles = function getLayoutStyles(mapCanvasProjection, offset, bounds, position) {
2356 return bounds !== undefined ? getLayoutStylesByBounds(mapCanvasProjection, offset, ensureOfType(bounds, google.maps.LatLngBounds, createLatLngBounds)) : getLayoutStylesByPosition(mapCanvasProjection, offset, ensureOfType(position, google.maps.LatLng, createLatLng));
2357};
2358
2359var ContentMountHandler =
2360/*#__PURE__*/
2361function (_React$Component) {
2362 _inheritsLoose(ContentMountHandler, _React$Component);
2363
2364 function ContentMountHandler() {
2365 return _React$Component.apply(this, arguments) || this;
2366 }
2367
2368 var _proto = ContentMountHandler.prototype;
2369
2370 _proto.componentDidMount = function componentDidMount() {
2371 if (this.props.onLoad) {
2372 this.props.onLoad();
2373 }
2374 };
2375
2376 _proto.render = function render() {
2377 return this.props.children;
2378 };
2379
2380 return ContentMountHandler;
2381}(React.Component);
2382
2383var OverlayView =
2384/*#__PURE__*/
2385function (_React$PureComponent) {
2386 _inheritsLoose(OverlayView, _React$PureComponent);
2387
2388 function OverlayView() {
2389 var _this;
2390
2391 _this = _React$PureComponent.apply(this, arguments) || this;
2392 _this.state = {
2393 overlayView: null
2394 };
2395 _this.containerElement = null;
2396
2397 _this.setOverlayViewCallback = function () {
2398 if (_this.state.overlayView !== null && _this.props.onLoad) {
2399 _this.props.onLoad(_this.state.overlayView);
2400 }
2401
2402 _this.onPositionElement();
2403 };
2404
2405 _this.onAdd = function () {
2406 _this.containerElement = document.createElement('div');
2407 _this.containerElement.style.position = 'absolute';
2408 };
2409
2410 _this.onPositionElement = function () {
2411 if (_this.state.overlayView !== null && _this.containerElement !== null) {
2412 var mapCanvasProjection = _this.state.overlayView.getProjection();
2413
2414 var offset = _extends({
2415 x: 0,
2416 y: 0
2417 }, getOffsetOverride(_this.containerElement, _this.props.getPixelPositionOffset));
2418
2419 var layoutStyles = getLayoutStyles(mapCanvasProjection, offset, _this.props.bounds, _this.props.position);
2420 Object.assign(_this.containerElement.style, layoutStyles);
2421 }
2422 };
2423
2424 _this.draw = function () {
2425 !!!_this.props.mapPaneName ? invariant(false, "OverlayView requires props.mapPaneName but got %s", _this.props.mapPaneName) : void 0;
2426 var overlayView = _this.state.overlayView;
2427
2428 if (overlayView === null) {
2429 return;
2430 } // https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapPanes
2431 // eslint-disable-next-line @typescript-eslint/no-explicit-any
2432
2433
2434 var mapPanes = overlayView.getPanes();
2435
2436 if (!mapPanes) {
2437 return;
2438 }
2439
2440 if (_this.containerElement) {
2441 mapPanes[_this.props.mapPaneName].appendChild(_this.containerElement);
2442 }
2443
2444 _this.onPositionElement();
2445
2446 _this.forceUpdate();
2447 };
2448
2449 _this.onRemove = function () {
2450 if (_this.containerElement !== null && _this.containerElement.parentNode) {
2451 _this.containerElement.parentNode.removeChild(_this.containerElement);
2452
2453 delete _this.containerElement;
2454 }
2455 };
2456
2457 return _this;
2458 }
2459
2460 var _proto = OverlayView.prototype;
2461
2462 _proto.componentDidMount = function componentDidMount() {
2463 var overlayView = new google.maps.OverlayView(); // You must implement three methods: onAdd(), draw(), and onRemove().
2464
2465 overlayView.onAdd = this.onAdd;
2466 overlayView.draw = this.draw;
2467 overlayView.onRemove = this.onRemove;
2468 overlayView.setMap(this.context); // You must call setMap() with a valid Map object to trigger the call to
2469 // the onAdd() method and setMap(null) in order to trigger the onRemove() method.
2470
2471 this.setState(function setOverlayView() {
2472 return {
2473 overlayView: overlayView
2474 };
2475 });
2476 };
2477
2478 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2479 var _this2 = this;
2480
2481 if (prevProps.position !== this.props.position || prevProps.bounds !== this.props.bounds) {
2482 setTimeout(function () {
2483 _this2.state.overlayView !== null && _this2.state.overlayView.draw();
2484 }, 0);
2485 }
2486 };
2487
2488 _proto.componentWillUnmount = function componentWillUnmount() {
2489 if (this.state.overlayView !== null) {
2490 if (this.props.onUnmount) {
2491 this.props.onUnmount(this.state.overlayView);
2492 }
2493
2494 this.state.overlayView.setMap(null);
2495 }
2496 };
2497
2498 _proto.render = function render() {
2499 return this.containerElement !== null ? ReactDOM.createPortal(React.createElement(ContentMountHandler, {
2500 onLoad: this.setOverlayViewCallback
2501 }, React.Children.only(this.props.children)), this.containerElement) : React.createElement(React.Fragment, null);
2502 };
2503
2504 return OverlayView;
2505}(React.PureComponent);
2506OverlayView.FLOAT_PANE = "floatPane";
2507OverlayView.MAP_PANE = "mapPane";
2508OverlayView.MARKER_LAYER = "markerLayer";
2509OverlayView.OVERLAY_LAYER = "overlayLayer";
2510OverlayView.OVERLAY_MOUSE_TARGET = "overlayMouseTarget";
2511OverlayView.contextType = MapContext;
2512
2513function noop() {}
2514
2515var eventMap$d = {
2516 onDblClick: 'dblclick',
2517 onClick: 'click'
2518};
2519var updaterMap$d = {
2520 opacity: function opacity(instance, _opacity) {
2521 instance.setOpacity(_opacity);
2522 }
2523};
2524var GroundOverlay =
2525/*#__PURE__*/
2526function (_React$PureComponent) {
2527 _inheritsLoose(GroundOverlay, _React$PureComponent);
2528
2529 function GroundOverlay() {
2530 var _this;
2531
2532 _this = _React$PureComponent.apply(this, arguments) || this;
2533 _this.registeredEvents = [];
2534 _this.state = {
2535 groundOverlay: null
2536 };
2537
2538 _this.setGroundOverlayCallback = function () {
2539 if (_this.state.groundOverlay !== null && _this.props.onLoad) {
2540 _this.props.onLoad(_this.state.groundOverlay);
2541 }
2542 };
2543
2544 return _this;
2545 }
2546
2547 var _proto = GroundOverlay.prototype;
2548
2549 _proto.componentDidMount = function componentDidMount() {
2550 !(!!this.props.url || !!this.props.bounds) ? invariant(false, "For GroundOverlay, url and bounds are passed in to constructor and are immutable after instantiated. This is the behavior of Google Maps JavaScript API v3 ( See https://developers.google.com/maps/documentation/javascript/reference#GroundOverlay) Hence, use the corresponding two props provided by `react-google-maps-api`, url and bounds. In some cases, you'll need the GroundOverlay component to reflect the changes of url and bounds. You can leverage the React's key property to remount the component. Typically, just `key={url}` would serve your need. See https://github.com/tomchentw/react-google-maps/issues/655") : void 0;
2551 var groundOverlay = new google.maps.GroundOverlay(this.props.url, this.props.bounds, _extends({}, this.props.options, {
2552 map: this.context
2553 }));
2554 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2555 updaterMap: updaterMap$d,
2556 eventMap: eventMap$d,
2557 prevProps: {},
2558 nextProps: this.props,
2559 instance: groundOverlay
2560 });
2561 this.setState(function setGroundOverlay() {
2562 return {
2563 groundOverlay: groundOverlay
2564 };
2565 }, this.setGroundOverlayCallback);
2566 };
2567
2568 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2569 if (this.state.groundOverlay !== null) {
2570 unregisterEvents(this.registeredEvents);
2571 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2572 updaterMap: updaterMap$d,
2573 eventMap: eventMap$d,
2574 prevProps: prevProps,
2575 nextProps: this.props,
2576 instance: this.state.groundOverlay
2577 });
2578 }
2579 };
2580
2581 _proto.componentWillUnmount = function componentWillUnmount() {
2582 if (this.state.groundOverlay) {
2583 if (this.props.onUnmount) {
2584 this.props.onUnmount(this.state.groundOverlay);
2585 }
2586
2587 this.state.groundOverlay.setMap(null);
2588 }
2589 };
2590
2591 _proto.render = function render() {
2592 return null;
2593 };
2594
2595 return GroundOverlay;
2596}(React.PureComponent);
2597GroundOverlay.defaultProps = {
2598 onLoad: noop
2599};
2600GroundOverlay.contextType = MapContext;
2601
2602var eventMap$e = {};
2603var updaterMap$e = {
2604 data: function data(instance, _data) {
2605 instance.setData(_data);
2606 },
2607 map: function map(instance, _map) {
2608 instance.setMap(_map);
2609 },
2610 options: function options(instance, _options) {
2611 instance.setOptions(_options);
2612 }
2613};
2614var HeatmapLayer =
2615/*#__PURE__*/
2616function (_React$PureComponent) {
2617 _inheritsLoose(HeatmapLayer, _React$PureComponent);
2618
2619 function HeatmapLayer() {
2620 var _this;
2621
2622 _this = _React$PureComponent.apply(this, arguments) || this;
2623 _this.registeredEvents = [];
2624 _this.state = {
2625 heatmapLayer: null
2626 };
2627
2628 _this.setHeatmapLayerCallback = function () {
2629 if (_this.state.heatmapLayer !== null && _this.props.onLoad) {
2630 _this.props.onLoad(_this.state.heatmapLayer);
2631 }
2632 };
2633
2634 return _this;
2635 }
2636
2637 var _proto = HeatmapLayer.prototype;
2638
2639 _proto.componentDidMount = function componentDidMount() {
2640 !!!google.maps.visualization ? invariant(false, 'Did you include prop libraries={["visualization"]} to <LoadScript />? %s', google.maps.visualization) : void 0;
2641 !!!this.props.data ? invariant(false, 'data property is required in HeatmapLayer %s', this.props.data) : void 0;
2642 var heatmapLayer = new google.maps.visualization.HeatmapLayer(_extends({
2643 data: this.props.data
2644 }, this.props.options || {}, {
2645 map: this.context
2646 }));
2647 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2648 updaterMap: updaterMap$e,
2649 eventMap: eventMap$e,
2650 prevProps: {},
2651 nextProps: this.props,
2652 instance: heatmapLayer
2653 });
2654 this.setState(function setHeatmapLayer() {
2655 return {
2656 heatmapLayer: heatmapLayer
2657 };
2658 }, this.setHeatmapLayerCallback);
2659 };
2660
2661 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2662 unregisterEvents(this.registeredEvents);
2663 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2664 updaterMap: updaterMap$e,
2665 eventMap: eventMap$e,
2666 prevProps: prevProps,
2667 nextProps: this.props,
2668 instance: this.state.heatmapLayer
2669 });
2670 };
2671
2672 _proto.componentWillUnmount = function componentWillUnmount() {
2673 if (this.state.heatmapLayer !== null) {
2674 if (this.props.onUnmount) {
2675 this.props.onUnmount(this.state.heatmapLayer);
2676 }
2677
2678 unregisterEvents(this.registeredEvents);
2679 this.state.heatmapLayer.setMap(null);
2680 }
2681 };
2682
2683 _proto.render = function render() {
2684 return null;
2685 };
2686
2687 return HeatmapLayer;
2688}(React.PureComponent);
2689HeatmapLayer.contextType = MapContext;
2690
2691var eventMap$f = {
2692 onCloseClick: 'closeclick',
2693 onPanoChanged: 'pano_changed',
2694 onPositionChanged: 'position_changed',
2695 onPovChanged: 'pov_changed',
2696 onResize: 'resize',
2697 onStatusChanged: 'status_changed',
2698 onVisibleChanged: 'visible_changed',
2699 onZoomChanged: 'zoom_changed'
2700};
2701var updaterMap$f = {
2702 register: function register(instance, provider, options) {
2703 instance.registerPanoProvider(provider, options);
2704 },
2705 links: function links(instance, _links) {
2706 instance.setLinks(_links);
2707 },
2708 motionTracking: function motionTracking(instance, _motionTracking) {
2709 instance.setMotionTracking(_motionTracking);
2710 },
2711 options: function options(instance, _options) {
2712 instance.setOptions(_options);
2713 },
2714 pano: function pano(instance, _pano) {
2715 instance.setPano(_pano);
2716 },
2717 position: function position(instance, _position) {
2718 instance.setPosition(_position);
2719 },
2720 pov: function pov(instance, _pov) {
2721 instance.setPov(_pov);
2722 },
2723 visible: function visible(instance, _visible) {
2724 instance.setVisible(_visible);
2725 },
2726 zoom: function zoom(instance, _zoom) {
2727 instance.setZoom(_zoom);
2728 }
2729};
2730var StreetViewPanorama =
2731/*#__PURE__*/
2732function (_React$PureComponent) {
2733 _inheritsLoose(StreetViewPanorama, _React$PureComponent);
2734
2735 function StreetViewPanorama() {
2736 var _this;
2737
2738 _this = _React$PureComponent.apply(this, arguments) || this;
2739 _this.registeredEvents = [];
2740 _this.state = {
2741 streetViewPanorama: null
2742 };
2743
2744 _this.setStreetViewPanoramaCallback = function () {
2745 if (_this.state.streetViewPanorama !== null && _this.props.onLoad) {
2746 _this.props.onLoad(_this.state.streetViewPanorama);
2747 }
2748 };
2749
2750 return _this;
2751 }
2752
2753 var _proto = StreetViewPanorama.prototype;
2754
2755 _proto.componentDidMount = function componentDidMount() {
2756 var streetViewPanorama = this.context.getStreetView();
2757 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2758 updaterMap: updaterMap$f,
2759 eventMap: eventMap$f,
2760 prevProps: {},
2761 nextProps: this.props,
2762 instance: streetViewPanorama
2763 });
2764 this.setState(function setStreetViewPanorama() {
2765 return {
2766 streetViewPanorama: streetViewPanorama
2767 };
2768 }, this.setStreetViewPanoramaCallback);
2769 };
2770
2771 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2772 if (this.state.streetViewPanorama !== null) {
2773 unregisterEvents(this.registeredEvents);
2774 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2775 updaterMap: updaterMap$f,
2776 eventMap: eventMap$f,
2777 prevProps: prevProps,
2778 nextProps: this.props,
2779 instance: this.state.streetViewPanorama
2780 });
2781 }
2782 };
2783
2784 _proto.componentWillUnmount = function componentWillUnmount() {
2785 if (this.state.streetViewPanorama !== null) {
2786 if (this.props.onUnmount) {
2787 this.props.onUnmount(this.state.streetViewPanorama);
2788 }
2789
2790 unregisterEvents(this.registeredEvents);
2791 this.state.streetViewPanorama.setVisible(false);
2792 }
2793 };
2794
2795 _proto.render = function render() {
2796 return null;
2797 };
2798
2799 return StreetViewPanorama;
2800}(React.PureComponent);
2801StreetViewPanorama.contextType = MapContext;
2802
2803var StreetViewService =
2804/*#__PURE__*/
2805function (_React$PureComponent) {
2806 _inheritsLoose(StreetViewService, _React$PureComponent);
2807
2808 function StreetViewService() {
2809 var _this;
2810
2811 _this = _React$PureComponent.apply(this, arguments) || this;
2812 _this.state = {
2813 streetViewService: null
2814 };
2815
2816 _this.setStreetViewServiceCallback = function () {
2817 if (_this.state.streetViewService !== null && _this.props.onLoad) {
2818 _this.props.onLoad(_this.state.streetViewService);
2819 }
2820 };
2821
2822 return _this;
2823 }
2824
2825 var _proto = StreetViewService.prototype;
2826
2827 _proto.componentDidMount = function componentDidMount() {
2828 var streetViewService = new google.maps.StreetViewService();
2829 this.setState(function setStreetViewService() {
2830 return {
2831 streetViewService: streetViewService
2832 };
2833 });
2834 };
2835
2836 _proto.componentWillUnmount = function componentWillUnmount() {
2837 if (this.state.streetViewService !== null) {
2838 if (this.props.onUnmount) {
2839 this.props.onUnmount(this.state.streetViewService);
2840 }
2841 }
2842 };
2843
2844 _proto.render = function render() {
2845 return null;
2846 };
2847
2848 return StreetViewService;
2849}(React.PureComponent);
2850StreetViewService.contextType = MapContext;
2851
2852var DirectionsService =
2853/*#__PURE__*/
2854function (_React$PureComponent) {
2855 _inheritsLoose(DirectionsService, _React$PureComponent);
2856
2857 function DirectionsService() {
2858 var _this;
2859
2860 _this = _React$PureComponent.apply(this, arguments) || this;
2861 _this.state = {
2862 directionsService: null
2863 };
2864
2865 _this.setDirectionsServiceCallback = function () {
2866 if (_this.state.directionsService !== null && _this.props.onLoad) {
2867 _this.props.onLoad(_this.state.directionsService);
2868 }
2869 };
2870
2871 return _this;
2872 }
2873
2874 var _proto = DirectionsService.prototype;
2875
2876 _proto.componentDidMount = function componentDidMount() {
2877 !!!this.props.options ? invariant(false, 'DirectionsService expected options object as parameter, but got %s', this.props.options) : void 0;
2878 var directionsService = new google.maps.DirectionsService();
2879 this.setState(function setDirectionsService() {
2880 return {
2881 directionsService: directionsService
2882 };
2883 }, this.setDirectionsServiceCallback);
2884 };
2885
2886 _proto.componentDidUpdate = function componentDidUpdate() {
2887 if (this.state.directionsService !== null) {
2888 this.state.directionsService.route(this.props.options, this.props.callback);
2889 }
2890 };
2891
2892 _proto.componentWillUnmount = function componentWillUnmount() {
2893 if (this.state.directionsService !== null) {
2894 if (this.props.onUnmount) {
2895 this.props.onUnmount(this.state.directionsService);
2896 }
2897 }
2898 };
2899
2900 _proto.render = function render() {
2901 return React.createElement(React.Fragment, null);
2902 };
2903
2904 return DirectionsService;
2905}(React.PureComponent);
2906
2907var eventMap$g = {
2908 onDirectionsChanged: 'directions_changed'
2909};
2910var updaterMap$g = {
2911 directions: function directions(instance, _directions) {
2912 instance.setDirections(_directions);
2913 },
2914 map: function map(instance, _map) {
2915 instance.setMap(_map);
2916 },
2917 options: function options(instance, _options) {
2918 instance.setOptions(_options);
2919 },
2920 panel: function panel(instance, _panel) {
2921 instance.setPanel(_panel);
2922 },
2923 routeIndex: function routeIndex(instance, _routeIndex) {
2924 instance.setRouteIndex(_routeIndex);
2925 }
2926};
2927var DirectionsRenderer =
2928/*#__PURE__*/
2929function (_React$PureComponent) {
2930 _inheritsLoose(DirectionsRenderer, _React$PureComponent);
2931
2932 function DirectionsRenderer() {
2933 var _this;
2934
2935 _this = _React$PureComponent.apply(this, arguments) || this;
2936 _this.registeredEvents = [];
2937 _this.state = {
2938 directionsRenderer: null
2939 };
2940
2941 _this.setDirectionsRendererCallback = function () {
2942 if (_this.state.directionsRenderer !== null) {
2943 _this.state.directionsRenderer.setMap(_this.context);
2944
2945 if (_this.props.onLoad) {
2946 _this.props.onLoad(_this.state.directionsRenderer);
2947 }
2948 }
2949 };
2950
2951 return _this;
2952 }
2953
2954 var _proto = DirectionsRenderer.prototype;
2955
2956 _proto.componentDidMount = function componentDidMount() {
2957 var directionsRenderer = new google.maps.DirectionsRenderer(this.props.options);
2958 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2959 updaterMap: updaterMap$g,
2960 eventMap: eventMap$g,
2961 prevProps: {},
2962 nextProps: this.props,
2963 instance: directionsRenderer
2964 });
2965 this.setState(function setDirectionsRenderer() {
2966 return {
2967 directionsRenderer: directionsRenderer
2968 };
2969 }, this.setDirectionsRendererCallback);
2970 };
2971
2972 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2973 if (this.state.directionsRenderer !== null) {
2974 unregisterEvents(this.registeredEvents);
2975 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2976 updaterMap: updaterMap$g,
2977 eventMap: eventMap$g,
2978 prevProps: prevProps,
2979 nextProps: this.props,
2980 instance: this.state.directionsRenderer
2981 });
2982 }
2983 };
2984
2985 _proto.componentWillUnmount = function componentWillUnmount() {
2986 if (this.state.directionsRenderer !== null) {
2987 if (this.props.onUnmount) {
2988 this.props.onUnmount(this.state.directionsRenderer);
2989 }
2990
2991 unregisterEvents(this.registeredEvents);
2992
2993 if (this.state.directionsRenderer) {
2994 this.state.directionsRenderer.setMap(null);
2995 }
2996 }
2997 };
2998
2999 _proto.render = function render() {
3000 return React.createElement(React.Fragment, null);
3001 };
3002
3003 return DirectionsRenderer;
3004}(React.PureComponent);
3005DirectionsRenderer.contextType = MapContext;
3006
3007var DistanceMatrixService =
3008/*#__PURE__*/
3009function (_React$PureComponent) {
3010 _inheritsLoose(DistanceMatrixService, _React$PureComponent);
3011
3012 function DistanceMatrixService() {
3013 var _this;
3014
3015 _this = _React$PureComponent.apply(this, arguments) || this;
3016 _this.state = {
3017 distanceMatrixService: null
3018 };
3019
3020 _this.setDistanceMatrixServiceCallback = function () {
3021 if (_this.state.distanceMatrixService !== null && _this.props.onLoad) {
3022 _this.props.onLoad(_this.state.distanceMatrixService);
3023 }
3024 };
3025
3026 return _this;
3027 }
3028
3029 var _proto = DistanceMatrixService.prototype;
3030
3031 _proto.componentDidMount = function componentDidMount() {
3032 !!!this.props.options ? invariant(false, 'DistanceMatrixService expected options object as parameter, but go %s', this.props.options) : void 0;
3033 var distanceMatrixService = new google.maps.DistanceMatrixService();
3034 this.setState(function setDistanceMatrixService() {
3035 return {
3036 distanceMatrixService: distanceMatrixService
3037 };
3038 }, this.setDistanceMatrixServiceCallback);
3039 };
3040
3041 _proto.componentDidUpdate = function componentDidUpdate() {
3042 if (this.state.distanceMatrixService !== null) {
3043 this.state.distanceMatrixService.getDistanceMatrix(this.props.options, this.props.callback);
3044 }
3045 };
3046
3047 _proto.componentWillUnmount = function componentWillUnmount() {
3048 if (this.state.distanceMatrixService !== null) {
3049 if (this.props.onUnmount) {
3050 this.props.onUnmount(this.state.distanceMatrixService);
3051 }
3052 }
3053 };
3054
3055 _proto.render = function render() {
3056 return React.createElement(React.Fragment, null);
3057 };
3058
3059 return DistanceMatrixService;
3060}(React.PureComponent);
3061
3062var eventMap$h = {
3063 onPlacesChanged: 'places_changed'
3064};
3065var updaterMap$h = {
3066 bounds: function bounds(instance, _bounds) {
3067 instance.setBounds(_bounds);
3068 }
3069};
3070
3071var StandaloneSearchBox =
3072/*#__PURE__*/
3073function (_React$PureComponent) {
3074 _inheritsLoose(StandaloneSearchBox, _React$PureComponent);
3075
3076 function StandaloneSearchBox() {
3077 var _this;
3078
3079 _this = _React$PureComponent.apply(this, arguments) || this;
3080 _this.registeredEvents = [];
3081 _this.containerElement = React.createRef();
3082 _this.state = {
3083 searchBox: null
3084 };
3085
3086 _this.setSearchBoxCallback = function () {
3087 if (_this.state.searchBox !== null && _this.props.onLoad) {
3088 _this.props.onLoad(_this.state.searchBox);
3089 }
3090 };
3091
3092 return _this;
3093 }
3094
3095 var _proto = StandaloneSearchBox.prototype;
3096
3097 _proto.componentDidMount = function componentDidMount() {
3098 !!!google.maps.places ? invariant(false, 'You need to provide libraries={["places"]} prop to <LoadScript /> component %s', google.maps.places) : void 0;
3099
3100 if (this.containerElement !== null && this.containerElement.current !== null) {
3101 var input = this.containerElement.current.querySelector('input');
3102
3103 if (input !== null) {
3104 var searchBox = new google.maps.places.SearchBox(input, this.props.options);
3105 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
3106 updaterMap: updaterMap$h,
3107 eventMap: eventMap$h,
3108 prevProps: {},
3109 nextProps: this.props,
3110 instance: searchBox
3111 });
3112 this.setState(function setSearchBox() {
3113 return {
3114 searchBox: searchBox
3115 };
3116 }, this.setSearchBoxCallback);
3117 }
3118 }
3119 };
3120
3121 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
3122 if (this.state.searchBox !== null) {
3123 unregisterEvents(this.registeredEvents);
3124 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
3125 updaterMap: updaterMap$h,
3126 eventMap: eventMap$h,
3127 prevProps: prevProps,
3128 nextProps: this.props,
3129 instance: this.state.searchBox
3130 });
3131 }
3132 };
3133
3134 _proto.componentWillUnmount = function componentWillUnmount() {
3135 if (this.state.searchBox !== null) {
3136 if (this.props.onUnmount) {
3137 this.props.onUnmount(this.state.searchBox);
3138 }
3139
3140 unregisterEvents(this.registeredEvents);
3141 }
3142 };
3143
3144 _proto.render = function render() {
3145 return React.createElement("div", {
3146 ref: this.containerElement
3147 }, React.Children.only(this.props.children));
3148 };
3149
3150 return StandaloneSearchBox;
3151}(React.PureComponent);
3152
3153StandaloneSearchBox.contextType = MapContext;
3154
3155var eventMap$i = {
3156 onPlaceChanged: 'place_changed'
3157};
3158var updaterMap$i = {
3159 bounds: function bounds(instance, _bounds) {
3160 instance.setBounds(_bounds);
3161 },
3162 restrictions: function restrictions(instance, _restrictions) {
3163 instance.setComponentRestrictions(_restrictions);
3164 },
3165 fields: function fields(instance, _fields) {
3166 instance.setFields(_fields);
3167 },
3168 options: function options(instance, _options) {
3169 instance.setOptions(_options);
3170 },
3171 types: function types(instance, _types) {
3172 instance.setTypes(_types);
3173 }
3174};
3175var Autocomplete =
3176/*#__PURE__*/
3177function (_React$PureComponent) {
3178 _inheritsLoose(Autocomplete, _React$PureComponent);
3179
3180 function Autocomplete() {
3181 var _this;
3182
3183 _this = _React$PureComponent.apply(this, arguments) || this;
3184 _this.registeredEvents = [];
3185 _this.containerElement = React.createRef();
3186 _this.state = {
3187 autocomplete: null
3188 };
3189
3190 _this.setAutocompleteCallback = function () {
3191 if (_this.state.autocomplete !== null && _this.props.onLoad) {
3192 _this.props.onLoad(_this.state.autocomplete);
3193 }
3194 };
3195
3196 return _this;
3197 }
3198
3199 var _proto = Autocomplete.prototype;
3200
3201 _proto.componentDidMount = function componentDidMount() {
3202 !!!google.maps.places ? invariant(false, 'You need to provide libraries={["places"]} prop to <LoadScript /> component %s', google.maps.places) : void 0; // TODO: why current could be equal null?
3203 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
3204 // @ts-ignore
3205
3206 var input = this.containerElement.current.querySelector('input');
3207
3208 if (input) {
3209 var autocomplete = new google.maps.places.Autocomplete(input, this.props.options);
3210 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
3211 updaterMap: updaterMap$i,
3212 eventMap: eventMap$i,
3213 prevProps: {},
3214 nextProps: this.props,
3215 instance: autocomplete
3216 });
3217 this.setState(function setAutocomplete() {
3218 return {
3219 autocomplete: autocomplete
3220 };
3221 }, this.setAutocompleteCallback);
3222 }
3223 };
3224
3225 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
3226 unregisterEvents(this.registeredEvents);
3227 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
3228 updaterMap: updaterMap$i,
3229 eventMap: eventMap$i,
3230 prevProps: prevProps,
3231 nextProps: this.props,
3232 instance: this.state.autocomplete
3233 });
3234 };
3235
3236 _proto.componentWillUnmount = function componentWillUnmount() {
3237 if (this.state.autocomplete !== null) {
3238 unregisterEvents(this.registeredEvents);
3239 }
3240 };
3241
3242 _proto.render = function render() {
3243 return React.createElement("div", {
3244 ref: this.containerElement
3245 }, React.Children.only(this.props.children));
3246 };
3247
3248 return Autocomplete;
3249}(React.PureComponent);
3250Autocomplete.contextType = MapContext;
3251
3252exports.Autocomplete = Autocomplete;
3253exports.BicyclingLayer = BicyclingLayer;
3254exports.Circle = Circle;
3255exports.Data = Data;
3256exports.DirectionsRenderer = DirectionsRenderer;
3257exports.DirectionsService = DirectionsService;
3258exports.DistanceMatrixService = DistanceMatrixService;
3259exports.DrawingManager = DrawingManager;
3260exports.GoogleMap = GoogleMap;
3261exports.GroundOverlay = GroundOverlay;
3262exports.HeatmapLayer = HeatmapLayer;
3263exports.InfoBox = InfoBoxComponent;
3264exports.InfoWindow = InfoWindow;
3265exports.KmlLayer = KmlLayer;
3266exports.LoadScript = LoadScript;
3267exports.LoadScriptNext = LoadScriptNext$1;
3268exports.Marker = Marker;
3269exports.MarkerClusterer = ClustererComponent;
3270exports.OverlayView = OverlayView;
3271exports.Polygon = Polygon;
3272exports.Polyline = Polyline;
3273exports.Rectangle = Rectangle;
3274exports.StandaloneSearchBox = StandaloneSearchBox;
3275exports.StreetViewPanorama = StreetViewPanorama;
3276exports.StreetViewService = StreetViewService;
3277exports.TrafficLayer = TrafficLayer;
3278exports.TransitLayer = TransitLayer;
3279exports.useGoogleMap = useGoogleMap;
3280exports.useLoadScript = useLoadScript;
3281//# sourceMappingURL=reactgooglemapsapi.cjs.development.js.map