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