UNPKG

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