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