1 | (function webpackUniversalModuleDefinition(root, factory) {
|
2 | if(typeof exports === 'object' && typeof module === 'object')
|
3 | module.exports = factory(require("react"), require("react-dom"));
|
4 | else if(typeof define === 'function' && define.amd)
|
5 | define(["react", "react-dom"], factory);
|
6 | else if(typeof exports === 'object')
|
7 | exports["GoogleMapReact"] = factory(require("react"), require("react-dom"));
|
8 | else
|
9 | root["GoogleMapReact"] = factory(root["React"], root["ReactDOM"]);
|
10 | })(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_33__) {
|
11 | return (function(modules) {
|
12 |
|
13 | var installedModules = {};
|
14 |
|
15 |
|
16 | function __webpack_require__(moduleId) {
|
17 |
|
18 |
|
19 | if(installedModules[moduleId])
|
20 | return installedModules[moduleId].exports;
|
21 |
|
22 |
|
23 | var module = installedModules[moduleId] = {
|
24 | exports: {},
|
25 | id: moduleId,
|
26 | loaded: false
|
27 | };
|
28 |
|
29 |
|
30 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31 |
|
32 |
|
33 | module.loaded = true;
|
34 |
|
35 |
|
36 | return module.exports;
|
37 | }
|
38 |
|
39 |
|
40 |
|
41 | __webpack_require__.m = modules;
|
42 |
|
43 |
|
44 | __webpack_require__.c = installedModules;
|
45 |
|
46 |
|
47 | __webpack_require__.p = "";
|
48 |
|
49 |
|
50 | return __webpack_require__(0);
|
51 | })
|
52 |
|
53 | ([
|
54 |
|
55 | (function(module, exports, __webpack_require__) {
|
56 |
|
57 | 'use strict';
|
58 |
|
59 | var _google_map = __webpack_require__(12);
|
60 |
|
61 | var _google_map2 = _interopRequireDefault(_google_map);
|
62 |
|
63 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
64 |
|
65 | module.exports = _google_map2.default;
|
66 |
|
67 | }),
|
68 |
|
69 | (function(module, exports) {
|
70 |
|
71 | module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
|
72 |
|
73 | }),
|
74 |
|
75 | (function(module, exports) {
|
76 |
|
77 | 'use strict';
|
78 |
|
79 | module.exports = Point;
|
80 |
|
81 | |
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | function Point(x, y) {
|
94 | this.x = x;
|
95 | this.y = y;
|
96 | }
|
97 |
|
98 | Point.prototype = {
|
99 |
|
100 | |
101 |
|
102 |
|
103 |
|
104 |
|
105 | clone: function() { return new Point(this.x, this.y); },
|
106 |
|
107 | |
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | add: function(p) { return this.clone()._add(p); },
|
114 |
|
115 | |
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 | sub: function(p) { return this.clone()._sub(p); },
|
122 |
|
123 | |
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | multByPoint: function(p) { return this.clone()._multByPoint(p); },
|
130 |
|
131 | |
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | divByPoint: function(p) { return this.clone()._divByPoint(p); },
|
138 |
|
139 | |
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 | mult: function(k) { return this.clone()._mult(k); },
|
146 |
|
147 | |
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 | div: function(k) { return this.clone()._div(k); },
|
154 |
|
155 | |
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 | rotate: function(a) { return this.clone()._rotate(a); },
|
162 |
|
163 | |
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 | rotateAround: function(a,p) { return this.clone()._rotateAround(a,p); },
|
171 |
|
172 | |
173 |
|
174 |
|
175 |
|
176 |
|
177 | matMult: function(m) { return this.clone()._matMult(m); },
|
178 |
|
179 | |
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 | unit: function() { return this.clone()._unit(); },
|
187 |
|
188 | |
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 | perp: function() { return this.clone()._perp(); },
|
195 |
|
196 | |
197 |
|
198 |
|
199 |
|
200 |
|
201 | round: function() { return this.clone()._round(); },
|
202 |
|
203 | |
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 | mag: function() {
|
210 | return Math.sqrt(this.x * this.x + this.y * this.y);
|
211 | },
|
212 |
|
213 | |
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 | equals: function(other) {
|
220 | return this.x === other.x &&
|
221 | this.y === other.y;
|
222 | },
|
223 |
|
224 | |
225 |
|
226 |
|
227 |
|
228 |
|
229 | dist: function(p) {
|
230 | return Math.sqrt(this.distSqr(p));
|
231 | },
|
232 |
|
233 | |
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 | distSqr: function(p) {
|
241 | var dx = p.x - this.x,
|
242 | dy = p.y - this.y;
|
243 | return dx * dx + dy * dy;
|
244 | },
|
245 |
|
246 | |
247 |
|
248 |
|
249 |
|
250 |
|
251 | angle: function() {
|
252 | return Math.atan2(this.y, this.x);
|
253 | },
|
254 |
|
255 | |
256 |
|
257 |
|
258 |
|
259 |
|
260 | angleTo: function(b) {
|
261 | return Math.atan2(this.y - b.y, this.x - b.x);
|
262 | },
|
263 |
|
264 | |
265 |
|
266 |
|
267 |
|
268 |
|
269 | angleWith: function(b) {
|
270 | return this.angleWithSep(b.x, b.y);
|
271 | },
|
272 |
|
273 | |
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 | angleWithSep: function(x, y) {
|
281 | return Math.atan2(
|
282 | this.x * y - this.y * x,
|
283 | this.x * x + this.y * y);
|
284 | },
|
285 |
|
286 | _matMult: function(m) {
|
287 | var x = m[0] * this.x + m[1] * this.y,
|
288 | y = m[2] * this.x + m[3] * this.y;
|
289 | this.x = x;
|
290 | this.y = y;
|
291 | return this;
|
292 | },
|
293 |
|
294 | _add: function(p) {
|
295 | this.x += p.x;
|
296 | this.y += p.y;
|
297 | return this;
|
298 | },
|
299 |
|
300 | _sub: function(p) {
|
301 | this.x -= p.x;
|
302 | this.y -= p.y;
|
303 | return this;
|
304 | },
|
305 |
|
306 | _mult: function(k) {
|
307 | this.x *= k;
|
308 | this.y *= k;
|
309 | return this;
|
310 | },
|
311 |
|
312 | _div: function(k) {
|
313 | this.x /= k;
|
314 | this.y /= k;
|
315 | return this;
|
316 | },
|
317 |
|
318 | _multByPoint: function(p) {
|
319 | this.x *= p.x;
|
320 | this.y *= p.y;
|
321 | return this;
|
322 | },
|
323 |
|
324 | _divByPoint: function(p) {
|
325 | this.x /= p.x;
|
326 | this.y /= p.y;
|
327 | return this;
|
328 | },
|
329 |
|
330 | _unit: function() {
|
331 | this._div(this.mag());
|
332 | return this;
|
333 | },
|
334 |
|
335 | _perp: function() {
|
336 | var y = this.y;
|
337 | this.y = this.x;
|
338 | this.x = -y;
|
339 | return this;
|
340 | },
|
341 |
|
342 | _rotate: function(angle) {
|
343 | var cos = Math.cos(angle),
|
344 | sin = Math.sin(angle),
|
345 | x = cos * this.x - sin * this.y,
|
346 | y = sin * this.x + cos * this.y;
|
347 | this.x = x;
|
348 | this.y = y;
|
349 | return this;
|
350 | },
|
351 |
|
352 | _rotateAround: function(angle, p) {
|
353 | var cos = Math.cos(angle),
|
354 | sin = Math.sin(angle),
|
355 | x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),
|
356 | y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
|
357 | this.x = x;
|
358 | this.y = y;
|
359 | return this;
|
360 | },
|
361 |
|
362 | _round: function() {
|
363 | this.x = Math.round(this.x);
|
364 | this.y = Math.round(this.y);
|
365 | return this;
|
366 | }
|
367 | };
|
368 |
|
369 | |
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 | Point.convert = function (a) {
|
381 | if (a instanceof Point) {
|
382 | return a;
|
383 | }
|
384 | if (Array.isArray(a)) {
|
385 | return new Point(a[0], a[1]);
|
386 | }
|
387 | return a;
|
388 | };
|
389 |
|
390 |
|
391 | }),
|
392 |
|
393 | (function(module, exports, __webpack_require__) {
|
394 |
|
395 | 'use strict';
|
396 |
|
397 | exports.__esModule = true;
|
398 |
|
399 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
400 |
|
401 | var _react = __webpack_require__(1);
|
402 |
|
403 | var _react2 = _interopRequireDefault(_react);
|
404 |
|
405 | var _propTypes = __webpack_require__(9);
|
406 |
|
407 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
408 |
|
409 | var _omit = __webpack_require__(6);
|
410 |
|
411 | var _omit2 = _interopRequireDefault(_omit);
|
412 |
|
413 | var _shallowEqual = __webpack_require__(8);
|
414 |
|
415 | var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
|
416 |
|
417 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
418 |
|
419 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
420 |
|
421 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
422 |
|
423 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
424 |
|
425 |
|
426 |
|
427 |
|
428 | var mainStyle = {
|
429 | width: '100%',
|
430 | height: '100%',
|
431 | left: 0,
|
432 | top: 0,
|
433 | margin: 0,
|
434 | padding: 0,
|
435 | position: 'absolute'
|
436 | };
|
437 |
|
438 | var style = {
|
439 | width: 0,
|
440 | height: 0,
|
441 | left: 0,
|
442 | top: 0,
|
443 | backgroundColor: 'transparent',
|
444 | position: 'absolute'
|
445 | };
|
446 |
|
447 | var GoogleMapMarkers = function (_Component) {
|
448 | _inherits(GoogleMapMarkers, _Component);
|
449 |
|
450 |
|
451 | function GoogleMapMarkers(props) {
|
452 | _classCallCheck(this, GoogleMapMarkers);
|
453 |
|
454 | var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
455 |
|
456 | _this._getState = function () {
|
457 | return {
|
458 | children: _this.props.dispatcher.getChildren(),
|
459 | updateCounter: _this.props.dispatcher.getUpdateCounter()
|
460 | };
|
461 | };
|
462 |
|
463 | _this._onChangeHandler = function () {
|
464 | if (!_this.dimensionsCache_) {
|
465 | return;
|
466 | }
|
467 |
|
468 | var prevChildCount = (_this.state.children || []).length;
|
469 | var state = _this._getState();
|
470 |
|
471 | _this.setState(state, function () {
|
472 | return (state.children || []).length !== prevChildCount && _this._onMouseChangeHandler();
|
473 | });
|
474 | };
|
475 |
|
476 | _this._onChildClick = function () {
|
477 | if (_this.props.onChildClick) {
|
478 | if (_this.hoverChildProps_) {
|
479 | var hoverKey = _this.hoverKey_;
|
480 | var childProps = _this.hoverChildProps_;
|
481 |
|
482 | _this.props.onChildClick(hoverKey, childProps);
|
483 | }
|
484 | }
|
485 | };
|
486 |
|
487 | _this._onChildMouseDown = function () {
|
488 | if (_this.props.onChildMouseDown) {
|
489 | if (_this.hoverChildProps_) {
|
490 | var hoverKey = _this.hoverKey_;
|
491 | var childProps = _this.hoverChildProps_;
|
492 |
|
493 | _this.props.onChildMouseDown(hoverKey, childProps);
|
494 | }
|
495 | }
|
496 | };
|
497 |
|
498 | _this._onChildMouseEnter = function (hoverKey, childProps) {
|
499 | if (!_this.dimensionsCache_) {
|
500 | return;
|
501 | }
|
502 |
|
503 | if (_this.props.onChildMouseEnter) {
|
504 | _this.props.onChildMouseEnter(hoverKey, childProps);
|
505 | }
|
506 |
|
507 | _this.hoverChildProps_ = childProps;
|
508 | _this.hoverKey_ = hoverKey;
|
509 | _this.setState({ hoverKey: hoverKey });
|
510 | };
|
511 |
|
512 | _this._onChildMouseLeave = function () {
|
513 | if (!_this.dimensionsCache_) {
|
514 | return;
|
515 | }
|
516 |
|
517 | var hoverKey = _this.hoverKey_;
|
518 | var childProps = _this.hoverChildProps_;
|
519 |
|
520 | if (hoverKey !== undefined && hoverKey !== null) {
|
521 | if (_this.props.onChildMouseLeave) {
|
522 | _this.props.onChildMouseLeave(hoverKey, childProps);
|
523 | }
|
524 |
|
525 | _this.hoverKey_ = null;
|
526 | _this.hoverChildProps_ = null;
|
527 | _this.setState({ hoverKey: null });
|
528 | }
|
529 | };
|
530 |
|
531 | _this._onMouseAllow = function (value) {
|
532 | if (!value) {
|
533 | _this._onChildMouseLeave();
|
534 | }
|
535 |
|
536 | _this.allowMouse_ = value;
|
537 | };
|
538 |
|
539 | _this._onMouseChangeHandler = function () {
|
540 | if (_this.allowMouse_) {
|
541 | _this._onMouseChangeHandlerRaf();
|
542 | }
|
543 | };
|
544 |
|
545 | _this._onMouseChangeHandlerRaf = function () {
|
546 | if (!_this.dimensionsCache_) {
|
547 | return;
|
548 | }
|
549 |
|
550 | var mp = _this.props.dispatcher.getMousePosition();
|
551 |
|
552 | if (mp) {
|
553 | var distances = [];
|
554 | var hoverDistance = _this.props.getHoverDistance();
|
555 |
|
556 | _react2.default.Children.forEach(_this.state.children, function (child, childIndex) {
|
557 | if (!child) return;
|
558 |
|
559 | if (child.props.latLng === undefined && child.props.lat === undefined && child.props.lng === undefined) {
|
560 | return;
|
561 | }
|
562 |
|
563 | var childKey = child.key !== undefined && child.key !== null ? child.key : childIndex;
|
564 | var dist = _this.props.distanceToMouse(_this.dimensionsCache_[childKey], mp, child.props);
|
565 | if (dist < hoverDistance) {
|
566 | distances.push({
|
567 | key: childKey,
|
568 | dist: dist,
|
569 | props: child.props
|
570 | });
|
571 | }
|
572 | });
|
573 |
|
574 | if (distances.length) {
|
575 | distances.sort(function (a, b) {
|
576 | return a.dist - b.dist;
|
577 | });
|
578 | var hoverKey = distances[0].key;
|
579 | var childProps = distances[0].props;
|
580 |
|
581 | if (_this.hoverKey_ !== hoverKey) {
|
582 | _this._onChildMouseLeave();
|
583 |
|
584 | _this._onChildMouseEnter(hoverKey, childProps);
|
585 | }
|
586 | } else {
|
587 | _this._onChildMouseLeave();
|
588 | }
|
589 | } else {
|
590 | _this._onChildMouseLeave();
|
591 | }
|
592 | };
|
593 |
|
594 | _this._getDimensions = function (key) {
|
595 | var childKey = key;
|
596 | return _this.dimensionsCache_[childKey];
|
597 | };
|
598 |
|
599 | _this.props.dispatcher.on('kON_CHANGE', _this._onChangeHandler);
|
600 | _this.props.dispatcher.on('kON_MOUSE_POSITION_CHANGE', _this._onMouseChangeHandler);
|
601 | _this.props.dispatcher.on('kON_CLICK', _this._onChildClick);
|
602 | _this.props.dispatcher.on('kON_MDOWN', _this._onChildMouseDown);
|
603 |
|
604 | _this.dimensionsCache_ = {};
|
605 | _this.hoverKey_ = null;
|
606 | _this.hoverChildProps_ = null;
|
607 | _this.allowMouse_ = true;
|
608 |
|
609 | _this.state = _extends({}, _this._getState(), { hoverKey: null });
|
610 | return _this;
|
611 | }
|
612 |
|
613 |
|
614 | GoogleMapMarkers.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
|
615 | if (this.props.experimental === true) {
|
616 | return !(0, _shallowEqual2.default)(this.props, nextProps) || !(0, _shallowEqual2.default)((0, _omit2.default)(this.state, ['hoverKey']), (0, _omit2.default)(nextState, ['hoverKey']));
|
617 | }
|
618 |
|
619 | return !(0, _shallowEqual2.default)(this.props, nextProps) || !(0, _shallowEqual2.default)(this.state, nextState);
|
620 | };
|
621 |
|
622 | GoogleMapMarkers.prototype.componentWillUnmount = function componentWillUnmount() {
|
623 | this.props.dispatcher.removeListener('kON_CHANGE', this._onChangeHandler);
|
624 | this.props.dispatcher.removeListener('kON_MOUSE_POSITION_CHANGE', this._onMouseChangeHandler);
|
625 | this.props.dispatcher.removeListener('kON_CLICK', this._onChildClick);
|
626 | this.props.dispatcher.removeListener('kON_MDOWN', this._onChildMouseDown);
|
627 |
|
628 | this.dimensionsCache_ = null;
|
629 | };
|
630 |
|
631 | GoogleMapMarkers.prototype.render = function render() {
|
632 | var _this2 = this;
|
633 |
|
634 | var mainElementStyle = this.props.style || mainStyle;
|
635 | this.dimensionsCache_ = {};
|
636 |
|
637 | var markers = _react2.default.Children.map(this.state.children, function (child, childIndex) {
|
638 | if (!child) return undefined;
|
639 | if (child.props.latLng === undefined && child.props.lat === undefined && child.props.lng === undefined) {
|
640 | return _react2.default.cloneElement(child, {
|
641 | $geoService: _this2.props.geoService,
|
642 | $onMouseAllow: _this2._onMouseAllow,
|
643 | $prerender: _this2.props.prerender
|
644 | });
|
645 | }
|
646 |
|
647 | var latLng = child.props.latLng !== undefined ? child.props.latLng : { lat: child.props.lat, lng: child.props.lng };
|
648 |
|
649 | var pt = _this2.props.insideMapPanes ? _this2.props.geoService.fromLatLngToDivPixel(latLng) : _this2.props.geoService.fromLatLngToCenterPixel(latLng);
|
650 |
|
651 | var stylePtPos = {
|
652 | left: pt.x,
|
653 | top: pt.y
|
654 | };
|
655 |
|
656 |
|
657 |
|
658 |
|
659 | if (child.props.seLatLng !== undefined || child.props.seLat !== undefined && child.props.seLng !== undefined) {
|
660 | var seLatLng = child.props.seLatLng !== undefined ? child.props.seLatLng : { lat: child.props.seLat, lng: child.props.seLng };
|
661 |
|
662 | var sePt = _this2.props.insideMapPanes ? _this2.props.geoService.fromLatLngToDivPixel(seLatLng) : _this2.props.geoService.fromLatLngToCenterPixel(seLatLng);
|
663 |
|
664 | stylePtPos.width = sePt.x - pt.x;
|
665 | stylePtPos.height = sePt.y - pt.y;
|
666 | }
|
667 |
|
668 | var containerPt = _this2.props.geoService.fromLatLngToContainerPixel(latLng);
|
669 |
|
670 |
|
671 |
|
672 | var childKey = child.key !== undefined && child.key !== null ? child.key : childIndex;
|
673 |
|
674 | _this2.dimensionsCache_[childKey] = _extends({
|
675 | x: containerPt.x,
|
676 | y: containerPt.y
|
677 | }, latLng);
|
678 |
|
679 | return _react2.default.createElement(
|
680 | 'div',
|
681 | {
|
682 | key: childKey,
|
683 | style: _extends({}, style, stylePtPos),
|
684 | className: child.props.$markerHolderClassName
|
685 | },
|
686 | _react2.default.cloneElement(child, {
|
687 | $hover: childKey === _this2.state.hoverKey,
|
688 | $getDimensions: _this2._getDimensions,
|
689 | $dimensionKey: childKey,
|
690 | $geoService: _this2.props.geoService,
|
691 | $onMouseAllow: _this2._onMouseAllow,
|
692 | $prerender: _this2.props.prerender
|
693 | })
|
694 | );
|
695 | });
|
696 |
|
697 | return _react2.default.createElement(
|
698 | 'div',
|
699 | { style: mainElementStyle },
|
700 | markers
|
701 | );
|
702 | };
|
703 |
|
704 | return GoogleMapMarkers;
|
705 | }(_react.Component);
|
706 |
|
707 | GoogleMapMarkers.propTypes = {
|
708 | geoService: _propTypes2.default.any,
|
709 | style: _propTypes2.default.any,
|
710 | distanceToMouse: _propTypes2.default.func,
|
711 | dispatcher: _propTypes2.default.any,
|
712 | onChildClick: _propTypes2.default.func,
|
713 | onChildMouseDown: _propTypes2.default.func,
|
714 | onChildMouseLeave: _propTypes2.default.func,
|
715 | onChildMouseEnter: _propTypes2.default.func,
|
716 | getHoverDistance: _propTypes2.default.func,
|
717 | insideMapPanes: _propTypes2.default.bool,
|
718 | prerender: _propTypes2.default.bool
|
719 | };
|
720 | GoogleMapMarkers.defaultProps = {
|
721 | insideMapPanes: false,
|
722 | prerender: false
|
723 | };
|
724 | exports.default = GoogleMapMarkers;
|
725 |
|
726 | }),
|
727 |
|
728 | (function(module, exports, __webpack_require__) {
|
729 |
|
730 | 'use strict';
|
731 |
|
732 | exports.__esModule = true;
|
733 |
|
734 | var _wrap2 = __webpack_require__(5);
|
735 |
|
736 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
737 |
|
738 | var LatLng = function () {
|
739 | function LatLng(lat, lng) {
|
740 | _classCallCheck(this, LatLng);
|
741 |
|
742 | if (isNaN(lat) || isNaN(lng)) {
|
743 | throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');
|
744 | }
|
745 | this.lat = +lat;
|
746 | this.lng = +lng;
|
747 | }
|
748 |
|
749 | LatLng.prototype.wrap = function wrap() {
|
750 | return new LatLng(this.lat, (0, _wrap2.wrap)(this.lng, -180, 180));
|
751 | };
|
752 |
|
753 | return LatLng;
|
754 | }();
|
755 |
|
756 | LatLng.convert = function (a) {
|
757 | if (a instanceof LatLng) {
|
758 | return a;
|
759 | }
|
760 |
|
761 | if (Array.isArray(a)) {
|
762 | return new LatLng(a[0], a[1]);
|
763 | }
|
764 |
|
765 | if ('lng' in a && 'lat' in a) {
|
766 | return new LatLng(a.lat, a.lng);
|
767 | }
|
768 |
|
769 | return a;
|
770 | };
|
771 |
|
772 | exports.default = LatLng;
|
773 |
|
774 | }),
|
775 |
|
776 | (function(module, exports) {
|
777 |
|
778 | "use strict";
|
779 |
|
780 | exports.__esModule = true;
|
781 | exports.wrap = wrap;
|
782 |
|
783 |
|
784 | function wrap(n, min, max) {
|
785 | var d = max - min;
|
786 | return n === max ? n : ((n - min) % d + d) % d + min;
|
787 | }
|
788 |
|
789 | }),
|
790 |
|
791 | (function(module, exports) {
|
792 |
|
793 | "use strict";
|
794 |
|
795 | exports.__esModule = true;
|
796 |
|
797 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
798 |
|
799 |
|
800 | var omit = function omit(obj, keys) {
|
801 | var rest = _objectWithoutProperties(obj, []);
|
802 |
|
803 | for (var i = 0; i < keys.length; i++) {
|
804 | var key = keys[i];
|
805 | if (key in rest) {
|
806 | delete rest[key];
|
807 | }
|
808 | }
|
809 | return rest;
|
810 | };
|
811 |
|
812 | exports.default = omit;
|
813 |
|
814 | }),
|
815 |
|
816 | (function(module, exports) {
|
817 |
|
818 | 'use strict';
|
819 |
|
820 | exports.__esModule = true;
|
821 | exports.default = addPassiveEventListener;
|
822 |
|
823 |
|
824 | function hasPassiveSupport() {
|
825 | var passiveSupported = false;
|
826 |
|
827 | try {
|
828 | var options = Object.defineProperty({}, 'passive', {
|
829 | get: function get() {
|
830 | passiveSupported = true;
|
831 | }
|
832 | });
|
833 |
|
834 | window.addEventListener('test', options, options);
|
835 | window.removeEventListener('test', options, options);
|
836 | } catch (err) {
|
837 | passiveSupported = false;
|
838 | }
|
839 |
|
840 | return passiveSupported;
|
841 | }
|
842 |
|
843 | function addPassiveEventListener(element, eventName, func, capture) {
|
844 | element.addEventListener(eventName, func, hasPassiveSupport() ? {
|
845 | capture: capture,
|
846 | passive: true
|
847 | } : capture);
|
848 | }
|
849 |
|
850 | }),
|
851 |
|
852 | (function(module, exports) {
|
853 |
|
854 | 'use strict';
|
855 |
|
856 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
857 |
|
858 | |
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 |
|
868 |
|
869 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
870 |
|
871 | |
872 |
|
873 |
|
874 |
|
875 | function is(x, y) {
|
876 |
|
877 | if (x === y) {
|
878 |
|
879 |
|
880 |
|
881 | return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
882 | }
|
883 |
|
884 |
|
885 | return x !== x && y !== y;
|
886 | }
|
887 |
|
888 | |
889 |
|
890 |
|
891 |
|
892 |
|
893 | function shallowEqual(objA, objB) {
|
894 | if (is(objA, objB)) {
|
895 | return true;
|
896 | }
|
897 |
|
898 | if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
|
899 | return false;
|
900 | }
|
901 |
|
902 | var keysA = Object.keys(objA);
|
903 | var keysB = Object.keys(objB);
|
904 |
|
905 | if (keysA.length !== keysB.length) {
|
906 | return false;
|
907 | }
|
908 |
|
909 |
|
910 | for (var i = 0; i < keysA.length; i++) {
|
911 | if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
912 | return false;
|
913 | }
|
914 | }
|
915 |
|
916 | return true;
|
917 | }
|
918 |
|
919 | module.exports = shallowEqual;
|
920 |
|
921 |
|
922 | }),
|
923 |
|
924 | (function(module, exports, __webpack_require__) {
|
925 |
|
926 | |
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 | if (true) {
|
934 | var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
|
935 | Symbol.for &&
|
936 | Symbol.for('react.element')) ||
|
937 | 0xeac7;
|
938 |
|
939 | var isValidElement = function(object) {
|
940 | return typeof object === 'object' &&
|
941 | object !== null &&
|
942 | object.$$typeof === REACT_ELEMENT_TYPE;
|
943 | };
|
944 |
|
945 |
|
946 |
|
947 | var throwOnDirectAccess = true;
|
948 | module.exports = __webpack_require__(31)(isValidElement, throwOnDirectAccess);
|
949 | } else {
|
950 |
|
951 |
|
952 | module.exports = require('./factoryWithThrowingShims')();
|
953 | }
|
954 |
|
955 |
|
956 | }),
|
957 |
|
958 | (function(module, exports) {
|
959 |
|
960 | |
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 | 'use strict';
|
968 |
|
969 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
970 |
|
971 | module.exports = ReactPropTypesSecret;
|
972 |
|
973 |
|
974 | }),
|
975 |
|
976 | (function(module, exports) {
|
977 |
|
978 | "use strict";
|
979 |
|
980 | exports.__esModule = true;
|
981 | var generateHeatmap = exports.generateHeatmap = function generateHeatmap(instance, _ref) {
|
982 | var positions = _ref.positions;
|
983 | return new instance.visualization.HeatmapLayer({
|
984 | data: positions.reduce(function (acc, _ref2) {
|
985 | var lat = _ref2.lat,
|
986 | lng = _ref2.lng,
|
987 | _ref2$weight = _ref2.weight,
|
988 | weight = _ref2$weight === undefined ? 1 : _ref2$weight;
|
989 |
|
990 | acc.push({
|
991 | location: new instance.LatLng(lat, lng),
|
992 | weight: weight
|
993 | });
|
994 | return acc;
|
995 | }, [])
|
996 | });
|
997 | };
|
998 |
|
999 | var optionsHeatmap = exports.optionsHeatmap = function optionsHeatmap(instance, _ref3) {
|
1000 | var _ref3$options = _ref3.options,
|
1001 | options = _ref3$options === undefined ? {} : _ref3$options;
|
1002 | return Object.keys(options).map(function (option) {
|
1003 | return instance.set(option, options[option]);
|
1004 | });
|
1005 | };
|
1006 |
|
1007 | }),
|
1008 |
|
1009 | (function(module, exports, __webpack_require__) {
|
1010 |
|
1011 | 'use strict';
|
1012 |
|
1013 | exports.__esModule = true;
|
1014 |
|
1015 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
1016 |
|
1017 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
1018 |
|
1019 | var _react = __webpack_require__(1);
|
1020 |
|
1021 | var _react2 = _interopRequireDefault(_react);
|
1022 |
|
1023 | var _propTypes = __webpack_require__(9);
|
1024 |
|
1025 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
1026 |
|
1027 | var _reactDom = __webpack_require__(33);
|
1028 |
|
1029 | var _reactDom2 = _interopRequireDefault(_reactDom);
|
1030 |
|
1031 | var _google_map_map = __webpack_require__(13);
|
1032 |
|
1033 | var _google_map_map2 = _interopRequireDefault(_google_map_map);
|
1034 |
|
1035 | var _marker_dispatcher = __webpack_require__(16);
|
1036 |
|
1037 | var _marker_dispatcher2 = _interopRequireDefault(_marker_dispatcher);
|
1038 |
|
1039 | var _google_map_markers = __webpack_require__(3);
|
1040 |
|
1041 | var _google_map_markers2 = _interopRequireDefault(_google_map_markers);
|
1042 |
|
1043 | var _google_map_markers_prerender = __webpack_require__(14);
|
1044 |
|
1045 | var _google_map_markers_prerender2 = _interopRequireDefault(_google_map_markers_prerender);
|
1046 |
|
1047 | var _google_heatmap = __webpack_require__(11);
|
1048 |
|
1049 | var _google_map_loader = __webpack_require__(15);
|
1050 |
|
1051 | var _google_map_loader2 = _interopRequireDefault(_google_map_loader);
|
1052 |
|
1053 | var _geo = __webpack_require__(19);
|
1054 |
|
1055 | var _geo2 = _interopRequireDefault(_geo);
|
1056 |
|
1057 | var _raf = __webpack_require__(27);
|
1058 |
|
1059 | var _raf2 = _interopRequireDefault(_raf);
|
1060 |
|
1061 | var _pick = __webpack_require__(26);
|
1062 |
|
1063 | var _pick2 = _interopRequireDefault(_pick);
|
1064 |
|
1065 | var _omit = __webpack_require__(6);
|
1066 |
|
1067 | var _omit2 = _interopRequireDefault(_omit);
|
1068 |
|
1069 | var _log = __webpack_require__(25);
|
1070 |
|
1071 | var _log2 = _interopRequireDefault(_log);
|
1072 |
|
1073 | var _isEmpty = __webpack_require__(21);
|
1074 |
|
1075 | var _isEmpty2 = _interopRequireDefault(_isEmpty);
|
1076 |
|
1077 | var _isNumber = __webpack_require__(22);
|
1078 |
|
1079 | var _isNumber2 = _interopRequireDefault(_isNumber);
|
1080 |
|
1081 | var _detect = __webpack_require__(17);
|
1082 |
|
1083 | var _detect2 = _interopRequireDefault(_detect);
|
1084 |
|
1085 | var _shallowEqual = __webpack_require__(8);
|
1086 |
|
1087 | var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
|
1088 |
|
1089 | var _isPlainObject = __webpack_require__(23);
|
1090 |
|
1091 | var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
|
1092 |
|
1093 | var _isArraysEqualEps = __webpack_require__(20);
|
1094 |
|
1095 | var _isArraysEqualEps2 = _interopRequireDefault(_isArraysEqualEps);
|
1096 |
|
1097 | var _detectElementResize = __webpack_require__(18);
|
1098 |
|
1099 | var _detectElementResize2 = _interopRequireDefault(_detectElementResize);
|
1100 |
|
1101 | var _passiveEvents = __webpack_require__(7);
|
1102 |
|
1103 | var _passiveEvents2 = _interopRequireDefault(_passiveEvents);
|
1104 |
|
1105 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1106 |
|
1107 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1108 |
|
1109 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
1110 |
|
1111 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 | var kEPS = 0.00001;
|
1125 | var K_GOOGLE_TILE_SIZE = 256;
|
1126 |
|
1127 | var K_IDLE_TIMEOUT = 100;
|
1128 | var K_IDLE_CLICK_TIMEOUT = 300;
|
1129 | var DEFAULT_MIN_ZOOM = 3;
|
1130 |
|
1131 |
|
1132 | var DRAW_CALLED_DURING_ANIMATION_VERSION = 32;
|
1133 | var IS_REACT_16 = _reactDom2.default.createPortal !== undefined;
|
1134 |
|
1135 | var createPortal = IS_REACT_16 ? _reactDom2.default.createPortal : _reactDom2.default.unstable_renderSubtreeIntoContainer;
|
1136 |
|
1137 | function defaultOptions_() /* maps */{
|
1138 | return {
|
1139 | overviewMapControl: false,
|
1140 | streetViewControl: false,
|
1141 | rotateControl: true,
|
1142 | mapTypeControl: false,
|
1143 |
|
1144 | styles: [{
|
1145 | featureType: 'poi',
|
1146 | elementType: 'labels',
|
1147 | stylers: [{ visibility: 'off' }]
|
1148 | }],
|
1149 | minZoom: DEFAULT_MIN_ZOOM
|
1150 | };
|
1151 | }
|
1152 |
|
1153 | var latLng2Obj = function latLng2Obj(latLng) {
|
1154 | return (0, _isPlainObject2.default)(latLng) ? latLng : { lat: latLng[0], lng: latLng[1] };
|
1155 | };
|
1156 |
|
1157 | var _checkMinZoom = function _checkMinZoom(zoom, minZoom) {
|
1158 | if (true) {
|
1159 | if (zoom < minZoom) {
|
1160 | console.warn('GoogleMap: ' +
|
1161 | 'minZoom option is less than recommended ' + 'minZoom option for your map sizes.\n' + 'overrided to value ' + minZoom);
|
1162 | }
|
1163 | }
|
1164 |
|
1165 | if (minZoom < zoom) {
|
1166 | return zoom;
|
1167 | }
|
1168 | return minZoom;
|
1169 | };
|
1170 |
|
1171 | var isFullScreen = function isFullScreen() {
|
1172 | return document.fullscreen || document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement;
|
1173 | };
|
1174 |
|
1175 | var GoogleMap = function (_Component) {
|
1176 | _inherits(GoogleMap, _Component);
|
1177 |
|
1178 |
|
1179 |
|
1180 | function GoogleMap(props) {
|
1181 | _classCallCheck(this, GoogleMap);
|
1182 |
|
1183 | var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
1184 |
|
1185 | _this._getMinZoom = function () {
|
1186 | if (_this.geoService_.getWidth() > 0 || _this.geoService_.getHeight() > 0) {
|
1187 | var tilesPerWidth = Math.ceil(_this.geoService_.getWidth() / K_GOOGLE_TILE_SIZE) + 2;
|
1188 | var tilesPerHeight = Math.ceil(_this.geoService_.getHeight() / K_GOOGLE_TILE_SIZE) + 2;
|
1189 | var maxTilesPerDim = Math.max(tilesPerWidth, tilesPerHeight);
|
1190 | return Math.ceil((0, _log2.default)(maxTilesPerDim));
|
1191 | }
|
1192 | return DEFAULT_MIN_ZOOM;
|
1193 | };
|
1194 |
|
1195 | _this._computeMinZoom = function (minZoom) {
|
1196 | if (!(0, _isEmpty2.default)(minZoom)) {
|
1197 | return minZoom;
|
1198 | }
|
1199 | return _this._getMinZoom();
|
1200 | };
|
1201 |
|
1202 | _this._mapDomResizeCallback = function () {
|
1203 | _this.resetSizeOnIdle_ = true;
|
1204 | if (_this.maps_) {
|
1205 | var originalCenter = _this.props.center || _this.props.defaultCenter;
|
1206 | var currentCenter = _this.map_.getCenter();
|
1207 | _this.maps_.event.trigger(_this.map_, 'resize');
|
1208 | _this.map_.setCenter(_this.props.resetBoundsOnResize ? originalCenter : currentCenter);
|
1209 | }
|
1210 | };
|
1211 |
|
1212 | _this._setLayers = function (layerTypes) {
|
1213 | layerTypes.forEach(function (layerType) {
|
1214 | _this.layers_[layerType] = new _this.maps_[layerType]();
|
1215 | _this.layers_[layerType].setMap(_this.map_);
|
1216 | });
|
1217 | };
|
1218 |
|
1219 | _this._renderPortal = function () {
|
1220 | return _react2.default.createElement(_google_map_markers2.default, {
|
1221 | experimental: _this.props.experimental,
|
1222 | onChildClick: _this._onChildClick,
|
1223 | onChildMouseDown: _this._onChildMouseDown,
|
1224 | onChildMouseEnter: _this._onChildMouseEnter,
|
1225 | onChildMouseLeave: _this._onChildMouseLeave,
|
1226 | geoService: _this.geoService_,
|
1227 | insideMapPanes: true,
|
1228 | distanceToMouse: _this.props.distanceToMouse,
|
1229 | getHoverDistance: _this._getHoverDistance,
|
1230 | dispatcher: _this.markersDispatcher_
|
1231 | });
|
1232 | };
|
1233 |
|
1234 | _this._initMap = function () {
|
1235 |
|
1236 | if (_this.initialized_) {
|
1237 | return;
|
1238 | }
|
1239 | _this.initialized_ = true;
|
1240 |
|
1241 | var propsCenter = latLng2Obj(_this.props.center || _this.props.defaultCenter);
|
1242 | _this.geoService_.setView(propsCenter, _this.props.zoom || _this.props.defaultZoom, 0);
|
1243 |
|
1244 | _this._onBoundsChanged();
|
1245 |
|
1246 | var bootstrapURLKeys = _extends({}, _this.props.apiKey && { key: _this.props.apiKey }, _this.props.bootstrapURLKeys);
|
1247 |
|
1248 | _this.props.googleMapLoader(bootstrapURLKeys, _this.props.heatmapLibrary).then(function (maps) {
|
1249 | if (!_this.mounted_) {
|
1250 | return;
|
1251 | }
|
1252 |
|
1253 | var centerLatLng = _this.geoService_.getCenter();
|
1254 |
|
1255 | var propsOptions = {
|
1256 | zoom: _this.props.zoom || _this.props.defaultZoom,
|
1257 | center: new maps.LatLng(centerLatLng.lat, centerLatLng.lng)
|
1258 | };
|
1259 |
|
1260 |
|
1261 | if (_this.props.heatmap.positions) {
|
1262 | Object.assign(_this, {
|
1263 | heatmap: (0, _google_heatmap.generateHeatmap)(maps, _this.props.heatmap)
|
1264 | });
|
1265 | (0, _google_heatmap.optionsHeatmap)(_this.heatmap, _this.props.heatmap);
|
1266 | }
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 | var mapPlainObjects = (0, _pick2.default)(maps, _isPlainObject2.default);
|
1281 | var options = typeof _this.props.options === 'function' ? _this.props.options(mapPlainObjects) : _this.props.options;
|
1282 | var defaultOptions = defaultOptions_(mapPlainObjects);
|
1283 |
|
1284 | var draggableOptions = !(0, _isEmpty2.default)(_this.props.draggable) && {
|
1285 | draggable: _this.props.draggable
|
1286 | };
|
1287 |
|
1288 | var minZoom = _this._computeMinZoom(options.minZoom);
|
1289 | _this.minZoom_ = minZoom;
|
1290 |
|
1291 | var preMapOptions = _extends({}, defaultOptions, {
|
1292 | minZoom: minZoom
|
1293 | }, options, propsOptions);
|
1294 |
|
1295 | _this.defaultDraggableOption_ = !(0, _isEmpty2.default)(preMapOptions.draggable) ? preMapOptions.draggable : _this.defaultDraggableOption_;
|
1296 |
|
1297 | var mapOptions = _extends({}, preMapOptions, draggableOptions);
|
1298 |
|
1299 | mapOptions.minZoom = _checkMinZoom(mapOptions.minZoom, minZoom);
|
1300 |
|
1301 | var map = new maps.Map(_reactDom2.default.findDOMNode(_this.googleMapDom_), mapOptions);
|
1302 |
|
1303 | _this.map_ = map;
|
1304 | _this.maps_ = maps;
|
1305 |
|
1306 | _this._setLayers(_this.props.layerTypes);
|
1307 |
|
1308 |
|
1309 | var versionMatch = maps.version.match(/^3\.(\d+)\./);
|
1310 |
|
1311 | var mapsVersion = versionMatch && Number(versionMatch[1]);
|
1312 |
|
1313 |
|
1314 | var this_ = _this;
|
1315 | var overlay = Object.assign(new maps.OverlayView(), {
|
1316 | onAdd: function onAdd() {
|
1317 | var K_MAX_WIDTH = typeof screen !== 'undefined' ? screen.width + 'px' : '2000px';
|
1318 | var K_MAX_HEIGHT = typeof screen !== 'undefined' ? screen.height + 'px' : '2000px';
|
1319 |
|
1320 | var div = document.createElement('div');
|
1321 | div.style.backgroundColor = 'transparent';
|
1322 | div.style.position = 'absolute';
|
1323 | div.style.left = '0px';
|
1324 | div.style.top = '0px';
|
1325 | div.style.width = K_MAX_WIDTH;
|
1326 | div.style.height = K_MAX_HEIGHT;
|
1327 |
|
1328 | if (this_.props.overlayViewDivStyle) {
|
1329 | var overlayViewDivStyle = this_.props.overlayViewDivStyle;
|
1330 |
|
1331 | if ((typeof overlayViewDivStyle === 'undefined' ? 'undefined' : _typeof(overlayViewDivStyle)) === 'object') {
|
1332 | Object.keys(overlayViewDivStyle).forEach(function (property) {
|
1333 | div.style[property] = overlayViewDivStyle[property];
|
1334 | });
|
1335 | }
|
1336 | }
|
1337 |
|
1338 | var panes = this.getPanes();
|
1339 | panes.overlayMouseTarget.appendChild(div);
|
1340 | this_.geoService_.setMapCanvasProjection(maps, overlay.getProjection());
|
1341 |
|
1342 | if (!IS_REACT_16) {
|
1343 | createPortal(this_, this_._renderPortal(), div,
|
1344 |
|
1345 | function () {
|
1346 | return this_.setState({ overlay: div });
|
1347 | });
|
1348 | } else {
|
1349 | this_.setState({ overlay: div });
|
1350 | }
|
1351 | },
|
1352 | onRemove: function onRemove() {
|
1353 | var renderedOverlay = this_.state.overlay;
|
1354 | if (renderedOverlay && !IS_REACT_16) {
|
1355 | _reactDom2.default.unmountComponentAtNode(renderedOverlay);
|
1356 | }
|
1357 | this_.setState({ overlay: null });
|
1358 | },
|
1359 | draw: function draw() {
|
1360 | this_.updateCounter_++;
|
1361 | this_._onBoundsChanged(map, maps, !this_.props.debounced);
|
1362 |
|
1363 | if (!this_.googleApiLoadedCalled_) {
|
1364 | this_._onGoogleApiLoaded({ map: map, maps: maps, ref: this_.googleMapDom_ });
|
1365 | this_.googleApiLoadedCalled_ = true;
|
1366 | }
|
1367 |
|
1368 | if (this_.mouse_) {
|
1369 | var latLng = this_.geoService_.fromContainerPixelToLatLng(this_.mouse_);
|
1370 | this_.mouse_.lat = latLng.lat;
|
1371 | this_.mouse_.lng = latLng.lng;
|
1372 | }
|
1373 |
|
1374 | this_._onChildMouseMove();
|
1375 |
|
1376 | if (this_.markersDispatcher_) {
|
1377 | this_.markersDispatcher_.emit('kON_CHANGE');
|
1378 | if (this_.fireMouseEventOnIdle_) {
|
1379 | this_.markersDispatcher_.emit('kON_MOUSE_POSITION_CHANGE');
|
1380 | }
|
1381 | }
|
1382 | }
|
1383 | });
|
1384 |
|
1385 | _this.overlay_ = overlay;
|
1386 |
|
1387 | overlay.setMap(map);
|
1388 | if (_this.props.heatmap.positions) {
|
1389 | _this.heatmap.setMap(map);
|
1390 | }
|
1391 |
|
1392 | if (_this.props.onTilesLoaded) {
|
1393 | maps.event.addListener(map, 'tilesloaded', function () {
|
1394 | this_._onTilesLoaded();
|
1395 | });
|
1396 | }
|
1397 |
|
1398 | maps.event.addListener(map, 'zoom_changed', function () {
|
1399 |
|
1400 | if (this_.geoService_.getZoom() !== map.getZoom()) {
|
1401 | if (!this_.zoomAnimationInProgress_) {
|
1402 | this_.zoomAnimationInProgress_ = true;
|
1403 | this_._onZoomAnimationStart(map.zoom);
|
1404 | }
|
1405 |
|
1406 |
|
1407 |
|
1408 | if (mapsVersion < DRAW_CALLED_DURING_ANIMATION_VERSION) {
|
1409 | var TIMEOUT_ZOOM = 300;
|
1410 |
|
1411 | if (new Date().getTime() - _this.zoomControlClickTime_ < TIMEOUT_ZOOM) {
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 | (0, _raf2.default)(function () {
|
1419 | return (0, _raf2.default)(function () {
|
1420 | this_.updateCounter_++;
|
1421 | this_._onBoundsChanged(map, maps);
|
1422 | });
|
1423 | });
|
1424 | } else {
|
1425 | this_.updateCounter_++;
|
1426 | this_._onBoundsChanged(map, maps);
|
1427 | }
|
1428 | }
|
1429 | }
|
1430 | });
|
1431 |
|
1432 | maps.event.addListener(map, 'idle', function () {
|
1433 | if (_this.resetSizeOnIdle_) {
|
1434 | _this._setViewSize();
|
1435 | var currMinZoom = _this._computeMinZoom(_this.props.options.minZoom);
|
1436 |
|
1437 | if (currMinZoom !== _this.minZoom_) {
|
1438 | _this.minZoom_ = currMinZoom;
|
1439 | map.setOptions({ minZoom: currMinZoom });
|
1440 | }
|
1441 |
|
1442 | _this.resetSizeOnIdle_ = false;
|
1443 | }
|
1444 |
|
1445 | if (this_.zoomAnimationInProgress_) {
|
1446 | this_.zoomAnimationInProgress_ = false;
|
1447 | this_._onZoomAnimationEnd(map.zoom);
|
1448 | }
|
1449 |
|
1450 | this_.updateCounter_++;
|
1451 | this_._onBoundsChanged(map, maps);
|
1452 |
|
1453 | this_.dragTime_ = 0;
|
1454 |
|
1455 | if (this_.markersDispatcher_) {
|
1456 | this_.markersDispatcher_.emit('kON_CHANGE');
|
1457 | }
|
1458 | });
|
1459 |
|
1460 | maps.event.addListener(map, 'mouseover', function () {
|
1461 |
|
1462 | this_.mouseInMap_ = true;
|
1463 | });
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 | maps.event.addListener(map, 'click', function () {
|
1470 | this_.mouseInMap_ = true;
|
1471 | });
|
1472 |
|
1473 | maps.event.addListener(map, 'mouseout', function () {
|
1474 |
|
1475 | this_.mouseInMap_ = false;
|
1476 | this_.mouse_ = null;
|
1477 | this_.markersDispatcher_.emit('kON_MOUSE_POSITION_CHANGE');
|
1478 | });
|
1479 |
|
1480 | maps.event.addListener(map, 'drag', function () {
|
1481 | this_.dragTime_ = new Date().getTime();
|
1482 | this_._onDrag(map);
|
1483 | });
|
1484 |
|
1485 | maps.event.addListener(map, 'dragend', function () {
|
1486 |
|
1487 |
|
1488 | var idleListener = maps.event.addListener(map, 'idle', function () {
|
1489 | maps.event.removeListener(idleListener);
|
1490 | this_._onDragEnd(map);
|
1491 | });
|
1492 | });
|
1493 |
|
1494 | maps.event.addListener(map, 'maptypeid_changed', function () {
|
1495 | this_._onMapTypeIdChange(map.getMapTypeId());
|
1496 | });
|
1497 | }).catch(function (e) {
|
1498 |
|
1499 | _this._onGoogleApiLoaded({
|
1500 | map: null,
|
1501 | maps: null,
|
1502 | ref: _this.googleMapDom_
|
1503 | });
|
1504 | console.error(e);
|
1505 | throw e;
|
1506 | });
|
1507 | };
|
1508 |
|
1509 | _this._onGoogleApiLoaded = function () {
|
1510 | if (_this.props.onGoogleApiLoaded) {
|
1511 | var _this$props;
|
1512 |
|
1513 | if (("development") !== 'production' && _this.props.yesIWantToUseGoogleMapApiInternals !== true) {
|
1514 | console.warn('GoogleMap: ' +
|
1515 | 'Usage of internal api objects is dangerous ' + 'and can cause a lot of issues.\n' + 'To hide this warning add yesIWantToUseGoogleMapApiInternals={true} ' + 'to <GoogleMap instance');
|
1516 | }
|
1517 |
|
1518 | (_this$props = _this.props).onGoogleApiLoaded.apply(_this$props, arguments);
|
1519 | }
|
1520 | };
|
1521 |
|
1522 | _this._getHoverDistance = function () {
|
1523 | return _this.props.hoverDistance;
|
1524 | };
|
1525 |
|
1526 | _this._onDrag = function () {
|
1527 | var _this$props2;
|
1528 |
|
1529 | return _this.props.onDrag && (_this$props2 = _this.props).onDrag.apply(_this$props2, arguments);
|
1530 | };
|
1531 |
|
1532 | _this._onDragEnd = function () {
|
1533 | var _this$props3;
|
1534 |
|
1535 | return _this.props.onDragEnd && (_this$props3 = _this.props).onDragEnd.apply(_this$props3, arguments);
|
1536 | };
|
1537 |
|
1538 | _this._onMapTypeIdChange = function () {
|
1539 | var _this$props4;
|
1540 |
|
1541 | return _this.props.onMapTypeIdChange && (_this$props4 = _this.props).onMapTypeIdChange.apply(_this$props4, arguments);
|
1542 | };
|
1543 |
|
1544 | _this._onZoomAnimationStart = function () {
|
1545 | var _this$props5;
|
1546 |
|
1547 | return _this.props.onZoomAnimationStart && (_this$props5 = _this.props).onZoomAnimationStart.apply(_this$props5, arguments);
|
1548 | };
|
1549 |
|
1550 | _this._onZoomAnimationEnd = function () {
|
1551 | var _this$props6;
|
1552 |
|
1553 | return _this.props.onZoomAnimationEnd && (_this$props6 = _this.props).onZoomAnimationEnd.apply(_this$props6, arguments);
|
1554 | };
|
1555 |
|
1556 | _this._onTilesLoaded = function () {
|
1557 | return _this.props.onTilesLoaded && _this.props.onTilesLoaded();
|
1558 | };
|
1559 |
|
1560 | _this._onChildClick = function () {
|
1561 | if (_this.props.onChildClick) {
|
1562 | var _this$props7;
|
1563 |
|
1564 | return (_this$props7 = _this.props).onChildClick.apply(_this$props7, arguments);
|
1565 | }
|
1566 | return undefined;
|
1567 | };
|
1568 |
|
1569 | _this._onChildMouseDown = function (hoverKey, childProps) {
|
1570 | _this.childMouseDownArgs_ = [hoverKey, childProps];
|
1571 | if (_this.props.onChildMouseDown) {
|
1572 | _this.props.onChildMouseDown(hoverKey, childProps, _extends({}, _this.mouse_));
|
1573 | }
|
1574 | };
|
1575 |
|
1576 | _this._onChildMouseUp = function () {
|
1577 | if (_this.childMouseDownArgs_) {
|
1578 | if (_this.props.onChildMouseUp) {
|
1579 | var _this$props8;
|
1580 |
|
1581 | (_this$props8 = _this.props).onChildMouseUp.apply(_this$props8, _this.childMouseDownArgs_.concat([_extends({}, _this.mouse_)]));
|
1582 | }
|
1583 | _this.childMouseDownArgs_ = null;
|
1584 | _this.childMouseUpTime_ = new Date().getTime();
|
1585 | }
|
1586 | };
|
1587 |
|
1588 | _this._onChildMouseMove = function () {
|
1589 | if (_this.childMouseDownArgs_) {
|
1590 | if (_this.props.onChildMouseMove) {
|
1591 | var _this$props9;
|
1592 |
|
1593 | (_this$props9 = _this.props).onChildMouseMove.apply(_this$props9, _this.childMouseDownArgs_.concat([_extends({}, _this.mouse_)]));
|
1594 | }
|
1595 | }
|
1596 | };
|
1597 |
|
1598 | _this._onChildMouseEnter = function () {
|
1599 | if (_this.props.onChildMouseEnter) {
|
1600 | var _this$props10;
|
1601 |
|
1602 | return (_this$props10 = _this.props).onChildMouseEnter.apply(_this$props10, arguments);
|
1603 | }
|
1604 | return undefined;
|
1605 | };
|
1606 |
|
1607 | _this._onChildMouseLeave = function () {
|
1608 | if (_this.props.onChildMouseLeave) {
|
1609 | var _this$props11;
|
1610 |
|
1611 | return (_this$props11 = _this.props).onChildMouseLeave.apply(_this$props11, arguments);
|
1612 | }
|
1613 | return undefined;
|
1614 | };
|
1615 |
|
1616 | _this._setViewSize = function () {
|
1617 | if (!_this.mounted_) return;
|
1618 | if (isFullScreen()) {
|
1619 | _this.geoService_.setViewSize(window.innerWidth, window.innerHeight);
|
1620 | } else {
|
1621 | var mapDom = _reactDom2.default.findDOMNode(_this.googleMapDom_);
|
1622 | _this.geoService_.setViewSize(mapDom.clientWidth, mapDom.clientHeight);
|
1623 | }
|
1624 | _this._onBoundsChanged();
|
1625 | };
|
1626 |
|
1627 | _this._onWindowResize = function () {
|
1628 | _this.resetSizeOnIdle_ = true;
|
1629 | };
|
1630 |
|
1631 | _this._onMapMouseMove = function (e) {
|
1632 | if (!_this.mouseInMap_) return;
|
1633 |
|
1634 | var currTime = new Date().getTime();
|
1635 | var K_RECALC_CLIENT_RECT_MS = 50;
|
1636 |
|
1637 | if (currTime - _this.mouseMoveTime_ > K_RECALC_CLIENT_RECT_MS) {
|
1638 | _this.boundingRect_ = e.currentTarget.getBoundingClientRect();
|
1639 | }
|
1640 | _this.mouseMoveTime_ = currTime;
|
1641 |
|
1642 | var mousePosX = e.clientX - _this.boundingRect_.left;
|
1643 | var mousePosY = e.clientY - _this.boundingRect_.top;
|
1644 |
|
1645 | if (!_this.mouse_) {
|
1646 | _this.mouse_ = { x: 0, y: 0, lat: 0, lng: 0 };
|
1647 | }
|
1648 |
|
1649 | _this.mouse_.x = mousePosX;
|
1650 | _this.mouse_.y = mousePosY;
|
1651 |
|
1652 | var latLng = _this.geoService_.fromContainerPixelToLatLng(_this.mouse_);
|
1653 | _this.mouse_.lat = latLng.lat;
|
1654 | _this.mouse_.lng = latLng.lng;
|
1655 |
|
1656 | _this._onChildMouseMove();
|
1657 |
|
1658 | if (currTime - _this.dragTime_ < K_IDLE_TIMEOUT) {
|
1659 | _this.fireMouseEventOnIdle_ = true;
|
1660 | } else {
|
1661 | _this.markersDispatcher_.emit('kON_MOUSE_POSITION_CHANGE');
|
1662 | _this.fireMouseEventOnIdle_ = false;
|
1663 | }
|
1664 | };
|
1665 |
|
1666 | _this._onClick = function () {
|
1667 | var _this$props12;
|
1668 |
|
1669 | return _this.props.onClick && !_this.childMouseDownArgs_ && new Date().getTime() - _this.childMouseUpTime_ > K_IDLE_CLICK_TIMEOUT && _this.dragTime_ === 0 && (_this$props12 = _this.props).onClick.apply(_this$props12, arguments);
|
1670 | };
|
1671 |
|
1672 | _this._onMapClick = function (event) {
|
1673 | if (_this.markersDispatcher_) {
|
1674 |
|
1675 | _this._onMapMouseMove(event);
|
1676 | var currTime = new Date().getTime();
|
1677 | if (currTime - _this.dragTime_ > K_IDLE_TIMEOUT) {
|
1678 | if (_this.mouse_) {
|
1679 | _this._onClick(_extends({}, _this.mouse_, {
|
1680 | event: event
|
1681 | }));
|
1682 | }
|
1683 |
|
1684 | _this.markersDispatcher_.emit('kON_CLICK', event);
|
1685 | }
|
1686 | }
|
1687 | };
|
1688 |
|
1689 | _this._onMapMouseDownNative = function (event) {
|
1690 | if (!_this.mouseInMap_) return;
|
1691 |
|
1692 | _this._onMapMouseDown(event);
|
1693 | };
|
1694 |
|
1695 | _this._onMapMouseDown = function (event) {
|
1696 | if (_this.markersDispatcher_) {
|
1697 | var currTime = new Date().getTime();
|
1698 | if (currTime - _this.dragTime_ > K_IDLE_TIMEOUT) {
|
1699 |
|
1700 |
|
1701 | _this._onMapMouseMove(event);
|
1702 | _this.markersDispatcher_.emit('kON_MDOWN', event);
|
1703 | }
|
1704 | }
|
1705 | };
|
1706 |
|
1707 | _this._onMapMouseDownCapture = function () {
|
1708 | if ((0, _detect2.default)().isChrome) {
|
1709 |
|
1710 | _this.zoomControlClickTime_ = new Date().getTime();
|
1711 | }
|
1712 | };
|
1713 |
|
1714 | _this._onKeyDownCapture = function () {
|
1715 | if ((0, _detect2.default)().isChrome) {
|
1716 | _this.zoomControlClickTime_ = new Date().getTime();
|
1717 | }
|
1718 | };
|
1719 |
|
1720 | _this._isCenterDefined = function (center) {
|
1721 | return center && ((0, _isPlainObject2.default)(center) && (0, _isNumber2.default)(center.lat) && (0, _isNumber2.default)(center.lng) || center.length === 2 && (0, _isNumber2.default)(center[0]) && (0, _isNumber2.default)(center[1]));
|
1722 | };
|
1723 |
|
1724 | _this._onBoundsChanged = function (map, maps, callExtBoundsChange) {
|
1725 | if (map) {
|
1726 | var gmC = map.getCenter();
|
1727 | _this.geoService_.setView([gmC.lat(), gmC.lng()], map.getZoom(), 0);
|
1728 | }
|
1729 |
|
1730 | if ((_this.props.onChange || _this.props.onBoundsChange) && _this.geoService_.canProject()) {
|
1731 | var zoom = _this.geoService_.getZoom();
|
1732 | var bounds = _this.geoService_.getBounds();
|
1733 | var centerLatLng = _this.geoService_.getCenter();
|
1734 |
|
1735 | if (!(0, _isArraysEqualEps2.default)(bounds, _this.prevBounds_, kEPS)) {
|
1736 | if (callExtBoundsChange !== false) {
|
1737 | var marginBounds = _this.geoService_.getBounds(_this.props.margin);
|
1738 | if (_this.props.onBoundsChange) {
|
1739 | _this.props.onBoundsChange(_this.centerIsObject_ ? _extends({}, centerLatLng) : [centerLatLng.lat, centerLatLng.lng], zoom, bounds, marginBounds);
|
1740 | }
|
1741 |
|
1742 | if (_this.props.onChange) {
|
1743 | _this.props.onChange({
|
1744 | center: _extends({}, centerLatLng),
|
1745 | zoom: zoom,
|
1746 | bounds: {
|
1747 | nw: {
|
1748 | lat: bounds[0],
|
1749 | lng: bounds[1]
|
1750 | },
|
1751 | se: {
|
1752 | lat: bounds[2],
|
1753 | lng: bounds[3]
|
1754 | },
|
1755 | sw: {
|
1756 | lat: bounds[4],
|
1757 | lng: bounds[5]
|
1758 | },
|
1759 | ne: {
|
1760 | lat: bounds[6],
|
1761 | lng: bounds[7]
|
1762 | }
|
1763 | },
|
1764 | marginBounds: {
|
1765 | nw: {
|
1766 | lat: marginBounds[0],
|
1767 | lng: marginBounds[1]
|
1768 | },
|
1769 | se: {
|
1770 | lat: marginBounds[2],
|
1771 | lng: marginBounds[3]
|
1772 | },
|
1773 | sw: {
|
1774 | lat: marginBounds[4],
|
1775 | lng: marginBounds[5]
|
1776 | },
|
1777 | ne: {
|
1778 | lat: marginBounds[6],
|
1779 | lng: marginBounds[7]
|
1780 | }
|
1781 | },
|
1782 |
|
1783 | size: _this.geoService_.hasSize() ? {
|
1784 | width: _this.geoService_.getWidth(),
|
1785 | height: _this.geoService_.getHeight()
|
1786 | } : {
|
1787 | width: 0,
|
1788 | height: 0
|
1789 | }
|
1790 | });
|
1791 | }
|
1792 |
|
1793 | _this.prevBounds_ = bounds;
|
1794 | }
|
1795 | }
|
1796 | }
|
1797 | };
|
1798 |
|
1799 | _this._registerChild = function (ref) {
|
1800 | _this.googleMapDom_ = ref;
|
1801 | };
|
1802 |
|
1803 | _this.mounted_ = false;
|
1804 | _this.initialized_ = false;
|
1805 | _this.googleApiLoadedCalled_ = false;
|
1806 |
|
1807 | _this.map_ = null;
|
1808 | _this.maps_ = null;
|
1809 | _this.prevBounds_ = null;
|
1810 | _this.heatmap = null;
|
1811 |
|
1812 | _this.layers_ = {};
|
1813 |
|
1814 | _this.mouse_ = null;
|
1815 | _this.mouseMoveTime_ = 0;
|
1816 | _this.boundingRect_ = null;
|
1817 | _this.mouseInMap_ = true;
|
1818 |
|
1819 | _this.dragTime_ = 0;
|
1820 | _this.fireMouseEventOnIdle_ = false;
|
1821 | _this.updateCounter_ = 0;
|
1822 |
|
1823 | _this.markersDispatcher_ = new _marker_dispatcher2.default(_this);
|
1824 | _this.geoService_ = new _geo2.default(K_GOOGLE_TILE_SIZE);
|
1825 | _this.centerIsObject_ = (0, _isPlainObject2.default)(_this.props.center);
|
1826 |
|
1827 | _this.minZoom_ = DEFAULT_MIN_ZOOM;
|
1828 | _this.defaultDraggableOption_ = true;
|
1829 |
|
1830 | _this.zoomControlClickTime_ = 0;
|
1831 |
|
1832 | _this.childMouseDownArgs_ = null;
|
1833 | _this.childMouseUpTime_ = 0;
|
1834 |
|
1835 | _this.googleMapDom_ = null;
|
1836 |
|
1837 | if (true) {
|
1838 | if (_this.props.apiKey) {
|
1839 | console.warn('GoogleMap: ' +
|
1840 | 'apiKey is deprecated, use ' + 'bootstrapURLKeys={{key: YOUR_API_KEY}} instead.');
|
1841 | }
|
1842 |
|
1843 | if (_this.props.onBoundsChange) {
|
1844 | console.warn('GoogleMap: ' +
|
1845 | 'onBoundsChange is deprecated, use ' + 'onChange({center, zoom, bounds, ...other}) instead.');
|
1846 | }
|
1847 |
|
1848 | if ((0, _isEmpty2.default)(_this.props.center) && (0, _isEmpty2.default)(_this.props.defaultCenter)) {
|
1849 | console.warn('GoogleMap: center or defaultCenter property must be defined'
|
1850 | );
|
1851 | }
|
1852 |
|
1853 | if ((0, _isEmpty2.default)(_this.props.zoom) && (0, _isEmpty2.default)(_this.props.defaultZoom)) {
|
1854 | console.warn('GoogleMap: zoom or defaultZoom property must be defined'
|
1855 | );
|
1856 | }
|
1857 | }
|
1858 |
|
1859 | if (_this._isCenterDefined(_this.props.center || _this.props.defaultCenter)) {
|
1860 | var propsCenter = latLng2Obj(_this.props.center || _this.props.defaultCenter);
|
1861 | _this.geoService_.setView(propsCenter, _this.props.zoom || _this.props.defaultZoom, 0);
|
1862 | }
|
1863 |
|
1864 | _this.zoomAnimationInProgress_ = false;
|
1865 |
|
1866 | _this.state = {
|
1867 | overlay: null
|
1868 | };
|
1869 | return _this;
|
1870 | }
|
1871 |
|
1872 | GoogleMap.prototype.componentDidMount = function componentDidMount() {
|
1873 | var _this2 = this;
|
1874 |
|
1875 | this.mounted_ = true;
|
1876 | (0, _passiveEvents2.default)(window, 'resize', this._onWindowResize, false);
|
1877 | (0, _passiveEvents2.default)(window, 'keydown', this._onKeyDownCapture, true);
|
1878 | var mapDom = _reactDom2.default.findDOMNode(this.googleMapDom_);
|
1879 |
|
1880 |
|
1881 |
|
1882 | if (mapDom) {
|
1883 | (0, _passiveEvents2.default)(mapDom, 'mousedown', this._onMapMouseDownNative, true);
|
1884 | }
|
1885 |
|
1886 | (0, _passiveEvents2.default)(window, 'mouseup', this._onChildMouseUp, false);
|
1887 | var bootstrapURLKeys = _extends({}, this.props.apiKey && { key: this.props.apiKey }, this.props.bootstrapURLKeys);
|
1888 |
|
1889 | this.props.googleMapLoader(bootstrapURLKeys, this.props.heatmapLibrary);
|
1890 |
|
1891 | setTimeout(function () {
|
1892 |
|
1893 | _this2._setViewSize();
|
1894 | if (_this2._isCenterDefined(_this2.props.center || _this2.props.defaultCenter)) {
|
1895 | _this2._initMap();
|
1896 | }
|
1897 | }, 0, this);
|
1898 | if (this.props.resetBoundsOnResize) {
|
1899 | var that = this;
|
1900 | _detectElementResize2.default.addResizeListener(mapDom, that._mapDomResizeCallback);
|
1901 | }
|
1902 | };
|
1903 |
|
1904 | GoogleMap.prototype.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
|
1905 | var _this3 = this;
|
1906 |
|
1907 | if (true) {
|
1908 | if (!(0, _shallowEqual2.default)(this.props.defaultCenter, nextProps.defaultCenter)) {
|
1909 | console.warn("GoogleMap: defaultCenter prop changed. You can't change default props.");
|
1910 | }
|
1911 |
|
1912 | if (!(0, _shallowEqual2.default)(this.props.defaultZoom, nextProps.defaultZoom)) {
|
1913 | console.warn("GoogleMap: defaultZoom prop changed. You can't change default props.");
|
1914 | }
|
1915 | }
|
1916 |
|
1917 | if (!this._isCenterDefined(this.props.center) && this._isCenterDefined(nextProps.center)) {
|
1918 | setTimeout(function () {
|
1919 | return _this3._initMap();
|
1920 | }, 0);
|
1921 | }
|
1922 |
|
1923 | if (this.map_) {
|
1924 | var centerLatLng = this.geoService_.getCenter();
|
1925 | if (this._isCenterDefined(nextProps.center)) {
|
1926 | var nextPropsCenter = latLng2Obj(nextProps.center);
|
1927 | var currCenter = this._isCenterDefined(this.props.center) ? latLng2Obj(this.props.center) : null;
|
1928 |
|
1929 | if (!currCenter || Math.abs(nextPropsCenter.lat - currCenter.lat) + Math.abs(nextPropsCenter.lng - currCenter.lng) > kEPS) {
|
1930 | if (Math.abs(nextPropsCenter.lat - centerLatLng.lat) + Math.abs(nextPropsCenter.lng - centerLatLng.lng) > kEPS) {
|
1931 | this.map_.panTo({
|
1932 | lat: nextPropsCenter.lat,
|
1933 | lng: nextPropsCenter.lng
|
1934 | });
|
1935 | }
|
1936 | }
|
1937 | }
|
1938 |
|
1939 | if (!(0, _isEmpty2.default)(nextProps.zoom)) {
|
1940 |
|
1941 | if (Math.abs(nextProps.zoom - this.props.zoom) > 0) {
|
1942 | this.map_.setZoom(nextProps.zoom);
|
1943 | }
|
1944 | }
|
1945 |
|
1946 | if (!(0, _isEmpty2.default)(this.props.draggable) && (0, _isEmpty2.default)(nextProps.draggable)) {
|
1947 |
|
1948 | this.map_.setOptions({ draggable: this.defaultDraggableOption_ });
|
1949 | } else if (!(0, _shallowEqual2.default)(this.props.draggable, nextProps.draggable)) {
|
1950 |
|
1951 | this.map_.setOptions({ draggable: nextProps.draggable });
|
1952 | }
|
1953 |
|
1954 |
|
1955 | if (!(0, _isEmpty2.default)(nextProps.options) && !(0, _shallowEqual2.default)(this.props.options, nextProps.options)) {
|
1956 | var mapPlainObjects = (0, _pick2.default)(this.maps_, _isPlainObject2.default);
|
1957 | var options = typeof nextProps.options === 'function' ? nextProps.options(mapPlainObjects) : nextProps.options;
|
1958 |
|
1959 | options = (0, _omit2.default)(options, ['zoom', 'center', 'draggable']);
|
1960 |
|
1961 | if ('minZoom' in options) {
|
1962 | var minZoom = this._computeMinZoom(options.minZoom);
|
1963 | options.minZoom = _checkMinZoom(options.minZoom, minZoom);
|
1964 | }
|
1965 |
|
1966 | this.map_.setOptions(options);
|
1967 | }
|
1968 |
|
1969 | if (!(0, _shallowEqual2.default)(nextProps.layerTypes, this.props.layerTypes)) {
|
1970 | Object.keys(this.layers_).forEach(function (layerKey) {
|
1971 | _this3.layers_[layerKey].setMap(null);
|
1972 | delete _this3.layers_[layerKey];
|
1973 | });
|
1974 | this._setLayers(nextProps.layerTypes);
|
1975 | }
|
1976 |
|
1977 | if (this.heatmap && !(0, _shallowEqual2.default)(nextProps.heatmap.positions, this.props.heatmap.positions)) {
|
1978 | this.heatmap.setData(nextProps.heatmap.positions.map(function (p) {
|
1979 | return {
|
1980 | location: new _this3.maps_.LatLng(p.lat, p.lng),
|
1981 | weight: p.weight
|
1982 | };
|
1983 | }));
|
1984 | }
|
1985 | }
|
1986 | };
|
1987 |
|
1988 | GoogleMap.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
|
1989 |
|
1990 | return !(0, _shallowEqual2.default)((0, _omit2.default)(this.props, ['draggable']), (0, _omit2.default)(nextProps, ['draggable'])) || !(0, _shallowEqual2.default)(this.state, nextState);
|
1991 | };
|
1992 |
|
1993 | GoogleMap.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
1994 | this.markersDispatcher_.emit('kON_CHANGE');
|
1995 |
|
1996 | if (!(0, _shallowEqual2.default)(this.props.hoverDistance, prevProps.hoverDistance)) {
|
1997 | this.markersDispatcher_.emit('kON_MOUSE_POSITION_CHANGE');
|
1998 | }
|
1999 | };
|
2000 |
|
2001 | GoogleMap.prototype.componentWillUnmount = function componentWillUnmount() {
|
2002 | this.mounted_ = false;
|
2003 | var mapDom = _reactDom2.default.findDOMNode(this.googleMapDom_);
|
2004 | if (mapDom) {
|
2005 | mapDom.removeEventListener('mousedown', this._onMapMouseDownNative, true);
|
2006 | }
|
2007 | window.removeEventListener('resize', this._onWindowResize);
|
2008 | window.removeEventListener('keydown', this._onKeyDownCapture);
|
2009 | window.removeEventListener('mouseup', this._onChildMouseUp, false);
|
2010 | if (this.props.resetBoundsOnResize) {
|
2011 | _detectElementResize2.default.removeResizeListener(mapDom, this._mapDomResizeCallback);
|
2012 | }
|
2013 |
|
2014 | if (this.overlay_) {
|
2015 |
|
2016 | this.overlay_.setMap(null);
|
2017 | }
|
2018 |
|
2019 | if (this.maps_ && this.map_ && this.props.shouldUnregisterMapOnUnmount) {
|
2020 |
|
2021 | this.map_.setOptions({ scrollwheel: false });
|
2022 | this.maps_.event.clearInstanceListeners(this.map_);
|
2023 | }
|
2024 |
|
2025 | if (this.props.shouldUnregisterMapOnUnmount) {
|
2026 | this.map_ = null;
|
2027 | this.maps_ = null;
|
2028 | }
|
2029 | this.markersDispatcher_.dispose();
|
2030 |
|
2031 | this.resetSizeOnIdle_ = false;
|
2032 |
|
2033 | if (this.props.shouldUnregisterMapOnUnmount) {
|
2034 | delete this.map_;
|
2035 | delete this.markersDispatcher_;
|
2036 | }
|
2037 | };
|
2038 |
|
2039 |
|
2040 |
|
2041 |
|
2042 |
|
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 |
|
2050 |
|
2051 |
|
2052 |
|
2053 |
|
2054 |
|
2055 |
|
2056 |
|
2057 | GoogleMap.prototype.render = function render() {
|
2058 | var overlay = this.state.overlay;
|
2059 | var mapMarkerPrerender = !overlay ? _react2.default.createElement(_google_map_markers_prerender2.default, {
|
2060 | experimental: this.props.experimental,
|
2061 | onChildClick: this._onChildClick,
|
2062 | onChildMouseDown: this._onChildMouseDown,
|
2063 | onChildMouseEnter: this._onChildMouseEnter,
|
2064 | onChildMouseLeave: this._onChildMouseLeave,
|
2065 | geoService: this.geoService_,
|
2066 | insideMapPanes: false,
|
2067 | distanceToMouse: this.props.distanceToMouse,
|
2068 | getHoverDistance: this._getHoverDistance,
|
2069 | dispatcher: this.markersDispatcher_
|
2070 | }) : null;
|
2071 |
|
2072 | return _react2.default.createElement(
|
2073 | 'div',
|
2074 | {
|
2075 | style: this.props.style,
|
2076 | onMouseMove: this._onMapMouseMove,
|
2077 | onMouseDownCapture: this._onMapMouseDownCapture,
|
2078 | onClick: this._onMapClick
|
2079 | },
|
2080 | _react2.default.createElement(_google_map_map2.default, { registerChild: this._registerChild }),
|
2081 | IS_REACT_16 && overlay && createPortal(this._renderPortal(), overlay),
|
2082 | mapMarkerPrerender
|
2083 | );
|
2084 | };
|
2085 |
|
2086 | return GoogleMap;
|
2087 | }(_react.Component);
|
2088 |
|
2089 | GoogleMap.propTypes = {
|
2090 | apiKey: _propTypes2.default.string,
|
2091 | bootstrapURLKeys: _propTypes2.default.any,
|
2092 |
|
2093 | defaultCenter: _propTypes2.default.oneOfType([_propTypes2.default.array, _propTypes2.default.shape({
|
2094 | lat: _propTypes2.default.number,
|
2095 | lng: _propTypes2.default.number
|
2096 | })]),
|
2097 | center: _propTypes2.default.oneOfType([_propTypes2.default.array, _propTypes2.default.shape({
|
2098 | lat: _propTypes2.default.number,
|
2099 | lng: _propTypes2.default.number
|
2100 | })]),
|
2101 | defaultZoom: _propTypes2.default.number,
|
2102 | zoom: _propTypes2.default.number,
|
2103 | onBoundsChange: _propTypes2.default.func,
|
2104 | onChange: _propTypes2.default.func,
|
2105 | onClick: _propTypes2.default.func,
|
2106 | onChildClick: _propTypes2.default.func,
|
2107 | onChildMouseDown: _propTypes2.default.func,
|
2108 | onChildMouseUp: _propTypes2.default.func,
|
2109 | onChildMouseMove: _propTypes2.default.func,
|
2110 | onChildMouseEnter: _propTypes2.default.func,
|
2111 | onChildMouseLeave: _propTypes2.default.func,
|
2112 | onZoomAnimationStart: _propTypes2.default.func,
|
2113 | onZoomAnimationEnd: _propTypes2.default.func,
|
2114 | onDrag: _propTypes2.default.func,
|
2115 | onDragEnd: _propTypes2.default.func,
|
2116 | onMapTypeIdChange: _propTypes2.default.func,
|
2117 | onTilesLoaded: _propTypes2.default.func,
|
2118 | options: _propTypes2.default.any,
|
2119 | distanceToMouse: _propTypes2.default.func,
|
2120 | hoverDistance: _propTypes2.default.number,
|
2121 | debounced: _propTypes2.default.bool,
|
2122 | margin: _propTypes2.default.array,
|
2123 | googleMapLoader: _propTypes2.default.any,
|
2124 | onGoogleApiLoaded: _propTypes2.default.func,
|
2125 | yesIWantToUseGoogleMapApiInternals: _propTypes2.default.bool,
|
2126 | draggable: _propTypes2.default.bool,
|
2127 | style: _propTypes2.default.any,
|
2128 | resetBoundsOnResize: _propTypes2.default.bool,
|
2129 | layerTypes: _propTypes2.default.arrayOf(_propTypes2.default.string),
|
2130 | shouldUnregisterMapOnUnmount: _propTypes2.default.bool
|
2131 | };
|
2132 | GoogleMap.defaultProps = {
|
2133 | distanceToMouse: function distanceToMouse(pt, mousePos /* , markerProps */) {
|
2134 | return Math.sqrt((pt.x - mousePos.x) * (pt.x - mousePos.x) + (pt.y - mousePos.y) * (pt.y - mousePos.y));
|
2135 | },
|
2136 |
|
2137 | hoverDistance: 30,
|
2138 | debounced: true,
|
2139 | options: defaultOptions_,
|
2140 | googleMapLoader: _google_map_loader2.default,
|
2141 | yesIWantToUseGoogleMapApiInternals: false,
|
2142 | style: {
|
2143 | width: '100%',
|
2144 | height: '100%',
|
2145 | margin: 0,
|
2146 | padding: 0,
|
2147 | position: 'relative'
|
2148 | },
|
2149 | layerTypes: [],
|
2150 | heatmap: {},
|
2151 | heatmapLibrary: false,
|
2152 | shouldUnregisterMapOnUnmount: true
|
2153 | };
|
2154 | GoogleMap.googleMapLoader = _google_map_loader2.default;
|
2155 | exports.default = GoogleMap;
|
2156 |
|
2157 | }),
|
2158 |
|
2159 | (function(module, exports, __webpack_require__) {
|
2160 |
|
2161 | 'use strict';
|
2162 |
|
2163 | exports.__esModule = true;
|
2164 |
|
2165 | var _react = __webpack_require__(1);
|
2166 |
|
2167 | var _react2 = _interopRequireDefault(_react);
|
2168 |
|
2169 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2170 |
|
2171 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2172 |
|
2173 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
2174 |
|
2175 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
2176 |
|
2177 | var style = {
|
2178 | width: '100%',
|
2179 | height: '100%',
|
2180 | left: 0,
|
2181 | top: 0,
|
2182 | margin: 0,
|
2183 | padding: 0,
|
2184 | position: 'absolute'
|
2185 | };
|
2186 |
|
2187 | var GoogleMapMap = function (_Component) {
|
2188 | _inherits(GoogleMapMap, _Component);
|
2189 |
|
2190 | function GoogleMapMap() {
|
2191 | _classCallCheck(this, GoogleMapMap);
|
2192 |
|
2193 | return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
2194 | }
|
2195 |
|
2196 | GoogleMapMap.prototype.shouldComponentUpdate = function shouldComponentUpdate() {
|
2197 | return false;
|
2198 | };
|
2199 |
|
2200 | GoogleMapMap.prototype.render = function render() {
|
2201 | var registerChild = this.props.registerChild;
|
2202 |
|
2203 | return _react2.default.createElement('div', { ref: registerChild, style: style });
|
2204 | };
|
2205 |
|
2206 | return GoogleMapMap;
|
2207 | }(_react.Component);
|
2208 |
|
2209 | exports.default = GoogleMapMap;
|
2210 |
|
2211 | }),
|
2212 |
|
2213 | (function(module, exports, __webpack_require__) {
|
2214 |
|
2215 | 'use strict';
|
2216 |
|
2217 | exports.__esModule = true;
|
2218 |
|
2219 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
2220 |
|
2221 | exports.default = function (props) {
|
2222 | return _react2.default.createElement(
|
2223 | 'div',
|
2224 | { style: style },
|
2225 | _react2.default.createElement(_google_map_markers2.default, _extends({}, props, { prerender: true }))
|
2226 | );
|
2227 | };
|
2228 |
|
2229 | var _react = __webpack_require__(1);
|
2230 |
|
2231 | var _react2 = _interopRequireDefault(_react);
|
2232 |
|
2233 | var _google_map_markers = __webpack_require__(3);
|
2234 |
|
2235 | var _google_map_markers2 = _interopRequireDefault(_google_map_markers);
|
2236 |
|
2237 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2238 |
|
2239 | var style = {
|
2240 | width: '50%',
|
2241 | height: '50%',
|
2242 | left: '50%',
|
2243 | top: '50%',
|
2244 |
|
2245 | margin: 0,
|
2246 | padding: 0,
|
2247 | position: 'absolute'
|
2248 |
|
2249 | };
|
2250 |
|
2251 | }),
|
2252 |
|
2253 | (function(module, exports, __webpack_require__) {
|
2254 |
|
2255 | 'use strict';
|
2256 |
|
2257 | exports.__esModule = true;
|
2258 | var BASE_URL = 'https://maps';
|
2259 | var DEFAULT_URL = BASE_URL + '.googleapis.com';
|
2260 | var API_PATH = '/maps/api/js?callback=_$_google_map_initialize_$_';
|
2261 |
|
2262 | var $script_ = null;
|
2263 |
|
2264 | var loadPromise_ = void 0;
|
2265 |
|
2266 | var resolveCustomPromise_ = void 0;
|
2267 |
|
2268 | var _customPromise = new Promise(function (resolve) {
|
2269 | resolveCustomPromise_ = resolve;
|
2270 | });
|
2271 |
|
2272 |
|
2273 |
|
2274 | exports.default = function (bootstrapURLKeys, heatmapLibrary) {
|
2275 | if (!$script_) {
|
2276 | $script_ = __webpack_require__(32);
|
2277 | }
|
2278 |
|
2279 |
|
2280 |
|
2281 | if (!bootstrapURLKeys) {
|
2282 | return _customPromise;
|
2283 | }
|
2284 |
|
2285 | if (loadPromise_) {
|
2286 | return loadPromise_;
|
2287 | }
|
2288 |
|
2289 | loadPromise_ = new Promise(function (resolve, reject) {
|
2290 | if (typeof window === 'undefined') {
|
2291 | reject(new Error('google map cannot be loaded outside browser env'));
|
2292 | return;
|
2293 | }
|
2294 |
|
2295 | if (window.google && window.google.maps) {
|
2296 | resolve(window.google.maps);
|
2297 | return;
|
2298 | }
|
2299 |
|
2300 | if (typeof window._$_google_map_initialize_$_ !== 'undefined') {
|
2301 | reject(new Error('google map initialization error'));
|
2302 | }
|
2303 |
|
2304 | window._$_google_map_initialize_$_ = function () {
|
2305 | delete window._$_google_map_initialize_$_;
|
2306 | resolve(window.google.maps);
|
2307 | };
|
2308 |
|
2309 | if (true) {
|
2310 | if (Object.keys(bootstrapURLKeys).indexOf('callback') > -1) {
|
2311 | var message = '"callback" key in bootstrapURLKeys is not allowed,\n use onGoogleApiLoaded property instead';
|
2312 |
|
2313 | console.error(message);
|
2314 | throw new Error(message);
|
2315 | }
|
2316 | }
|
2317 |
|
2318 | var params = Object.keys(bootstrapURLKeys).reduce(function (r, key) {
|
2319 | return r + '&' + key + '=' + bootstrapURLKeys[key];
|
2320 | }, '');
|
2321 |
|
2322 | var libraries = heatmapLibrary ? '&libraries=visualization' : '';
|
2323 |
|
2324 | $script_('' + DEFAULT_URL + API_PATH + params + libraries, function () {
|
2325 | return typeof window.google === 'undefined' && reject(new Error('google map initialization error (not loaded)'));
|
2326 | });
|
2327 | });
|
2328 |
|
2329 | resolveCustomPromise_(loadPromise_);
|
2330 |
|
2331 | return loadPromise_;
|
2332 | };
|
2333 |
|
2334 | }),
|
2335 |
|
2336 | (function(module, exports, __webpack_require__) {
|
2337 |
|
2338 | 'use strict';
|
2339 |
|
2340 | exports.__esModule = true;
|
2341 |
|
2342 | var _eventemitter = __webpack_require__(28);
|
2343 |
|
2344 | var _eventemitter2 = _interopRequireDefault(_eventemitter);
|
2345 |
|
2346 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2347 |
|
2348 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2349 |
|
2350 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
2351 |
|
2352 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
2353 |
|
2354 | var MarkerDispatcher = function (_EventEmitter) {
|
2355 | _inherits(MarkerDispatcher, _EventEmitter);
|
2356 |
|
2357 | function MarkerDispatcher(gmapInstance) {
|
2358 | _classCallCheck(this, MarkerDispatcher);
|
2359 |
|
2360 | var _this = _possibleConstructorReturn(this, _EventEmitter.call(this));
|
2361 |
|
2362 | _this.gmapInstance = gmapInstance;
|
2363 | return _this;
|
2364 | }
|
2365 |
|
2366 | MarkerDispatcher.prototype.getChildren = function getChildren() {
|
2367 | return this.gmapInstance.props.children;
|
2368 | };
|
2369 |
|
2370 | MarkerDispatcher.prototype.getMousePosition = function getMousePosition() {
|
2371 | return this.gmapInstance.mouse_;
|
2372 | };
|
2373 |
|
2374 | MarkerDispatcher.prototype.getUpdateCounter = function getUpdateCounter() {
|
2375 | return this.gmapInstance.updateCounter_;
|
2376 | };
|
2377 |
|
2378 | MarkerDispatcher.prototype.dispose = function dispose() {
|
2379 | this.gmapInstance = null;
|
2380 | this.removeAllListeners();
|
2381 | };
|
2382 |
|
2383 | return MarkerDispatcher;
|
2384 | }(_eventemitter2.default);
|
2385 |
|
2386 | exports.default = MarkerDispatcher;
|
2387 |
|
2388 | }),
|
2389 |
|
2390 | (function(module, exports) {
|
2391 |
|
2392 | 'use strict';
|
2393 |
|
2394 | exports.__esModule = true;
|
2395 | exports.default = detectBrowser;
|
2396 |
|
2397 | var detectBrowserResult_ = null;
|
2398 |
|
2399 | function detectBrowser() {
|
2400 | if (detectBrowserResult_) {
|
2401 | return detectBrowserResult_;
|
2402 | }
|
2403 |
|
2404 | if (typeof navigator !== 'undefined') {
|
2405 | var isExplorer = navigator.userAgent.indexOf('MSIE') > -1;
|
2406 | var isFirefox = navigator.userAgent.indexOf('Firefox') > -1;
|
2407 | var isOpera = navigator.userAgent.toLowerCase().indexOf('op') > -1;
|
2408 |
|
2409 | var isChrome = navigator.userAgent.indexOf('Chrome') > -1;
|
2410 | var isSafari = navigator.userAgent.indexOf('Safari') > -1;
|
2411 |
|
2412 | if (isChrome && isSafari) {
|
2413 | isSafari = false;
|
2414 | }
|
2415 |
|
2416 | if (isChrome && isOpera) {
|
2417 | isChrome = false;
|
2418 | }
|
2419 |
|
2420 | detectBrowserResult_ = {
|
2421 | isExplorer: isExplorer,
|
2422 | isFirefox: isFirefox,
|
2423 | isOpera: isOpera,
|
2424 | isChrome: isChrome,
|
2425 | isSafari: isSafari
|
2426 | };
|
2427 | return detectBrowserResult_;
|
2428 | }
|
2429 |
|
2430 | detectBrowserResult_ = {
|
2431 | isChrome: true,
|
2432 | isExplorer: false,
|
2433 | isFirefox: false,
|
2434 | isOpera: false,
|
2435 | isSafari: false
|
2436 | };
|
2437 |
|
2438 | return detectBrowserResult_;
|
2439 | }
|
2440 |
|
2441 | }),
|
2442 |
|
2443 | (function(module, exports, __webpack_require__) {
|
2444 |
|
2445 | 'use strict';
|
2446 |
|
2447 | var _passiveEvents = __webpack_require__(7);
|
2448 |
|
2449 | var _passiveEvents2 = _interopRequireDefault(_passiveEvents);
|
2450 |
|
2451 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2452 |
|
2453 |
|
2454 | var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
2455 |
|
2456 |
|
2457 |
|
2458 | |
2459 |
|
2460 |
|
2461 |
|
2462 |
|
2463 |
|
2464 |
|
2465 |
|
2466 |
|
2467 |
|
2468 | var _window;
|
2469 | if (canUseDOM) {
|
2470 | _window = window;
|
2471 | } else if (typeof self !== 'undefined') {
|
2472 | _window = self;
|
2473 | } else {
|
2474 | _window = undefined;
|
2475 | }
|
2476 |
|
2477 | var attachEvent = typeof document !== 'undefined' && document.attachEvent;
|
2478 | var stylesCreated = false;
|
2479 |
|
2480 | if (canUseDOM && !attachEvent) {
|
2481 | var requestFrame = function () {
|
2482 | var raf = _window.requestAnimationFrame || _window.mozRequestAnimationFrame || _window.webkitRequestAnimationFrame || function (fn) {
|
2483 | return _window.setTimeout(fn, 20);
|
2484 | };
|
2485 | return function (fn) {
|
2486 | return raf(fn);
|
2487 | };
|
2488 | }();
|
2489 |
|
2490 | var cancelFrame = function () {
|
2491 | var cancel = _window.cancelAnimationFrame || _window.mozCancelAnimationFrame || _window.webkitCancelAnimationFrame || _window.clearTimeout;
|
2492 | return function (id) {
|
2493 | return cancel(id);
|
2494 | };
|
2495 | }();
|
2496 |
|
2497 | var resetTriggers = function resetTriggers(element) {
|
2498 | var triggers = element.__resizeTriggers__,
|
2499 | expand = triggers.firstElementChild,
|
2500 | contract = triggers.lastElementChild,
|
2501 | expandChild = expand.firstElementChild;
|
2502 | contract.scrollLeft = contract.scrollWidth;
|
2503 | contract.scrollTop = contract.scrollHeight;
|
2504 | expandChild.style.width = expand.offsetWidth + 1 + 'px';
|
2505 | expandChild.style.height = expand.offsetHeight + 1 + 'px';
|
2506 | expand.scrollLeft = expand.scrollWidth;
|
2507 | expand.scrollTop = expand.scrollHeight;
|
2508 | };
|
2509 |
|
2510 | var checkTriggers = function checkTriggers(element) {
|
2511 | return element.offsetWidth != element.__resizeLast__.width || element.offsetHeight != element.__resizeLast__.height;
|
2512 | };
|
2513 |
|
2514 | var scrollListener = function scrollListener(e) {
|
2515 | var element = this;
|
2516 | resetTriggers(this);
|
2517 | if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
|
2518 | this.__resizeRAF__ = requestFrame(function () {
|
2519 | if (checkTriggers(element)) {
|
2520 | element.__resizeLast__.width = element.offsetWidth;
|
2521 | element.__resizeLast__.height = element.offsetHeight;
|
2522 | element.__resizeListeners__.forEach(function (fn) {
|
2523 | fn.call(element, e);
|
2524 | });
|
2525 | }
|
2526 | });
|
2527 | };
|
2528 |
|
2529 |
|
2530 | var animation = false,
|
2531 | animationstring = 'animation',
|
2532 | keyframeprefix = '',
|
2533 | animationstartevent = 'animationstart',
|
2534 | domPrefixes = 'Webkit Moz O ms'.split(' '),
|
2535 | startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' '),
|
2536 | pfx = '';
|
2537 |
|
2538 | if (canUseDOM) {
|
2539 | var elm = document.createElement('fakeelement');
|
2540 | if (elm.style.animationName !== undefined) {
|
2541 | animation = true;
|
2542 | }
|
2543 |
|
2544 | if (animation === false) {
|
2545 | for (var i = 0; i < domPrefixes.length; i++) {
|
2546 | if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
|
2547 | pfx = domPrefixes[i];
|
2548 | animationstring = pfx + 'Animation';
|
2549 | keyframeprefix = '-' + pfx.toLowerCase() + '-';
|
2550 | animationstartevent = startEvents[i];
|
2551 | animation = true;
|
2552 | break;
|
2553 | }
|
2554 | }
|
2555 | }
|
2556 | }
|
2557 |
|
2558 | var animationName = 'resizeanim';
|
2559 | var animationKeyframes = '@' + keyframeprefix + 'keyframes ' + animationName + ' { from { opacity: 0; } to { opacity: 0; } } ';
|
2560 | var animationStyle = keyframeprefix + 'animation: 1ms ' + animationName + '; ';
|
2561 | }
|
2562 |
|
2563 | var createStyles = function createStyles() {
|
2564 | if (!stylesCreated) {
|
2565 |
|
2566 | var css = (animationKeyframes ? animationKeyframes : '') + '.resize-triggers { ' + (animationStyle ? animationStyle : '') + 'visibility: hidden; opacity: 0; } ' + '.resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',
|
2567 | head = document.head || document.getElementsByTagName('head')[0],
|
2568 | style = document.createElement('style');
|
2569 |
|
2570 | style.type = 'text/css';
|
2571 | if (style.styleSheet) {
|
2572 | style.styleSheet.cssText = css;
|
2573 | } else {
|
2574 | style.appendChild(document.createTextNode(css));
|
2575 | }
|
2576 |
|
2577 | head.appendChild(style);
|
2578 | stylesCreated = true;
|
2579 | }
|
2580 | };
|
2581 |
|
2582 | var addResizeListener = function addResizeListener(element, fn) {
|
2583 | if (element.parentNode === undefined) {
|
2584 | var tempParentDiv = document.createElement('div');
|
2585 | element.parentNode = tempParentDiv;
|
2586 | }
|
2587 | element = element.parentNode;
|
2588 | if (attachEvent) element.attachEvent('onresize', fn);else {
|
2589 | if (!element.__resizeTriggers__) {
|
2590 | if (getComputedStyle(element).position == 'static') element.style.position = 'relative';
|
2591 | createStyles();
|
2592 | element.__resizeLast__ = {};
|
2593 | element.__resizeListeners__ = [];
|
2594 | (element.__resizeTriggers__ = document.createElement('div')).className = 'resize-triggers';
|
2595 | element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div>' + '<div class="contract-trigger"></div>';
|
2596 | element.appendChild(element.__resizeTriggers__);
|
2597 | resetTriggers(element);
|
2598 |
|
2599 | (0, _passiveEvents2.default)(element, 'scroll', scrollListener, true);
|
2600 |
|
2601 |
|
2602 | animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
|
2603 | if (e.animationName == animationName) resetTriggers(element);
|
2604 | });
|
2605 | }
|
2606 | element.__resizeListeners__.push(fn);
|
2607 | }
|
2608 | };
|
2609 |
|
2610 | var removeResizeListener = function removeResizeListener(element, fn) {
|
2611 | element = element.parentNode;
|
2612 | if (attachEvent) element.detachEvent('onresize', fn);else {
|
2613 | element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
|
2614 | if (!element.__resizeListeners__.length) {
|
2615 | element.removeEventListener('scroll', scrollListener);
|
2616 | element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
|
2617 | }
|
2618 | }
|
2619 | };
|
2620 |
|
2621 | module.exports = {
|
2622 | addResizeListener: addResizeListener,
|
2623 | removeResizeListener: removeResizeListener
|
2624 | };
|
2625 |
|
2626 | }),
|
2627 |
|
2628 | (function(module, exports, __webpack_require__) {
|
2629 |
|
2630 | 'use strict';
|
2631 |
|
2632 | exports.__esModule = true;
|
2633 |
|
2634 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
2635 |
|
2636 | var _pointGeometry = __webpack_require__(2);
|
2637 |
|
2638 | var _pointGeometry2 = _interopRequireDefault(_pointGeometry);
|
2639 |
|
2640 | var _lat_lng = __webpack_require__(4);
|
2641 |
|
2642 | var _lat_lng2 = _interopRequireDefault(_lat_lng);
|
2643 |
|
2644 | var _transform = __webpack_require__(24);
|
2645 |
|
2646 | var _transform2 = _interopRequireDefault(_transform);
|
2647 |
|
2648 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2649 |
|
2650 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2651 |
|
2652 | var Geo = function () {
|
2653 | function Geo(tileSize) {
|
2654 | _classCallCheck(this, Geo);
|
2655 |
|
2656 |
|
2657 |
|
2658 | this.hasSize_ = false;
|
2659 | this.hasView_ = false;
|
2660 | this.transform_ = new _transform2.default(tileSize || 512);
|
2661 | }
|
2662 |
|
2663 | Geo.prototype.setView = function setView(center, zoom, bearing) {
|
2664 | this.transform_.center = _lat_lng2.default.convert(center);
|
2665 | this.transform_.zoom = +zoom;
|
2666 | this.transform_.bearing = +bearing;
|
2667 | this.hasView_ = true;
|
2668 | };
|
2669 |
|
2670 | Geo.prototype.setViewSize = function setViewSize(width, height) {
|
2671 | this.transform_.width = width;
|
2672 | this.transform_.height = height;
|
2673 | this.hasSize_ = true;
|
2674 | };
|
2675 |
|
2676 | Geo.prototype.setMapCanvasProjection = function setMapCanvasProjection(maps, mapCanvasProjection) {
|
2677 | this.maps_ = maps;
|
2678 | this.mapCanvasProjection_ = mapCanvasProjection;
|
2679 | };
|
2680 |
|
2681 | Geo.prototype.canProject = function canProject() {
|
2682 | return this.hasSize_ && this.hasView_;
|
2683 | };
|
2684 |
|
2685 | Geo.prototype.hasSize = function hasSize() {
|
2686 | return this.hasSize_;
|
2687 | };
|
2688 |
|
2689 |
|
2690 |
|
2691 |
|
2692 | Geo.prototype.fromLatLngToCenterPixel = function fromLatLngToCenterPixel(ptLatLng) {
|
2693 | return this.transform_.locationPoint(_lat_lng2.default.convert(ptLatLng));
|
2694 | };
|
2695 |
|
2696 | |
2697 |
|
2698 |
|
2699 |
|
2700 |
|
2701 |
|
2702 | Geo.prototype.fromLatLngToDivPixel = function fromLatLngToDivPixel(ptLatLng) {
|
2703 | if (this.mapCanvasProjection_) {
|
2704 | var latLng = new this.maps_.LatLng(ptLatLng.lat, ptLatLng.lng);
|
2705 | return this.mapCanvasProjection_.fromLatLngToDivPixel(latLng);
|
2706 | }
|
2707 | return this.fromLatLngToCenterPixel(ptLatLng);
|
2708 | };
|
2709 |
|
2710 |
|
2711 |
|
2712 |
|
2713 | Geo.prototype.fromLatLngToContainerPixel = function fromLatLngToContainerPixel(ptLatLng) {
|
2714 | if (this.mapCanvasProjection_) {
|
2715 | var latLng = new this.maps_.LatLng(ptLatLng.lat, ptLatLng.lng);
|
2716 | return this.mapCanvasProjection_.fromLatLngToContainerPixel(latLng);
|
2717 | }
|
2718 |
|
2719 | var pt = this.fromLatLngToCenterPixel(ptLatLng);
|
2720 | pt.x -= this.transform_.worldSize * Math.round(pt.x / this.transform_.worldSize);
|
2721 |
|
2722 | pt.x += this.transform_.width / 2;
|
2723 | pt.y += this.transform_.height / 2;
|
2724 |
|
2725 | return pt;
|
2726 | };
|
2727 |
|
2728 |
|
2729 |
|
2730 |
|
2731 | Geo.prototype.fromContainerPixelToLatLng = function fromContainerPixelToLatLng(ptXY) {
|
2732 | if (this.mapCanvasProjection_) {
|
2733 | var latLng = this.mapCanvasProjection_.fromContainerPixelToLatLng(ptXY);
|
2734 | return { lat: latLng.lat(), lng: latLng.lng() };
|
2735 | }
|
2736 |
|
2737 | var ptxy = _extends({}, ptXY);
|
2738 | ptxy.x -= this.transform_.width / 2;
|
2739 | ptxy.y -= this.transform_.height / 2;
|
2740 | var ptRes = this.transform_.pointLocation(_pointGeometry2.default.convert(ptxy));
|
2741 |
|
2742 | ptRes.lng -= 360 * Math.round(ptRes.lng / 360);
|
2743 | return ptRes;
|
2744 | };
|
2745 |
|
2746 | Geo.prototype.getWidth = function getWidth() {
|
2747 | return this.transform_.width;
|
2748 | };
|
2749 |
|
2750 | Geo.prototype.getHeight = function getHeight() {
|
2751 | return this.transform_.height;
|
2752 | };
|
2753 |
|
2754 | Geo.prototype.getZoom = function getZoom() {
|
2755 | return this.transform_.zoom;
|
2756 | };
|
2757 |
|
2758 | Geo.prototype.getCenter = function getCenter() {
|
2759 | var ptRes = this.transform_.pointLocation({ x: 0, y: 0 });
|
2760 |
|
2761 | return ptRes;
|
2762 | };
|
2763 |
|
2764 | Geo.prototype.getBounds = function getBounds(margins, roundFactor) {
|
2765 | var bndT = margins && margins[0] || 0;
|
2766 | var bndR = margins && margins[1] || 0;
|
2767 | var bndB = margins && margins[2] || 0;
|
2768 | var bndL = margins && margins[3] || 0;
|
2769 |
|
2770 | if (this.getWidth() - bndR - bndL > 0 && this.getHeight() - bndT - bndB > 0) {
|
2771 | var topLeftCorner = this.transform_.pointLocation(_pointGeometry2.default.convert({
|
2772 | x: bndL - this.getWidth() / 2,
|
2773 | y: bndT - this.getHeight() / 2
|
2774 | }));
|
2775 | var bottomRightCorner = this.transform_.pointLocation(_pointGeometry2.default.convert({
|
2776 | x: this.getWidth() / 2 - bndR,
|
2777 | y: this.getHeight() / 2 - bndB
|
2778 | }));
|
2779 |
|
2780 | var res = [topLeftCorner.lat, topLeftCorner.lng,
|
2781 | bottomRightCorner.lat, bottomRightCorner.lng,
|
2782 | bottomRightCorner.lat, topLeftCorner.lng,
|
2783 | topLeftCorner.lat, bottomRightCorner.lng];
|
2784 |
|
2785 | if (roundFactor) {
|
2786 | res = res.map(function (r) {
|
2787 | return Math.round(r * roundFactor) / roundFactor;
|
2788 | });
|
2789 | }
|
2790 | return res;
|
2791 | }
|
2792 |
|
2793 | return [0, 0, 0, 0];
|
2794 | };
|
2795 |
|
2796 | return Geo;
|
2797 | }();
|
2798 |
|
2799 | exports.default = Geo;
|
2800 |
|
2801 | }),
|
2802 |
|
2803 | (function(module, exports) {
|
2804 |
|
2805 | "use strict";
|
2806 |
|
2807 | exports.__esModule = true;
|
2808 | exports.default = isArraysEqualEps;
|
2809 | function isArraysEqualEps(arrayA, arrayB, eps) {
|
2810 | if (arrayA && arrayB) {
|
2811 | for (var i = 0; i !== arrayA.length; ++i) {
|
2812 | if (Math.abs(arrayA[i] - arrayB[i]) > eps) {
|
2813 | return false;
|
2814 | }
|
2815 | }
|
2816 | return true;
|
2817 | }
|
2818 | return false;
|
2819 | }
|
2820 |
|
2821 | }),
|
2822 |
|
2823 | (function(module, exports) {
|
2824 |
|
2825 | 'use strict';
|
2826 |
|
2827 | exports.__esModule = true;
|
2828 |
|
2829 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
2830 |
|
2831 | var isEmpty = function isEmpty(val) {
|
2832 |
|
2833 | if (val !== null && (typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') {
|
2834 | if (Object.keys(val).length === 0) {
|
2835 | return true;
|
2836 | }
|
2837 | } else if (val === null || val === undefined || val === '') {
|
2838 |
|
2839 | return true;
|
2840 | }
|
2841 | return false;
|
2842 | };
|
2843 |
|
2844 | exports.default = isEmpty;
|
2845 |
|
2846 | }),
|
2847 |
|
2848 | (function(module, exports) {
|
2849 |
|
2850 | 'use strict';
|
2851 |
|
2852 | exports.__esModule = true;
|
2853 |
|
2854 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
2855 |
|
2856 | exports.default = isNumber;
|
2857 | function isObjectLike(value) {
|
2858 | return !!value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object';
|
2859 | }
|
2860 |
|
2861 | var objectToString = Object.prototype.toString;
|
2862 |
|
2863 | function isNumber(value) {
|
2864 | var numberTag = '[object Number]';
|
2865 | return typeof value === 'number' || isObjectLike(value) && objectToString.call(value) === numberTag;
|
2866 | }
|
2867 |
|
2868 | }),
|
2869 |
|
2870 | (function(module, exports) {
|
2871 |
|
2872 | 'use strict';
|
2873 |
|
2874 | exports.__esModule = true;
|
2875 |
|
2876 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
2877 |
|
2878 | exports.default = isPlainObject;
|
2879 |
|
2880 | var fnToString = function fnToString(fn) {
|
2881 | return Function.prototype.toString.call(fn);
|
2882 | };
|
2883 |
|
2884 | |
2885 |
|
2886 |
|
2887 |
|
2888 | function isPlainObject(obj) {
|
2889 | if (!obj || (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') {
|
2890 | return false;
|
2891 | }
|
2892 |
|
2893 | var proto = typeof obj.constructor === 'function' ? Object.getPrototypeOf(obj) : Object.prototype;
|
2894 |
|
2895 | if (proto === null) {
|
2896 | return true;
|
2897 | }
|
2898 |
|
2899 | var constructor = proto.constructor;
|
2900 |
|
2901 | return typeof constructor === 'function' && constructor instanceof constructor && fnToString(constructor) === fnToString(Object);
|
2902 | }
|
2903 |
|
2904 | /***/ }),
|
2905 | /* 24 */
|
2906 | /***/ (function(module, exports, __webpack_require__) {
|
2907 |
|
2908 | 'use strict';
|
2909 |
|
2910 | exports.__esModule = true;
|
2911 |
|
2912 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
2913 |
|
2914 |
|
2915 | var _pointGeometry = __webpack_require__(2);
|
2916 |
|
2917 | var _pointGeometry2 = _interopRequireDefault(_pointGeometry);
|
2918 |
|
2919 | var _lat_lng = __webpack_require__(4);
|
2920 |
|
2921 | var _lat_lng2 = _interopRequireDefault(_lat_lng);
|
2922 |
|
2923 | var _wrap = __webpack_require__(5);
|
2924 |
|
2925 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2926 |
|
2927 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2928 |
|
2929 |
|
2930 | var Transform = function () {
|
2931 | function Transform(tileSize, minZoom, maxZoom) {
|
2932 | _classCallCheck(this, Transform);
|
2933 |
|
2934 | this.tileSize = tileSize || 512;
|
2935 |
|
2936 | this._minZoom = minZoom || 0;
|
2937 | this._maxZoom = maxZoom || 52;
|
2938 |
|
2939 | this.latRange = [-85.05113, 85.05113];
|
2940 |
|
2941 | this.width = 0;
|
2942 | this.height = 0;
|
2943 | this.zoom = 0;
|
2944 | this.center = new _lat_lng2.default(0, 0);
|
2945 | this.angle = 0;
|
2946 | }
|
2947 |
|
2948 | Transform.prototype.zoomScale = function zoomScale(zoom) {
|
2949 | return Math.pow(2, zoom);
|
2950 | };
|
2951 |
|
2952 | Transform.prototype.scaleZoom = function scaleZoom(scale) {
|
2953 | return Math.log(scale) / Math.LN2;
|
2954 | };
|
2955 |
|
2956 | Transform.prototype.project = function project(latlng, worldSize) {
|
2957 | return new _pointGeometry2.default(this.lngX(latlng.lng, worldSize), this.latY(latlng.lat, worldSize));
|
2958 | };
|
2959 |
|
2960 | Transform.prototype.unproject = function unproject(point, worldSize) {
|
2961 | return new _lat_lng2.default(this.yLat(point.y, worldSize), this.xLng(point.x, worldSize));
|
2962 | };
|
2963 |
|
2964 |
|
2965 | Transform.prototype.lngX = function lngX(lon, worldSize) {
|
2966 | return (180 + lon) * (worldSize || this.worldSize) / 360;
|
2967 | };
|
2968 |
|
2969 |
|
2970 |
|
2971 |
|
2972 | Transform.prototype.latY = function latY(lat, worldSize) {
|
2973 | var y = 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360));
|
2974 | return (180 - y) * (worldSize || this.worldSize) / 360;
|
2975 | };
|
2976 |
|
2977 | Transform.prototype.xLng = function xLng(x, worldSize) {
|
2978 | return x * 360 / (worldSize || this.worldSize) - 180;
|
2979 | };
|
2980 |
|
2981 | Transform.prototype.yLat = function yLat(y, worldSize) {
|
2982 | var y2 = 180 - y * 360 / (worldSize || this.worldSize);
|
2983 | return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
2984 | };
|
2985 |
|
2986 | Transform.prototype.locationPoint = function locationPoint(latlng) {
|
2987 | var p = this.project(latlng);
|
2988 | return this.centerPoint._sub(this.point._sub(p)._rotate(this.angle));
|
2989 | };
|
2990 |
|
2991 | Transform.prototype.pointLocation = function pointLocation(p) {
|
2992 | var p2 = this.centerPoint._sub(p)._rotate(-this.angle);
|
2993 | return this.unproject(this.point.sub(p2));
|
2994 | };
|
2995 |
|
2996 | _createClass(Transform, [{
|
2997 | key: 'minZoom',
|
2998 | get: function get() {
|
2999 | return this._minZoom;
|
3000 | },
|
3001 | set: function set(zoom) {
|
3002 | this._minZoom = zoom;
|
3003 | this.zoom = Math.max(this.zoom, zoom);
|
3004 | }
|
3005 | }, {
|
3006 | key: 'maxZoom',
|
3007 | get: function get() {
|
3008 | return this._maxZoom;
|
3009 | },
|
3010 | set: function set(zoom) {
|
3011 | this._maxZoom = zoom;
|
3012 | this.zoom = Math.min(this.zoom, zoom);
|
3013 | }
|
3014 | }, {
|
3015 | key: 'worldSize',
|
3016 | get: function get() {
|
3017 | return this.tileSize * this.scale;
|
3018 | }
|
3019 | }, {
|
3020 | key: 'centerPoint',
|
3021 | get: function get() {
|
3022 | return new _pointGeometry2.default(0, 0);
|
3023 | }
|
3024 | }, {
|
3025 | key: 'size',
|
3026 | get: function get() {
|
3027 | return new _pointGeometry2.default(this.width, this.height);
|
3028 | }
|
3029 | }, {
|
3030 | key: 'bearing',
|
3031 | get: function get() {
|
3032 | return -this.angle / Math.PI * 180;
|
3033 | },
|
3034 | set: function set(bearing) {
|
3035 | this.angle = -(0, _wrap.wrap)(bearing, -180, 180) * Math.PI / 180;
|
3036 | }
|
3037 | }, {
|
3038 | key: 'zoom',
|
3039 | get: function get() {
|
3040 | return this._zoom;
|
3041 | },
|
3042 | set: function set(zoom) {
|
3043 | var zoomV = Math.min(Math.max(zoom, this.minZoom), this.maxZoom);
|
3044 | this._zoom = zoomV;
|
3045 | this.scale = this.zoomScale(zoomV);
|
3046 | this.tileZoom = Math.floor(zoomV);
|
3047 | this.zoomFraction = zoomV - this.tileZoom;
|
3048 | }
|
3049 | }, {
|
3050 | key: 'x',
|
3051 | get: function get() {
|
3052 | return this.lngX(this.center.lng);
|
3053 | }
|
3054 | }, {
|
3055 | key: 'y',
|
3056 | get: function get() {
|
3057 | return this.latY(this.center.lat);
|
3058 | }
|
3059 | }, {
|
3060 | key: 'point',
|
3061 | get: function get() {
|
3062 | return new _pointGeometry2.default(this.x, this.y);
|
3063 | }
|
3064 | }]);
|
3065 |
|
3066 | return Transform;
|
3067 | }();
|
3068 |
|
3069 | exports.default = Transform;
|
3070 |
|
3071 | }),
|
3072 |
|
3073 | (function(module, exports) {
|
3074 |
|
3075 | "use strict";
|
3076 |
|
3077 | exports.__esModule = true;
|
3078 | var log2 = Math.log2 ? Math.log2 : function (x) {
|
3079 | return Math.log(x) / Math.LN2;
|
3080 | };
|
3081 |
|
3082 | exports.default = log2;
|
3083 |
|
3084 | }),
|
3085 |
|
3086 | (function(module, exports) {
|
3087 |
|
3088 | "use strict";
|
3089 |
|
3090 | exports.__esModule = true;
|
3091 | exports.default = pick;
|
3092 |
|
3093 |
|
3094 | function pick(obj, fn) {
|
3095 | return Object.keys(obj).reduce(function (result, key) {
|
3096 | if (fn(obj[key])) {
|
3097 | result[key] = obj[key];
|
3098 | }
|
3099 | return result;
|
3100 | }, {});
|
3101 | }
|
3102 |
|
3103 | }),
|
3104 |
|
3105 | (function(module, exports) {
|
3106 |
|
3107 | "use strict";
|
3108 |
|
3109 | exports.__esModule = true;
|
3110 | exports.default = raf;
|
3111 | function raf(callback) {
|
3112 | if (window.requestAnimationFrame) {
|
3113 | return window.requestAnimationFrame(callback);
|
3114 | }
|
3115 |
|
3116 | var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
|
3117 |
|
3118 | return nativeRaf ? nativeRaf(callback) : window.setTimeout(callback, 1e3 / 60);
|
3119 | }
|
3120 |
|
3121 | }),
|
3122 |
|
3123 | (function(module, exports, __webpack_require__) {
|
3124 |
|
3125 | 'use strict';
|
3126 |
|
3127 | var has = Object.prototype.hasOwnProperty;
|
3128 |
|
3129 |
|
3130 |
|
3131 |
|
3132 |
|
3133 |
|
3134 |
|
3135 |
|
3136 |
|
3137 | var prefix = typeof Object.create !== 'function' ? '~' : false;
|
3138 |
|
3139 | |
3140 |
|
3141 |
|
3142 |
|
3143 |
|
3144 |
|
3145 |
|
3146 |
|
3147 | function EE(fn, context, once) {
|
3148 | this.fn = fn;
|
3149 | this.context = context;
|
3150 | this.once = once || false;
|
3151 | }
|
3152 |
|
3153 | |
3154 |
|
3155 |
|
3156 |
|
3157 |
|
3158 |
|
3159 |
|
3160 | function EventEmitter() { }
|
3161 |
|
3162 | |
3163 |
|
3164 |
|
3165 |
|
3166 |
|
3167 |
|
3168 | EventEmitter.prototype._events = undefined;
|
3169 |
|
3170 | |
3171 |
|
3172 |
|
3173 |
|
3174 |
|
3175 |
|
3176 |
|
3177 | EventEmitter.prototype.eventNames = function eventNames() {
|
3178 | var events = this._events
|
3179 | , names = []
|
3180 | , name;
|
3181 |
|
3182 | if (!events) return names;
|
3183 |
|
3184 | for (name in events) {
|
3185 | if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
3186 | }
|
3187 |
|
3188 | if (Object.getOwnPropertySymbols) {
|
3189 | return names.concat(Object.getOwnPropertySymbols(events));
|
3190 | }
|
3191 |
|
3192 | return names;
|
3193 | };
|
3194 |
|
3195 | |
3196 |
|
3197 |
|
3198 |
|
3199 |
|
3200 |
|
3201 |
|
3202 |
|
3203 | EventEmitter.prototype.listeners = function listeners(event, exists) {
|
3204 | var evt = prefix ? prefix + event : event
|
3205 | , available = this._events && this._events[evt];
|
3206 |
|
3207 | if (exists) return !!available;
|
3208 | if (!available) return [];
|
3209 | if (available.fn) return [available.fn];
|
3210 |
|
3211 | for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
|
3212 | ee[i] = available[i].fn;
|
3213 | }
|
3214 |
|
3215 | return ee;
|
3216 | };
|
3217 |
|
3218 | |
3219 |
|
3220 |
|
3221 |
|
3222 |
|
3223 |
|
3224 |
|
3225 | EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
3226 | var evt = prefix ? prefix + event : event;
|
3227 |
|
3228 | if (!this._events || !this._events[evt]) return false;
|
3229 |
|
3230 | var listeners = this._events[evt]
|
3231 | , len = arguments.length
|
3232 | , args
|
3233 | , i;
|
3234 |
|
3235 | if ('function' === typeof listeners.fn) {
|
3236 | if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
3237 |
|
3238 | switch (len) {
|
3239 | case 1: return listeners.fn.call(listeners.context), true;
|
3240 | case 2: return listeners.fn.call(listeners.context, a1), true;
|
3241 | case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
3242 | case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
3243 | case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
3244 | case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
3245 | }
|
3246 |
|
3247 | for (i = 1, args = new Array(len -1); i < len; i++) {
|
3248 | args[i - 1] = arguments[i];
|
3249 | }
|
3250 |
|
3251 | listeners.fn.apply(listeners.context, args);
|
3252 | } else {
|
3253 | var length = listeners.length
|
3254 | , j;
|
3255 |
|
3256 | for (i = 0; i < length; i++) {
|
3257 | if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
3258 |
|
3259 | switch (len) {
|
3260 | case 1: listeners[i].fn.call(listeners[i].context); break;
|
3261 | case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
3262 | case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
3263 | default:
|
3264 | if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
3265 | args[j - 1] = arguments[j];
|
3266 | }
|
3267 |
|
3268 | listeners[i].fn.apply(listeners[i].context, args);
|
3269 | }
|
3270 | }
|
3271 | }
|
3272 |
|
3273 | return true;
|
3274 | };
|
3275 |
|
3276 | |
3277 |
|
3278 |
|
3279 |
|
3280 |
|
3281 |
|
3282 |
|
3283 |
|
3284 | EventEmitter.prototype.on = function on(event, fn, context) {
|
3285 | var listener = new EE(fn, context || this)
|
3286 | , evt = prefix ? prefix + event : event;
|
3287 |
|
3288 | if (!this._events) this._events = prefix ? {} : Object.create(null);
|
3289 | if (!this._events[evt]) this._events[evt] = listener;
|
3290 | else {
|
3291 | if (!this._events[evt].fn) this._events[evt].push(listener);
|
3292 | else this._events[evt] = [
|
3293 | this._events[evt], listener
|
3294 | ];
|
3295 | }
|
3296 |
|
3297 | return this;
|
3298 | };
|
3299 |
|
3300 | |
3301 |
|
3302 |
|
3303 |
|
3304 |
|
3305 |
|
3306 |
|
3307 |
|
3308 | EventEmitter.prototype.once = function once(event, fn, context) {
|
3309 | var listener = new EE(fn, context || this, true)
|
3310 | , evt = prefix ? prefix + event : event;
|
3311 |
|
3312 | if (!this._events) this._events = prefix ? {} : Object.create(null);
|
3313 | if (!this._events[evt]) this._events[evt] = listener;
|
3314 | else {
|
3315 | if (!this._events[evt].fn) this._events[evt].push(listener);
|
3316 | else this._events[evt] = [
|
3317 | this._events[evt], listener
|
3318 | ];
|
3319 | }
|
3320 |
|
3321 | return this;
|
3322 | };
|
3323 |
|
3324 | |
3325 |
|
3326 |
|
3327 |
|
3328 |
|
3329 |
|
3330 |
|
3331 |
|
3332 |
|
3333 | EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
3334 | var evt = prefix ? prefix + event : event;
|
3335 |
|
3336 | if (!this._events || !this._events[evt]) return this;
|
3337 |
|
3338 | var listeners = this._events[evt]
|
3339 | , events = [];
|
3340 |
|
3341 | if (fn) {
|
3342 | if (listeners.fn) {
|
3343 | if (
|
3344 | listeners.fn !== fn
|
3345 | || (once && !listeners.once)
|
3346 | || (context && listeners.context !== context)
|
3347 | ) {
|
3348 | events.push(listeners);
|
3349 | }
|
3350 | } else {
|
3351 | for (var i = 0, length = listeners.length; i < length; i++) {
|
3352 | if (
|
3353 | listeners[i].fn !== fn
|
3354 | || (once && !listeners[i].once)
|
3355 | || (context && listeners[i].context !== context)
|
3356 | ) {
|
3357 | events.push(listeners[i]);
|
3358 | }
|
3359 | }
|
3360 | }
|
3361 | }
|
3362 |
|
3363 |
|
3364 |
|
3365 |
|
3366 | if (events.length) {
|
3367 | this._events[evt] = events.length === 1 ? events[0] : events;
|
3368 | } else {
|
3369 | delete this._events[evt];
|
3370 | }
|
3371 |
|
3372 | return this;
|
3373 | };
|
3374 |
|
3375 | |
3376 |
|
3377 |
|
3378 |
|
3379 |
|
3380 |
|
3381 | EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
3382 | if (!this._events) return this;
|
3383 |
|
3384 | if (event) delete this._events[prefix ? prefix + event : event];
|
3385 | else this._events = prefix ? {} : Object.create(null);
|
3386 |
|
3387 | return this;
|
3388 | };
|
3389 |
|
3390 |
|
3391 |
|
3392 |
|
3393 | EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
3394 | EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
3395 |
|
3396 |
|
3397 |
|
3398 |
|
3399 | EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
|
3400 | return this;
|
3401 | };
|
3402 |
|
3403 |
|
3404 |
|
3405 |
|
3406 | EventEmitter.prefixed = prefix;
|
3407 |
|
3408 |
|
3409 |
|
3410 |
|
3411 | if (true) {
|
3412 | module.exports = EventEmitter;
|
3413 | }
|
3414 |
|
3415 |
|
3416 | }),
|
3417 |
|
3418 | (function(module, exports) {
|
3419 |
|
3420 | |
3421 |
|
3422 |
|
3423 |
|
3424 |
|
3425 |
|
3426 | 'use strict';
|
3427 |
|
3428 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
3429 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
3430 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
3431 |
|
3432 | function toObject(val) {
|
3433 | if (val === null || val === undefined) {
|
3434 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
3435 | }
|
3436 |
|
3437 | return Object(val);
|
3438 | }
|
3439 |
|
3440 | function shouldUseNative() {
|
3441 | try {
|
3442 | if (!Object.assign) {
|
3443 | return false;
|
3444 | }
|
3445 |
|
3446 |
|
3447 |
|
3448 |
|
3449 | var test1 = new String('abc');
|
3450 | test1[5] = 'de';
|
3451 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
3452 | return false;
|
3453 | }
|
3454 |
|
3455 |
|
3456 | var test2 = {};
|
3457 | for (var i = 0; i < 10; i++) {
|
3458 | test2['_' + String.fromCharCode(i)] = i;
|
3459 | }
|
3460 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
3461 | return test2[n];
|
3462 | });
|
3463 | if (order2.join('') !== '0123456789') {
|
3464 | return false;
|
3465 | }
|
3466 |
|
3467 |
|
3468 | var test3 = {};
|
3469 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
3470 | test3[letter] = letter;
|
3471 | });
|
3472 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
3473 | 'abcdefghijklmnopqrst') {
|
3474 | return false;
|
3475 | }
|
3476 |
|
3477 | return true;
|
3478 | } catch (err) {
|
3479 |
|
3480 | return false;
|
3481 | }
|
3482 | }
|
3483 |
|
3484 | module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
3485 | var from;
|
3486 | var to = toObject(target);
|
3487 | var symbols;
|
3488 |
|
3489 | for (var s = 1; s < arguments.length; s++) {
|
3490 | from = Object(arguments[s]);
|
3491 |
|
3492 | for (var key in from) {
|
3493 | if (hasOwnProperty.call(from, key)) {
|
3494 | to[key] = from[key];
|
3495 | }
|
3496 | }
|
3497 |
|
3498 | if (getOwnPropertySymbols) {
|
3499 | symbols = getOwnPropertySymbols(from);
|
3500 | for (var i = 0; i < symbols.length; i++) {
|
3501 | if (propIsEnumerable.call(from, symbols[i])) {
|
3502 | to[symbols[i]] = from[symbols[i]];
|
3503 | }
|
3504 | }
|
3505 | }
|
3506 | }
|
3507 |
|
3508 | return to;
|
3509 | };
|
3510 |
|
3511 |
|
3512 | }),
|
3513 |
|
3514 | (function(module, exports, __webpack_require__) {
|
3515 |
|
3516 | |
3517 |
|
3518 |
|
3519 |
|
3520 |
|
3521 |
|
3522 |
|
3523 | 'use strict';
|
3524 |
|
3525 | var printWarning = function() {};
|
3526 |
|
3527 | if (true) {
|
3528 | var ReactPropTypesSecret = __webpack_require__(10);
|
3529 | var loggedTypeFailures = {};
|
3530 |
|
3531 | printWarning = function(text) {
|
3532 | var message = 'Warning: ' + text;
|
3533 | if (typeof console !== 'undefined') {
|
3534 | console.error(message);
|
3535 | }
|
3536 | try {
|
3537 |
|
3538 |
|
3539 |
|
3540 | throw new Error(message);
|
3541 | } catch (x) {}
|
3542 | };
|
3543 | }
|
3544 |
|
3545 | |
3546 |
|
3547 |
|
3548 |
|
3549 |
|
3550 |
|
3551 |
|
3552 |
|
3553 |
|
3554 |
|
3555 |
|
3556 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
3557 | if (true) {
|
3558 | for (var typeSpecName in typeSpecs) {
|
3559 | if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
3560 | var error;
|
3561 |
|
3562 |
|
3563 |
|
3564 | try {
|
3565 |
|
3566 |
|
3567 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
3568 | var err = Error(
|
3569 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
3570 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
3571 | );
|
3572 | err.name = 'Invariant Violation';
|
3573 | throw err;
|
3574 | }
|
3575 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
3576 | } catch (ex) {
|
3577 | error = ex;
|
3578 | }
|
3579 | if (error && !(error instanceof Error)) {
|
3580 | printWarning(
|
3581 | (componentName || 'React class') + ': type specification of ' +
|
3582 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
3583 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
3584 | 'You may have forgotten to pass an argument to the type checker ' +
|
3585 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
3586 | 'shape all require an argument).'
|
3587 | )
|
3588 |
|
3589 | }
|
3590 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
3591 |
|
3592 |
|
3593 | loggedTypeFailures[error.message] = true;
|
3594 |
|
3595 | var stack = getStack ? getStack() : '';
|
3596 |
|
3597 | printWarning(
|
3598 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
3599 | );
|
3600 | }
|
3601 | }
|
3602 | }
|
3603 | }
|
3604 | }
|
3605 |
|
3606 | module.exports = checkPropTypes;
|
3607 |
|
3608 |
|
3609 | }),
|
3610 |
|
3611 | (function(module, exports, __webpack_require__) {
|
3612 |
|
3613 | |
3614 |
|
3615 |
|
3616 |
|
3617 |
|
3618 |
|
3619 |
|
3620 | 'use strict';
|
3621 |
|
3622 | var assign = __webpack_require__(29);
|
3623 |
|
3624 | var ReactPropTypesSecret = __webpack_require__(10);
|
3625 | var checkPropTypes = __webpack_require__(30);
|
3626 |
|
3627 | var printWarning = function() {};
|
3628 |
|
3629 | if (true) {
|
3630 | printWarning = function(text) {
|
3631 | var message = 'Warning: ' + text;
|
3632 | if (typeof console !== 'undefined') {
|
3633 | console.error(message);
|
3634 | }
|
3635 | try {
|
3636 |
|
3637 |
|
3638 |
|
3639 | throw new Error(message);
|
3640 | } catch (x) {}
|
3641 | };
|
3642 | }
|
3643 |
|
3644 | function emptyFunctionThatReturnsNull() {
|
3645 | return null;
|
3646 | }
|
3647 |
|
3648 | module.exports = function(isValidElement, throwOnDirectAccess) {
|
3649 |
|
3650 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
3651 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
3652 |
|
3653 | |
3654 |
|
3655 |
|
3656 |
|
3657 |
|
3658 |
|
3659 |
|
3660 |
|
3661 |
|
3662 |
|
3663 |
|
3664 |
|
3665 |
|
3666 |
|
3667 | function getIteratorFn(maybeIterable) {
|
3668 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
3669 | if (typeof iteratorFn === 'function') {
|
3670 | return iteratorFn;
|
3671 | }
|
3672 | }
|
3673 |
|
3674 | |
3675 |
|
3676 |
|
3677 |
|
3678 |
|
3679 |
|
3680 |
|
3681 |
|
3682 |
|
3683 |
|
3684 |
|
3685 |
|
3686 |
|
3687 |
|
3688 |
|
3689 |
|
3690 |
|
3691 |
|
3692 |
|
3693 |
|
3694 |
|
3695 |
|
3696 |
|
3697 |
|
3698 |
|
3699 |
|
3700 |
|
3701 |
|
3702 |
|
3703 |
|
3704 |
|
3705 |
|
3706 |
|
3707 |
|
3708 |
|
3709 |
|
3710 |
|
3711 |
|
3712 |
|
3713 |
|
3714 |
|
3715 |
|
3716 |
|
3717 |
|
3718 |
|
3719 |
|
3720 |
|
3721 | var ANONYMOUS = '<<anonymous>>';
|
3722 |
|
3723 |
|
3724 |
|
3725 | var ReactPropTypes = {
|
3726 | array: createPrimitiveTypeChecker('array'),
|
3727 | bool: createPrimitiveTypeChecker('boolean'),
|
3728 | func: createPrimitiveTypeChecker('function'),
|
3729 | number: createPrimitiveTypeChecker('number'),
|
3730 | object: createPrimitiveTypeChecker('object'),
|
3731 | string: createPrimitiveTypeChecker('string'),
|
3732 | symbol: createPrimitiveTypeChecker('symbol'),
|
3733 |
|
3734 | any: createAnyTypeChecker(),
|
3735 | arrayOf: createArrayOfTypeChecker,
|
3736 | element: createElementTypeChecker(),
|
3737 | instanceOf: createInstanceTypeChecker,
|
3738 | node: createNodeChecker(),
|
3739 | objectOf: createObjectOfTypeChecker,
|
3740 | oneOf: createEnumTypeChecker,
|
3741 | oneOfType: createUnionTypeChecker,
|
3742 | shape: createShapeTypeChecker,
|
3743 | exact: createStrictShapeTypeChecker,
|
3744 | };
|
3745 |
|
3746 | |
3747 |
|
3748 |
|
3749 |
|
3750 |
|
3751 | function is(x, y) {
|
3752 |
|
3753 | if (x === y) {
|
3754 |
|
3755 |
|
3756 | return x !== 0 || 1 / x === 1 / y;
|
3757 | } else {
|
3758 |
|
3759 | return x !== x && y !== y;
|
3760 | }
|
3761 | }
|
3762 |
|
3763 |
|
3764 | |
3765 |
|
3766 |
|
3767 |
|
3768 |
|
3769 |
|
3770 |
|
3771 | function PropTypeError(message) {
|
3772 | this.message = message;
|
3773 | this.stack = '';
|
3774 | }
|
3775 |
|
3776 | PropTypeError.prototype = Error.prototype;
|
3777 |
|
3778 | function createChainableTypeChecker(validate) {
|
3779 | if (true) {
|
3780 | var manualPropTypeCallCache = {};
|
3781 | var manualPropTypeWarningCount = 0;
|
3782 | }
|
3783 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
3784 | componentName = componentName || ANONYMOUS;
|
3785 | propFullName = propFullName || propName;
|
3786 |
|
3787 | if (secret !== ReactPropTypesSecret) {
|
3788 | if (throwOnDirectAccess) {
|
3789 |
|
3790 | var err = new Error(
|
3791 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
3792 | 'Use `PropTypes.checkPropTypes()` to call them. ' +
|
3793 | 'Read more at http://fb.me/use-check-prop-types'
|
3794 | );
|
3795 | err.name = 'Invariant Violation';
|
3796 | throw err;
|
3797 | } else if (("development") !== 'production' && typeof console !== 'undefined') {
|
3798 |
|
3799 | var cacheKey = componentName + ':' + propName;
|
3800 | if (
|
3801 | !manualPropTypeCallCache[cacheKey] &&
|
3802 |
|
3803 | manualPropTypeWarningCount < 3
|
3804 | ) {
|
3805 | printWarning(
|
3806 | 'You are manually calling a React.PropTypes validation ' +
|
3807 | 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
3808 | 'and will throw in the standalone `prop-types` package. ' +
|
3809 | 'You may be seeing this warning due to a third-party PropTypes ' +
|
3810 | 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
3811 | );
|
3812 | manualPropTypeCallCache[cacheKey] = true;
|
3813 | manualPropTypeWarningCount++;
|
3814 | }
|
3815 | }
|
3816 | }
|
3817 | if (props[propName] == null) {
|
3818 | if (isRequired) {
|
3819 | if (props[propName] === null) {
|
3820 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
3821 | }
|
3822 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
3823 | }
|
3824 | return null;
|
3825 | } else {
|
3826 | return validate(props, propName, componentName, location, propFullName);
|
3827 | }
|
3828 | }
|
3829 |
|
3830 | var chainedCheckType = checkType.bind(null, false);
|
3831 | chainedCheckType.isRequired = checkType.bind(null, true);
|
3832 |
|
3833 | return chainedCheckType;
|
3834 | }
|
3835 |
|
3836 | function createPrimitiveTypeChecker(expectedType) {
|
3837 | function validate(props, propName, componentName, location, propFullName, secret) {
|
3838 | var propValue = props[propName];
|
3839 | var propType = getPropType(propValue);
|
3840 | if (propType !== expectedType) {
|
3841 |
|
3842 |
|
3843 |
|
3844 | var preciseType = getPreciseType(propValue);
|
3845 |
|
3846 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
3847 | }
|
3848 | return null;
|
3849 | }
|
3850 | return createChainableTypeChecker(validate);
|
3851 | }
|
3852 |
|
3853 | function createAnyTypeChecker() {
|
3854 | return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
3855 | }
|
3856 |
|
3857 | function createArrayOfTypeChecker(typeChecker) {
|
3858 | function validate(props, propName, componentName, location, propFullName) {
|
3859 | if (typeof typeChecker !== 'function') {
|
3860 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
3861 | }
|
3862 | var propValue = props[propName];
|
3863 | if (!Array.isArray(propValue)) {
|
3864 | var propType = getPropType(propValue);
|
3865 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
3866 | }
|
3867 | for (var i = 0; i < propValue.length; i++) {
|
3868 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
3869 | if (error instanceof Error) {
|
3870 | return error;
|
3871 | }
|
3872 | }
|
3873 | return null;
|
3874 | }
|
3875 | return createChainableTypeChecker(validate);
|
3876 | }
|
3877 |
|
3878 | function createElementTypeChecker() {
|
3879 | function validate(props, propName, componentName, location, propFullName) {
|
3880 | var propValue = props[propName];
|
3881 | if (!isValidElement(propValue)) {
|
3882 | var propType = getPropType(propValue);
|
3883 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
3884 | }
|
3885 | return null;
|
3886 | }
|
3887 | return createChainableTypeChecker(validate);
|
3888 | }
|
3889 |
|
3890 | function createInstanceTypeChecker(expectedClass) {
|
3891 | function validate(props, propName, componentName, location, propFullName) {
|
3892 | if (!(props[propName] instanceof expectedClass)) {
|
3893 | var expectedClassName = expectedClass.name || ANONYMOUS;
|
3894 | var actualClassName = getClassName(props[propName]);
|
3895 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
3896 | }
|
3897 | return null;
|
3898 | }
|
3899 | return createChainableTypeChecker(validate);
|
3900 | }
|
3901 |
|
3902 | function createEnumTypeChecker(expectedValues) {
|
3903 | if (!Array.isArray(expectedValues)) {
|
3904 | true ? printWarning('Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
|
3905 | return emptyFunctionThatReturnsNull;
|
3906 | }
|
3907 |
|
3908 | function validate(props, propName, componentName, location, propFullName) {
|
3909 | var propValue = props[propName];
|
3910 | for (var i = 0; i < expectedValues.length; i++) {
|
3911 | if (is(propValue, expectedValues[i])) {
|
3912 | return null;
|
3913 | }
|
3914 | }
|
3915 |
|
3916 | var valuesString = JSON.stringify(expectedValues);
|
3917 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
3918 | }
|
3919 | return createChainableTypeChecker(validate);
|
3920 | }
|
3921 |
|
3922 | function createObjectOfTypeChecker(typeChecker) {
|
3923 | function validate(props, propName, componentName, location, propFullName) {
|
3924 | if (typeof typeChecker !== 'function') {
|
3925 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
3926 | }
|
3927 | var propValue = props[propName];
|
3928 | var propType = getPropType(propValue);
|
3929 | if (propType !== 'object') {
|
3930 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
3931 | }
|
3932 | for (var key in propValue) {
|
3933 | if (propValue.hasOwnProperty(key)) {
|
3934 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
3935 | if (error instanceof Error) {
|
3936 | return error;
|
3937 | }
|
3938 | }
|
3939 | }
|
3940 | return null;
|
3941 | }
|
3942 | return createChainableTypeChecker(validate);
|
3943 | }
|
3944 |
|
3945 | function createUnionTypeChecker(arrayOfTypeCheckers) {
|
3946 | if (!Array.isArray(arrayOfTypeCheckers)) {
|
3947 | true ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
3948 | return emptyFunctionThatReturnsNull;
|
3949 | }
|
3950 |
|
3951 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
3952 | var checker = arrayOfTypeCheckers[i];
|
3953 | if (typeof checker !== 'function') {
|
3954 | printWarning(
|
3955 | 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
3956 | 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
3957 | );
|
3958 | return emptyFunctionThatReturnsNull;
|
3959 | }
|
3960 | }
|
3961 |
|
3962 | function validate(props, propName, componentName, location, propFullName) {
|
3963 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
3964 | var checker = arrayOfTypeCheckers[i];
|
3965 | if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
|
3966 | return null;
|
3967 | }
|
3968 | }
|
3969 |
|
3970 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
3971 | }
|
3972 | return createChainableTypeChecker(validate);
|
3973 | }
|
3974 |
|
3975 | function createNodeChecker() {
|
3976 | function validate(props, propName, componentName, location, propFullName) {
|
3977 | if (!isNode(props[propName])) {
|
3978 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
3979 | }
|
3980 | return null;
|
3981 | }
|
3982 | return createChainableTypeChecker(validate);
|
3983 | }
|
3984 |
|
3985 | function createShapeTypeChecker(shapeTypes) {
|
3986 | function validate(props, propName, componentName, location, propFullName) {
|
3987 | var propValue = props[propName];
|
3988 | var propType = getPropType(propValue);
|
3989 | if (propType !== 'object') {
|
3990 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
3991 | }
|
3992 | for (var key in shapeTypes) {
|
3993 | var checker = shapeTypes[key];
|
3994 | if (!checker) {
|
3995 | continue;
|
3996 | }
|
3997 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
3998 | if (error) {
|
3999 | return error;
|
4000 | }
|
4001 | }
|
4002 | return null;
|
4003 | }
|
4004 | return createChainableTypeChecker(validate);
|
4005 | }
|
4006 |
|
4007 | function createStrictShapeTypeChecker(shapeTypes) {
|
4008 | function validate(props, propName, componentName, location, propFullName) {
|
4009 | var propValue = props[propName];
|
4010 | var propType = getPropType(propValue);
|
4011 | if (propType !== 'object') {
|
4012 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
4013 | }
|
4014 |
|
4015 |
|
4016 | var allKeys = assign({}, props[propName], shapeTypes);
|
4017 | for (var key in allKeys) {
|
4018 | var checker = shapeTypes[key];
|
4019 | if (!checker) {
|
4020 | return new PropTypeError(
|
4021 | 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
4022 | '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
4023 | '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
4024 | );
|
4025 | }
|
4026 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
4027 | if (error) {
|
4028 | return error;
|
4029 | }
|
4030 | }
|
4031 | return null;
|
4032 | }
|
4033 |
|
4034 | return createChainableTypeChecker(validate);
|
4035 | }
|
4036 |
|
4037 | function isNode(propValue) {
|
4038 | switch (typeof propValue) {
|
4039 | case 'number':
|
4040 | case 'string':
|
4041 | case 'undefined':
|
4042 | return true;
|
4043 | case 'boolean':
|
4044 | return !propValue;
|
4045 | case 'object':
|
4046 | if (Array.isArray(propValue)) {
|
4047 | return propValue.every(isNode);
|
4048 | }
|
4049 | if (propValue === null || isValidElement(propValue)) {
|
4050 | return true;
|
4051 | }
|
4052 |
|
4053 | var iteratorFn = getIteratorFn(propValue);
|
4054 | if (iteratorFn) {
|
4055 | var iterator = iteratorFn.call(propValue);
|
4056 | var step;
|
4057 | if (iteratorFn !== propValue.entries) {
|
4058 | while (!(step = iterator.next()).done) {
|
4059 | if (!isNode(step.value)) {
|
4060 | return false;
|
4061 | }
|
4062 | }
|
4063 | } else {
|
4064 |
|
4065 | while (!(step = iterator.next()).done) {
|
4066 | var entry = step.value;
|
4067 | if (entry) {
|
4068 | if (!isNode(entry[1])) {
|
4069 | return false;
|
4070 | }
|
4071 | }
|
4072 | }
|
4073 | }
|
4074 | } else {
|
4075 | return false;
|
4076 | }
|
4077 |
|
4078 | return true;
|
4079 | default:
|
4080 | return false;
|
4081 | }
|
4082 | }
|
4083 |
|
4084 | function isSymbol(propType, propValue) {
|
4085 |
|
4086 | if (propType === 'symbol') {
|
4087 | return true;
|
4088 | }
|
4089 |
|
4090 |
|
4091 | if (propValue['@@toStringTag'] === 'Symbol') {
|
4092 | return true;
|
4093 | }
|
4094 |
|
4095 |
|
4096 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
4097 | return true;
|
4098 | }
|
4099 |
|
4100 | return false;
|
4101 | }
|
4102 |
|
4103 |
|
4104 | function getPropType(propValue) {
|
4105 | var propType = typeof propValue;
|
4106 | if (Array.isArray(propValue)) {
|
4107 | return 'array';
|
4108 | }
|
4109 | if (propValue instanceof RegExp) {
|
4110 |
|
4111 |
|
4112 |
|
4113 | return 'object';
|
4114 | }
|
4115 | if (isSymbol(propType, propValue)) {
|
4116 | return 'symbol';
|
4117 | }
|
4118 | return propType;
|
4119 | }
|
4120 |
|
4121 |
|
4122 |
|
4123 | function getPreciseType(propValue) {
|
4124 | if (typeof propValue === 'undefined' || propValue === null) {
|
4125 | return '' + propValue;
|
4126 | }
|
4127 | var propType = getPropType(propValue);
|
4128 | if (propType === 'object') {
|
4129 | if (propValue instanceof Date) {
|
4130 | return 'date';
|
4131 | } else if (propValue instanceof RegExp) {
|
4132 | return 'regexp';
|
4133 | }
|
4134 | }
|
4135 | return propType;
|
4136 | }
|
4137 |
|
4138 |
|
4139 |
|
4140 | function getPostfixForTypeWarning(value) {
|
4141 | var type = getPreciseType(value);
|
4142 | switch (type) {
|
4143 | case 'array':
|
4144 | case 'object':
|
4145 | return 'an ' + type;
|
4146 | case 'boolean':
|
4147 | case 'date':
|
4148 | case 'regexp':
|
4149 | return 'a ' + type;
|
4150 | default:
|
4151 | return type;
|
4152 | }
|
4153 | }
|
4154 |
|
4155 |
|
4156 | function getClassName(propValue) {
|
4157 | if (!propValue.constructor || !propValue.constructor.name) {
|
4158 | return ANONYMOUS;
|
4159 | }
|
4160 | return propValue.constructor.name;
|
4161 | }
|
4162 |
|
4163 | ReactPropTypes.checkPropTypes = checkPropTypes;
|
4164 | ReactPropTypes.PropTypes = ReactPropTypes;
|
4165 |
|
4166 | return ReactPropTypes;
|
4167 | };
|
4168 |
|
4169 |
|
4170 | }),
|
4171 |
|
4172 | (function(module, exports, __webpack_require__) {
|
4173 |
|
4174 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__; |
4175 |
|
4176 |
|
4177 |
|
4178 |
|
4179 |
|
4180 | (function (name, definition) {
|
4181 | if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
4182 | else if (true) !(__WEBPACK_AMD_DEFINE_FACTORY__ = (definition), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))
|
4183 | else this[name] = definition()
|
4184 | })('$script', function () {
|
4185 | var doc = document
|
4186 | , head = doc.getElementsByTagName('head')[0]
|
4187 | , s = 'string'
|
4188 | , f = false
|
4189 | , push = 'push'
|
4190 | , readyState = 'readyState'
|
4191 | , onreadystatechange = 'onreadystatechange'
|
4192 | , list = {}
|
4193 | , ids = {}
|
4194 | , delay = {}
|
4195 | , scripts = {}
|
4196 | , scriptpath
|
4197 | , urlArgs
|
4198 |
|
4199 | function every(ar, fn) {
|
4200 | for (var i = 0, j = ar.length; i < j; ++i) if (!fn(ar[i])) return f
|
4201 | return 1
|
4202 | }
|
4203 | function each(ar, fn) {
|
4204 | every(ar, function (el) {
|
4205 | return !fn(el)
|
4206 | })
|
4207 | }
|
4208 |
|
4209 | function $script(paths, idOrDone, optDone) {
|
4210 | paths = paths[push] ? paths : [paths]
|
4211 | var idOrDoneIsDone = idOrDone && idOrDone.call
|
4212 | , done = idOrDoneIsDone ? idOrDone : optDone
|
4213 | , id = idOrDoneIsDone ? paths.join('') : idOrDone
|
4214 | , queue = paths.length
|
4215 | function loopFn(item) {
|
4216 | return item.call ? item() : list[item]
|
4217 | }
|
4218 | function callback() {
|
4219 | if (!--queue) {
|
4220 | list[id] = 1
|
4221 | done && done()
|
4222 | for (var dset in delay) {
|
4223 | every(dset.split('|'), loopFn) && !each(delay[dset], loopFn) && (delay[dset] = [])
|
4224 | }
|
4225 | }
|
4226 | }
|
4227 | setTimeout(function () {
|
4228 | each(paths, function loading(path, force) {
|
4229 | if (path === null) return callback()
|
4230 |
|
4231 | if (!force && !/^https?:\/\//.test(path) && scriptpath) {
|
4232 | path = (path.indexOf('.js') === -1) ? scriptpath + path + '.js' : scriptpath + path;
|
4233 | }
|
4234 |
|
4235 | if (scripts[path]) {
|
4236 | if (id) ids[id] = 1
|
4237 | return (scripts[path] == 2) ? callback() : setTimeout(function () { loading(path, true) }, 0)
|
4238 | }
|
4239 |
|
4240 | scripts[path] = 1
|
4241 | if (id) ids[id] = 1
|
4242 | create(path, callback)
|
4243 | })
|
4244 | }, 0)
|
4245 | return $script
|
4246 | }
|
4247 |
|
4248 | function create(path, fn) {
|
4249 | var el = doc.createElement('script'), loaded
|
4250 | el.onload = el.onerror = el[onreadystatechange] = function () {
|
4251 | if ((el[readyState] && !(/^c|loade/.test(el[readyState]))) || loaded) return;
|
4252 | el.onload = el[onreadystatechange] = null
|
4253 | loaded = 1
|
4254 | scripts[path] = 2
|
4255 | fn()
|
4256 | }
|
4257 | el.async = 1
|
4258 | el.src = urlArgs ? path + (path.indexOf('?') === -1 ? '?' : '&') + urlArgs : path;
|
4259 | head.insertBefore(el, head.lastChild)
|
4260 | }
|
4261 |
|
4262 | $script.get = create
|
4263 |
|
4264 | $script.order = function (scripts, id, done) {
|
4265 | (function callback(s) {
|
4266 | s = scripts.shift()
|
4267 | !scripts.length ? $script(s, id, done) : $script(s, callback)
|
4268 | }())
|
4269 | }
|
4270 |
|
4271 | $script.path = function (p) {
|
4272 | scriptpath = p
|
4273 | }
|
4274 | $script.urlArgs = function (str) {
|
4275 | urlArgs = str;
|
4276 | }
|
4277 | $script.ready = function (deps, ready, req) {
|
4278 | deps = deps[push] ? deps : [deps]
|
4279 | var missing = [];
|
4280 | !each(deps, function (dep) {
|
4281 | list[dep] || missing[push](dep);
|
4282 | }) && every(deps, function (dep) {return list[dep]}) ?
|
4283 | ready() : !function (key) {
|
4284 | delay[key] = delay[key] || []
|
4285 | delay[key][push](ready)
|
4286 | req && req(missing)
|
4287 | }(deps.join('|'))
|
4288 | return $script
|
4289 | }
|
4290 |
|
4291 | $script.done = function (idOrDone) {
|
4292 | $script([null], idOrDone)
|
4293 | }
|
4294 |
|
4295 | return $script
|
4296 | });
|
4297 |
|
4298 |
|
4299 | }),
|
4300 |
|
4301 | (function(module, exports) {
|
4302 |
|
4303 | module.exports = __WEBPACK_EXTERNAL_MODULE_33__;
|
4304 |
|
4305 | })
|
4306 | ])
|
4307 | });
|
4308 | ; |
\ | No newline at end of file |