UNPKG

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