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 typeof script.src === 'string' && 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(props) {
2385 var _this;
2386
2387 _this = _React$PureComponent.call(this, props) || this;
2388 _this.state = {
2389 overlayView: null,
2390 containerStyle: {}
2391 };
2392 _this.mapPaneEl = null;
2393
2394 _this.setOverlayViewCallback = function () {
2395 if (_this.state.overlayView !== null && _this.props.onLoad) {
2396 _this.props.onLoad(_this.state.overlayView);
2397 }
2398
2399 _this.onPositionElement();
2400 };
2401
2402 _this.onAdd = function () {
2403 var _this$state$overlayVi;
2404
2405 !!!_this.props.mapPaneName ? invariant(false, "OverlayView requires props.mapPaneName but got %s", _this.props.mapPaneName) : void 0; // https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapPanes
2406 // eslint-disable-next-line @typescript-eslint/no-explicit-any
2407
2408 var mapPanes = (_this$state$overlayVi = _this.state.overlayView) === null || _this$state$overlayVi === void 0 ? void 0 : _this$state$overlayVi.getPanes();
2409
2410 if (!mapPanes) {
2411 return;
2412 }
2413
2414 _this.mapPaneEl = mapPanes[_this.props.mapPaneName];
2415 };
2416
2417 _this.onPositionElement = function () {
2418 if (_this.state.overlayView !== null) {
2419 var mapCanvasProjection = _this.state.overlayView.getProjection();
2420
2421 var offset = _extends({
2422 x: 0,
2423 y: 0
2424 }, _this.containerRef.current ? getOffsetOverride(_this.containerRef.current, _this.props.getPixelPositionOffset) : {});
2425
2426 var layoutStyles = getLayoutStyles(mapCanvasProjection, offset, _this.props.bounds, _this.props.position);
2427
2428 _this.setState({
2429 containerStyle: layoutStyles
2430 });
2431 }
2432 };
2433
2434 _this.draw = function () {
2435 _this.onPositionElement();
2436 };
2437
2438 _this.onRemove = function () {
2439 _this.mapPaneEl = null;
2440 };
2441
2442 _this.containerRef = React.createRef();
2443 return _this;
2444 }
2445
2446 var _proto = OverlayView.prototype;
2447
2448 _proto.componentDidMount = function componentDidMount() {
2449 var overlayView = new google.maps.OverlayView(); // You must implement three methods: onAdd(), draw(), and onRemove().
2450
2451 overlayView.onAdd = this.onAdd;
2452 overlayView.draw = this.draw;
2453 overlayView.onRemove = this.onRemove;
2454 overlayView.setMap(this.context); // You must call setMap() with a valid Map object to trigger the call to
2455 // the onAdd() method and setMap(null) in order to trigger the onRemove() method.
2456
2457 this.setState(function setOverlayView() {
2458 return {
2459 overlayView: overlayView
2460 };
2461 });
2462 };
2463
2464 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2465 var _this2 = this;
2466
2467 if (prevProps.position !== this.props.position || prevProps.bounds !== this.props.bounds) {
2468 setTimeout(function () {
2469 _this2.state.overlayView !== null && _this2.state.overlayView.draw();
2470 }, 0);
2471 }
2472 };
2473
2474 _proto.componentWillUnmount = function componentWillUnmount() {
2475 if (this.state.overlayView !== null) {
2476 if (this.props.onUnmount) {
2477 this.props.onUnmount(this.state.overlayView);
2478 }
2479
2480 this.state.overlayView.setMap(null);
2481 }
2482 };
2483
2484 _proto.render = function render() {
2485 return this.mapPaneEl ? ReactDOM.createPortal(React.createElement("div", {
2486 ref: this.containerRef,
2487 style: _extends({}, this.state.containerStyle, {
2488 position: 'absolute'
2489 })
2490 }, React.createElement(ContentMountHandler, {
2491 onLoad: this.setOverlayViewCallback
2492 }, React.Children.only(this.props.children))), this.mapPaneEl) : React.createElement(React.Fragment, null);
2493 };
2494
2495 return OverlayView;
2496 }(React.PureComponent);
2497 OverlayView.FLOAT_PANE = "floatPane";
2498 OverlayView.MAP_PANE = "mapPane";
2499 OverlayView.MARKER_LAYER = "markerLayer";
2500 OverlayView.OVERLAY_LAYER = "overlayLayer";
2501 OverlayView.OVERLAY_MOUSE_TARGET = "overlayMouseTarget";
2502 OverlayView.contextType = MapContext;
2503
2504 function noop() {}
2505
2506 var eventMap$d = {
2507 onDblClick: 'dblclick',
2508 onClick: 'click'
2509 };
2510 var updaterMap$d = {
2511 opacity: function opacity(instance, _opacity) {
2512 instance.setOpacity(_opacity);
2513 }
2514 };
2515 var GroundOverlay =
2516 /*#__PURE__*/
2517 function (_React$PureComponent) {
2518 _inheritsLoose(GroundOverlay, _React$PureComponent);
2519
2520 function GroundOverlay() {
2521 var _this;
2522
2523 _this = _React$PureComponent.apply(this, arguments) || this;
2524 _this.registeredEvents = [];
2525 _this.state = {
2526 groundOverlay: null
2527 };
2528
2529 _this.setGroundOverlayCallback = function () {
2530 if (_this.state.groundOverlay !== null && _this.props.onLoad) {
2531 _this.props.onLoad(_this.state.groundOverlay);
2532 }
2533 };
2534
2535 return _this;
2536 }
2537
2538 var _proto = GroundOverlay.prototype;
2539
2540 _proto.componentDidMount = function componentDidMount() {
2541 !(!!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;
2542 var groundOverlay = new google.maps.GroundOverlay(this.props.url, this.props.bounds, _extends({}, this.props.options, {
2543 map: this.context
2544 }));
2545 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2546 updaterMap: updaterMap$d,
2547 eventMap: eventMap$d,
2548 prevProps: {},
2549 nextProps: this.props,
2550 instance: groundOverlay
2551 });
2552 this.setState(function setGroundOverlay() {
2553 return {
2554 groundOverlay: groundOverlay
2555 };
2556 }, this.setGroundOverlayCallback);
2557 };
2558
2559 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2560 if (this.state.groundOverlay !== null) {
2561 unregisterEvents(this.registeredEvents);
2562 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2563 updaterMap: updaterMap$d,
2564 eventMap: eventMap$d,
2565 prevProps: prevProps,
2566 nextProps: this.props,
2567 instance: this.state.groundOverlay
2568 });
2569 }
2570 };
2571
2572 _proto.componentWillUnmount = function componentWillUnmount() {
2573 if (this.state.groundOverlay) {
2574 if (this.props.onUnmount) {
2575 this.props.onUnmount(this.state.groundOverlay);
2576 }
2577
2578 this.state.groundOverlay.setMap(null);
2579 }
2580 };
2581
2582 _proto.render = function render() {
2583 return null;
2584 };
2585
2586 return GroundOverlay;
2587 }(React.PureComponent);
2588 GroundOverlay.defaultProps = {
2589 onLoad: noop
2590 };
2591 GroundOverlay.contextType = MapContext;
2592
2593 var eventMap$e = {};
2594 var updaterMap$e = {
2595 data: function data(instance, _data) {
2596 instance.setData(_data);
2597 },
2598 map: function map(instance, _map) {
2599 instance.setMap(_map);
2600 },
2601 options: function options(instance, _options) {
2602 instance.setOptions(_options);
2603 }
2604 };
2605 var HeatmapLayer =
2606 /*#__PURE__*/
2607 function (_React$PureComponent) {
2608 _inheritsLoose(HeatmapLayer, _React$PureComponent);
2609
2610 function HeatmapLayer() {
2611 var _this;
2612
2613 _this = _React$PureComponent.apply(this, arguments) || this;
2614 _this.registeredEvents = [];
2615 _this.state = {
2616 heatmapLayer: null
2617 };
2618
2619 _this.setHeatmapLayerCallback = function () {
2620 if (_this.state.heatmapLayer !== null && _this.props.onLoad) {
2621 _this.props.onLoad(_this.state.heatmapLayer);
2622 }
2623 };
2624
2625 return _this;
2626 }
2627
2628 var _proto = HeatmapLayer.prototype;
2629
2630 _proto.componentDidMount = function componentDidMount() {
2631 !!!google.maps.visualization ? invariant(false, 'Did you include prop libraries={["visualization"]} to <LoadScript />? %s', google.maps.visualization) : void 0;
2632 !!!this.props.data ? invariant(false, 'data property is required in HeatmapLayer %s', this.props.data) : void 0;
2633 var heatmapLayer = new google.maps.visualization.HeatmapLayer(_extends({
2634 data: this.props.data
2635 }, this.props.options || {}, {
2636 map: this.context
2637 }));
2638 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2639 updaterMap: updaterMap$e,
2640 eventMap: eventMap$e,
2641 prevProps: {},
2642 nextProps: this.props,
2643 instance: heatmapLayer
2644 });
2645 this.setState(function setHeatmapLayer() {
2646 return {
2647 heatmapLayer: heatmapLayer
2648 };
2649 }, this.setHeatmapLayerCallback);
2650 };
2651
2652 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2653 unregisterEvents(this.registeredEvents);
2654 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2655 updaterMap: updaterMap$e,
2656 eventMap: eventMap$e,
2657 prevProps: prevProps,
2658 nextProps: this.props,
2659 instance: this.state.heatmapLayer
2660 });
2661 };
2662
2663 _proto.componentWillUnmount = function componentWillUnmount() {
2664 if (this.state.heatmapLayer !== null) {
2665 if (this.props.onUnmount) {
2666 this.props.onUnmount(this.state.heatmapLayer);
2667 }
2668
2669 unregisterEvents(this.registeredEvents);
2670 this.state.heatmapLayer.setMap(null);
2671 }
2672 };
2673
2674 _proto.render = function render() {
2675 return null;
2676 };
2677
2678 return HeatmapLayer;
2679 }(React.PureComponent);
2680 HeatmapLayer.contextType = MapContext;
2681
2682 var eventMap$f = {
2683 onCloseClick: 'closeclick',
2684 onPanoChanged: 'pano_changed',
2685 onPositionChanged: 'position_changed',
2686 onPovChanged: 'pov_changed',
2687 onResize: 'resize',
2688 onStatusChanged: 'status_changed',
2689 onVisibleChanged: 'visible_changed',
2690 onZoomChanged: 'zoom_changed'
2691 };
2692 var updaterMap$f = {
2693 register: function register(instance, provider, options) {
2694 instance.registerPanoProvider(provider, options);
2695 },
2696 links: function links(instance, _links) {
2697 instance.setLinks(_links);
2698 },
2699 motionTracking: function motionTracking(instance, _motionTracking) {
2700 instance.setMotionTracking(_motionTracking);
2701 },
2702 options: function options(instance, _options) {
2703 instance.setOptions(_options);
2704 },
2705 pano: function pano(instance, _pano) {
2706 instance.setPano(_pano);
2707 },
2708 position: function position(instance, _position) {
2709 instance.setPosition(_position);
2710 },
2711 pov: function pov(instance, _pov) {
2712 instance.setPov(_pov);
2713 },
2714 visible: function visible(instance, _visible) {
2715 instance.setVisible(_visible);
2716 },
2717 zoom: function zoom(instance, _zoom) {
2718 instance.setZoom(_zoom);
2719 }
2720 };
2721 var StreetViewPanorama =
2722 /*#__PURE__*/
2723 function (_React$PureComponent) {
2724 _inheritsLoose(StreetViewPanorama, _React$PureComponent);
2725
2726 function StreetViewPanorama() {
2727 var _this;
2728
2729 _this = _React$PureComponent.apply(this, arguments) || this;
2730 _this.registeredEvents = [];
2731 _this.state = {
2732 streetViewPanorama: null
2733 };
2734
2735 _this.setStreetViewPanoramaCallback = function () {
2736 if (_this.state.streetViewPanorama !== null && _this.props.onLoad) {
2737 _this.props.onLoad(_this.state.streetViewPanorama);
2738 }
2739 };
2740
2741 return _this;
2742 }
2743
2744 var _proto = StreetViewPanorama.prototype;
2745
2746 _proto.componentDidMount = function componentDidMount() {
2747 var streetViewPanorama = this.context.getStreetView();
2748 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2749 updaterMap: updaterMap$f,
2750 eventMap: eventMap$f,
2751 prevProps: {},
2752 nextProps: this.props,
2753 instance: streetViewPanorama
2754 });
2755 this.setState(function setStreetViewPanorama() {
2756 return {
2757 streetViewPanorama: streetViewPanorama
2758 };
2759 }, this.setStreetViewPanoramaCallback);
2760 };
2761
2762 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2763 if (this.state.streetViewPanorama !== null) {
2764 unregisterEvents(this.registeredEvents);
2765 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2766 updaterMap: updaterMap$f,
2767 eventMap: eventMap$f,
2768 prevProps: prevProps,
2769 nextProps: this.props,
2770 instance: this.state.streetViewPanorama
2771 });
2772 }
2773 };
2774
2775 _proto.componentWillUnmount = function componentWillUnmount() {
2776 if (this.state.streetViewPanorama !== null) {
2777 if (this.props.onUnmount) {
2778 this.props.onUnmount(this.state.streetViewPanorama);
2779 }
2780
2781 unregisterEvents(this.registeredEvents);
2782 this.state.streetViewPanorama.setVisible(false);
2783 }
2784 };
2785
2786 _proto.render = function render() {
2787 return null;
2788 };
2789
2790 return StreetViewPanorama;
2791 }(React.PureComponent);
2792 StreetViewPanorama.contextType = MapContext;
2793
2794 var StreetViewService =
2795 /*#__PURE__*/
2796 function (_React$PureComponent) {
2797 _inheritsLoose(StreetViewService, _React$PureComponent);
2798
2799 function StreetViewService() {
2800 var _this;
2801
2802 _this = _React$PureComponent.apply(this, arguments) || this;
2803 _this.state = {
2804 streetViewService: null
2805 };
2806
2807 _this.setStreetViewServiceCallback = function () {
2808 if (_this.state.streetViewService !== null && _this.props.onLoad) {
2809 _this.props.onLoad(_this.state.streetViewService);
2810 }
2811 };
2812
2813 return _this;
2814 }
2815
2816 var _proto = StreetViewService.prototype;
2817
2818 _proto.componentDidMount = function componentDidMount() {
2819 var streetViewService = new google.maps.StreetViewService();
2820 this.setState(function setStreetViewService() {
2821 return {
2822 streetViewService: streetViewService
2823 };
2824 }, this.setStreetViewServiceCallback);
2825 };
2826
2827 _proto.componentWillUnmount = function componentWillUnmount() {
2828 if (this.state.streetViewService !== null) {
2829 if (this.props.onUnmount) {
2830 this.props.onUnmount(this.state.streetViewService);
2831 }
2832 }
2833 };
2834
2835 _proto.render = function render() {
2836 return null;
2837 };
2838
2839 return StreetViewService;
2840 }(React.PureComponent);
2841 StreetViewService.contextType = MapContext;
2842
2843 var DirectionsService =
2844 /*#__PURE__*/
2845 function (_React$PureComponent) {
2846 _inheritsLoose(DirectionsService, _React$PureComponent);
2847
2848 function DirectionsService() {
2849 var _this;
2850
2851 _this = _React$PureComponent.apply(this, arguments) || this;
2852 _this.state = {
2853 directionsService: null
2854 };
2855
2856 _this.setDirectionsServiceCallback = function () {
2857 if (_this.state.directionsService !== null && _this.props.onLoad) {
2858 _this.props.onLoad(_this.state.directionsService);
2859 }
2860 };
2861
2862 return _this;
2863 }
2864
2865 var _proto = DirectionsService.prototype;
2866
2867 _proto.componentDidMount = function componentDidMount() {
2868 !!!this.props.options ? invariant(false, 'DirectionsService expected options object as parameter, but got %s', this.props.options) : void 0;
2869 var directionsService = new google.maps.DirectionsService();
2870 this.setState(function setDirectionsService() {
2871 return {
2872 directionsService: directionsService
2873 };
2874 }, this.setDirectionsServiceCallback);
2875 };
2876
2877 _proto.componentDidUpdate = function componentDidUpdate() {
2878 if (this.state.directionsService !== null) {
2879 this.state.directionsService.route(this.props.options, this.props.callback);
2880 }
2881 };
2882
2883 _proto.componentWillUnmount = function componentWillUnmount() {
2884 if (this.state.directionsService !== null) {
2885 if (this.props.onUnmount) {
2886 this.props.onUnmount(this.state.directionsService);
2887 }
2888 }
2889 };
2890
2891 _proto.render = function render() {
2892 return React.createElement(React.Fragment, null);
2893 };
2894
2895 return DirectionsService;
2896 }(React.PureComponent);
2897
2898 var eventMap$g = {
2899 onDirectionsChanged: 'directions_changed'
2900 };
2901 var updaterMap$g = {
2902 directions: function directions(instance, _directions) {
2903 instance.setDirections(_directions);
2904 },
2905 map: function map(instance, _map) {
2906 instance.setMap(_map);
2907 },
2908 options: function options(instance, _options) {
2909 instance.setOptions(_options);
2910 },
2911 panel: function panel(instance, _panel) {
2912 instance.setPanel(_panel);
2913 },
2914 routeIndex: function routeIndex(instance, _routeIndex) {
2915 instance.setRouteIndex(_routeIndex);
2916 }
2917 };
2918 var DirectionsRenderer =
2919 /*#__PURE__*/
2920 function (_React$PureComponent) {
2921 _inheritsLoose(DirectionsRenderer, _React$PureComponent);
2922
2923 function DirectionsRenderer() {
2924 var _this;
2925
2926 _this = _React$PureComponent.apply(this, arguments) || this;
2927 _this.registeredEvents = [];
2928 _this.state = {
2929 directionsRenderer: null
2930 };
2931
2932 _this.setDirectionsRendererCallback = function () {
2933 if (_this.state.directionsRenderer !== null) {
2934 _this.state.directionsRenderer.setMap(_this.context);
2935
2936 if (_this.props.onLoad) {
2937 _this.props.onLoad(_this.state.directionsRenderer);
2938 }
2939 }
2940 };
2941
2942 return _this;
2943 }
2944
2945 var _proto = DirectionsRenderer.prototype;
2946
2947 _proto.componentDidMount = function componentDidMount() {
2948 var directionsRenderer = new google.maps.DirectionsRenderer(this.props.options);
2949 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2950 updaterMap: updaterMap$g,
2951 eventMap: eventMap$g,
2952 prevProps: {},
2953 nextProps: this.props,
2954 instance: directionsRenderer
2955 });
2956 this.setState(function setDirectionsRenderer() {
2957 return {
2958 directionsRenderer: directionsRenderer
2959 };
2960 }, this.setDirectionsRendererCallback);
2961 };
2962
2963 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2964 if (this.state.directionsRenderer !== null) {
2965 unregisterEvents(this.registeredEvents);
2966 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
2967 updaterMap: updaterMap$g,
2968 eventMap: eventMap$g,
2969 prevProps: prevProps,
2970 nextProps: this.props,
2971 instance: this.state.directionsRenderer
2972 });
2973 }
2974 };
2975
2976 _proto.componentWillUnmount = function componentWillUnmount() {
2977 if (this.state.directionsRenderer !== null) {
2978 if (this.props.onUnmount) {
2979 this.props.onUnmount(this.state.directionsRenderer);
2980 }
2981
2982 unregisterEvents(this.registeredEvents);
2983
2984 if (this.state.directionsRenderer) {
2985 this.state.directionsRenderer.setMap(null);
2986 }
2987 }
2988 };
2989
2990 _proto.render = function render() {
2991 return React.createElement(React.Fragment, null);
2992 };
2993
2994 return DirectionsRenderer;
2995 }(React.PureComponent);
2996 DirectionsRenderer.contextType = MapContext;
2997
2998 var DistanceMatrixService =
2999 /*#__PURE__*/
3000 function (_React$PureComponent) {
3001 _inheritsLoose(DistanceMatrixService, _React$PureComponent);
3002
3003 function DistanceMatrixService() {
3004 var _this;
3005
3006 _this = _React$PureComponent.apply(this, arguments) || this;
3007 _this.state = {
3008 distanceMatrixService: null
3009 };
3010
3011 _this.setDistanceMatrixServiceCallback = function () {
3012 if (_this.state.distanceMatrixService !== null && _this.props.onLoad) {
3013 _this.props.onLoad(_this.state.distanceMatrixService);
3014 }
3015 };
3016
3017 return _this;
3018 }
3019
3020 var _proto = DistanceMatrixService.prototype;
3021
3022 _proto.componentDidMount = function componentDidMount() {
3023 !!!this.props.options ? invariant(false, 'DistanceMatrixService expected options object as parameter, but go %s', this.props.options) : void 0;
3024 var distanceMatrixService = new google.maps.DistanceMatrixService();
3025 this.setState(function setDistanceMatrixService() {
3026 return {
3027 distanceMatrixService: distanceMatrixService
3028 };
3029 }, this.setDistanceMatrixServiceCallback);
3030 };
3031
3032 _proto.componentDidUpdate = function componentDidUpdate() {
3033 if (this.state.distanceMatrixService !== null) {
3034 this.state.distanceMatrixService.getDistanceMatrix(this.props.options, this.props.callback);
3035 }
3036 };
3037
3038 _proto.componentWillUnmount = function componentWillUnmount() {
3039 if (this.state.distanceMatrixService !== null) {
3040 if (this.props.onUnmount) {
3041 this.props.onUnmount(this.state.distanceMatrixService);
3042 }
3043 }
3044 };
3045
3046 _proto.render = function render() {
3047 return React.createElement(React.Fragment, null);
3048 };
3049
3050 return DistanceMatrixService;
3051 }(React.PureComponent);
3052
3053 var eventMap$h = {
3054 onPlacesChanged: 'places_changed'
3055 };
3056 var updaterMap$h = {
3057 bounds: function bounds(instance, _bounds) {
3058 instance.setBounds(_bounds);
3059 }
3060 };
3061
3062 var StandaloneSearchBox =
3063 /*#__PURE__*/
3064 function (_React$PureComponent) {
3065 _inheritsLoose(StandaloneSearchBox, _React$PureComponent);
3066
3067 function StandaloneSearchBox() {
3068 var _this;
3069
3070 _this = _React$PureComponent.apply(this, arguments) || this;
3071 _this.registeredEvents = [];
3072 _this.containerElement = React.createRef();
3073 _this.state = {
3074 searchBox: null
3075 };
3076
3077 _this.setSearchBoxCallback = function () {
3078 if (_this.state.searchBox !== null && _this.props.onLoad) {
3079 _this.props.onLoad(_this.state.searchBox);
3080 }
3081 };
3082
3083 return _this;
3084 }
3085
3086 var _proto = StandaloneSearchBox.prototype;
3087
3088 _proto.componentDidMount = function componentDidMount() {
3089 !!!google.maps.places ? invariant(false, 'You need to provide libraries={["places"]} prop to <LoadScript /> component %s', google.maps.places) : void 0;
3090
3091 if (this.containerElement !== null && this.containerElement.current !== null) {
3092 var input = this.containerElement.current.querySelector('input');
3093
3094 if (input !== null) {
3095 var searchBox = new google.maps.places.SearchBox(input, this.props.options);
3096 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
3097 updaterMap: updaterMap$h,
3098 eventMap: eventMap$h,
3099 prevProps: {},
3100 nextProps: this.props,
3101 instance: searchBox
3102 });
3103 this.setState(function setSearchBox() {
3104 return {
3105 searchBox: searchBox
3106 };
3107 }, this.setSearchBoxCallback);
3108 }
3109 }
3110 };
3111
3112 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
3113 if (this.state.searchBox !== null) {
3114 unregisterEvents(this.registeredEvents);
3115 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
3116 updaterMap: updaterMap$h,
3117 eventMap: eventMap$h,
3118 prevProps: prevProps,
3119 nextProps: this.props,
3120 instance: this.state.searchBox
3121 });
3122 }
3123 };
3124
3125 _proto.componentWillUnmount = function componentWillUnmount() {
3126 if (this.state.searchBox !== null) {
3127 if (this.props.onUnmount) {
3128 this.props.onUnmount(this.state.searchBox);
3129 }
3130
3131 unregisterEvents(this.registeredEvents);
3132 }
3133 };
3134
3135 _proto.render = function render() {
3136 return React.createElement("div", {
3137 ref: this.containerElement
3138 }, React.Children.only(this.props.children));
3139 };
3140
3141 return StandaloneSearchBox;
3142 }(React.PureComponent);
3143
3144 StandaloneSearchBox.contextType = MapContext;
3145
3146 var eventMap$i = {
3147 onPlaceChanged: 'place_changed'
3148 };
3149 var updaterMap$i = {
3150 bounds: function bounds(instance, _bounds) {
3151 instance.setBounds(_bounds);
3152 },
3153 restrictions: function restrictions(instance, _restrictions) {
3154 instance.setComponentRestrictions(_restrictions);
3155 },
3156 fields: function fields(instance, _fields) {
3157 instance.setFields(_fields);
3158 },
3159 options: function options(instance, _options) {
3160 instance.setOptions(_options);
3161 },
3162 types: function types(instance, _types) {
3163 instance.setTypes(_types);
3164 }
3165 };
3166 var Autocomplete =
3167 /*#__PURE__*/
3168 function (_React$PureComponent) {
3169 _inheritsLoose(Autocomplete, _React$PureComponent);
3170
3171 function Autocomplete() {
3172 var _this;
3173
3174 _this = _React$PureComponent.apply(this, arguments) || this;
3175 _this.registeredEvents = [];
3176 _this.containerElement = React.createRef();
3177 _this.state = {
3178 autocomplete: null
3179 };
3180
3181 _this.setAutocompleteCallback = function () {
3182 if (_this.state.autocomplete !== null && _this.props.onLoad) {
3183 _this.props.onLoad(_this.state.autocomplete);
3184 }
3185 };
3186
3187 return _this;
3188 }
3189
3190 var _proto = Autocomplete.prototype;
3191
3192 _proto.componentDidMount = function componentDidMount() {
3193 !!!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?
3194 // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
3195 // @ts-ignore
3196
3197 var input = this.containerElement.current.querySelector('input');
3198
3199 if (input) {
3200 var autocomplete = new google.maps.places.Autocomplete(input, this.props.options);
3201 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
3202 updaterMap: updaterMap$i,
3203 eventMap: eventMap$i,
3204 prevProps: {},
3205 nextProps: this.props,
3206 instance: autocomplete
3207 });
3208 this.setState(function setAutocomplete() {
3209 return {
3210 autocomplete: autocomplete
3211 };
3212 }, this.setAutocompleteCallback);
3213 }
3214 };
3215
3216 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
3217 unregisterEvents(this.registeredEvents);
3218 this.registeredEvents = applyUpdatersToPropsAndRegisterEvents({
3219 updaterMap: updaterMap$i,
3220 eventMap: eventMap$i,
3221 prevProps: prevProps,
3222 nextProps: this.props,
3223 instance: this.state.autocomplete
3224 });
3225 };
3226
3227 _proto.componentWillUnmount = function componentWillUnmount() {
3228 if (this.state.autocomplete !== null) {
3229 unregisterEvents(this.registeredEvents);
3230 }
3231 };
3232
3233 _proto.render = function render() {
3234 return React.createElement("div", {
3235 ref: this.containerElement
3236 }, React.Children.only(this.props.children));
3237 };
3238
3239 return Autocomplete;
3240 }(React.PureComponent);
3241 Autocomplete.contextType = MapContext;
3242
3243 exports.Autocomplete = Autocomplete;
3244 exports.BicyclingLayer = BicyclingLayer;
3245 exports.Circle = Circle;
3246 exports.Data = Data;
3247 exports.DirectionsRenderer = DirectionsRenderer;
3248 exports.DirectionsService = DirectionsService;
3249 exports.DistanceMatrixService = DistanceMatrixService;
3250 exports.DrawingManager = DrawingManager;
3251 exports.GoogleMap = GoogleMap;
3252 exports.GroundOverlay = GroundOverlay;
3253 exports.HeatmapLayer = HeatmapLayer;
3254 exports.InfoBox = InfoBoxComponent;
3255 exports.InfoWindow = InfoWindow;
3256 exports.KmlLayer = KmlLayer;
3257 exports.LoadScript = LoadScript;
3258 exports.LoadScriptNext = LoadScriptNext$1;
3259 exports.Marker = Marker;
3260 exports.MarkerClusterer = ClustererComponent;
3261 exports.OverlayView = OverlayView;
3262 exports.Polygon = Polygon;
3263 exports.Polyline = Polyline;
3264 exports.Rectangle = Rectangle;
3265 exports.StandaloneSearchBox = StandaloneSearchBox;
3266 exports.StreetViewPanorama = StreetViewPanorama;
3267 exports.StreetViewService = StreetViewService;
3268 exports.TrafficLayer = TrafficLayer;
3269 exports.TransitLayer = TransitLayer;
3270 exports.useGoogleMap = useGoogleMap;
3271 exports.useLoadScript = useLoadScript;
3272
3273})));
3274//# sourceMappingURL=reactgooglemapsapi.umd.development.js.map