UNPKG

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