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 |
|
1134 | function defaultOptions_() /* maps */{
|
1135 | return {
|
1136 | overviewMapControl: false,
|
1137 | streetViewControl: false,
|
1138 | rotateControl: true,
|
1139 | mapTypeControl: false,
|
1140 |
|
1141 | styles: [{
|
1142 | featureType: 'poi',
|
1143 | elementType: 'labels',
|
1144 | stylers: [{ visibility: 'off' }]
|
1145 | }],
|
1146 | minZoom: DEFAULT_MIN_ZOOM
|
1147 | };
|
1148 | }
|
1149 |
|
1150 | var latLng2Obj = function latLng2Obj(latLng) {
|
1151 | return (0, _isPlainObject2.default)(latLng) ? latLng : { lat: latLng[0], lng: latLng[1] };
|
1152 | };
|
1153 |
|
1154 | var _checkMinZoom = function _checkMinZoom(zoom, minZoom) {
|
1155 | if (true) {
|
1156 | if (zoom < minZoom) {
|
1157 | console.warn('GoogleMap: ' +
|
1158 | 'minZoom option is less than recommended ' + 'minZoom option for your map sizes.\n' + 'overrided to value ' + minZoom);
|
1159 | }
|
1160 | }
|
1161 |
|
1162 | if (minZoom < zoom) {
|
1163 | return zoom;
|
1164 | }
|
1165 | return minZoom;
|
1166 | };
|
1167 |
|
1168 | var isFullScreen = function isFullScreen() {
|
1169 | return document.fullscreen || document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement;
|
1170 | };
|
1171 |
|
1172 | var GoogleMap = function (_Component) {
|
1173 | _inherits(GoogleMap, _Component);
|
1174 |
|
1175 |
|
1176 |
|
1177 | function GoogleMap(props) {
|
1178 | _classCallCheck(this, GoogleMap);
|
1179 |
|
1180 | var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
1181 |
|
1182 | _this._getMinZoom = function () {
|
1183 | if (_this.geoService_.getWidth() > 0 || _this.geoService_.getHeight() > 0) {
|
1184 | var tilesPerWidth = Math.ceil(_this.geoService_.getWidth() / K_GOOGLE_TILE_SIZE) + 2;
|
1185 | var tilesPerHeight = Math.ceil(_this.geoService_.getHeight() / K_GOOGLE_TILE_SIZE) + 2;
|
1186 | var maxTilesPerDim = Math.max(tilesPerWidth, tilesPerHeight);
|
1187 | return Math.ceil((0, _log2.default)(maxTilesPerDim));
|
1188 | }
|
1189 | return DEFAULT_MIN_ZOOM;
|
1190 | };
|
1191 |
|
1192 | _this._computeMinZoom = function (minZoom) {
|
1193 | if (!(0, _isEmpty2.default)(minZoom)) {
|
1194 | return minZoom;
|
1195 | }
|
1196 | return _this._getMinZoom();
|
1197 | };
|
1198 |
|
1199 | _this._mapDomResizeCallback = function () {
|
1200 | _this.resetSizeOnIdle_ = true;
|
1201 | if (_this.maps_) {
|
1202 | var originalCenter = _this.props.center || _this.props.defaultCenter;
|
1203 | var currentCenter = _this.map_.getCenter();
|
1204 | _this.maps_.event.trigger(_this.map_, 'resize');
|
1205 | _this.map_.setCenter(_this.props.resetBoundsOnResize ? originalCenter : currentCenter);
|
1206 | }
|
1207 | };
|
1208 |
|
1209 | _this._setLayers = function (layerTypes) {
|
1210 | layerTypes.forEach(function (layerType) {
|
1211 | _this.layers_[layerType] = new _this.maps_[layerType]();
|
1212 | _this.layers_[layerType].setMap(_this.map_);
|
1213 | });
|
1214 | };
|
1215 |
|
1216 | _this._initMap = function () {
|
1217 |
|
1218 | if (_this.initialized_) {
|
1219 | return;
|
1220 | }
|
1221 | _this.initialized_ = true;
|
1222 |
|
1223 | var propsCenter = latLng2Obj(_this.props.center || _this.props.defaultCenter);
|
1224 | _this.geoService_.setView(propsCenter, _this.props.zoom || _this.props.defaultZoom, 0);
|
1225 |
|
1226 | _this._onBoundsChanged();
|
1227 |
|
1228 | var bootstrapURLKeys = _extends({}, _this.props.apiKey && { key: _this.props.apiKey }, _this.props.bootstrapURLKeys);
|
1229 |
|
1230 | _this.props.googleMapLoader(bootstrapURLKeys, _this.props.heatmapLibrary).then(function (maps) {
|
1231 | if (!_this.mounted_) {
|
1232 | return;
|
1233 | }
|
1234 |
|
1235 | var centerLatLng = _this.geoService_.getCenter();
|
1236 |
|
1237 | var propsOptions = {
|
1238 | zoom: _this.props.zoom || _this.props.defaultZoom,
|
1239 | center: new maps.LatLng(centerLatLng.lat, centerLatLng.lng)
|
1240 | };
|
1241 |
|
1242 |
|
1243 | if (_this.props.heatmap.positions) {
|
1244 | Object.assign(_this, {
|
1245 | heatmap: (0, _google_heatmap.generateHeatmap)(maps, _this.props.heatmap)
|
1246 | });
|
1247 | (0, _google_heatmap.optionsHeatmap)(_this.heatmap, _this.props.heatmap);
|
1248 | }
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 | var mapPlainObjects = (0, _pick2.default)(maps, _isPlainObject2.default);
|
1263 | var options = typeof _this.props.options === 'function' ? _this.props.options(mapPlainObjects) : _this.props.options;
|
1264 | var defaultOptions = defaultOptions_(mapPlainObjects);
|
1265 |
|
1266 | var draggableOptions = !(0, _isEmpty2.default)(_this.props.draggable) && {
|
1267 | draggable: _this.props.draggable
|
1268 | };
|
1269 |
|
1270 | var minZoom = _this._computeMinZoom(options.minZoom);
|
1271 | _this.minZoom_ = minZoom;
|
1272 |
|
1273 | var preMapOptions = _extends({}, defaultOptions, {
|
1274 | minZoom: minZoom
|
1275 | }, options, propsOptions);
|
1276 |
|
1277 | _this.defaultDraggableOption_ = !(0, _isEmpty2.default)(preMapOptions.draggable) ? preMapOptions.draggable : _this.defaultDraggableOption_;
|
1278 |
|
1279 | var mapOptions = _extends({}, preMapOptions, draggableOptions);
|
1280 |
|
1281 | mapOptions.minZoom = _checkMinZoom(mapOptions.minZoom, minZoom);
|
1282 |
|
1283 | var map = new maps.Map(_reactDom2.default.findDOMNode(_this.googleMapDom_), mapOptions);
|
1284 |
|
1285 | _this.map_ = map;
|
1286 | _this.maps_ = maps;
|
1287 |
|
1288 | _this._setLayers(_this.props.layerTypes);
|
1289 |
|
1290 |
|
1291 | var versionMatch = maps.version.match(/^3\.(\d+)\./);
|
1292 |
|
1293 | var mapsVersion = versionMatch && Number(versionMatch[1]);
|
1294 |
|
1295 |
|
1296 | var this_ = _this;
|
1297 | var overlay = Object.assign(new maps.OverlayView(), {
|
1298 | onAdd: function onAdd() {
|
1299 | var K_MAX_WIDTH = typeof screen !== 'undefined' ? screen.width + 'px' : '2000px';
|
1300 | var K_MAX_HEIGHT = typeof screen !== 'undefined' ? screen.height + 'px' : '2000px';
|
1301 |
|
1302 | var div = document.createElement('div');
|
1303 | this.div = div;
|
1304 | div.style.backgroundColor = 'transparent';
|
1305 | div.style.position = 'absolute';
|
1306 | div.style.left = '0px';
|
1307 | div.style.top = '0px';
|
1308 | div.style.width = K_MAX_WIDTH;
|
1309 | div.style.height = K_MAX_HEIGHT;
|
1310 |
|
1311 | if (this_.props.overlayViewDivStyle) {
|
1312 | var overlayViewDivStyle = this_.props.overlayViewDivStyle;
|
1313 |
|
1314 | if ((typeof overlayViewDivStyle === 'undefined' ? 'undefined' : _typeof(overlayViewDivStyle)) === 'object') {
|
1315 | Object.keys(overlayViewDivStyle).forEach(function (property) {
|
1316 | div.style[property] = overlayViewDivStyle[property];
|
1317 | });
|
1318 | }
|
1319 | }
|
1320 |
|
1321 | var panes = this.getPanes();
|
1322 | panes.overlayMouseTarget.appendChild(div);
|
1323 | this_.geoService_.setMapCanvasProjection(maps, overlay.getProjection());
|
1324 | _reactDom2.default.unstable_renderSubtreeIntoContainer(this_, _react2.default.createElement(_google_map_markers2.default, {
|
1325 | experimental: this_.props.experimental,
|
1326 | onChildClick: this_._onChildClick,
|
1327 | onChildMouseDown: this_._onChildMouseDown,
|
1328 | onChildMouseEnter: this_._onChildMouseEnter,
|
1329 | onChildMouseLeave: this_._onChildMouseLeave,
|
1330 | geoService: this_.geoService_,
|
1331 | insideMapPanes: true,
|
1332 | distanceToMouse: this_.props.distanceToMouse,
|
1333 | getHoverDistance: this_._getHoverDistance,
|
1334 | dispatcher: this_.markersDispatcher_
|
1335 | }), div,
|
1336 |
|
1337 | function () {
|
1338 | return this_.setState({ overlayCreated: true });
|
1339 | });
|
1340 | },
|
1341 | onRemove: function onRemove() {
|
1342 | if (this.div) {
|
1343 | _reactDom2.default.unmountComponentAtNode(this.div);
|
1344 | }
|
1345 | },
|
1346 | draw: function draw() {
|
1347 | this_.updateCounter_++;
|
1348 | this_._onBoundsChanged(map, maps, !this_.props.debounced);
|
1349 |
|
1350 | if (!this_.googleApiLoadedCalled_) {
|
1351 | this_._onGoogleApiLoaded({ map: map, maps: maps });
|
1352 | this_.googleApiLoadedCalled_ = true;
|
1353 | }
|
1354 |
|
1355 | if (this_.mouse_) {
|
1356 | var latLng = this_.geoService_.fromContainerPixelToLatLng(this_.mouse_);
|
1357 | this_.mouse_.lat = latLng.lat;
|
1358 | this_.mouse_.lng = latLng.lng;
|
1359 | }
|
1360 |
|
1361 | this_._onChildMouseMove();
|
1362 |
|
1363 | if (this_.markersDispatcher_) {
|
1364 | this_.markersDispatcher_.emit('kON_CHANGE');
|
1365 | if (this_.fireMouseEventOnIdle_) {
|
1366 | this_.markersDispatcher_.emit('kON_MOUSE_POSITION_CHANGE');
|
1367 | }
|
1368 | }
|
1369 | }
|
1370 | });
|
1371 |
|
1372 | _this.overlay_ = overlay;
|
1373 |
|
1374 | overlay.setMap(map);
|
1375 | if (_this.props.heatmap.positions) {
|
1376 | _this.heatmap.setMap(map);
|
1377 | }
|
1378 |
|
1379 | if (_this.props.onTilesLoaded) {
|
1380 | maps.event.addListener(map, 'tilesloaded', function () {
|
1381 | this_._onTilesLoaded();
|
1382 | });
|
1383 | }
|
1384 |
|
1385 | maps.event.addListener(map, 'zoom_changed', function () {
|
1386 |
|
1387 | if (this_.geoService_.getZoom() !== map.getZoom()) {
|
1388 | if (!this_.zoomAnimationInProgress_) {
|
1389 | this_.zoomAnimationInProgress_ = true;
|
1390 | this_._onZoomAnimationStart();
|
1391 | }
|
1392 |
|
1393 |
|
1394 |
|
1395 | if (mapsVersion < DRAW_CALLED_DURING_ANIMATION_VERSION) {
|
1396 | var TIMEOUT_ZOOM = 300;
|
1397 |
|
1398 | if (new Date().getTime() - _this.zoomControlClickTime_ < TIMEOUT_ZOOM) {
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 | (0, _raf2.default)(function () {
|
1406 | return (0, _raf2.default)(function () {
|
1407 | this_.updateCounter_++;
|
1408 | this_._onBoundsChanged(map, maps);
|
1409 | });
|
1410 | });
|
1411 | } else {
|
1412 | this_.updateCounter_++;
|
1413 | this_._onBoundsChanged(map, maps);
|
1414 | }
|
1415 | }
|
1416 | }
|
1417 | });
|
1418 |
|
1419 | maps.event.addListener(map, 'idle', function () {
|
1420 | if (_this.resetSizeOnIdle_) {
|
1421 | _this._setViewSize();
|
1422 | var currMinZoom = _this._computeMinZoom(_this.props.options.minZoom);
|
1423 |
|
1424 | if (currMinZoom !== _this.minZoom_) {
|
1425 | _this.minZoom_ = currMinZoom;
|
1426 | map.setOptions({ minZoom: currMinZoom });
|
1427 | }
|
1428 |
|
1429 | _this.resetSizeOnIdle_ = false;
|
1430 | }
|
1431 |
|
1432 | if (this_.zoomAnimationInProgress_) {
|
1433 | this_.zoomAnimationInProgress_ = false;
|
1434 | this_._onZoomAnimationEnd();
|
1435 | }
|
1436 |
|
1437 | this_.updateCounter_++;
|
1438 | this_._onBoundsChanged(map, maps);
|
1439 |
|
1440 | this_.dragTime_ = 0;
|
1441 |
|
1442 | if (this_.markersDispatcher_) {
|
1443 | this_.markersDispatcher_.emit('kON_CHANGE');
|
1444 | }
|
1445 | });
|
1446 |
|
1447 | maps.event.addListener(map, 'mouseover', function () {
|
1448 |
|
1449 | this_.mouseInMap_ = true;
|
1450 | });
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 | maps.event.addListener(map, 'click', function () {
|
1457 | this_.mouseInMap_ = true;
|
1458 | });
|
1459 |
|
1460 | maps.event.addListener(map, 'mouseout', function () {
|
1461 |
|
1462 | this_.mouseInMap_ = false;
|
1463 | this_.mouse_ = null;
|
1464 | this_.markersDispatcher_.emit('kON_MOUSE_POSITION_CHANGE');
|
1465 | });
|
1466 |
|
1467 | maps.event.addListener(map, 'drag', function () {
|
1468 | this_.dragTime_ = new Date().getTime();
|
1469 | this_._onDrag(map);
|
1470 | });
|
1471 |
|
1472 | maps.event.addListener(map, 'maptypeid_changed', function () {
|
1473 | this_._onMapTypeIdChange(map.getMapTypeId());
|
1474 | });
|
1475 | }).catch(function (e) {
|
1476 |
|
1477 | _this._onGoogleApiLoaded({ map: null, maps: null });
|
1478 | console.error(e);
|
1479 | throw e;
|
1480 | });
|
1481 | };
|
1482 |
|
1483 | _this._onGoogleApiLoaded = function () {
|
1484 | if (_this.props.onGoogleApiLoaded) {
|
1485 | var _this$props;
|
1486 |
|
1487 | if (("development") !== 'production' && _this.props.yesIWantToUseGoogleMapApiInternals !== true) {
|
1488 | console.warn('GoogleMap: ' +
|
1489 | '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');
|
1490 | }
|
1491 |
|
1492 | (_this$props = _this.props).onGoogleApiLoaded.apply(_this$props, arguments);
|
1493 | }
|
1494 | };
|
1495 |
|
1496 | _this._getHoverDistance = function () {
|
1497 | return _this.props.hoverDistance;
|
1498 | };
|
1499 |
|
1500 | _this._onDrag = function () {
|
1501 | var _this$props2;
|
1502 |
|
1503 | return _this.props.onDrag && (_this$props2 = _this.props).onDrag.apply(_this$props2, arguments);
|
1504 | };
|
1505 |
|
1506 | _this._onMapTypeIdChange = function () {
|
1507 | var _this$props3;
|
1508 |
|
1509 | return _this.props.onMapTypeIdChange && (_this$props3 = _this.props).onMapTypeIdChange.apply(_this$props3, arguments);
|
1510 | };
|
1511 |
|
1512 | _this._onZoomAnimationStart = function () {
|
1513 | var _this$props4;
|
1514 |
|
1515 | return _this.props.onZoomAnimationStart && (_this$props4 = _this.props).onZoomAnimationStart.apply(_this$props4, arguments);
|
1516 | };
|
1517 |
|
1518 | _this._onZoomAnimationEnd = function () {
|
1519 | var _this$props5;
|
1520 |
|
1521 | return _this.props.onZoomAnimationEnd && (_this$props5 = _this.props).onZoomAnimationEnd.apply(_this$props5, arguments);
|
1522 | };
|
1523 |
|
1524 | _this._onTilesLoaded = function () {
|
1525 | return _this.props.onTilesLoaded && _this.props.onTilesLoaded();
|
1526 | };
|
1527 |
|
1528 | _this._onChildClick = function () {
|
1529 | if (_this.props.onChildClick) {
|
1530 | var _this$props6;
|
1531 |
|
1532 | return (_this$props6 = _this.props).onChildClick.apply(_this$props6, arguments);
|
1533 | }
|
1534 | return undefined;
|
1535 | };
|
1536 |
|
1537 | _this._onChildMouseDown = function (hoverKey, childProps) {
|
1538 | _this.childMouseDownArgs_ = [hoverKey, childProps];
|
1539 | if (_this.props.onChildMouseDown) {
|
1540 | _this.props.onChildMouseDown(hoverKey, childProps, _extends({}, _this.mouse_));
|
1541 | }
|
1542 | };
|
1543 |
|
1544 | _this._onChildMouseUp = function () {
|
1545 | if (_this.childMouseDownArgs_) {
|
1546 | if (_this.props.onChildMouseUp) {
|
1547 | var _this$props7;
|
1548 |
|
1549 | (_this$props7 = _this.props).onChildMouseUp.apply(_this$props7, _this.childMouseDownArgs_.concat([_extends({}, _this.mouse_)]));
|
1550 | }
|
1551 | _this.childMouseDownArgs_ = null;
|
1552 | _this.childMouseUpTime_ = new Date().getTime();
|
1553 | }
|
1554 | };
|
1555 |
|
1556 | _this._onChildMouseMove = function () {
|
1557 | if (_this.childMouseDownArgs_) {
|
1558 | if (_this.props.onChildMouseMove) {
|
1559 | var _this$props8;
|
1560 |
|
1561 | (_this$props8 = _this.props).onChildMouseMove.apply(_this$props8, _this.childMouseDownArgs_.concat([_extends({}, _this.mouse_)]));
|
1562 | }
|
1563 | }
|
1564 | };
|
1565 |
|
1566 | _this._onChildMouseEnter = function () {
|
1567 | if (_this.props.onChildMouseEnter) {
|
1568 | var _this$props9;
|
1569 |
|
1570 | return (_this$props9 = _this.props).onChildMouseEnter.apply(_this$props9, arguments);
|
1571 | }
|
1572 | return undefined;
|
1573 | };
|
1574 |
|
1575 | _this._onChildMouseLeave = function () {
|
1576 | if (_this.props.onChildMouseLeave) {
|
1577 | var _this$props10;
|
1578 |
|
1579 | return (_this$props10 = _this.props).onChildMouseLeave.apply(_this$props10, arguments);
|
1580 | }
|
1581 | return undefined;
|
1582 | };
|
1583 |
|
1584 | _this._setViewSize = function () {
|
1585 | if (!_this.mounted_) return;
|
1586 | if (isFullScreen()) {
|
1587 | _this.geoService_.setViewSize(window.innerWidth, window.innerHeight);
|
1588 | } else {
|
1589 | var mapDom = _reactDom2.default.findDOMNode(_this.googleMapDom_);
|
1590 | _this.geoService_.setViewSize(mapDom.clientWidth, mapDom.clientHeight);
|
1591 | }
|
1592 | _this._onBoundsChanged();
|
1593 | };
|
1594 |
|
1595 | _this._onWindowResize = function () {
|
1596 | _this.resetSizeOnIdle_ = true;
|
1597 | };
|
1598 |
|
1599 | _this._onMapMouseMove = function (e) {
|
1600 | if (!_this.mouseInMap_) return;
|
1601 |
|
1602 | var currTime = new Date().getTime();
|
1603 | var K_RECALC_CLIENT_RECT_MS = 50;
|
1604 |
|
1605 | if (currTime - _this.mouseMoveTime_ > K_RECALC_CLIENT_RECT_MS) {
|
1606 | _this.boundingRect_ = e.currentTarget.getBoundingClientRect();
|
1607 | }
|
1608 | _this.mouseMoveTime_ = currTime;
|
1609 |
|
1610 | var mousePosX = e.clientX - _this.boundingRect_.left;
|
1611 | var mousePosY = e.clientY - _this.boundingRect_.top;
|
1612 |
|
1613 | if (!_this.mouse_) {
|
1614 | _this.mouse_ = { x: 0, y: 0, lat: 0, lng: 0 };
|
1615 | }
|
1616 |
|
1617 | _this.mouse_.x = mousePosX;
|
1618 | _this.mouse_.y = mousePosY;
|
1619 |
|
1620 | var latLng = _this.geoService_.fromContainerPixelToLatLng(_this.mouse_);
|
1621 | _this.mouse_.lat = latLng.lat;
|
1622 | _this.mouse_.lng = latLng.lng;
|
1623 |
|
1624 | _this._onChildMouseMove();
|
1625 |
|
1626 | if (currTime - _this.dragTime_ < K_IDLE_TIMEOUT) {
|
1627 | _this.fireMouseEventOnIdle_ = true;
|
1628 | } else {
|
1629 | _this.markersDispatcher_.emit('kON_MOUSE_POSITION_CHANGE');
|
1630 | _this.fireMouseEventOnIdle_ = false;
|
1631 | }
|
1632 | };
|
1633 |
|
1634 | _this._onClick = function () {
|
1635 | var _this$props11;
|
1636 |
|
1637 | return _this.props.onClick && !_this.childMouseDownArgs_ && new Date().getTime() - _this.childMouseUpTime_ > K_IDLE_CLICK_TIMEOUT && _this.dragTime_ === 0 && (_this$props11 = _this.props).onClick.apply(_this$props11, arguments);
|
1638 | };
|
1639 |
|
1640 | _this._onMapClick = function (event) {
|
1641 | if (_this.markersDispatcher_) {
|
1642 |
|
1643 | _this._onMapMouseMove(event);
|
1644 | var currTime = new Date().getTime();
|
1645 | if (currTime - _this.dragTime_ > K_IDLE_TIMEOUT) {
|
1646 | if (_this.mouse_) {
|
1647 | _this._onClick(_extends({}, _this.mouse_, {
|
1648 | event: event
|
1649 | }));
|
1650 | }
|
1651 |
|
1652 | _this.markersDispatcher_.emit('kON_CLICK', event);
|
1653 | }
|
1654 | }
|
1655 | };
|
1656 |
|
1657 | _this._onMapMouseDownNative = function (event) {
|
1658 | if (!_this.mouseInMap_) return;
|
1659 |
|
1660 | _this._onMapMouseDown(event);
|
1661 | };
|
1662 |
|
1663 | _this._onMapMouseDown = function (event) {
|
1664 | if (_this.markersDispatcher_) {
|
1665 | var currTime = new Date().getTime();
|
1666 | if (currTime - _this.dragTime_ > K_IDLE_TIMEOUT) {
|
1667 |
|
1668 |
|
1669 | _this._onMapMouseMove(event);
|
1670 | _this.markersDispatcher_.emit('kON_MDOWN', event);
|
1671 | }
|
1672 | }
|
1673 | };
|
1674 |
|
1675 | _this._onMapMouseDownCapture = function () {
|
1676 | if ((0, _detect2.default)().isChrome) {
|
1677 |
|
1678 | _this.zoomControlClickTime_ = new Date().getTime();
|
1679 | }
|
1680 | };
|
1681 |
|
1682 | _this._onKeyDownCapture = function () {
|
1683 | if ((0, _detect2.default)().isChrome) {
|
1684 | _this.zoomControlClickTime_ = new Date().getTime();
|
1685 | }
|
1686 | };
|
1687 |
|
1688 | _this._isCenterDefined = function (center) {
|
1689 | 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]));
|
1690 | };
|
1691 |
|
1692 | _this._onBoundsChanged = function (map, maps, callExtBoundsChange) {
|
1693 | if (map) {
|
1694 | var gmC = map.getCenter();
|
1695 | _this.geoService_.setView([gmC.lat(), gmC.lng()], map.getZoom(), 0);
|
1696 | }
|
1697 |
|
1698 | if ((_this.props.onChange || _this.props.onBoundsChange) && _this.geoService_.canProject()) {
|
1699 | var zoom = _this.geoService_.getZoom();
|
1700 | var bounds = _this.geoService_.getBounds();
|
1701 | var centerLatLng = _this.geoService_.getCenter();
|
1702 |
|
1703 | if (!(0, _isArraysEqualEps2.default)(bounds, _this.prevBounds_, kEPS)) {
|
1704 | if (callExtBoundsChange !== false) {
|
1705 | var marginBounds = _this.geoService_.getBounds(_this.props.margin);
|
1706 | if (_this.props.onBoundsChange) {
|
1707 | _this.props.onBoundsChange(_this.centerIsObject_ ? _extends({}, centerLatLng) : [centerLatLng.lat, centerLatLng.lng], zoom, bounds, marginBounds);
|
1708 | }
|
1709 |
|
1710 | if (_this.props.onChange) {
|
1711 | _this.props.onChange({
|
1712 | center: _extends({}, centerLatLng),
|
1713 | zoom: zoom,
|
1714 | bounds: {
|
1715 | nw: {
|
1716 | lat: bounds[0],
|
1717 | lng: bounds[1]
|
1718 | },
|
1719 | se: {
|
1720 | lat: bounds[2],
|
1721 | lng: bounds[3]
|
1722 | },
|
1723 | sw: {
|
1724 | lat: bounds[4],
|
1725 | lng: bounds[5]
|
1726 | },
|
1727 | ne: {
|
1728 | lat: bounds[6],
|
1729 | lng: bounds[7]
|
1730 | }
|
1731 | },
|
1732 | marginBounds: {
|
1733 | nw: {
|
1734 | lat: marginBounds[0],
|
1735 | lng: marginBounds[1]
|
1736 | },
|
1737 | se: {
|
1738 | lat: marginBounds[2],
|
1739 | lng: marginBounds[3]
|
1740 | },
|
1741 | sw: {
|
1742 | lat: marginBounds[4],
|
1743 | lng: marginBounds[5]
|
1744 | },
|
1745 | ne: {
|
1746 | lat: marginBounds[6],
|
1747 | lng: marginBounds[7]
|
1748 | }
|
1749 | },
|
1750 |
|
1751 | size: _this.geoService_.hasSize() ? {
|
1752 | width: _this.geoService_.getWidth(),
|
1753 | height: _this.geoService_.getHeight()
|
1754 | } : {
|
1755 | width: 0,
|
1756 | height: 0
|
1757 | }
|
1758 | });
|
1759 | }
|
1760 |
|
1761 | _this.prevBounds_ = bounds;
|
1762 | }
|
1763 | }
|
1764 | }
|
1765 | };
|
1766 |
|
1767 | _this._registerChild = function (ref) {
|
1768 | _this.googleMapDom_ = ref;
|
1769 | };
|
1770 |
|
1771 | _this.mounted_ = false;
|
1772 | _this.initialized_ = false;
|
1773 | _this.googleApiLoadedCalled_ = false;
|
1774 |
|
1775 | _this.map_ = null;
|
1776 | _this.maps_ = null;
|
1777 | _this.prevBounds_ = null;
|
1778 | _this.heatmap = null;
|
1779 |
|
1780 | _this.layers_ = {};
|
1781 |
|
1782 | _this.mouse_ = null;
|
1783 | _this.mouseMoveTime_ = 0;
|
1784 | _this.boundingRect_ = null;
|
1785 | _this.mouseInMap_ = true;
|
1786 |
|
1787 | _this.dragTime_ = 0;
|
1788 | _this.fireMouseEventOnIdle_ = false;
|
1789 | _this.updateCounter_ = 0;
|
1790 |
|
1791 | _this.markersDispatcher_ = new _marker_dispatcher2.default(_this);
|
1792 | _this.geoService_ = new _geo2.default(K_GOOGLE_TILE_SIZE);
|
1793 | _this.centerIsObject_ = (0, _isPlainObject2.default)(_this.props.center);
|
1794 |
|
1795 | _this.minZoom_ = DEFAULT_MIN_ZOOM;
|
1796 | _this.defaultDraggableOption_ = true;
|
1797 |
|
1798 | _this.zoomControlClickTime_ = 0;
|
1799 |
|
1800 | _this.childMouseDownArgs_ = null;
|
1801 | _this.childMouseUpTime_ = 0;
|
1802 |
|
1803 | _this.googleMapDom_ = null;
|
1804 |
|
1805 | if (true) {
|
1806 | if (_this.props.apiKey) {
|
1807 | console.warn('GoogleMap: ' +
|
1808 | 'apiKey is deprecated, use ' + 'bootstrapURLKeys={{key: YOUR_API_KEY}} instead.');
|
1809 | }
|
1810 |
|
1811 | if (_this.props.onBoundsChange) {
|
1812 | console.warn('GoogleMap: ' +
|
1813 | 'onBoundsChange is deprecated, use ' + 'onChange({center, zoom, bounds, ...other}) instead.');
|
1814 | }
|
1815 |
|
1816 | if ((0, _isEmpty2.default)(_this.props.center) && (0, _isEmpty2.default)(_this.props.defaultCenter)) {
|
1817 | console.warn('GoogleMap: center or defaultCenter property must be defined'
|
1818 | );
|
1819 | }
|
1820 |
|
1821 | if ((0, _isEmpty2.default)(_this.props.zoom) && (0, _isEmpty2.default)(_this.props.defaultZoom)) {
|
1822 | console.warn('GoogleMap: zoom or defaultZoom property must be defined'
|
1823 | );
|
1824 | }
|
1825 | }
|
1826 |
|
1827 | if (_this._isCenterDefined(_this.props.center || _this.props.defaultCenter)) {
|
1828 | var propsCenter = latLng2Obj(_this.props.center || _this.props.defaultCenter);
|
1829 | _this.geoService_.setView(propsCenter, _this.props.zoom || _this.props.defaultZoom, 0);
|
1830 | }
|
1831 |
|
1832 | _this.zoomAnimationInProgress_ = false;
|
1833 |
|
1834 | _this.state = {
|
1835 | overlayCreated: false
|
1836 | };
|
1837 | return _this;
|
1838 | }
|
1839 |
|
1840 | GoogleMap.prototype.componentDidMount = function componentDidMount() {
|
1841 | var _this2 = this;
|
1842 |
|
1843 | this.mounted_ = true;
|
1844 | (0, _passiveEvents2.default)(window, 'resize', this._onWindowResize, false);
|
1845 | (0, _passiveEvents2.default)(window, 'keydown', this._onKeyDownCapture, true);
|
1846 | var mapDom = _reactDom2.default.findDOMNode(this.googleMapDom_);
|
1847 |
|
1848 |
|
1849 |
|
1850 | if (mapDom) {
|
1851 | (0, _passiveEvents2.default)(mapDom, 'mousedown', this._onMapMouseDownNative, true);
|
1852 | }
|
1853 |
|
1854 | (0, _passiveEvents2.default)(window, 'mouseup', this._onChildMouseUp, false);
|
1855 | var bootstrapURLKeys = _extends({}, this.props.apiKey && { key: this.props.apiKey }, this.props.bootstrapURLKeys);
|
1856 |
|
1857 | this.props.googleMapLoader(bootstrapURLKeys, this.props.heatmapLibrary);
|
1858 |
|
1859 | setTimeout(function () {
|
1860 |
|
1861 | _this2._setViewSize();
|
1862 | if (_this2._isCenterDefined(_this2.props.center || _this2.props.defaultCenter)) {
|
1863 | _this2._initMap();
|
1864 | }
|
1865 | }, 0, this);
|
1866 | if (this.props.resetBoundsOnResize) {
|
1867 | var that = this;
|
1868 | _detectElementResize2.default.addResizeListener(mapDom, that._mapDomResizeCallback);
|
1869 | }
|
1870 | };
|
1871 |
|
1872 | GoogleMap.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
1873 | var _this3 = this;
|
1874 |
|
1875 | if (true) {
|
1876 | if (!(0, _shallowEqual2.default)(this.props.defaultCenter, nextProps.defaultCenter)) {
|
1877 | console.warn("GoogleMap: defaultCenter prop changed. You can't change default props.");
|
1878 | }
|
1879 |
|
1880 | if (!(0, _shallowEqual2.default)(this.props.defaultZoom, nextProps.defaultZoom)) {
|
1881 | console.warn("GoogleMap: defaultZoom prop changed. You can't change default props.");
|
1882 | }
|
1883 | }
|
1884 |
|
1885 | if (!this._isCenterDefined(this.props.center) && this._isCenterDefined(nextProps.center)) {
|
1886 | setTimeout(function () {
|
1887 | return _this3._initMap();
|
1888 | }, 0);
|
1889 | }
|
1890 |
|
1891 | if (this.map_) {
|
1892 | var centerLatLng = this.geoService_.getCenter();
|
1893 | if (this._isCenterDefined(nextProps.center)) {
|
1894 | var nextPropsCenter = latLng2Obj(nextProps.center);
|
1895 | var currCenter = this._isCenterDefined(this.props.center) ? latLng2Obj(this.props.center) : null;
|
1896 |
|
1897 | if (!currCenter || Math.abs(nextPropsCenter.lat - currCenter.lat) + Math.abs(nextPropsCenter.lng - currCenter.lng) > kEPS) {
|
1898 | if (Math.abs(nextPropsCenter.lat - centerLatLng.lat) + Math.abs(nextPropsCenter.lng - centerLatLng.lng) > kEPS) {
|
1899 | this.map_.panTo({
|
1900 | lat: nextPropsCenter.lat,
|
1901 | lng: nextPropsCenter.lng
|
1902 | });
|
1903 | }
|
1904 | }
|
1905 | }
|
1906 |
|
1907 | if (!(0, _isEmpty2.default)(nextProps.zoom)) {
|
1908 |
|
1909 | if (Math.abs(nextProps.zoom - this.props.zoom) > 0) {
|
1910 | this.map_.setZoom(nextProps.zoom);
|
1911 | }
|
1912 | }
|
1913 |
|
1914 | if (!(0, _isEmpty2.default)(this.props.draggable) && (0, _isEmpty2.default)(nextProps.draggable)) {
|
1915 |
|
1916 | this.map_.setOptions({ draggable: this.defaultDraggableOption_ });
|
1917 | } else if (!(0, _shallowEqual2.default)(this.props.draggable, nextProps.draggable)) {
|
1918 |
|
1919 | this.map_.setOptions({ draggable: nextProps.draggable });
|
1920 | }
|
1921 |
|
1922 |
|
1923 | if (!(0, _isEmpty2.default)(nextProps.options) && !(0, _shallowEqual2.default)(this.props.options, nextProps.options)) {
|
1924 | var mapPlainObjects = (0, _pick2.default)(this.maps_, _isPlainObject2.default);
|
1925 | var options = typeof nextProps.options === 'function' ? nextProps.options(mapPlainObjects) : nextProps.options;
|
1926 |
|
1927 | options = (0, _omit2.default)(options, ['zoom', 'center', 'draggable']);
|
1928 |
|
1929 | if ('minZoom' in options) {
|
1930 | var minZoom = this._computeMinZoom(options.minZoom);
|
1931 | options.minZoom = _checkMinZoom(options.minZoom, minZoom);
|
1932 | }
|
1933 |
|
1934 | this.map_.setOptions(options);
|
1935 | }
|
1936 |
|
1937 | if (!(0, _shallowEqual2.default)(nextProps.layerTypes, this.props.layerTypes)) {
|
1938 | Object.keys(this.layers_).forEach(function (layerKey) {
|
1939 | _this3.layers_[layerKey].setMap(null);
|
1940 | delete _this3.layers_[layerKey];
|
1941 | });
|
1942 | this._setLayers(nextProps.layerTypes);
|
1943 | }
|
1944 | }
|
1945 | };
|
1946 |
|
1947 | GoogleMap.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
|
1948 |
|
1949 | return !(0, _shallowEqual2.default)((0, _omit2.default)(this.props, ['draggable']), (0, _omit2.default)(nextProps, ['draggable'])) || !(0, _shallowEqual2.default)(this.state, nextState);
|
1950 | };
|
1951 |
|
1952 | GoogleMap.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
1953 | this.markersDispatcher_.emit('kON_CHANGE');
|
1954 |
|
1955 | if (!(0, _shallowEqual2.default)(this.props.hoverDistance, prevProps.hoverDistance)) {
|
1956 | this.markersDispatcher_.emit('kON_MOUSE_POSITION_CHANGE');
|
1957 | }
|
1958 | };
|
1959 |
|
1960 | GoogleMap.prototype.componentWillUnmount = function componentWillUnmount() {
|
1961 | this.mounted_ = false;
|
1962 | var mapDom = _reactDom2.default.findDOMNode(this.googleMapDom_);
|
1963 | if (mapDom) {
|
1964 | mapDom.removeEventListener('mousedown', this._onMapMouseDownNative, true);
|
1965 | }
|
1966 | window.removeEventListener('resize', this._onWindowResize);
|
1967 | window.removeEventListener('keydown', this._onKeyDownCapture);
|
1968 | window.removeEventListener('mouseup', this._onChildMouseUp, false);
|
1969 | if (this.props.resetBoundsOnResize) {
|
1970 | _detectElementResize2.default.removeResizeListener(mapDom, this._mapDomResizeCallback);
|
1971 | }
|
1972 |
|
1973 | if (this.overlay_) {
|
1974 |
|
1975 | this.overlay_.setMap(null);
|
1976 | }
|
1977 |
|
1978 | if (this.maps_ && this.map_) {
|
1979 |
|
1980 | this.map_.setOptions({ scrollwheel: false });
|
1981 | this.maps_.event.clearInstanceListeners(this.map_);
|
1982 | }
|
1983 |
|
1984 | this.map_ = null;
|
1985 | this.maps_ = null;
|
1986 | this.markersDispatcher_.dispose();
|
1987 |
|
1988 | this.resetSizeOnIdle_ = false;
|
1989 |
|
1990 | delete this.map_;
|
1991 | delete this.markersDispatcher_;
|
1992 | };
|
1993 |
|
1994 |
|
1995 |
|
1996 |
|
1997 |
|
1998 |
|
1999 |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 |
|
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 |
|
2012 | GoogleMap.prototype.render = function render() {
|
2013 | var mapMarkerPrerender = !this.state.overlayCreated ? _react2.default.createElement(_google_map_markers_prerender2.default, {
|
2014 | experimental: this.props.experimental,
|
2015 | onChildClick: this._onChildClick,
|
2016 | onChildMouseDown: this._onChildMouseDown,
|
2017 | onChildMouseEnter: this._onChildMouseEnter,
|
2018 | onChildMouseLeave: this._onChildMouseLeave,
|
2019 | geoService: this.geoService_,
|
2020 | insideMapPanes: false,
|
2021 | distanceToMouse: this.props.distanceToMouse,
|
2022 | getHoverDistance: this._getHoverDistance,
|
2023 | dispatcher: this.markersDispatcher_
|
2024 | }) : null;
|
2025 |
|
2026 | return _react2.default.createElement(
|
2027 | 'div',
|
2028 | {
|
2029 | style: this.props.style,
|
2030 | onMouseMove: this._onMapMouseMove,
|
2031 | onMouseDownCapture: this._onMapMouseDownCapture,
|
2032 | onClick: this._onMapClick
|
2033 | },
|
2034 | _react2.default.createElement(_google_map_map2.default, { registerChild: this._registerChild }),
|
2035 | mapMarkerPrerender
|
2036 | );
|
2037 | };
|
2038 |
|
2039 | return GoogleMap;
|
2040 | }(_react.Component);
|
2041 |
|
2042 | GoogleMap.propTypes = {
|
2043 | apiKey: _propTypes2.default.string,
|
2044 | bootstrapURLKeys: _propTypes2.default.any,
|
2045 |
|
2046 | defaultCenter: _propTypes2.default.oneOfType([_propTypes2.default.array, _propTypes2.default.shape({
|
2047 | lat: _propTypes2.default.number,
|
2048 | lng: _propTypes2.default.number
|
2049 | })]),
|
2050 | center: _propTypes2.default.oneOfType([_propTypes2.default.array, _propTypes2.default.shape({
|
2051 | lat: _propTypes2.default.number,
|
2052 | lng: _propTypes2.default.number
|
2053 | })]),
|
2054 | defaultZoom: _propTypes2.default.number,
|
2055 | zoom: _propTypes2.default.number,
|
2056 | onBoundsChange: _propTypes2.default.func,
|
2057 | onChange: _propTypes2.default.func,
|
2058 | onClick: _propTypes2.default.func,
|
2059 | onChildClick: _propTypes2.default.func,
|
2060 | onChildMouseDown: _propTypes2.default.func,
|
2061 | onChildMouseUp: _propTypes2.default.func,
|
2062 | onChildMouseMove: _propTypes2.default.func,
|
2063 | onChildMouseEnter: _propTypes2.default.func,
|
2064 | onChildMouseLeave: _propTypes2.default.func,
|
2065 | onZoomAnimationStart: _propTypes2.default.func,
|
2066 | onZoomAnimationEnd: _propTypes2.default.func,
|
2067 | onDrag: _propTypes2.default.func,
|
2068 | onMapTypeIdChange: _propTypes2.default.func,
|
2069 | onTilesLoaded: _propTypes2.default.func,
|
2070 | options: _propTypes2.default.any,
|
2071 | distanceToMouse: _propTypes2.default.func,
|
2072 | hoverDistance: _propTypes2.default.number,
|
2073 | debounced: _propTypes2.default.bool,
|
2074 | margin: _propTypes2.default.array,
|
2075 | googleMapLoader: _propTypes2.default.any,
|
2076 | onGoogleApiLoaded: _propTypes2.default.func,
|
2077 | yesIWantToUseGoogleMapApiInternals: _propTypes2.default.bool,
|
2078 | draggable: _propTypes2.default.bool,
|
2079 | style: _propTypes2.default.any,
|
2080 | resetBoundsOnResize: _propTypes2.default.bool,
|
2081 | layerTypes: _propTypes2.default.arrayOf(_propTypes2.default.string)
|
2082 | };
|
2083 | GoogleMap.defaultProps = {
|
2084 | distanceToMouse: function distanceToMouse(pt, mousePos /* , markerProps */) {
|
2085 | return Math.sqrt((pt.x - mousePos.x) * (pt.x - mousePos.x) + (pt.y - mousePos.y) * (pt.y - mousePos.y));
|
2086 | },
|
2087 |
|
2088 | hoverDistance: 30,
|
2089 | debounced: true,
|
2090 | options: defaultOptions_,
|
2091 | googleMapLoader: _google_map_loader2.default,
|
2092 | yesIWantToUseGoogleMapApiInternals: false,
|
2093 | style: {
|
2094 | width: '100%',
|
2095 | height: '100%',
|
2096 | margin: 0,
|
2097 | padding: 0,
|
2098 | position: 'relative'
|
2099 | },
|
2100 | layerTypes: [],
|
2101 | heatmap: {},
|
2102 | heatmapLibrary: false
|
2103 | };
|
2104 | GoogleMap.googleMapLoader = _google_map_loader2.default;
|
2105 | exports.default = GoogleMap;
|
2106 |
|
2107 | }),
|
2108 |
|
2109 | (function(module, exports, __webpack_require__) {
|
2110 |
|
2111 | 'use strict';
|
2112 |
|
2113 | exports.__esModule = true;
|
2114 |
|
2115 | var _react = __webpack_require__(1);
|
2116 |
|
2117 | var _react2 = _interopRequireDefault(_react);
|
2118 |
|
2119 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2120 |
|
2121 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2122 |
|
2123 | 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; }
|
2124 |
|
2125 | 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; }
|
2126 |
|
2127 | var style = {
|
2128 | width: '100%',
|
2129 | height: '100%',
|
2130 | left: 0,
|
2131 | top: 0,
|
2132 | margin: 0,
|
2133 | padding: 0,
|
2134 | position: 'absolute'
|
2135 | };
|
2136 |
|
2137 | var GoogleMapMap = function (_Component) {
|
2138 | _inherits(GoogleMapMap, _Component);
|
2139 |
|
2140 | function GoogleMapMap() {
|
2141 | _classCallCheck(this, GoogleMapMap);
|
2142 |
|
2143 | return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
2144 | }
|
2145 |
|
2146 | GoogleMapMap.prototype.shouldComponentUpdate = function shouldComponentUpdate() {
|
2147 | return false;
|
2148 | };
|
2149 |
|
2150 | GoogleMapMap.prototype.render = function render() {
|
2151 | var registerChild = this.props.registerChild;
|
2152 |
|
2153 | return _react2.default.createElement('div', { ref: registerChild, style: style });
|
2154 | };
|
2155 |
|
2156 | return GoogleMapMap;
|
2157 | }(_react.Component);
|
2158 |
|
2159 | exports.default = GoogleMapMap;
|
2160 |
|
2161 | }),
|
2162 |
|
2163 | (function(module, exports, __webpack_require__) {
|
2164 |
|
2165 | 'use strict';
|
2166 |
|
2167 | exports.__esModule = true;
|
2168 |
|
2169 | 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; };
|
2170 |
|
2171 | exports.default = function (props) {
|
2172 | return _react2.default.createElement(
|
2173 | 'div',
|
2174 | { style: style },
|
2175 | _react2.default.createElement(_google_map_markers2.default, _extends({}, props, { prerender: true }))
|
2176 | );
|
2177 | };
|
2178 |
|
2179 | var _react = __webpack_require__(1);
|
2180 |
|
2181 | var _react2 = _interopRequireDefault(_react);
|
2182 |
|
2183 | var _google_map_markers = __webpack_require__(3);
|
2184 |
|
2185 | var _google_map_markers2 = _interopRequireDefault(_google_map_markers);
|
2186 |
|
2187 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2188 |
|
2189 | var style = {
|
2190 | width: '50%',
|
2191 | height: '50%',
|
2192 | left: '50%',
|
2193 | top: '50%',
|
2194 |
|
2195 | margin: 0,
|
2196 | padding: 0,
|
2197 | position: 'absolute'
|
2198 |
|
2199 | };
|
2200 |
|
2201 | }),
|
2202 |
|
2203 | (function(module, exports, __webpack_require__) {
|
2204 |
|
2205 | 'use strict';
|
2206 |
|
2207 | exports.__esModule = true;
|
2208 | var BASE_URL = 'https://maps';
|
2209 | var DEFAULT_URL = BASE_URL + '.googleapis.com';
|
2210 | var API_PATH = '/maps/api/js?callback=_$_google_map_initialize_$_';
|
2211 |
|
2212 | var getUrl = function getUrl(region) {
|
2213 | if (region && region.toLowerCase() === 'cn') {
|
2214 | return BASE_URL + '.google.cn';
|
2215 | }
|
2216 | return DEFAULT_URL;
|
2217 | };
|
2218 |
|
2219 | var $script_ = null;
|
2220 |
|
2221 | var loadPromise_ = void 0;
|
2222 |
|
2223 | var resolveCustomPromise_ = void 0;
|
2224 |
|
2225 | var _customPromise = new Promise(function (resolve) {
|
2226 | resolveCustomPromise_ = resolve;
|
2227 | });
|
2228 |
|
2229 |
|
2230 |
|
2231 | exports.default = function (bootstrapURLKeys, heatmapLibrary) {
|
2232 | if (!$script_) {
|
2233 | $script_ = __webpack_require__(32);
|
2234 | }
|
2235 |
|
2236 |
|
2237 |
|
2238 | if (!bootstrapURLKeys) {
|
2239 | return _customPromise;
|
2240 | }
|
2241 |
|
2242 | if (loadPromise_) {
|
2243 | return loadPromise_;
|
2244 | }
|
2245 |
|
2246 | loadPromise_ = new Promise(function (resolve, reject) {
|
2247 | if (typeof window === 'undefined') {
|
2248 | reject(new Error('google map cannot be loaded outside browser env'));
|
2249 | return;
|
2250 | }
|
2251 |
|
2252 | if (window.google && window.google.maps) {
|
2253 | resolve(window.google.maps);
|
2254 | return;
|
2255 | }
|
2256 |
|
2257 | if (typeof window._$_google_map_initialize_$_ !== 'undefined') {
|
2258 | reject(new Error('google map initialization error'));
|
2259 | }
|
2260 |
|
2261 | window._$_google_map_initialize_$_ = function () {
|
2262 | delete window._$_google_map_initialize_$_;
|
2263 | resolve(window.google.maps);
|
2264 | };
|
2265 |
|
2266 | if (true) {
|
2267 | if (Object.keys(bootstrapURLKeys).indexOf('callback') > -1) {
|
2268 | var message = '"callback" key in bootstrapURLKeys is not allowed,\n use onGoogleApiLoaded property instead';
|
2269 |
|
2270 | console.error(message);
|
2271 | throw new Error(message);
|
2272 | }
|
2273 | }
|
2274 |
|
2275 | var params = Object.keys(bootstrapURLKeys).reduce(function (r, key) {
|
2276 | return r + '&' + key + '=' + bootstrapURLKeys[key];
|
2277 | }, '');
|
2278 |
|
2279 | var baseUrl = getUrl(bootstrapURLKeys.region);
|
2280 | var libraries = heatmapLibrary ? '&libraries=visualization' : '';
|
2281 |
|
2282 | $script_('' + baseUrl + API_PATH + params + libraries, function () {
|
2283 | return typeof window.google === 'undefined' && reject(new Error('google map initialization error (not loaded)'));
|
2284 | });
|
2285 | });
|
2286 |
|
2287 | resolveCustomPromise_(loadPromise_);
|
2288 |
|
2289 | return loadPromise_;
|
2290 | };
|
2291 |
|
2292 | }),
|
2293 |
|
2294 | (function(module, exports, __webpack_require__) {
|
2295 |
|
2296 | 'use strict';
|
2297 |
|
2298 | exports.__esModule = true;
|
2299 |
|
2300 | var _eventemitter = __webpack_require__(28);
|
2301 |
|
2302 | var _eventemitter2 = _interopRequireDefault(_eventemitter);
|
2303 |
|
2304 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2305 |
|
2306 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2307 |
|
2308 | 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; }
|
2309 |
|
2310 | 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; }
|
2311 |
|
2312 | var MarkerDispatcher = function (_EventEmitter) {
|
2313 | _inherits(MarkerDispatcher, _EventEmitter);
|
2314 |
|
2315 | function MarkerDispatcher(gmapInstance) {
|
2316 | _classCallCheck(this, MarkerDispatcher);
|
2317 |
|
2318 | var _this = _possibleConstructorReturn(this, _EventEmitter.call(this));
|
2319 |
|
2320 | _this.gmapInstance = gmapInstance;
|
2321 | return _this;
|
2322 | }
|
2323 |
|
2324 | MarkerDispatcher.prototype.getChildren = function getChildren() {
|
2325 | return this.gmapInstance.props.children;
|
2326 | };
|
2327 |
|
2328 | MarkerDispatcher.prototype.getMousePosition = function getMousePosition() {
|
2329 | return this.gmapInstance.mouse_;
|
2330 | };
|
2331 |
|
2332 | MarkerDispatcher.prototype.getUpdateCounter = function getUpdateCounter() {
|
2333 | return this.gmapInstance.updateCounter_;
|
2334 | };
|
2335 |
|
2336 | MarkerDispatcher.prototype.dispose = function dispose() {
|
2337 | this.gmapInstance = null;
|
2338 | this.removeAllListeners();
|
2339 | };
|
2340 |
|
2341 | return MarkerDispatcher;
|
2342 | }(_eventemitter2.default);
|
2343 |
|
2344 | exports.default = MarkerDispatcher;
|
2345 |
|
2346 | }),
|
2347 |
|
2348 | (function(module, exports) {
|
2349 |
|
2350 | 'use strict';
|
2351 |
|
2352 | exports.__esModule = true;
|
2353 | exports.default = detectBrowser;
|
2354 |
|
2355 | var detectBrowserResult_ = null;
|
2356 |
|
2357 | function detectBrowser() {
|
2358 | if (detectBrowserResult_) {
|
2359 | return detectBrowserResult_;
|
2360 | }
|
2361 |
|
2362 | if (typeof navigator !== 'undefined') {
|
2363 | var isExplorer = navigator.userAgent.indexOf('MSIE') > -1;
|
2364 | var isFirefox = navigator.userAgent.indexOf('Firefox') > -1;
|
2365 | var isOpera = navigator.userAgent.toLowerCase().indexOf('op') > -1;
|
2366 |
|
2367 | var isChrome = navigator.userAgent.indexOf('Chrome') > -1;
|
2368 | var isSafari = navigator.userAgent.indexOf('Safari') > -1;
|
2369 |
|
2370 | if (isChrome && isSafari) {
|
2371 | isSafari = false;
|
2372 | }
|
2373 |
|
2374 | if (isChrome && isOpera) {
|
2375 | isChrome = false;
|
2376 | }
|
2377 |
|
2378 | detectBrowserResult_ = {
|
2379 | isExplorer: isExplorer,
|
2380 | isFirefox: isFirefox,
|
2381 | isOpera: isOpera,
|
2382 | isChrome: isChrome,
|
2383 | isSafari: isSafari
|
2384 | };
|
2385 | return detectBrowserResult_;
|
2386 | }
|
2387 |
|
2388 | detectBrowserResult_ = {
|
2389 | isChrome: true,
|
2390 | isExplorer: false,
|
2391 | isFirefox: false,
|
2392 | isOpera: false,
|
2393 | isSafari: false
|
2394 | };
|
2395 |
|
2396 | return detectBrowserResult_;
|
2397 | }
|
2398 |
|
2399 | }),
|
2400 |
|
2401 | (function(module, exports, __webpack_require__) {
|
2402 |
|
2403 | 'use strict';
|
2404 |
|
2405 | var _passiveEvents = __webpack_require__(7);
|
2406 |
|
2407 | var _passiveEvents2 = _interopRequireDefault(_passiveEvents);
|
2408 |
|
2409 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2410 |
|
2411 |
|
2412 | var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
2413 |
|
2414 |
|
2415 |
|
2416 | |
2417 |
|
2418 |
|
2419 |
|
2420 |
|
2421 |
|
2422 |
|
2423 |
|
2424 |
|
2425 |
|
2426 | var _window;
|
2427 | if (canUseDOM) {
|
2428 | _window = window;
|
2429 | } else if (typeof self !== 'undefined') {
|
2430 | _window = self;
|
2431 | } else {
|
2432 | _window = undefined;
|
2433 | }
|
2434 |
|
2435 | var attachEvent = typeof document !== 'undefined' && document.attachEvent;
|
2436 | var stylesCreated = false;
|
2437 |
|
2438 | if (canUseDOM && !attachEvent) {
|
2439 | var requestFrame = function () {
|
2440 | var raf = _window.requestAnimationFrame || _window.mozRequestAnimationFrame || _window.webkitRequestAnimationFrame || function (fn) {
|
2441 | return _window.setTimeout(fn, 20);
|
2442 | };
|
2443 | return function (fn) {
|
2444 | return raf(fn);
|
2445 | };
|
2446 | }();
|
2447 |
|
2448 | var cancelFrame = function () {
|
2449 | var cancel = _window.cancelAnimationFrame || _window.mozCancelAnimationFrame || _window.webkitCancelAnimationFrame || _window.clearTimeout;
|
2450 | return function (id) {
|
2451 | return cancel(id);
|
2452 | };
|
2453 | }();
|
2454 |
|
2455 | var resetTriggers = function resetTriggers(element) {
|
2456 | var triggers = element.__resizeTriggers__,
|
2457 | expand = triggers.firstElementChild,
|
2458 | contract = triggers.lastElementChild,
|
2459 | expandChild = expand.firstElementChild;
|
2460 | contract.scrollLeft = contract.scrollWidth;
|
2461 | contract.scrollTop = contract.scrollHeight;
|
2462 | expandChild.style.width = expand.offsetWidth + 1 + 'px';
|
2463 | expandChild.style.height = expand.offsetHeight + 1 + 'px';
|
2464 | expand.scrollLeft = expand.scrollWidth;
|
2465 | expand.scrollTop = expand.scrollHeight;
|
2466 | };
|
2467 |
|
2468 | var checkTriggers = function checkTriggers(element) {
|
2469 | return element.offsetWidth != element.__resizeLast__.width || element.offsetHeight != element.__resizeLast__.height;
|
2470 | };
|
2471 |
|
2472 | var scrollListener = function scrollListener(e) {
|
2473 | var element = this;
|
2474 | resetTriggers(this);
|
2475 | if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
|
2476 | this.__resizeRAF__ = requestFrame(function () {
|
2477 | if (checkTriggers(element)) {
|
2478 | element.__resizeLast__.width = element.offsetWidth;
|
2479 | element.__resizeLast__.height = element.offsetHeight;
|
2480 | element.__resizeListeners__.forEach(function (fn) {
|
2481 | fn.call(element, e);
|
2482 | });
|
2483 | }
|
2484 | });
|
2485 | };
|
2486 |
|
2487 |
|
2488 | var animation = false,
|
2489 | animationstring = 'animation',
|
2490 | keyframeprefix = '',
|
2491 | animationstartevent = 'animationstart',
|
2492 | domPrefixes = 'Webkit Moz O ms'.split(' '),
|
2493 | startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' '),
|
2494 | pfx = '';
|
2495 |
|
2496 | if (canUseDOM) {
|
2497 | var elm = document.createElement('fakeelement');
|
2498 | if (elm.style.animationName !== undefined) {
|
2499 | animation = true;
|
2500 | }
|
2501 |
|
2502 | if (animation === false) {
|
2503 | for (var i = 0; i < domPrefixes.length; i++) {
|
2504 | if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
|
2505 | pfx = domPrefixes[i];
|
2506 | animationstring = pfx + 'Animation';
|
2507 | keyframeprefix = '-' + pfx.toLowerCase() + '-';
|
2508 | animationstartevent = startEvents[i];
|
2509 | animation = true;
|
2510 | break;
|
2511 | }
|
2512 | }
|
2513 | }
|
2514 | }
|
2515 |
|
2516 | var animationName = 'resizeanim';
|
2517 | var animationKeyframes = '@' + keyframeprefix + 'keyframes ' + animationName + ' { from { opacity: 0; } to { opacity: 0; } } ';
|
2518 | var animationStyle = keyframeprefix + 'animation: 1ms ' + animationName + '; ';
|
2519 | }
|
2520 |
|
2521 | var createStyles = function createStyles() {
|
2522 | if (!stylesCreated) {
|
2523 |
|
2524 | 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%; }',
|
2525 | head = document.head || document.getElementsByTagName('head')[0],
|
2526 | style = document.createElement('style');
|
2527 |
|
2528 | style.type = 'text/css';
|
2529 | if (style.styleSheet) {
|
2530 | style.styleSheet.cssText = css;
|
2531 | } else {
|
2532 | style.appendChild(document.createTextNode(css));
|
2533 | }
|
2534 |
|
2535 | head.appendChild(style);
|
2536 | stylesCreated = true;
|
2537 | }
|
2538 | };
|
2539 |
|
2540 | var addResizeListener = function addResizeListener(element, fn) {
|
2541 | if (element.parentNode === undefined) {
|
2542 | var tempParentDiv = document.createElement('div');
|
2543 | element.parentNode = tempParentDiv;
|
2544 | }
|
2545 | element = element.parentNode;
|
2546 | if (attachEvent) element.attachEvent('onresize', fn);else {
|
2547 | if (!element.__resizeTriggers__) {
|
2548 | if (getComputedStyle(element).position == 'static') element.style.position = 'relative';
|
2549 | createStyles();
|
2550 | element.__resizeLast__ = {};
|
2551 | element.__resizeListeners__ = [];
|
2552 | (element.__resizeTriggers__ = document.createElement('div')).className = 'resize-triggers';
|
2553 | element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div>' + '<div class="contract-trigger"></div>';
|
2554 | element.appendChild(element.__resizeTriggers__);
|
2555 | resetTriggers(element);
|
2556 |
|
2557 | (0, _passiveEvents2.default)(element, 'scroll', scrollListener, true);
|
2558 |
|
2559 |
|
2560 | animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
|
2561 | if (e.animationName == animationName) resetTriggers(element);
|
2562 | });
|
2563 | }
|
2564 | element.__resizeListeners__.push(fn);
|
2565 | }
|
2566 | };
|
2567 |
|
2568 | var removeResizeListener = function removeResizeListener(element, fn) {
|
2569 | element = element.parentNode;
|
2570 | if (attachEvent) element.detachEvent('onresize', fn);else {
|
2571 | element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
|
2572 | if (!element.__resizeListeners__.length) {
|
2573 | element.removeEventListener('scroll', scrollListener);
|
2574 | element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
|
2575 | }
|
2576 | }
|
2577 | };
|
2578 |
|
2579 | module.exports = {
|
2580 | addResizeListener: addResizeListener,
|
2581 | removeResizeListener: removeResizeListener
|
2582 | };
|
2583 |
|
2584 | }),
|
2585 |
|
2586 | (function(module, exports, __webpack_require__) {
|
2587 |
|
2588 | 'use strict';
|
2589 |
|
2590 | exports.__esModule = true;
|
2591 |
|
2592 | 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; };
|
2593 |
|
2594 | var _pointGeometry = __webpack_require__(2);
|
2595 |
|
2596 | var _pointGeometry2 = _interopRequireDefault(_pointGeometry);
|
2597 |
|
2598 | var _lat_lng = __webpack_require__(4);
|
2599 |
|
2600 | var _lat_lng2 = _interopRequireDefault(_lat_lng);
|
2601 |
|
2602 | var _transform = __webpack_require__(24);
|
2603 |
|
2604 | var _transform2 = _interopRequireDefault(_transform);
|
2605 |
|
2606 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2607 |
|
2608 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2609 |
|
2610 | var Geo = function () {
|
2611 | function Geo(tileSize) {
|
2612 | _classCallCheck(this, Geo);
|
2613 |
|
2614 |
|
2615 |
|
2616 | this.hasSize_ = false;
|
2617 | this.hasView_ = false;
|
2618 | this.transform_ = new _transform2.default(tileSize || 512);
|
2619 | }
|
2620 |
|
2621 | Geo.prototype.setView = function setView(center, zoom, bearing) {
|
2622 | this.transform_.center = _lat_lng2.default.convert(center);
|
2623 | this.transform_.zoom = +zoom;
|
2624 | this.transform_.bearing = +bearing;
|
2625 | this.hasView_ = true;
|
2626 | };
|
2627 |
|
2628 | Geo.prototype.setViewSize = function setViewSize(width, height) {
|
2629 | this.transform_.width = width;
|
2630 | this.transform_.height = height;
|
2631 | this.hasSize_ = true;
|
2632 | };
|
2633 |
|
2634 | Geo.prototype.setMapCanvasProjection = function setMapCanvasProjection(maps, mapCanvasProjection) {
|
2635 | this.maps_ = maps;
|
2636 | this.mapCanvasProjection_ = mapCanvasProjection;
|
2637 | };
|
2638 |
|
2639 | Geo.prototype.canProject = function canProject() {
|
2640 | return this.hasSize_ && this.hasView_;
|
2641 | };
|
2642 |
|
2643 | Geo.prototype.hasSize = function hasSize() {
|
2644 | return this.hasSize_;
|
2645 | };
|
2646 |
|
2647 |
|
2648 |
|
2649 |
|
2650 | Geo.prototype.fromLatLngToCenterPixel = function fromLatLngToCenterPixel(ptLatLng) {
|
2651 | return this.transform_.locationPoint(_lat_lng2.default.convert(ptLatLng));
|
2652 | };
|
2653 |
|
2654 | |
2655 |
|
2656 |
|
2657 |
|
2658 |
|
2659 |
|
2660 | Geo.prototype.fromLatLngToDivPixel = function fromLatLngToDivPixel(ptLatLng) {
|
2661 | if (this.mapCanvasProjection_) {
|
2662 | var latLng = new this.maps_.LatLng(ptLatLng.lat, ptLatLng.lng);
|
2663 | return this.mapCanvasProjection_.fromLatLngToDivPixel(latLng);
|
2664 | }
|
2665 | return this.fromLatLngToCenterPixel(ptLatLng);
|
2666 | };
|
2667 |
|
2668 |
|
2669 |
|
2670 |
|
2671 | Geo.prototype.fromLatLngToContainerPixel = function fromLatLngToContainerPixel(ptLatLng) {
|
2672 | if (this.mapCanvasProjection_) {
|
2673 | var latLng = new this.maps_.LatLng(ptLatLng.lat, ptLatLng.lng);
|
2674 | return this.mapCanvasProjection_.fromLatLngToContainerPixel(latLng);
|
2675 | }
|
2676 |
|
2677 | var pt = this.fromLatLngToCenterPixel(ptLatLng);
|
2678 | pt.x -= this.transform_.worldSize * Math.round(pt.x / this.transform_.worldSize);
|
2679 |
|
2680 | pt.x += this.transform_.width / 2;
|
2681 | pt.y += this.transform_.height / 2;
|
2682 |
|
2683 | return pt;
|
2684 | };
|
2685 |
|
2686 |
|
2687 |
|
2688 |
|
2689 | Geo.prototype.fromContainerPixelToLatLng = function fromContainerPixelToLatLng(ptXY) {
|
2690 | if (this.mapCanvasProjection_) {
|
2691 | var latLng = this.mapCanvasProjection_.fromContainerPixelToLatLng(ptXY);
|
2692 | return { lat: latLng.lat(), lng: latLng.lng() };
|
2693 | }
|
2694 |
|
2695 | var ptxy = _extends({}, ptXY);
|
2696 | ptxy.x -= this.transform_.width / 2;
|
2697 | ptxy.y -= this.transform_.height / 2;
|
2698 | var ptRes = this.transform_.pointLocation(_pointGeometry2.default.convert(ptxy));
|
2699 |
|
2700 | ptRes.lng -= 360 * Math.round(ptRes.lng / 360);
|
2701 | return ptRes;
|
2702 | };
|
2703 |
|
2704 | Geo.prototype.getWidth = function getWidth() {
|
2705 | return this.transform_.width;
|
2706 | };
|
2707 |
|
2708 | Geo.prototype.getHeight = function getHeight() {
|
2709 | return this.transform_.height;
|
2710 | };
|
2711 |
|
2712 | Geo.prototype.getZoom = function getZoom() {
|
2713 | return this.transform_.zoom;
|
2714 | };
|
2715 |
|
2716 | Geo.prototype.getCenter = function getCenter() {
|
2717 | var ptRes = this.transform_.pointLocation({ x: 0, y: 0 });
|
2718 |
|
2719 | return ptRes;
|
2720 | };
|
2721 |
|
2722 | Geo.prototype.getBounds = function getBounds(margins, roundFactor) {
|
2723 | var bndT = margins && margins[0] || 0;
|
2724 | var bndR = margins && margins[1] || 0;
|
2725 | var bndB = margins && margins[2] || 0;
|
2726 | var bndL = margins && margins[3] || 0;
|
2727 |
|
2728 | if (this.getWidth() - bndR - bndL > 0 && this.getHeight() - bndT - bndB > 0) {
|
2729 | var topLeftCorner = this.transform_.pointLocation(_pointGeometry2.default.convert({
|
2730 | x: bndL - this.getWidth() / 2,
|
2731 | y: bndT - this.getHeight() / 2
|
2732 | }));
|
2733 | var bottomRightCorner = this.transform_.pointLocation(_pointGeometry2.default.convert({
|
2734 | x: this.getWidth() / 2 - bndR,
|
2735 | y: this.getHeight() / 2 - bndB
|
2736 | }));
|
2737 |
|
2738 | var res = [topLeftCorner.lat, topLeftCorner.lng,
|
2739 | bottomRightCorner.lat, bottomRightCorner.lng,
|
2740 | bottomRightCorner.lat, topLeftCorner.lng,
|
2741 | topLeftCorner.lat, bottomRightCorner.lng];
|
2742 |
|
2743 | if (roundFactor) {
|
2744 | res = res.map(function (r) {
|
2745 | return Math.round(r * roundFactor) / roundFactor;
|
2746 | });
|
2747 | }
|
2748 | return res;
|
2749 | }
|
2750 |
|
2751 | return [0, 0, 0, 0];
|
2752 | };
|
2753 |
|
2754 | return Geo;
|
2755 | }();
|
2756 |
|
2757 | exports.default = Geo;
|
2758 |
|
2759 | }),
|
2760 |
|
2761 | (function(module, exports) {
|
2762 |
|
2763 | "use strict";
|
2764 |
|
2765 | exports.__esModule = true;
|
2766 | exports.default = isArraysEqualEps;
|
2767 | function isArraysEqualEps(arrayA, arrayB, eps) {
|
2768 | if (arrayA && arrayB) {
|
2769 | for (var i = 0; i !== arrayA.length; ++i) {
|
2770 | if (Math.abs(arrayA[i] - arrayB[i]) > eps) {
|
2771 | return false;
|
2772 | }
|
2773 | }
|
2774 | return true;
|
2775 | }
|
2776 | return false;
|
2777 | }
|
2778 |
|
2779 | }),
|
2780 |
|
2781 | (function(module, exports) {
|
2782 |
|
2783 | 'use strict';
|
2784 |
|
2785 | exports.__esModule = true;
|
2786 |
|
2787 | 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; };
|
2788 |
|
2789 | var isEmpty = function isEmpty(val) {
|
2790 |
|
2791 | if (val !== null && (typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') {
|
2792 | if (Object.keys(val).length === 0) {
|
2793 | return true;
|
2794 | }
|
2795 | } else if (val === null || val === undefined || val === '') {
|
2796 |
|
2797 | return true;
|
2798 | }
|
2799 | return false;
|
2800 | };
|
2801 |
|
2802 | exports.default = isEmpty;
|
2803 |
|
2804 | }),
|
2805 |
|
2806 | (function(module, exports) {
|
2807 |
|
2808 | 'use strict';
|
2809 |
|
2810 | exports.__esModule = true;
|
2811 |
|
2812 | 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; };
|
2813 |
|
2814 | exports.default = isNumber;
|
2815 | function isObjectLike(value) {
|
2816 | return !!value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object';
|
2817 | }
|
2818 |
|
2819 | var objectToString = Object.prototype.toString;
|
2820 |
|
2821 | function isNumber(value) {
|
2822 | var numberTag = '[object Number]';
|
2823 | return typeof value === 'number' || isObjectLike(value) && objectToString.call(value) === numberTag;
|
2824 | }
|
2825 |
|
2826 | }),
|
2827 |
|
2828 | (function(module, exports) {
|
2829 |
|
2830 | 'use strict';
|
2831 |
|
2832 | exports.__esModule = true;
|
2833 |
|
2834 | 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; };
|
2835 |
|
2836 | exports.default = isPlainObject;
|
2837 |
|
2838 | var fnToString = function fnToString(fn) {
|
2839 | return Function.prototype.toString.call(fn);
|
2840 | };
|
2841 |
|
2842 | |
2843 |
|
2844 |
|
2845 |
|
2846 | function isPlainObject(obj) {
|
2847 | if (!obj || (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') {
|
2848 | return false;
|
2849 | }
|
2850 |
|
2851 | var proto = typeof obj.constructor === 'function' ? Object.getPrototypeOf(obj) : Object.prototype;
|
2852 |
|
2853 | if (proto === null) {
|
2854 | return true;
|
2855 | }
|
2856 |
|
2857 | var constructor = proto.constructor;
|
2858 |
|
2859 | return typeof constructor === 'function' && constructor instanceof constructor && fnToString(constructor) === fnToString(Object);
|
2860 | }
|
2861 |
|
2862 | /***/ }),
|
2863 | /* 24 */
|
2864 | /***/ (function(module, exports, __webpack_require__) {
|
2865 |
|
2866 | 'use strict';
|
2867 |
|
2868 | exports.__esModule = true;
|
2869 |
|
2870 | 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; }; }();
|
2871 |
|
2872 |
|
2873 | var _pointGeometry = __webpack_require__(2);
|
2874 |
|
2875 | var _pointGeometry2 = _interopRequireDefault(_pointGeometry);
|
2876 |
|
2877 | var _lat_lng = __webpack_require__(4);
|
2878 |
|
2879 | var _lat_lng2 = _interopRequireDefault(_lat_lng);
|
2880 |
|
2881 | var _wrap = __webpack_require__(5);
|
2882 |
|
2883 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2884 |
|
2885 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2886 |
|
2887 |
|
2888 | var Transform = function () {
|
2889 | function Transform(tileSize, minZoom, maxZoom) {
|
2890 | _classCallCheck(this, Transform);
|
2891 |
|
2892 | this.tileSize = tileSize || 512;
|
2893 |
|
2894 | this._minZoom = minZoom || 0;
|
2895 | this._maxZoom = maxZoom || 52;
|
2896 |
|
2897 | this.latRange = [-85.05113, 85.05113];
|
2898 |
|
2899 | this.width = 0;
|
2900 | this.height = 0;
|
2901 | this.zoom = 0;
|
2902 | this.center = new _lat_lng2.default(0, 0);
|
2903 | this.angle = 0;
|
2904 | }
|
2905 |
|
2906 | Transform.prototype.zoomScale = function zoomScale(zoom) {
|
2907 | return Math.pow(2, zoom);
|
2908 | };
|
2909 |
|
2910 | Transform.prototype.scaleZoom = function scaleZoom(scale) {
|
2911 | return Math.log(scale) / Math.LN2;
|
2912 | };
|
2913 |
|
2914 | Transform.prototype.project = function project(latlng, worldSize) {
|
2915 | return new _pointGeometry2.default(this.lngX(latlng.lng, worldSize), this.latY(latlng.lat, worldSize));
|
2916 | };
|
2917 |
|
2918 | Transform.prototype.unproject = function unproject(point, worldSize) {
|
2919 | return new _lat_lng2.default(this.yLat(point.y, worldSize), this.xLng(point.x, worldSize));
|
2920 | };
|
2921 |
|
2922 |
|
2923 | Transform.prototype.lngX = function lngX(lon, worldSize) {
|
2924 | return (180 + lon) * (worldSize || this.worldSize) / 360;
|
2925 | };
|
2926 |
|
2927 |
|
2928 |
|
2929 |
|
2930 | Transform.prototype.latY = function latY(lat, worldSize) {
|
2931 | var y = 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360));
|
2932 | return (180 - y) * (worldSize || this.worldSize) / 360;
|
2933 | };
|
2934 |
|
2935 | Transform.prototype.xLng = function xLng(x, worldSize) {
|
2936 | return x * 360 / (worldSize || this.worldSize) - 180;
|
2937 | };
|
2938 |
|
2939 | Transform.prototype.yLat = function yLat(y, worldSize) {
|
2940 | var y2 = 180 - y * 360 / (worldSize || this.worldSize);
|
2941 | return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
2942 | };
|
2943 |
|
2944 | Transform.prototype.locationPoint = function locationPoint(latlng) {
|
2945 | var p = this.project(latlng);
|
2946 | return this.centerPoint._sub(this.point._sub(p)._rotate(this.angle));
|
2947 | };
|
2948 |
|
2949 | Transform.prototype.pointLocation = function pointLocation(p) {
|
2950 | var p2 = this.centerPoint._sub(p)._rotate(-this.angle);
|
2951 | return this.unproject(this.point.sub(p2));
|
2952 | };
|
2953 |
|
2954 | _createClass(Transform, [{
|
2955 | key: 'minZoom',
|
2956 | get: function get() {
|
2957 | return this._minZoom;
|
2958 | },
|
2959 | set: function set(zoom) {
|
2960 | this._minZoom = zoom;
|
2961 | this.zoom = Math.max(this.zoom, zoom);
|
2962 | }
|
2963 | }, {
|
2964 | key: 'maxZoom',
|
2965 | get: function get() {
|
2966 | return this._maxZoom;
|
2967 | },
|
2968 | set: function set(zoom) {
|
2969 | this._maxZoom = zoom;
|
2970 | this.zoom = Math.min(this.zoom, zoom);
|
2971 | }
|
2972 | }, {
|
2973 | key: 'worldSize',
|
2974 | get: function get() {
|
2975 | return this.tileSize * this.scale;
|
2976 | }
|
2977 | }, {
|
2978 | key: 'centerPoint',
|
2979 | get: function get() {
|
2980 | return new _pointGeometry2.default(0, 0);
|
2981 | }
|
2982 | }, {
|
2983 | key: 'size',
|
2984 | get: function get() {
|
2985 | return new _pointGeometry2.default(this.width, this.height);
|
2986 | }
|
2987 | }, {
|
2988 | key: 'bearing',
|
2989 | get: function get() {
|
2990 | return -this.angle / Math.PI * 180;
|
2991 | },
|
2992 | set: function set(bearing) {
|
2993 | this.angle = -(0, _wrap.wrap)(bearing, -180, 180) * Math.PI / 180;
|
2994 | }
|
2995 | }, {
|
2996 | key: 'zoom',
|
2997 | get: function get() {
|
2998 | return this._zoom;
|
2999 | },
|
3000 | set: function set(zoom) {
|
3001 | var zoomV = Math.min(Math.max(zoom, this.minZoom), this.maxZoom);
|
3002 | this._zoom = zoomV;
|
3003 | this.scale = this.zoomScale(zoomV);
|
3004 | this.tileZoom = Math.floor(zoomV);
|
3005 | this.zoomFraction = zoomV - this.tileZoom;
|
3006 | }
|
3007 | }, {
|
3008 | key: 'x',
|
3009 | get: function get() {
|
3010 | return this.lngX(this.center.lng);
|
3011 | }
|
3012 | }, {
|
3013 | key: 'y',
|
3014 | get: function get() {
|
3015 | return this.latY(this.center.lat);
|
3016 | }
|
3017 | }, {
|
3018 | key: 'point',
|
3019 | get: function get() {
|
3020 | return new _pointGeometry2.default(this.x, this.y);
|
3021 | }
|
3022 | }]);
|
3023 |
|
3024 | return Transform;
|
3025 | }();
|
3026 |
|
3027 | exports.default = Transform;
|
3028 |
|
3029 | }),
|
3030 |
|
3031 | (function(module, exports) {
|
3032 |
|
3033 | "use strict";
|
3034 |
|
3035 | exports.__esModule = true;
|
3036 | var log2 = Math.log2 ? Math.log2 : function (x) {
|
3037 | return Math.log(x) / Math.LN2;
|
3038 | };
|
3039 |
|
3040 | exports.default = log2;
|
3041 |
|
3042 | }),
|
3043 |
|
3044 | (function(module, exports) {
|
3045 |
|
3046 | "use strict";
|
3047 |
|
3048 | exports.__esModule = true;
|
3049 | exports.default = pick;
|
3050 |
|
3051 |
|
3052 | function pick(obj, fn) {
|
3053 | return Object.keys(obj).reduce(function (result, key) {
|
3054 | if (fn(obj[key])) {
|
3055 | result[key] = obj[key];
|
3056 | }
|
3057 | return result;
|
3058 | }, {});
|
3059 | }
|
3060 |
|
3061 | }),
|
3062 |
|
3063 | (function(module, exports) {
|
3064 |
|
3065 | "use strict";
|
3066 |
|
3067 | exports.__esModule = true;
|
3068 | exports.default = raf;
|
3069 | function raf(callback) {
|
3070 | if (window.requestAnimationFrame) {
|
3071 | return window.requestAnimationFrame(callback);
|
3072 | }
|
3073 |
|
3074 | var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
|
3075 |
|
3076 | return nativeRaf ? nativeRaf(callback) : window.setTimeout(callback, 1e3 / 60);
|
3077 | }
|
3078 |
|
3079 | }),
|
3080 |
|
3081 | (function(module, exports, __webpack_require__) {
|
3082 |
|
3083 | 'use strict';
|
3084 |
|
3085 | var has = Object.prototype.hasOwnProperty;
|
3086 |
|
3087 |
|
3088 |
|
3089 |
|
3090 |
|
3091 |
|
3092 |
|
3093 |
|
3094 |
|
3095 | var prefix = typeof Object.create !== 'function' ? '~' : false;
|
3096 |
|
3097 | |
3098 |
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 |
|
3104 |
|
3105 | function EE(fn, context, once) {
|
3106 | this.fn = fn;
|
3107 | this.context = context;
|
3108 | this.once = once || false;
|
3109 | }
|
3110 |
|
3111 | |
3112 |
|
3113 |
|
3114 |
|
3115 |
|
3116 |
|
3117 |
|
3118 | function EventEmitter() { }
|
3119 |
|
3120 | |
3121 |
|
3122 |
|
3123 |
|
3124 |
|
3125 |
|
3126 | EventEmitter.prototype._events = undefined;
|
3127 |
|
3128 | |
3129 |
|
3130 |
|
3131 |
|
3132 |
|
3133 |
|
3134 |
|
3135 | EventEmitter.prototype.eventNames = function eventNames() {
|
3136 | var events = this._events
|
3137 | , names = []
|
3138 | , name;
|
3139 |
|
3140 | if (!events) return names;
|
3141 |
|
3142 | for (name in events) {
|
3143 | if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
3144 | }
|
3145 |
|
3146 | if (Object.getOwnPropertySymbols) {
|
3147 | return names.concat(Object.getOwnPropertySymbols(events));
|
3148 | }
|
3149 |
|
3150 | return names;
|
3151 | };
|
3152 |
|
3153 | |
3154 |
|
3155 |
|
3156 |
|
3157 |
|
3158 |
|
3159 |
|
3160 |
|
3161 | EventEmitter.prototype.listeners = function listeners(event, exists) {
|
3162 | var evt = prefix ? prefix + event : event
|
3163 | , available = this._events && this._events[evt];
|
3164 |
|
3165 | if (exists) return !!available;
|
3166 | if (!available) return [];
|
3167 | if (available.fn) return [available.fn];
|
3168 |
|
3169 | for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
|
3170 | ee[i] = available[i].fn;
|
3171 | }
|
3172 |
|
3173 | return ee;
|
3174 | };
|
3175 |
|
3176 | |
3177 |
|
3178 |
|
3179 |
|
3180 |
|
3181 |
|
3182 |
|
3183 | EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
3184 | var evt = prefix ? prefix + event : event;
|
3185 |
|
3186 | if (!this._events || !this._events[evt]) return false;
|
3187 |
|
3188 | var listeners = this._events[evt]
|
3189 | , len = arguments.length
|
3190 | , args
|
3191 | , i;
|
3192 |
|
3193 | if ('function' === typeof listeners.fn) {
|
3194 | if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
3195 |
|
3196 | switch (len) {
|
3197 | case 1: return listeners.fn.call(listeners.context), true;
|
3198 | case 2: return listeners.fn.call(listeners.context, a1), true;
|
3199 | case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
3200 | case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
3201 | case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
3202 | case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
3203 | }
|
3204 |
|
3205 | for (i = 1, args = new Array(len -1); i < len; i++) {
|
3206 | args[i - 1] = arguments[i];
|
3207 | }
|
3208 |
|
3209 | listeners.fn.apply(listeners.context, args);
|
3210 | } else {
|
3211 | var length = listeners.length
|
3212 | , j;
|
3213 |
|
3214 | for (i = 0; i < length; i++) {
|
3215 | if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
3216 |
|
3217 | switch (len) {
|
3218 | case 1: listeners[i].fn.call(listeners[i].context); break;
|
3219 | case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
3220 | case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
3221 | default:
|
3222 | if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
3223 | args[j - 1] = arguments[j];
|
3224 | }
|
3225 |
|
3226 | listeners[i].fn.apply(listeners[i].context, args);
|
3227 | }
|
3228 | }
|
3229 | }
|
3230 |
|
3231 | return true;
|
3232 | };
|
3233 |
|
3234 | |
3235 |
|
3236 |
|
3237 |
|
3238 |
|
3239 |
|
3240 |
|
3241 |
|
3242 | EventEmitter.prototype.on = function on(event, fn, context) {
|
3243 | var listener = new EE(fn, context || this)
|
3244 | , evt = prefix ? prefix + event : event;
|
3245 |
|
3246 | if (!this._events) this._events = prefix ? {} : Object.create(null);
|
3247 | if (!this._events[evt]) this._events[evt] = listener;
|
3248 | else {
|
3249 | if (!this._events[evt].fn) this._events[evt].push(listener);
|
3250 | else this._events[evt] = [
|
3251 | this._events[evt], listener
|
3252 | ];
|
3253 | }
|
3254 |
|
3255 | return this;
|
3256 | };
|
3257 |
|
3258 | |
3259 |
|
3260 |
|
3261 |
|
3262 |
|
3263 |
|
3264 |
|
3265 |
|
3266 | EventEmitter.prototype.once = function once(event, fn, context) {
|
3267 | var listener = new EE(fn, context || this, true)
|
3268 | , evt = prefix ? prefix + event : event;
|
3269 |
|
3270 | if (!this._events) this._events = prefix ? {} : Object.create(null);
|
3271 | if (!this._events[evt]) this._events[evt] = listener;
|
3272 | else {
|
3273 | if (!this._events[evt].fn) this._events[evt].push(listener);
|
3274 | else this._events[evt] = [
|
3275 | this._events[evt], listener
|
3276 | ];
|
3277 | }
|
3278 |
|
3279 | return this;
|
3280 | };
|
3281 |
|
3282 | |
3283 |
|
3284 |
|
3285 |
|
3286 |
|
3287 |
|
3288 |
|
3289 |
|
3290 |
|
3291 | EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
3292 | var evt = prefix ? prefix + event : event;
|
3293 |
|
3294 | if (!this._events || !this._events[evt]) return this;
|
3295 |
|
3296 | var listeners = this._events[evt]
|
3297 | , events = [];
|
3298 |
|
3299 | if (fn) {
|
3300 | if (listeners.fn) {
|
3301 | if (
|
3302 | listeners.fn !== fn
|
3303 | || (once && !listeners.once)
|
3304 | || (context && listeners.context !== context)
|
3305 | ) {
|
3306 | events.push(listeners);
|
3307 | }
|
3308 | } else {
|
3309 | for (var i = 0, length = listeners.length; i < length; i++) {
|
3310 | if (
|
3311 | listeners[i].fn !== fn
|
3312 | || (once && !listeners[i].once)
|
3313 | || (context && listeners[i].context !== context)
|
3314 | ) {
|
3315 | events.push(listeners[i]);
|
3316 | }
|
3317 | }
|
3318 | }
|
3319 | }
|
3320 |
|
3321 |
|
3322 |
|
3323 |
|
3324 | if (events.length) {
|
3325 | this._events[evt] = events.length === 1 ? events[0] : events;
|
3326 | } else {
|
3327 | delete this._events[evt];
|
3328 | }
|
3329 |
|
3330 | return this;
|
3331 | };
|
3332 |
|
3333 | |
3334 |
|
3335 |
|
3336 |
|
3337 |
|
3338 |
|
3339 | EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
3340 | if (!this._events) return this;
|
3341 |
|
3342 | if (event) delete this._events[prefix ? prefix + event : event];
|
3343 | else this._events = prefix ? {} : Object.create(null);
|
3344 |
|
3345 | return this;
|
3346 | };
|
3347 |
|
3348 |
|
3349 |
|
3350 |
|
3351 | EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
3352 | EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
3353 |
|
3354 |
|
3355 |
|
3356 |
|
3357 | EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
|
3358 | return this;
|
3359 | };
|
3360 |
|
3361 |
|
3362 |
|
3363 |
|
3364 | EventEmitter.prefixed = prefix;
|
3365 |
|
3366 |
|
3367 |
|
3368 |
|
3369 | if (true) {
|
3370 | module.exports = EventEmitter;
|
3371 | }
|
3372 |
|
3373 |
|
3374 | }),
|
3375 |
|
3376 | (function(module, exports) {
|
3377 |
|
3378 | |
3379 |
|
3380 |
|
3381 |
|
3382 |
|
3383 |
|
3384 | 'use strict';
|
3385 |
|
3386 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
3387 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
3388 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
3389 |
|
3390 | function toObject(val) {
|
3391 | if (val === null || val === undefined) {
|
3392 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
3393 | }
|
3394 |
|
3395 | return Object(val);
|
3396 | }
|
3397 |
|
3398 | function shouldUseNative() {
|
3399 | try {
|
3400 | if (!Object.assign) {
|
3401 | return false;
|
3402 | }
|
3403 |
|
3404 |
|
3405 |
|
3406 |
|
3407 | var test1 = new String('abc');
|
3408 | test1[5] = 'de';
|
3409 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
3410 | return false;
|
3411 | }
|
3412 |
|
3413 |
|
3414 | var test2 = {};
|
3415 | for (var i = 0; i < 10; i++) {
|
3416 | test2['_' + String.fromCharCode(i)] = i;
|
3417 | }
|
3418 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
3419 | return test2[n];
|
3420 | });
|
3421 | if (order2.join('') !== '0123456789') {
|
3422 | return false;
|
3423 | }
|
3424 |
|
3425 |
|
3426 | var test3 = {};
|
3427 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
3428 | test3[letter] = letter;
|
3429 | });
|
3430 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
3431 | 'abcdefghijklmnopqrst') {
|
3432 | return false;
|
3433 | }
|
3434 |
|
3435 | return true;
|
3436 | } catch (err) {
|
3437 |
|
3438 | return false;
|
3439 | }
|
3440 | }
|
3441 |
|
3442 | module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
3443 | var from;
|
3444 | var to = toObject(target);
|
3445 | var symbols;
|
3446 |
|
3447 | for (var s = 1; s < arguments.length; s++) {
|
3448 | from = Object(arguments[s]);
|
3449 |
|
3450 | for (var key in from) {
|
3451 | if (hasOwnProperty.call(from, key)) {
|
3452 | to[key] = from[key];
|
3453 | }
|
3454 | }
|
3455 |
|
3456 | if (getOwnPropertySymbols) {
|
3457 | symbols = getOwnPropertySymbols(from);
|
3458 | for (var i = 0; i < symbols.length; i++) {
|
3459 | if (propIsEnumerable.call(from, symbols[i])) {
|
3460 | to[symbols[i]] = from[symbols[i]];
|
3461 | }
|
3462 | }
|
3463 | }
|
3464 | }
|
3465 |
|
3466 | return to;
|
3467 | };
|
3468 |
|
3469 |
|
3470 | }),
|
3471 |
|
3472 | (function(module, exports, __webpack_require__) {
|
3473 |
|
3474 | |
3475 |
|
3476 |
|
3477 |
|
3478 |
|
3479 |
|
3480 |
|
3481 | 'use strict';
|
3482 |
|
3483 | var printWarning = function() {};
|
3484 |
|
3485 | if (true) {
|
3486 | var ReactPropTypesSecret = __webpack_require__(10);
|
3487 | var loggedTypeFailures = {};
|
3488 |
|
3489 | printWarning = function(text) {
|
3490 | var message = 'Warning: ' + text;
|
3491 | if (typeof console !== 'undefined') {
|
3492 | console.error(message);
|
3493 | }
|
3494 | try {
|
3495 |
|
3496 |
|
3497 |
|
3498 | throw new Error(message);
|
3499 | } catch (x) {}
|
3500 | };
|
3501 | }
|
3502 |
|
3503 | |
3504 |
|
3505 |
|
3506 |
|
3507 |
|
3508 |
|
3509 |
|
3510 |
|
3511 |
|
3512 |
|
3513 |
|
3514 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
3515 | if (true) {
|
3516 | for (var typeSpecName in typeSpecs) {
|
3517 | if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
3518 | var error;
|
3519 |
|
3520 |
|
3521 |
|
3522 | try {
|
3523 |
|
3524 |
|
3525 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
3526 | var err = Error(
|
3527 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
3528 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
3529 | );
|
3530 | err.name = 'Invariant Violation';
|
3531 | throw err;
|
3532 | }
|
3533 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
3534 | } catch (ex) {
|
3535 | error = ex;
|
3536 | }
|
3537 | if (error && !(error instanceof Error)) {
|
3538 | printWarning(
|
3539 | (componentName || 'React class') + ': type specification of ' +
|
3540 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
3541 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
3542 | 'You may have forgotten to pass an argument to the type checker ' +
|
3543 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
3544 | 'shape all require an argument).'
|
3545 | )
|
3546 |
|
3547 | }
|
3548 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
3549 |
|
3550 |
|
3551 | loggedTypeFailures[error.message] = true;
|
3552 |
|
3553 | var stack = getStack ? getStack() : '';
|
3554 |
|
3555 | printWarning(
|
3556 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
3557 | );
|
3558 | }
|
3559 | }
|
3560 | }
|
3561 | }
|
3562 | }
|
3563 |
|
3564 | module.exports = checkPropTypes;
|
3565 |
|
3566 |
|
3567 | }),
|
3568 |
|
3569 | (function(module, exports, __webpack_require__) {
|
3570 |
|
3571 | |
3572 |
|
3573 |
|
3574 |
|
3575 |
|
3576 |
|
3577 |
|
3578 | 'use strict';
|
3579 |
|
3580 | var assign = __webpack_require__(29);
|
3581 |
|
3582 | var ReactPropTypesSecret = __webpack_require__(10);
|
3583 | var checkPropTypes = __webpack_require__(30);
|
3584 |
|
3585 | var printWarning = function() {};
|
3586 |
|
3587 | if (true) {
|
3588 | printWarning = function(text) {
|
3589 | var message = 'Warning: ' + text;
|
3590 | if (typeof console !== 'undefined') {
|
3591 | console.error(message);
|
3592 | }
|
3593 | try {
|
3594 |
|
3595 |
|
3596 |
|
3597 | throw new Error(message);
|
3598 | } catch (x) {}
|
3599 | };
|
3600 | }
|
3601 |
|
3602 | function emptyFunctionThatReturnsNull() {
|
3603 | return null;
|
3604 | }
|
3605 |
|
3606 | module.exports = function(isValidElement, throwOnDirectAccess) {
|
3607 |
|
3608 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
3609 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
3610 |
|
3611 | |
3612 |
|
3613 |
|
3614 |
|
3615 |
|
3616 |
|
3617 |
|
3618 |
|
3619 |
|
3620 |
|
3621 |
|
3622 |
|
3623 |
|
3624 |
|
3625 | function getIteratorFn(maybeIterable) {
|
3626 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
3627 | if (typeof iteratorFn === 'function') {
|
3628 | return iteratorFn;
|
3629 | }
|
3630 | }
|
3631 |
|
3632 | |
3633 |
|
3634 |
|
3635 |
|
3636 |
|
3637 |
|
3638 |
|
3639 |
|
3640 |
|
3641 |
|
3642 |
|
3643 |
|
3644 |
|
3645 |
|
3646 |
|
3647 |
|
3648 |
|
3649 |
|
3650 |
|
3651 |
|
3652 |
|
3653 |
|
3654 |
|
3655 |
|
3656 |
|
3657 |
|
3658 |
|
3659 |
|
3660 |
|
3661 |
|
3662 |
|
3663 |
|
3664 |
|
3665 |
|
3666 |
|
3667 |
|
3668 |
|
3669 |
|
3670 |
|
3671 |
|
3672 |
|
3673 |
|
3674 |
|
3675 |
|
3676 |
|
3677 |
|
3678 |
|
3679 | var ANONYMOUS = '<<anonymous>>';
|
3680 |
|
3681 |
|
3682 |
|
3683 | var ReactPropTypes = {
|
3684 | array: createPrimitiveTypeChecker('array'),
|
3685 | bool: createPrimitiveTypeChecker('boolean'),
|
3686 | func: createPrimitiveTypeChecker('function'),
|
3687 | number: createPrimitiveTypeChecker('number'),
|
3688 | object: createPrimitiveTypeChecker('object'),
|
3689 | string: createPrimitiveTypeChecker('string'),
|
3690 | symbol: createPrimitiveTypeChecker('symbol'),
|
3691 |
|
3692 | any: createAnyTypeChecker(),
|
3693 | arrayOf: createArrayOfTypeChecker,
|
3694 | element: createElementTypeChecker(),
|
3695 | instanceOf: createInstanceTypeChecker,
|
3696 | node: createNodeChecker(),
|
3697 | objectOf: createObjectOfTypeChecker,
|
3698 | oneOf: createEnumTypeChecker,
|
3699 | oneOfType: createUnionTypeChecker,
|
3700 | shape: createShapeTypeChecker,
|
3701 | exact: createStrictShapeTypeChecker,
|
3702 | };
|
3703 |
|
3704 | |
3705 |
|
3706 |
|
3707 |
|
3708 |
|
3709 | function is(x, y) {
|
3710 |
|
3711 | if (x === y) {
|
3712 |
|
3713 |
|
3714 | return x !== 0 || 1 / x === 1 / y;
|
3715 | } else {
|
3716 |
|
3717 | return x !== x && y !== y;
|
3718 | }
|
3719 | }
|
3720 |
|
3721 |
|
3722 | |
3723 |
|
3724 |
|
3725 |
|
3726 |
|
3727 |
|
3728 |
|
3729 | function PropTypeError(message) {
|
3730 | this.message = message;
|
3731 | this.stack = '';
|
3732 | }
|
3733 |
|
3734 | PropTypeError.prototype = Error.prototype;
|
3735 |
|
3736 | function createChainableTypeChecker(validate) {
|
3737 | if (true) {
|
3738 | var manualPropTypeCallCache = {};
|
3739 | var manualPropTypeWarningCount = 0;
|
3740 | }
|
3741 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
3742 | componentName = componentName || ANONYMOUS;
|
3743 | propFullName = propFullName || propName;
|
3744 |
|
3745 | if (secret !== ReactPropTypesSecret) {
|
3746 | if (throwOnDirectAccess) {
|
3747 |
|
3748 | var err = new Error(
|
3749 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
3750 | 'Use `PropTypes.checkPropTypes()` to call them. ' +
|
3751 | 'Read more at http://fb.me/use-check-prop-types'
|
3752 | );
|
3753 | err.name = 'Invariant Violation';
|
3754 | throw err;
|
3755 | } else if (("development") !== 'production' && typeof console !== 'undefined') {
|
3756 |
|
3757 | var cacheKey = componentName + ':' + propName;
|
3758 | if (
|
3759 | !manualPropTypeCallCache[cacheKey] &&
|
3760 |
|
3761 | manualPropTypeWarningCount < 3
|
3762 | ) {
|
3763 | printWarning(
|
3764 | 'You are manually calling a React.PropTypes validation ' +
|
3765 | 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
3766 | 'and will throw in the standalone `prop-types` package. ' +
|
3767 | 'You may be seeing this warning due to a third-party PropTypes ' +
|
3768 | 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
3769 | );
|
3770 | manualPropTypeCallCache[cacheKey] = true;
|
3771 | manualPropTypeWarningCount++;
|
3772 | }
|
3773 | }
|
3774 | }
|
3775 | if (props[propName] == null) {
|
3776 | if (isRequired) {
|
3777 | if (props[propName] === null) {
|
3778 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
3779 | }
|
3780 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
3781 | }
|
3782 | return null;
|
3783 | } else {
|
3784 | return validate(props, propName, componentName, location, propFullName);
|
3785 | }
|
3786 | }
|
3787 |
|
3788 | var chainedCheckType = checkType.bind(null, false);
|
3789 | chainedCheckType.isRequired = checkType.bind(null, true);
|
3790 |
|
3791 | return chainedCheckType;
|
3792 | }
|
3793 |
|
3794 | function createPrimitiveTypeChecker(expectedType) {
|
3795 | function validate(props, propName, componentName, location, propFullName, secret) {
|
3796 | var propValue = props[propName];
|
3797 | var propType = getPropType(propValue);
|
3798 | if (propType !== expectedType) {
|
3799 |
|
3800 |
|
3801 |
|
3802 | var preciseType = getPreciseType(propValue);
|
3803 |
|
3804 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
3805 | }
|
3806 | return null;
|
3807 | }
|
3808 | return createChainableTypeChecker(validate);
|
3809 | }
|
3810 |
|
3811 | function createAnyTypeChecker() {
|
3812 | return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
3813 | }
|
3814 |
|
3815 | function createArrayOfTypeChecker(typeChecker) {
|
3816 | function validate(props, propName, componentName, location, propFullName) {
|
3817 | if (typeof typeChecker !== 'function') {
|
3818 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
3819 | }
|
3820 | var propValue = props[propName];
|
3821 | if (!Array.isArray(propValue)) {
|
3822 | var propType = getPropType(propValue);
|
3823 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
3824 | }
|
3825 | for (var i = 0; i < propValue.length; i++) {
|
3826 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
3827 | if (error instanceof Error) {
|
3828 | return error;
|
3829 | }
|
3830 | }
|
3831 | return null;
|
3832 | }
|
3833 | return createChainableTypeChecker(validate);
|
3834 | }
|
3835 |
|
3836 | function createElementTypeChecker() {
|
3837 | function validate(props, propName, componentName, location, propFullName) {
|
3838 | var propValue = props[propName];
|
3839 | if (!isValidElement(propValue)) {
|
3840 | var propType = getPropType(propValue);
|
3841 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
3842 | }
|
3843 | return null;
|
3844 | }
|
3845 | return createChainableTypeChecker(validate);
|
3846 | }
|
3847 |
|
3848 | function createInstanceTypeChecker(expectedClass) {
|
3849 | function validate(props, propName, componentName, location, propFullName) {
|
3850 | if (!(props[propName] instanceof expectedClass)) {
|
3851 | var expectedClassName = expectedClass.name || ANONYMOUS;
|
3852 | var actualClassName = getClassName(props[propName]);
|
3853 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
3854 | }
|
3855 | return null;
|
3856 | }
|
3857 | return createChainableTypeChecker(validate);
|
3858 | }
|
3859 |
|
3860 | function createEnumTypeChecker(expectedValues) {
|
3861 | if (!Array.isArray(expectedValues)) {
|
3862 | true ? printWarning('Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
|
3863 | return emptyFunctionThatReturnsNull;
|
3864 | }
|
3865 |
|
3866 | function validate(props, propName, componentName, location, propFullName) {
|
3867 | var propValue = props[propName];
|
3868 | for (var i = 0; i < expectedValues.length; i++) {
|
3869 | if (is(propValue, expectedValues[i])) {
|
3870 | return null;
|
3871 | }
|
3872 | }
|
3873 |
|
3874 | var valuesString = JSON.stringify(expectedValues);
|
3875 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
3876 | }
|
3877 | return createChainableTypeChecker(validate);
|
3878 | }
|
3879 |
|
3880 | function createObjectOfTypeChecker(typeChecker) {
|
3881 | function validate(props, propName, componentName, location, propFullName) {
|
3882 | if (typeof typeChecker !== 'function') {
|
3883 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
3884 | }
|
3885 | var propValue = props[propName];
|
3886 | var propType = getPropType(propValue);
|
3887 | if (propType !== 'object') {
|
3888 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
3889 | }
|
3890 | for (var key in propValue) {
|
3891 | if (propValue.hasOwnProperty(key)) {
|
3892 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
3893 | if (error instanceof Error) {
|
3894 | return error;
|
3895 | }
|
3896 | }
|
3897 | }
|
3898 | return null;
|
3899 | }
|
3900 | return createChainableTypeChecker(validate);
|
3901 | }
|
3902 |
|
3903 | function createUnionTypeChecker(arrayOfTypeCheckers) {
|
3904 | if (!Array.isArray(arrayOfTypeCheckers)) {
|
3905 | true ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
3906 | return emptyFunctionThatReturnsNull;
|
3907 | }
|
3908 |
|
3909 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
3910 | var checker = arrayOfTypeCheckers[i];
|
3911 | if (typeof checker !== 'function') {
|
3912 | printWarning(
|
3913 | 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
3914 | 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
3915 | );
|
3916 | return emptyFunctionThatReturnsNull;
|
3917 | }
|
3918 | }
|
3919 |
|
3920 | function validate(props, propName, componentName, location, propFullName) {
|
3921 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
3922 | var checker = arrayOfTypeCheckers[i];
|
3923 | if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
|
3924 | return null;
|
3925 | }
|
3926 | }
|
3927 |
|
3928 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
3929 | }
|
3930 | return createChainableTypeChecker(validate);
|
3931 | }
|
3932 |
|
3933 | function createNodeChecker() {
|
3934 | function validate(props, propName, componentName, location, propFullName) {
|
3935 | if (!isNode(props[propName])) {
|
3936 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
3937 | }
|
3938 | return null;
|
3939 | }
|
3940 | return createChainableTypeChecker(validate);
|
3941 | }
|
3942 |
|
3943 | function createShapeTypeChecker(shapeTypes) {
|
3944 | function validate(props, propName, componentName, location, propFullName) {
|
3945 | var propValue = props[propName];
|
3946 | var propType = getPropType(propValue);
|
3947 | if (propType !== 'object') {
|
3948 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
3949 | }
|
3950 | for (var key in shapeTypes) {
|
3951 | var checker = shapeTypes[key];
|
3952 | if (!checker) {
|
3953 | continue;
|
3954 | }
|
3955 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
3956 | if (error) {
|
3957 | return error;
|
3958 | }
|
3959 | }
|
3960 | return null;
|
3961 | }
|
3962 | return createChainableTypeChecker(validate);
|
3963 | }
|
3964 |
|
3965 | function createStrictShapeTypeChecker(shapeTypes) {
|
3966 | function validate(props, propName, componentName, location, propFullName) {
|
3967 | var propValue = props[propName];
|
3968 | var propType = getPropType(propValue);
|
3969 | if (propType !== 'object') {
|
3970 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
3971 | }
|
3972 |
|
3973 |
|
3974 | var allKeys = assign({}, props[propName], shapeTypes);
|
3975 | for (var key in allKeys) {
|
3976 | var checker = shapeTypes[key];
|
3977 | if (!checker) {
|
3978 | return new PropTypeError(
|
3979 | 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
3980 | '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
3981 | '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
3982 | );
|
3983 | }
|
3984 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
3985 | if (error) {
|
3986 | return error;
|
3987 | }
|
3988 | }
|
3989 | return null;
|
3990 | }
|
3991 |
|
3992 | return createChainableTypeChecker(validate);
|
3993 | }
|
3994 |
|
3995 | function isNode(propValue) {
|
3996 | switch (typeof propValue) {
|
3997 | case 'number':
|
3998 | case 'string':
|
3999 | case 'undefined':
|
4000 | return true;
|
4001 | case 'boolean':
|
4002 | return !propValue;
|
4003 | case 'object':
|
4004 | if (Array.isArray(propValue)) {
|
4005 | return propValue.every(isNode);
|
4006 | }
|
4007 | if (propValue === null || isValidElement(propValue)) {
|
4008 | return true;
|
4009 | }
|
4010 |
|
4011 | var iteratorFn = getIteratorFn(propValue);
|
4012 | if (iteratorFn) {
|
4013 | var iterator = iteratorFn.call(propValue);
|
4014 | var step;
|
4015 | if (iteratorFn !== propValue.entries) {
|
4016 | while (!(step = iterator.next()).done) {
|
4017 | if (!isNode(step.value)) {
|
4018 | return false;
|
4019 | }
|
4020 | }
|
4021 | } else {
|
4022 |
|
4023 | while (!(step = iterator.next()).done) {
|
4024 | var entry = step.value;
|
4025 | if (entry) {
|
4026 | if (!isNode(entry[1])) {
|
4027 | return false;
|
4028 | }
|
4029 | }
|
4030 | }
|
4031 | }
|
4032 | } else {
|
4033 | return false;
|
4034 | }
|
4035 |
|
4036 | return true;
|
4037 | default:
|
4038 | return false;
|
4039 | }
|
4040 | }
|
4041 |
|
4042 | function isSymbol(propType, propValue) {
|
4043 |
|
4044 | if (propType === 'symbol') {
|
4045 | return true;
|
4046 | }
|
4047 |
|
4048 |
|
4049 | if (propValue['@@toStringTag'] === 'Symbol') {
|
4050 | return true;
|
4051 | }
|
4052 |
|
4053 |
|
4054 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
4055 | return true;
|
4056 | }
|
4057 |
|
4058 | return false;
|
4059 | }
|
4060 |
|
4061 |
|
4062 | function getPropType(propValue) {
|
4063 | var propType = typeof propValue;
|
4064 | if (Array.isArray(propValue)) {
|
4065 | return 'array';
|
4066 | }
|
4067 | if (propValue instanceof RegExp) {
|
4068 |
|
4069 |
|
4070 |
|
4071 | return 'object';
|
4072 | }
|
4073 | if (isSymbol(propType, propValue)) {
|
4074 | return 'symbol';
|
4075 | }
|
4076 | return propType;
|
4077 | }
|
4078 |
|
4079 |
|
4080 |
|
4081 | function getPreciseType(propValue) {
|
4082 | if (typeof propValue === 'undefined' || propValue === null) {
|
4083 | return '' + propValue;
|
4084 | }
|
4085 | var propType = getPropType(propValue);
|
4086 | if (propType === 'object') {
|
4087 | if (propValue instanceof Date) {
|
4088 | return 'date';
|
4089 | } else if (propValue instanceof RegExp) {
|
4090 | return 'regexp';
|
4091 | }
|
4092 | }
|
4093 | return propType;
|
4094 | }
|
4095 |
|
4096 |
|
4097 |
|
4098 | function getPostfixForTypeWarning(value) {
|
4099 | var type = getPreciseType(value);
|
4100 | switch (type) {
|
4101 | case 'array':
|
4102 | case 'object':
|
4103 | return 'an ' + type;
|
4104 | case 'boolean':
|
4105 | case 'date':
|
4106 | case 'regexp':
|
4107 | return 'a ' + type;
|
4108 | default:
|
4109 | return type;
|
4110 | }
|
4111 | }
|
4112 |
|
4113 |
|
4114 | function getClassName(propValue) {
|
4115 | if (!propValue.constructor || !propValue.constructor.name) {
|
4116 | return ANONYMOUS;
|
4117 | }
|
4118 | return propValue.constructor.name;
|
4119 | }
|
4120 |
|
4121 | ReactPropTypes.checkPropTypes = checkPropTypes;
|
4122 | ReactPropTypes.PropTypes = ReactPropTypes;
|
4123 |
|
4124 | return ReactPropTypes;
|
4125 | };
|
4126 |
|
4127 |
|
4128 | }),
|
4129 |
|
4130 | (function(module, exports, __webpack_require__) {
|
4131 |
|
4132 | var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__; |
4133 |
|
4134 |
|
4135 |
|
4136 |
|
4137 |
|
4138 | (function (name, definition) {
|
4139 | if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
4140 | 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__))
|
4141 | else this[name] = definition()
|
4142 | })('$script', function () {
|
4143 | var doc = document
|
4144 | , head = doc.getElementsByTagName('head')[0]
|
4145 | , s = 'string'
|
4146 | , f = false
|
4147 | , push = 'push'
|
4148 | , readyState = 'readyState'
|
4149 | , onreadystatechange = 'onreadystatechange'
|
4150 | , list = {}
|
4151 | , ids = {}
|
4152 | , delay = {}
|
4153 | , scripts = {}
|
4154 | , scriptpath
|
4155 | , urlArgs
|
4156 |
|
4157 | function every(ar, fn) {
|
4158 | for (var i = 0, j = ar.length; i < j; ++i) if (!fn(ar[i])) return f
|
4159 | return 1
|
4160 | }
|
4161 | function each(ar, fn) {
|
4162 | every(ar, function (el) {
|
4163 | return !fn(el)
|
4164 | })
|
4165 | }
|
4166 |
|
4167 | function $script(paths, idOrDone, optDone) {
|
4168 | paths = paths[push] ? paths : [paths]
|
4169 | var idOrDoneIsDone = idOrDone && idOrDone.call
|
4170 | , done = idOrDoneIsDone ? idOrDone : optDone
|
4171 | , id = idOrDoneIsDone ? paths.join('') : idOrDone
|
4172 | , queue = paths.length
|
4173 | function loopFn(item) {
|
4174 | return item.call ? item() : list[item]
|
4175 | }
|
4176 | function callback() {
|
4177 | if (!--queue) {
|
4178 | list[id] = 1
|
4179 | done && done()
|
4180 | for (var dset in delay) {
|
4181 | every(dset.split('|'), loopFn) && !each(delay[dset], loopFn) && (delay[dset] = [])
|
4182 | }
|
4183 | }
|
4184 | }
|
4185 | setTimeout(function () {
|
4186 | each(paths, function loading(path, force) {
|
4187 | if (path === null) return callback()
|
4188 |
|
4189 | if (!force && !/^https?:\/\//.test(path) && scriptpath) {
|
4190 | path = (path.indexOf('.js') === -1) ? scriptpath + path + '.js' : scriptpath + path;
|
4191 | }
|
4192 |
|
4193 | if (scripts[path]) {
|
4194 | if (id) ids[id] = 1
|
4195 | return (scripts[path] == 2) ? callback() : setTimeout(function () { loading(path, true) }, 0)
|
4196 | }
|
4197 |
|
4198 | scripts[path] = 1
|
4199 | if (id) ids[id] = 1
|
4200 | create(path, callback)
|
4201 | })
|
4202 | }, 0)
|
4203 | return $script
|
4204 | }
|
4205 |
|
4206 | function create(path, fn) {
|
4207 | var el = doc.createElement('script'), loaded
|
4208 | el.onload = el.onerror = el[onreadystatechange] = function () {
|
4209 | if ((el[readyState] && !(/^c|loade/.test(el[readyState]))) || loaded) return;
|
4210 | el.onload = el[onreadystatechange] = null
|
4211 | loaded = 1
|
4212 | scripts[path] = 2
|
4213 | fn()
|
4214 | }
|
4215 | el.async = 1
|
4216 | el.src = urlArgs ? path + (path.indexOf('?') === -1 ? '?' : '&') + urlArgs : path;
|
4217 | head.insertBefore(el, head.lastChild)
|
4218 | }
|
4219 |
|
4220 | $script.get = create
|
4221 |
|
4222 | $script.order = function (scripts, id, done) {
|
4223 | (function callback(s) {
|
4224 | s = scripts.shift()
|
4225 | !scripts.length ? $script(s, id, done) : $script(s, callback)
|
4226 | }())
|
4227 | }
|
4228 |
|
4229 | $script.path = function (p) {
|
4230 | scriptpath = p
|
4231 | }
|
4232 | $script.urlArgs = function (str) {
|
4233 | urlArgs = str;
|
4234 | }
|
4235 | $script.ready = function (deps, ready, req) {
|
4236 | deps = deps[push] ? deps : [deps]
|
4237 | var missing = [];
|
4238 | !each(deps, function (dep) {
|
4239 | list[dep] || missing[push](dep);
|
4240 | }) && every(deps, function (dep) {return list[dep]}) ?
|
4241 | ready() : !function (key) {
|
4242 | delay[key] = delay[key] || []
|
4243 | delay[key][push](ready)
|
4244 | req && req(missing)
|
4245 | }(deps.join('|'))
|
4246 | return $script
|
4247 | }
|
4248 |
|
4249 | $script.done = function (idOrDone) {
|
4250 | $script([null], idOrDone)
|
4251 | }
|
4252 |
|
4253 | return $script
|
4254 | });
|
4255 |
|
4256 |
|
4257 | }),
|
4258 |
|
4259 | (function(module, exports) {
|
4260 |
|
4261 | module.exports = __WEBPACK_EXTERNAL_MODULE_33__;
|
4262 |
|
4263 | })
|
4264 | ])
|
4265 | });
|
4266 | ; |
\ | No newline at end of file |