UNPKG

1.11 MBJavaScriptView Raw
1/*!
2 * author: sakitam-fdd <smilefdd@gmail.com>
3 * @sakitam-gis/react-map v0.0.2
4 * build-time: 2018-7-22 20:13
5 * LICENSE: BSD-3-Clause
6 * (c) 2018-2018 https://sakitam-gis.github.io/react-map/
7 */
8(function webpackUniversalModuleDefinition(root, factory) {
9 if(typeof exports === 'object' && typeof module === 'object')
10 module.exports = factory();
11 else if(typeof define === 'function' && define.amd)
12 define([], factory);
13 else if(typeof exports === 'object')
14 exports["ReactMap"] = factory();
15 else
16 root["ReactMap"] = factory();
17})(typeof self !== 'undefined' ? self : this, function() {
18return /******/ (function(modules) { // webpackBootstrap
19/******/ // The module cache
20/******/ var installedModules = {};
21/******/
22/******/ // The require function
23/******/ function __webpack_require__(moduleId) {
24/******/
25/******/ // Check if module is in cache
26/******/ if(installedModules[moduleId]) {
27/******/ return installedModules[moduleId].exports;
28/******/ }
29/******/ // Create a new module (and put it into the cache)
30/******/ var module = installedModules[moduleId] = {
31/******/ i: moduleId,
32/******/ l: false,
33/******/ exports: {}
34/******/ };
35/******/
36/******/ // Execute the module function
37/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
38/******/
39/******/ // Flag the module as loaded
40/******/ module.l = true;
41/******/
42/******/ // Return the exports of the module
43/******/ return module.exports;
44/******/ }
45/******/
46/******/
47/******/ // expose the modules object (__webpack_modules__)
48/******/ __webpack_require__.m = modules;
49/******/
50/******/ // expose the module cache
51/******/ __webpack_require__.c = installedModules;
52/******/
53/******/ // define getter function for harmony exports
54/******/ __webpack_require__.d = function(exports, name, getter) {
55/******/ if(!__webpack_require__.o(exports, name)) {
56/******/ Object.defineProperty(exports, name, {
57/******/ configurable: false,
58/******/ enumerable: true,
59/******/ get: getter
60/******/ });
61/******/ }
62/******/ };
63/******/
64/******/ // getDefaultExport function for compatibility with non-harmony modules
65/******/ __webpack_require__.n = function(module) {
66/******/ var getter = module && module.__esModule ?
67/******/ function getDefault() { return module['default']; } :
68/******/ function getModuleExports() { return module; };
69/******/ __webpack_require__.d(getter, 'a', getter);
70/******/ return getter;
71/******/ };
72/******/
73/******/ // Object.prototype.hasOwnProperty.call
74/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
75/******/
76/******/ // __webpack_public_path__
77/******/ __webpack_require__.p = "";
78/******/
79/******/ // Load entry module and return exports
80/******/ return __webpack_require__(__webpack_require__.s = 33);
81/******/ })
82/************************************************************************/
83/******/ ([
84/* 0 */
85/***/ (function(module, exports, __webpack_require__) {
86
87/**
88 * Copyright (c) 2013-present, Facebook, Inc.
89 *
90 * This source code is licensed under the MIT license found in the
91 * LICENSE file in the root directory of this source tree.
92 */
93
94if ("development".NODE_ENV !== 'production') {
95 var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
96 Symbol.for &&
97 Symbol.for('react.element')) ||
98 0xeac7;
99
100 var isValidElement = function(object) {
101 return typeof object === 'object' &&
102 object !== null &&
103 object.$$typeof === REACT_ELEMENT_TYPE;
104 };
105
106 // By explicitly using `prop-types` you are opting into new development behavior.
107 // http://fb.me/prop-types-in-prod
108 var throwOnDirectAccess = true;
109 module.exports = __webpack_require__(105)(isValidElement, throwOnDirectAccess);
110} else {
111 // By explicitly using `prop-types` you are opting into new production behavior.
112 // http://fb.me/prop-types-in-prod
113 module.exports = __webpack_require__(106)();
114}
115
116
117/***/ }),
118/* 1 */
119/***/ (function(module, __webpack_exports__, __webpack_require__) {
120
121"use strict";
122/* WEBPACK VAR INJECTION */(function(process, global) {/* unused harmony export Util */
123/* unused harmony export DomUtil */
124/* unused harmony export StringUtil */
125/* unused harmony export MapboxUtil */
126/* unused harmony export ui */
127/* unused harmony export control */
128/* unused harmony export renderer */
129/* unused harmony export symbolizer */
130/* unused harmony export animation */
131/* unused harmony export Browser */
132/* unused harmony export Ajax */
133/* unused harmony export Canvas */
134/* unused harmony export Class */
135/* unused harmony export Eventable */
136/* unused harmony export JSONAble */
137/* unused harmony export Handlerable */
138/* unused harmony export Handler */
139/* unused harmony export DragHandler */
140/* unused harmony export MapTool */
141/* unused harmony export DrawTool */
142/* unused harmony export AreaTool */
143/* unused harmony export DistanceTool */
144/* unused harmony export SpatialReference */
145/* unused harmony export INTERNAL_LAYER_PREFIX */
146/* unused harmony export GEOMETRY_COLLECTION_TYPES */
147/* unused harmony export GEOJSON_TYPES */
148/* unused harmony export RESOURCE_PROPERTIES */
149/* unused harmony export RESOURCE_SIZE_PROPERTIES */
150/* unused harmony export NUMERICAL_PROPERTIES */
151/* unused harmony export COLOR_PROPERTIES */
152/* unused harmony export projection */
153/* unused harmony export measurer */
154/* unused harmony export Coordinate */
155/* unused harmony export CRS */
156/* unused harmony export Extent */
157/* unused harmony export Point */
158/* unused harmony export PointExtent */
159/* unused harmony export Size */
160/* unused harmony export Transformation */
161/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return Map; });
162/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Layer; });
163/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return TileLayer; });
164/* unused harmony export GroupTileLayer */
165/* unused harmony export WMSTileLayer */
166/* unused harmony export CanvasTileLayer */
167/* unused harmony export ImageLayer */
168/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return OverlayLayer; });
169/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return VectorLayer; });
170/* unused harmony export CanvasLayer */
171/* unused harmony export ParticleLayer */
172/* unused harmony export TileSystem */
173/* unused harmony export TileConfig */
174/* unused harmony export ArcCurve */
175/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Circle; });
176/* unused harmony export ConnectorLine */
177/* unused harmony export ArcConnectorLine */
178/* unused harmony export CubicBezierCurve */
179/* unused harmony export Curve */
180/* unused harmony export Ellipse */
181/* unused harmony export GeoJSON */
182/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Geometry; });
183/* unused harmony export GeometryCollection */
184/* unused harmony export Label */
185/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return LineString; });
186/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return Marker; });
187/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return MultiLineString; });
188/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return MultiPoint; });
189/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return MultiPolygon; });
190/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return Polygon; });
191/* unused harmony export QuadBezierCurve */
192/* unused harmony export Rectangle */
193/* unused harmony export Sector */
194/* unused harmony export TextBox */
195/* unused harmony export TextMarker */
196/*!
197 * maptalks v0.40.5
198 * LICENSE : BSD-3-Clause
199 * (c) 2016-2018 maptalks.org
200 */
201var INTERNAL_LAYER_PREFIX = '_maptalks__internal_layer_';
202
203var GEOMETRY_COLLECTION_TYPES = ['MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection'];
204
205var GEOJSON_TYPES = ['FeatureCollection', 'Feature', 'Point', 'LineString', 'Polygon'].concat(GEOMETRY_COLLECTION_TYPES);
206
207var RESOURCE_PROPERTIES = ['markerFile', 'polygonPatternFile', 'linePatternFile', 'markerFillPatternFile', 'markerLinePatternFile'];
208
209var RESOURCE_SIZE_PROPERTIES = [['markerWidth', 'markerHeight'], [], [null, 'lineWidth'], [], [null, 'markerLineWidth']];
210
211var NUMERICAL_PROPERTIES = {
212 'lineWidth': 1,
213 'lineOpacity': 1,
214 'lineDx': 1,
215 'lineDy': 1,
216 'polygonOpacity': 1,
217 'markerWidth': 1,
218 'markerHeight': 1,
219 'markerDx': 1,
220 'markerDy': 1,
221 'markerOpacity': 1,
222 'markerFillOpacity': 1,
223 'markerLineWidth': 1,
224 'markerLineOpacity': 1,
225 'textSize': 1,
226 'textOpacity': 1,
227 'textHaloRadius': 1,
228 'textWrapWidth': 1,
229 'textLineSpacing': 1,
230 'textDx': 1,
231 'textDy': 1
232};
233
234var COLOR_PROPERTIES = ['lineColor', 'polygonFill', 'markerFill', 'markerLineColor', 'textFill'];
235
236function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
237
238var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
239 return typeof obj;
240} : function (obj) {
241 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
242};
243
244
245
246
247
248
249
250
251
252
253
254var classCallCheck = function (instance, Constructor) {
255 if (!(instance instanceof Constructor)) {
256 throw new TypeError("Cannot call a class as a function");
257 }
258};
259
260
261
262
263
264
265
266
267
268
269
270var inherits = function (subClass, superClass) {
271 if (typeof superClass !== "function" && superClass !== null) {
272 throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
273 }
274
275 subClass.prototype = Object.create(superClass && superClass.prototype, {
276 constructor: {
277 value: subClass,
278 enumerable: false,
279 writable: true,
280 configurable: true
281 }
282 });
283 if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass);
284};
285
286
287
288
289
290
291
292
293
294
295
296var possibleConstructorReturn = function (self, call) {
297 if (!self) {
298 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
299 }
300
301 return call && (typeof call === "object" || typeof call === "function") ? call : self;
302};
303
304function now() {
305 return Date.now();
306}
307
308function extend(dest) {
309 for (var i = 1; i < arguments.length; i++) {
310 var src = arguments[i];
311 for (var k in src) {
312 dest[k] = src[k];
313 }
314 }
315 return dest;
316}
317
318function isNil(obj) {
319 return obj == null;
320}
321
322function isNumber(val) {
323 return typeof val === 'number' && !isNaN(val);
324}
325
326function isInteger(n) {
327 return (n | 0) === n;
328}
329
330function isObject(obj) {
331 return (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && !!obj;
332}
333
334function isString(obj) {
335 if (isNil(obj)) {
336 return false;
337 }
338 return typeof obj === 'string' || obj.constructor !== null && obj.constructor === String;
339}
340
341function isFunction(obj) {
342 if (isNil(obj)) {
343 return false;
344 }
345 return typeof obj === 'function' || obj.constructor !== null && obj.constructor === Function;
346}
347
348var hasOwnProperty = Object.prototype.hasOwnProperty;
349
350function hasOwn(obj, key) {
351 return hasOwnProperty.call(obj, key);
352}
353
354function join(arr, seperator) {
355 if (arr.join) {
356 return arr.join(seperator || ',');
357 } else {
358 return Array.prototype.join.call(arr, seperator || ',');
359 }
360}
361
362var pi = Math.PI / 180;
363
364function toRadian(d) {
365 return d * pi;
366}
367
368function toDegree(r) {
369 return r / pi;
370}
371
372var IS_NODE = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]' && !process.versions['electron'] && !process.versions['nw'] && !process.versions['node-webkit'];
373
374var requestAnimFrame = void 0;
375var cancelAnimFrame = void 0;
376
377(function () {
378 if (IS_NODE) {
379 requestAnimFrame = function requestAnimFrame(fn) {
380 return setTimeout(fn, 16);
381 };
382
383 cancelAnimFrame = clearTimeout;
384 return;
385 }
386
387 var requestFn = void 0,
388 cancelFn = void 0;
389
390 var timeToCall = 1000 / 30;
391 function timeoutDefer(fn) {
392 return setTimeout(fn, timeToCall);
393 }
394
395 function getPrefixed(name) {
396 return window['webkit' + name] || window['moz' + name] || window['ms' + name];
397 }
398 if (typeof window != 'undefined') {
399
400 requestFn = window['requestAnimationFrame'] || getPrefixed('RequestAnimationFrame') || timeoutDefer;
401 cancelFn = window['cancelAnimationFrame'] || getPrefixed('CancelAnimationFrame') || getPrefixed('CancelRequestAnimationFrame') || function (id) {
402 window.clearTimeout(id);
403 };
404 } else {
405 requestFn = timeoutDefer;
406 cancelFn = clearTimeout;
407 }
408
409 requestAnimFrame = function requestAnimFrame(fn) {
410 return requestFn(fn);
411 };
412
413 cancelAnimFrame = function cancelAnimFrame(id) {
414 if (id) {
415 cancelFn(id);
416 }
417 };
418})();
419function isSVG(url) {
420 var prefix = 'data:image/svg+xml';
421 if (url.length > 4 && url.slice(-4) === '.svg') {
422 return 1;
423 } else if (url.slice(0, prefix.length) === prefix) {
424 return 2;
425 }
426 return 0;
427}
428
429function loadImage(img, imgDesc) {
430 if (IS_NODE && loadImage.node) {
431 loadImage.node(img, imgDesc);
432 return;
433 }
434 img.src = imgDesc[0];
435}
436
437var uid = 0;
438
439function UID() {
440 return uid++;
441}
442var GUID = UID;
443
444function parseJSON(str) {
445 if (!str || !isString(str)) {
446 return str;
447 }
448 return JSON.parse(str);
449}
450
451function pushIn(dest) {
452 for (var i = 1; i < arguments.length; i++) {
453 var src = arguments[i];
454 if (src) {
455 for (var ii = 0, ll = src.length; ii < ll; ii++) {
456 dest.push(src[ii]);
457 }
458 }
459 }
460 return dest.length;
461}
462
463function removeFromArray(obj, array) {
464 var i = array.indexOf(obj);
465 if (i > -1) {
466 array.splice(i, 1);
467 }
468}
469
470function forEachCoord(arr, fn, context) {
471 if (!Array.isArray(arr)) {
472 return context ? fn.call(context, arr) : fn(arr);
473 }
474 var result = [];
475 var p = void 0,
476 pp = void 0;
477 for (var i = 0, len = arr.length; i < len; i++) {
478 p = arr[i];
479 if (isNil(p)) {
480 result.push(null);
481 continue;
482 }
483 if (Array.isArray(p)) {
484 result.push(forEachCoord(p, fn, context));
485 } else {
486 pp = context ? fn.call(context, p) : fn(p);
487 result.push(pp);
488 }
489 }
490 return result;
491}
492
493function getValueOrDefault(v, d) {
494 return v === undefined ? d : v;
495}
496
497function sign(x) {
498 if (Math.sign) {
499 return Math.sign(x);
500 }
501 x = +x;
502 if (x === 0 || isNaN(x)) {
503 return Number(x);
504 }
505 return x > 0 ? 1 : -1;
506}
507
508function log2(x) {
509 if (Math.log2) {
510 return Math.log2(x);
511 }
512 var v = Math.log(x) * Math.LOG2E;
513 var rounded = Math.round(v);
514 if (Math.abs(rounded - v) < 1E-14) {
515 return rounded;
516 } else {
517 return v;
518 }
519}
520
521function interpolate(a, b, t) {
522 return a * (1 - t) + b * t;
523}
524
525function wrap(n, min, max) {
526 if (n === max || n === min) {
527 return n;
528 }
529 var d = max - min;
530 var w = ((n - min) % d + d) % d + min;
531 return w;
532}
533
534function clamp(n, min, max) {
535 return Math.min(max, Math.max(min, n));
536}
537
538function isArrayHasData(obj) {
539 return Array.isArray(obj) && obj.length > 0;
540}
541
542function isURL(url) {
543 if (!url) {
544 return false;
545 }
546 var head = url.slice(0, 6);
547 if (head === 'http:/' || head === 'https:' || head === 'file:/') {
548 return true;
549 }
550 return false;
551}
552
553var cssUrlReWithQuote = /^url\((['"])(.+)\1\)$/i;
554
555var cssUrlRe = /^url\(([^'"].*[^'"])\)$/i;
556
557function isCssUrl(str) {
558 if (!isString(str)) {
559 return 0;
560 }
561 var head = str.slice(0, 6);
562 if (head === 'http:/' || head === 'https:') {
563 return 3;
564 }
565 if (cssUrlRe.test(str)) {
566 return 1;
567 }
568 if (cssUrlReWithQuote.test(str)) {
569 return 2;
570 }
571 return 0;
572}
573
574function extractCssUrl(str) {
575 var test = isCssUrl(str);
576 var matches = void 0;
577 if (test === 3) {
578 return str;
579 }
580 if (test === 1) {
581 matches = cssUrlRe.exec(str);
582 return matches[1];
583 } else if (test === 2) {
584 matches = cssUrlReWithQuote.exec(str);
585 return matches[2];
586 } else {
587 return str;
588 }
589}
590
591var b64chrs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
592
593function btoa(input) {
594 if (typeof window !== 'undefined' && window.btoa) {
595 return window.btoa(input);
596 }
597 var str = String(input);
598 var output = '';
599 for (var block, charCode, idx = 0, map = b64chrs; str.charAt(idx | 0) || (map = '=', idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) {
600 charCode = str.charCodeAt(idx += 3 / 4);
601 if (charCode > 0xFF) {
602 throw new Error('\'btoa\' failed: The string to be encoded contains characters outside of the Latin1 range.');
603 }
604 block = block << 8 | charCode;
605 }
606 return output;
607}
608
609function b64toBlob(b64Data, contentType) {
610 var byteCharacters = atob(b64Data);
611 var arraybuffer = new ArrayBuffer(byteCharacters.length);
612 var view = new Uint8Array(arraybuffer);
613 for (var i = 0; i < byteCharacters.length; i++) {
614 view[i] = byteCharacters.charCodeAt(i) & 0xff;
615 }
616 var blob = new Blob([arraybuffer], { type: contentType });
617 return blob;
618}
619
620function computeDegree(x0, y0, x1, y1) {
621 var dx = x1 - x0;
622 var dy = y1 - y0;
623 return Math.atan2(dy, dx);
624}
625
626var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
627
628function equalMapView(obj1, obj2) {
629 if (!obj1 && !obj2) {
630 return true;
631 } else if (!obj1 || !obj2) {
632 return false;
633 }
634 for (var p in obj1) {
635 if (p === 'center') {
636 if (!obj2[p] || !approx(obj1[p][0], obj2[p][0]) || !approx(obj1[p][1], obj2[p][1])) {
637 return false;
638 }
639 } else if (obj1[p] !== obj2[p]) {
640 return false;
641 }
642 }
643 return true;
644}
645
646function approx(val, expected, delta) {
647 if (delta == null) {
648 delta = 1e-6;
649 }
650 return val >= expected - delta && val <= expected + delta;
651}
652
653function flash(interval, count, cb, context) {
654 if (!interval) {
655 interval = 100;
656 }
657 if (!count) {
658 count = 4;
659 }
660 var me = this;
661 count *= 2;
662 if (this._flashTimeout) {
663 clearTimeout(this._flashTimeout);
664 }
665
666 function flashGeo() {
667 if (count === 0) {
668 me.show();
669 if (cb) {
670 if (context) {
671 cb.call(context);
672 } else {
673 cb();
674 }
675 }
676 return;
677 }
678
679 if (count % 2 === 0) {
680 me.hide();
681 } else {
682 me.show();
683 }
684 count--;
685 me._flashTimeout = setTimeout(flashGeo, interval);
686 }
687 this._flashTimeout = setTimeout(flashGeo, interval);
688 return this;
689}
690
691var types = ['Unknown', 'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection'];
692
693function createFilter(filter) {
694 return new Function('f', 'var p = (f && f.properties || {}); return ' + compile(filter));
695}
696
697function compile(filter) {
698 if (!filter) return 'true';
699 var op = filter[0];
700 if (filter.length <= 1) return op === 'any' ? 'false' : 'true';
701 var str = op === '==' ? compileComparisonOp(filter[1], filter[2], '===', false) : op === '!=' ? compileComparisonOp(filter[1], filter[2], '!==', false) : op === '<' || op === '>' || op === '<=' || op === '>=' ? compileComparisonOp(filter[1], filter[2], op, true) : op === 'any' ? compileLogicalOp(filter.slice(1), '||') : op === 'all' ? compileLogicalOp(filter.slice(1), '&&') : op === 'none' ? compileNegation(compileLogicalOp(filter.slice(1), '||')) : op === 'in' ? compileInOp(filter[1], filter.slice(2)) : op === '!in' ? compileNegation(compileInOp(filter[1], filter.slice(2))) : op === 'has' ? compileHasOp(filter[1]) : op === '!has' ? compileNegation(compileHasOp(filter[1])) : 'true';
702 return '(' + str + ')';
703}
704
705function compilePropertyReference(property) {
706 return property[0] === '$' ? 'f.' + property.substring(1) : 'p[' + JSON.stringify(property) + ']';
707}
708
709function compileComparisonOp(property, value, op, checkType) {
710 var left = compilePropertyReference(property);
711 var right = property === '$type' ? types.indexOf(value) : JSON.stringify(value);
712 return (checkType ? 'typeof ' + left + '=== typeof ' + right + '&&' : '') + left + op + right;
713}
714
715function compileLogicalOp(expressions, op) {
716 return expressions.map(compile).join(op);
717}
718
719function compileInOp(property, values) {
720 if (property === '$type') values = values.map(function (value) {
721 return types.indexOf(value);
722 });
723 var left = JSON.stringify(values.sort(compare));
724 var right = compilePropertyReference(property);
725
726 if (values.length <= 200) return left + '.indexOf(' + right + ') !== -1';
727
728 return '' + ('function(v, a, i, j) {' + 'while (i <= j) { var m = (i + j) >> 1;' + ' if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;' + '}' + 'return false; }(') + right + ', ' + left + ',0,' + (values.length - 1) + ')';
729}
730
731function compileHasOp(property) {
732 return property === '$id' ? '"id" in f' : JSON.stringify(property) + ' in p';
733}
734
735function compileNegation(expression) {
736 return '!(' + expression + ')';
737}
738
739function compare(a, b) {
740 return a < b ? -1 : a > b ? 1 : 0;
741}
742
743function getFilterFeature(geometry) {
744 var json = geometry._toJSON(),
745 g = json['feature'];
746 g['type'] = types.indexOf(g['geometry']['type']);
747 g['subType'] = json['subType'];
748 return g;
749}
750
751function compileStyle(styles) {
752 if (!Array.isArray(styles)) {
753 return compileStyle([styles]);
754 }
755 var compiled = [];
756 for (var i = 0; i < styles.length; i++) {
757 var filter = void 0;
758 if (styles[i]['filter'] === true) {
759 filter = function filter() {
760 return true;
761 };
762 } else {
763 filter = createFilter(styles[i]['filter']);
764 }
765 compiled.push(extend({}, styles[i], {
766 filter: filter
767 }));
768 }
769 return compiled;
770}
771
772function createFunction(parameters, defaultType) {
773 var fun;
774
775 if (!isFunctionDefinition(parameters)) {
776 fun = function fun() {
777 return parameters;
778 };
779 fun.isFeatureConstant = true;
780 fun.isZoomConstant = true;
781 } else {
782 var zoomAndFeatureDependent = parameters.stops && _typeof(parameters.stops[0][0]) === 'object';
783 var featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;
784 var zoomDependent = zoomAndFeatureDependent || !featureDependent;
785 var type = parameters.type || defaultType || 'exponential';
786
787 var innerFun;
788 if (type === 'exponential') {
789 innerFun = evaluateExponentialFunction;
790 } else if (type === 'interval') {
791 innerFun = evaluateIntervalFunction;
792 } else if (type === 'categorical') {
793 innerFun = evaluateCategoricalFunction;
794 } else if (type === 'identity') {
795 innerFun = evaluateIdentityFunction;
796 } else {
797 throw new Error('Unknown function type "' + type + '"');
798 }
799
800 if (zoomAndFeatureDependent) {
801 var featureFunctions = {};
802 var featureFunctionStops = [];
803 for (var s = 0; s < parameters.stops.length; s++) {
804 var stop = parameters.stops[s];
805 if (featureFunctions[stop[0].zoom] === undefined) {
806 featureFunctions[stop[0].zoom] = {
807 zoom: stop[0].zoom,
808 type: parameters.type,
809 property: parameters.property,
810 stops: []
811 };
812 }
813 featureFunctions[stop[0].zoom].stops.push([stop[0].value, stop[1]]);
814 }
815
816 for (var z in featureFunctions) {
817 featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z])]);
818 }
819 fun = function fun(zoom, feature) {
820 return evaluateExponentialFunction({ stops: featureFunctionStops, base: parameters.base }, zoom)(zoom, feature);
821 };
822 fun.isFeatureConstant = false;
823 fun.isZoomConstant = false;
824 } else if (zoomDependent) {
825 fun = function fun(zoom) {
826 return innerFun(parameters, zoom);
827 };
828 fun.isFeatureConstant = true;
829 fun.isZoomConstant = false;
830 } else {
831 fun = function fun(zoom, feature) {
832 return innerFun(parameters, feature[parameters.property]);
833 };
834 fun.isFeatureConstant = false;
835 fun.isZoomConstant = true;
836 }
837 }
838
839 return fun;
840}
841
842function evaluateCategoricalFunction(parameters, input) {
843 for (var i = 0; i < parameters.stops.length; i++) {
844 if (input === parameters.stops[i][0]) {
845 return parameters.stops[i][1];
846 }
847 }
848 return parameters.stops[0][1];
849}
850
851function evaluateIntervalFunction(parameters, input) {
852 for (var i = 0; i < parameters.stops.length; i++) {
853 if (input < parameters.stops[i][0]) break;
854 }
855 return parameters.stops[Math.max(i - 1, 0)][1];
856}
857
858function evaluateExponentialFunction(parameters, input) {
859 var base = parameters.base !== undefined ? parameters.base : 1;
860
861 var i = 0;
862 while (true) {
863 if (i >= parameters.stops.length) break;else if (input <= parameters.stops[i][0]) break;else i++;
864 }
865
866 if (i === 0) {
867 return parameters.stops[i][1];
868 } else if (i === parameters.stops.length) {
869 return parameters.stops[i - 1][1];
870 } else {
871 return interpolate$1(input, base, parameters.stops[i - 1][0], parameters.stops[i][0], parameters.stops[i - 1][1], parameters.stops[i][1]);
872 }
873}
874
875function evaluateIdentityFunction(parameters, input) {
876 return input;
877}
878
879function interpolate$1(input, base, inputLower, inputUpper, outputLower, outputUpper) {
880 if (typeof outputLower === 'function') {
881 return function () {
882 var evaluatedLower = outputLower.apply(undefined, arguments);
883 var evaluatedUpper = outputUpper.apply(undefined, arguments);
884 return interpolate$1(input, base, inputLower, inputUpper, evaluatedLower, evaluatedUpper);
885 };
886 } else if (outputLower.length) {
887 return interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper);
888 } else {
889 return interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper);
890 }
891}
892
893function interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper) {
894 var difference = inputUpper - inputLower;
895 var progress = input - inputLower;
896
897 var ratio;
898 if (base === 1) {
899 ratio = progress / difference;
900 } else {
901 ratio = (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
902 }
903
904 return outputLower * (1 - ratio) + outputUpper * ratio;
905}
906
907function interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper) {
908 var output = [];
909 for (var i = 0; i < outputLower.length; i++) {
910 output[i] = interpolateNumber(input, base, inputLower, inputUpper, outputLower[i], outputUpper[i]);
911 }
912 return output;
913}
914
915function isFunctionDefinition(obj) {
916 return obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && (obj.stops || obj.property && obj.type === 'identity');
917}
918
919function hasFunctionDefinition(obj) {
920 for (var p in obj) {
921 if (isFunctionDefinition(obj[p])) {
922 return true;
923 }
924 }
925 return false;
926}
927
928function interpolated(parameters) {
929 return createFunction(parameters, 'exponential');
930}
931
932function piecewiseConstant(parameters) {
933 return createFunction(parameters, 'interval');
934}
935
936function loadFunctionTypes(obj, argFn) {
937 if (!obj) {
938 return null;
939 }
940 var hit = false;
941 if (Array.isArray(obj)) {
942 var multResult = [],
943 loaded;
944 for (var i = 0; i < obj.length; i++) {
945 loaded = loadFunctionTypes(obj[i], argFn);
946 if (!loaded) {
947 multResult.push(obj[i]);
948 } else {
949 multResult.push(loaded);
950 hit = true;
951 }
952 }
953 return hit ? multResult : obj;
954 }
955 var result = {
956 '__fn_types_loaded': true
957 },
958 props = [],
959 p;
960 for (p in obj) {
961 if (obj.hasOwnProperty(p)) {
962 props.push(p);
963 }
964 }
965
966 for (var _i = 0, len = props.length; _i < len; _i++) {
967 p = props[_i];
968 if (isFunctionDefinition(obj[p])) {
969 hit = true;
970 result['_' + p] = obj[p];
971 (function (_p) {
972 Object.defineProperty(result, _p, {
973 get: function get$$1() {
974 if (!this['__fn_' + _p]) {
975 this['__fn_' + _p] = interpolated(this['_' + _p]);
976 }
977 return this['__fn_' + _p].apply(this, argFn());
978 },
979 set: function set$$1(v) {
980 this['_' + _p] = v;
981 },
982 configurable: true,
983 enumerable: true
984 });
985 })(p);
986 } else {
987 result[p] = obj[p];
988 }
989 }
990 return hit ? result : obj;
991}
992
993function getFunctionTypeResources(t) {
994 if (!t || !t.stops) {
995 return [];
996 }
997 var res = [];
998 for (var i = 0, l = t.stops.length; i < l; i++) {
999 res.push(t.stops[i][1]);
1000 }
1001 return res;
1002}
1003
1004
1005
1006var index$1 = Object.freeze({
1007 createFilter: createFilter,
1008 getFilterFeature: getFilterFeature,
1009 compileStyle: compileStyle,
1010 isFunctionDefinition: isFunctionDefinition,
1011 hasFunctionDefinition: hasFunctionDefinition,
1012 interpolated: interpolated,
1013 piecewiseConstant: piecewiseConstant,
1014 loadFunctionTypes: loadFunctionTypes,
1015 getFunctionTypeResources: getFunctionTypeResources
1016});
1017
1018function translateToSVGStyles(s) {
1019 var result = {
1020 'stroke': {
1021 'stroke': s['markerLineColor'],
1022 'stroke-width': s['markerLineWidth'],
1023 'stroke-opacity': s['markerLineOpacity'],
1024 'stroke-dasharray': null,
1025 'stroke-linecap': 'butt',
1026 'stroke-linejoin': 'round'
1027 },
1028 'fill': {
1029 'fill': s['markerFill'],
1030 'fill-opacity': s['markerFillOpacity']
1031 }
1032 };
1033
1034 if (result['stroke']['stroke-linecap'] === 'butt') {
1035 if (Browser$1.vml) {
1036 result['stroke']['stroke-linecap'] = 'flat';
1037 }
1038 }
1039 if (result['stroke']['stroke-width'] === 0) {
1040 result['stroke']['stroke-opacity'] = 0;
1041 }
1042 return result;
1043}
1044
1045function getMarkerPathBase64(symbol, width, height) {
1046 if (!symbol['markerPath']) {
1047 return null;
1048 }
1049 var op = 1;
1050 var styles = translateToSVGStyles(symbol);
1051
1052 if (isNumber(symbol['markerOpacity'])) {
1053 op = symbol['markerOpacity'];
1054 }
1055 if (isNumber(symbol['opacity'])) {
1056 op *= symbol['opacity'];
1057 }
1058 var svgStyles = {};
1059 if (styles) {
1060 for (var p in styles['stroke']) {
1061 if (styles['stroke'].hasOwnProperty(p)) {
1062 if (!isNil(styles['stroke'][p])) {
1063 svgStyles[p] = styles['stroke'][p];
1064 }
1065 }
1066 }
1067 for (var _p in styles['fill']) {
1068 if (styles['fill'].hasOwnProperty(_p)) {
1069 if (!isNil(styles['fill'][_p])) {
1070 svgStyles[_p] = styles['fill'][_p];
1071 }
1072 }
1073 }
1074 }
1075
1076 var pathes = Array.isArray(symbol['markerPath']) ? symbol['markerPath'] : [symbol['markerPath']];
1077 var path = void 0;
1078 var pathesToRender = [];
1079 for (var i = 0; i < pathes.length; i++) {
1080 path = isString(pathes[i]) ? {
1081 'path': pathes[i]
1082 } : pathes[i];
1083 path = extend({}, path, svgStyles);
1084 path['d'] = path['path'];
1085 delete path['path'];
1086 pathesToRender.push(path);
1087 }
1088 var svg = ['<svg version="1.1"', 'xmlns="http://www.w3.org/2000/svg"'];
1089 if (op < 1) {
1090 svg.push('opacity="' + op + '"');
1091 }
1092
1093 if (symbol['markerPathWidth'] && symbol['markerPathHeight']) {
1094 svg.push('viewBox="0 0 ' + symbol['markerPathWidth'] + ' ' + symbol['markerPathHeight'] + '"');
1095 }
1096 svg.push('preserveAspectRatio="none"');
1097 if (width) {
1098 svg.push('width="' + width + '"');
1099 }
1100 if (height) {
1101 svg.push('height="' + height + '"');
1102 }
1103 svg.push('><defs></defs>');
1104
1105 for (var _i = 0; _i < pathesToRender.length; _i++) {
1106 var strPath = '<path ';
1107 for (var _p2 in pathesToRender[_i]) {
1108 if (pathesToRender[_i].hasOwnProperty(_p2)) {
1109 strPath += ' ' + _p2 + '="' + pathesToRender[_i][_p2] + '"';
1110 }
1111 }
1112 strPath += '></path>';
1113 svg.push(strPath);
1114 }
1115 svg.push('</svg>');
1116 var b64 = 'data:image/svg+xml;base64,' + btoa(svg.join(' '));
1117 return b64;
1118}
1119
1120function getExternalResources(symbol, toAbsolute) {
1121 if (!symbol) {
1122 return [];
1123 }
1124 var symbols = symbol;
1125 if (!Array.isArray(symbol)) {
1126 symbols = [symbol];
1127 }
1128 var resources = [];
1129 var props = RESOURCE_PROPERTIES;
1130 var res = void 0,
1131 resSizeProp = void 0;
1132 var w = void 0,
1133 h = void 0;
1134 for (var i = symbols.length - 1; i >= 0; i--) {
1135 symbol = symbols[i];
1136 if (!symbol) {
1137 continue;
1138 }
1139 if (toAbsolute) {
1140 symbol = convertResourceUrl(symbol);
1141 }
1142 for (var ii = 0; ii < props.length; ii++) {
1143 res = symbol[props[ii]];
1144 if (isFunctionDefinition(res)) {
1145 res = getFunctionTypeResources(res);
1146 }
1147 if (!res) {
1148 continue;
1149 }
1150 if (!Array.isArray(res)) {
1151 res = [res];
1152 }
1153 for (var iii = 0; iii < res.length; iii++) {
1154 if (res[iii].slice(0, 4) === 'url(') {
1155 res[iii] = extractCssUrl(res[iii]);
1156 }
1157 resSizeProp = RESOURCE_SIZE_PROPERTIES[ii];
1158 resources.push([res[iii], symbol[resSizeProp[0]], symbol[resSizeProp[1]]]);
1159 }
1160 }
1161 if (symbol['markerType'] === 'path' && symbol['markerPath']) {
1162 w = isFunctionDefinition(symbol['markerWidth']) ? 200 : symbol['markerWidth'];
1163 h = isFunctionDefinition(symbol['markerHeight']) ? 200 : symbol['markerHeight'];
1164 if (isFunctionDefinition(symbol['markerPath'])) {
1165 res = getFunctionTypeResources(symbol['markerPath']);
1166 var path = symbol['markerPath'];
1167 for (var _iii = 0; _iii < res.length; _iii++) {
1168 symbol['markerPath'] = res[_iii];
1169 resources.push([getMarkerPathBase64(symbol), w, h]);
1170 }
1171 symbol['markerPath'] = path;
1172 } else {
1173 resources.push([getMarkerPathBase64(symbol), w, h]);
1174 }
1175 }
1176 }
1177 return resources;
1178}
1179
1180function convertResourceUrl(symbol) {
1181 if (!symbol) {
1182 return null;
1183 }
1184
1185 var s = symbol;
1186 if (IS_NODE) {
1187 return s;
1188 }
1189 var props = RESOURCE_PROPERTIES;
1190 var res = void 0;
1191 for (var ii = 0, len = props.length; ii < len; ii++) {
1192 res = s[props[ii]];
1193 if (!res) {
1194 continue;
1195 }
1196 s[props[ii]] = _convertUrlToAbsolute(res);
1197 }
1198 return s;
1199}
1200
1201function _convertUrlToAbsolute(res) {
1202 if (isFunctionDefinition(res)) {
1203 var stops = res.stops;
1204 for (var i = 0; i < stops.length; i++) {
1205 stops[i][1] = _convertUrlToAbsolute(stops[i][1]);
1206 }
1207 return res;
1208 }
1209 var embed = 'data:';
1210 if (res.slice(0, 4) === 'url(') {
1211 res = extractCssUrl(res);
1212 }
1213 if (!isURL(res) && (res.length <= embed.length || res.substring(0, embed.length) !== embed)) {
1214 res = _absolute(location.href, res);
1215 }
1216 return res;
1217}
1218
1219function _absolute(base, relative) {
1220 var stack = base.split('/'),
1221 parts = relative.split('/');
1222 if (relative.slice(0, 1) === 0) {
1223 return stack.slice(0, 3).join('/') + relative;
1224 } else {
1225 stack.pop();
1226 for (var i = 0; i < parts.length; i++) {
1227 if (parts[i] === '.') continue;
1228 if (parts[i] === '..') stack.pop();else stack.push(parts[i]);
1229 }
1230 return stack.join('/');
1231 }
1232}
1233
1234function isGradient(g) {
1235 return g && g['colorStops'];
1236}
1237
1238function getGradientStamp(g) {
1239 var keys = [g['type']];
1240 if (g['places']) {
1241 keys.push(g['places'].join());
1242 }
1243 if (g['colorStops']) {
1244 var stops = [];
1245 for (var i = g['colorStops'].length - 1; i >= 0; i--) {
1246 stops.push(g['colorStops'][i].join());
1247 }
1248 keys.push(stops.join(','));
1249 }
1250 return keys.join('_');
1251}
1252
1253function getSymbolStamp(symbol) {
1254 var keys = [];
1255 if (Array.isArray(symbol)) {
1256 for (var i = 0; i < symbol.length; i++) {
1257 keys.push(getSymbolStamp(symbol[i]));
1258 }
1259 return '[ ' + keys.join(' , ') + ' ]';
1260 }
1261 for (var p in symbol) {
1262 if (hasOwn(symbol, p)) {
1263 if (!isFunction(symbol[p])) {
1264 if (isGradient(symbol[p])) {
1265 keys.push(p + '=' + getGradientStamp(symbol[p]));
1266 } else {
1267 keys.push(p + '=' + symbol[p]);
1268 }
1269 }
1270 }
1271 }
1272 return keys.join(';');
1273}
1274
1275function lowerSymbolOpacity(symbol, ratio) {
1276 function s(_symbol, _ratio) {
1277 var op = _symbol['opacity'];
1278 if (isNil(op)) {
1279 _symbol['opacity'] = _ratio;
1280 } else {
1281 _symbol['opacity'] *= _ratio;
1282 }
1283 }
1284 var lower = void 0;
1285 if (Array.isArray(symbol)) {
1286 lower = [];
1287 for (var i = 0; i < symbol.length; i++) {
1288 var d = extend({}, symbol[i]);
1289 s(d, ratio);
1290 lower.push(d);
1291 }
1292 } else {
1293 lower = extend({}, symbol);
1294 s(lower, ratio);
1295 }
1296 return lower;
1297}
1298
1299function extendSymbol(symbol) {
1300 var sources = Array.prototype.slice.call(arguments, 1);
1301 if (!sources || !sources.length) {
1302 sources = [{}];
1303 }
1304 if (Array.isArray(symbol)) {
1305 var s = void 0,
1306 dest = void 0;
1307 var result = [];
1308 for (var i = 0, l = symbol.length; i < l; i++) {
1309 s = symbol[i];
1310 dest = {};
1311 for (var ii = 0, ll = sources.length; ii < ll; ii++) {
1312 if (!Array.isArray(sources[ii])) {
1313 extend(dest, s, sources[ii] ? sources[ii] : {});
1314 } else if (!isNil(sources[ii][i])) {
1315 extend(dest, s, sources[ii][i]);
1316 } else {
1317 extend(dest, s ? s : {});
1318 }
1319 }
1320 result.push(dest);
1321 }
1322 return result;
1323 } else {
1324 var args = [{}, symbol];
1325 args.push.apply(args, sources);
1326 return extend.apply(this, args);
1327 }
1328}
1329
1330
1331
1332var index = Object.freeze({
1333 now: now,
1334 extend: extend,
1335 isNil: isNil,
1336 isNumber: isNumber,
1337 isInteger: isInteger,
1338 isObject: isObject,
1339 isString: isString,
1340 isFunction: isFunction,
1341 hasOwn: hasOwn,
1342 join: join,
1343 toRadian: toRadian,
1344 toDegree: toDegree,
1345 IS_NODE: IS_NODE,
1346 get requestAnimFrame () { return requestAnimFrame; },
1347 get cancelAnimFrame () { return cancelAnimFrame; },
1348 isSVG: isSVG,
1349 loadImage: loadImage,
1350 UID: UID,
1351 GUID: GUID,
1352 parseJSON: parseJSON,
1353 pushIn: pushIn,
1354 removeFromArray: removeFromArray,
1355 forEachCoord: forEachCoord,
1356 getValueOrDefault: getValueOrDefault,
1357 sign: sign,
1358 log2: log2,
1359 interpolate: interpolate,
1360 wrap: wrap,
1361 clamp: clamp,
1362 isArrayHasData: isArrayHasData,
1363 isURL: isURL,
1364 isCssUrl: isCssUrl,
1365 extractCssUrl: extractCssUrl,
1366 btoa: btoa,
1367 b64toBlob: b64toBlob,
1368 computeDegree: computeDegree,
1369 emptyImageUrl: emptyImageUrl,
1370 equalMapView: equalMapView,
1371 flash: flash,
1372 translateToSVGStyles: translateToSVGStyles,
1373 getMarkerPathBase64: getMarkerPathBase64,
1374 getExternalResources: getExternalResources,
1375 convertResourceUrl: convertResourceUrl,
1376 isGradient: isGradient,
1377 getGradientStamp: getGradientStamp,
1378 getSymbolStamp: getSymbolStamp,
1379 lowerSymbolOpacity: lowerSymbolOpacity,
1380 extendSymbol: extendSymbol
1381});
1382
1383var Browser = {};
1384
1385if (!IS_NODE) {
1386 var ua = navigator.userAgent.toLowerCase(),
1387 doc = document.documentElement,
1388 ie = 'ActiveXObject' in window,
1389 webkit = ua.indexOf('webkit') !== -1,
1390 phantomjs = ua.indexOf('phantom') !== -1,
1391 android23 = ua.search('android [23]') !== -1,
1392 chrome = ua.indexOf('chrome') !== -1,
1393 gecko = ua.indexOf('gecko') !== -1 && !webkit && !window.opera && !ie,
1394 mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1,
1395 msPointer = !window.PointerEvent && window.MSPointerEvent,
1396 pointer = window.PointerEvent && navigator.pointerEnabled || msPointer,
1397 ie3d = ie && 'transition' in doc.style,
1398 webkit3d = 'WebKitCSSMatrix' in window && 'm11' in new window.WebKitCSSMatrix() && !android23,
1399 gecko3d = 'MozPerspective' in doc.style,
1400 opera12 = 'OTransition' in doc.style,
1401 any3d = (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs;
1402
1403 var chromeVersion = 0;
1404 if (chrome) {
1405 chromeVersion = ua.match(/chrome\/([\d.]+)/)[1];
1406 }
1407
1408 var touch = !phantomjs && (pointer || 'ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch);
1409
1410 var webgl = void 0;
1411 try {
1412 var canvas = document.createElement('canvas');
1413 var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
1414 webgl = gl && gl instanceof WebGLRenderingContext;
1415 } catch (err) {
1416 webgl = false;
1417 }
1418
1419 Browser = {
1420 ie: ie,
1421 ielt9: ie && !document.addEventListener,
1422 edge: 'msLaunchUri' in navigator && !('documentMode' in document),
1423 webkit: webkit,
1424 gecko: gecko,
1425 android: ua.indexOf('android') !== -1,
1426 android23: android23,
1427 chrome: chrome,
1428 chromeVersion: chromeVersion,
1429 safari: !chrome && ua.indexOf('safari') !== -1,
1430 phantomjs: phantomjs,
1431
1432 ie3d: ie3d,
1433 webkit3d: webkit3d,
1434 gecko3d: gecko3d,
1435 opera12: opera12,
1436 any3d: any3d,
1437
1438 mobile: mobile,
1439 mobileWebkit: mobile && webkit,
1440 mobileWebkit3d: mobile && webkit3d,
1441 mobileOpera: mobile && window.opera,
1442 mobileGecko: mobile && gecko,
1443
1444 touch: !!touch,
1445 msPointer: !!msPointer,
1446 pointer: !!pointer,
1447
1448 retina: (window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI) > 1,
1449
1450 language: navigator.browserLanguage ? navigator.browserLanguage : navigator.language,
1451 ie9: ie && document.documentMode === 9,
1452 ie10: ie && document.documentMode === 10,
1453
1454 webgl: webgl
1455 };
1456}
1457
1458var Browser$1 = Browser;
1459
1460var Position = function () {
1461 function Position(x, y) {
1462 classCallCheck(this, Position);
1463
1464 if (!isNil(x) && !isNil(y)) {
1465 this.x = +x;
1466
1467 this.y = +y;
1468 } else if (!isNil(x.x) && !isNil(x.y)) {
1469 this.x = +x.x;
1470 this.y = +x.y;
1471 } else if (Array.isArray(x)) {
1472 this.x = +x[0];
1473 this.y = +x[1];
1474 }
1475 if (this._isNaN()) {
1476 throw new Error('Position is NaN');
1477 }
1478 }
1479
1480 Position.prototype.abs = function abs() {
1481 return new this.constructor(Math.abs(this.x), Math.abs(this.y));
1482 };
1483
1484 Position.prototype._abs = function _abs() {
1485 this.x = Math.abs(this.x);
1486 this.y = Math.abs(this.y);
1487 return this;
1488 };
1489
1490 Position.prototype._round = function _round() {
1491 this.x = Math.round(this.x);
1492 this.y = Math.round(this.y);
1493 return this;
1494 };
1495
1496 Position.prototype.round = function round() {
1497 return new this.constructor(Math.round(this.x), Math.round(this.y));
1498 };
1499
1500 Position.prototype._ceil = function _ceil() {
1501 this.x = Math.ceil(this.x);
1502 this.y = Math.ceil(this.y);
1503 return this;
1504 };
1505
1506 Position.prototype.ceil = function ceil() {
1507 return new this.constructor(Math.ceil(this.x), Math.ceil(this.y));
1508 };
1509
1510 Position.prototype._floor = function _floor() {
1511 this.x = Math.floor(this.x);
1512 this.y = Math.floor(this.y);
1513 return this;
1514 };
1515
1516 Position.prototype.floor = function floor() {
1517 return new this.constructor(Math.floor(this.x), Math.floor(this.y));
1518 };
1519
1520 Position.prototype.copy = function copy() {
1521 return new this.constructor(this.x, this.y);
1522 };
1523
1524 Position.prototype._add = function _add(x, y) {
1525 if (!isNil(x.x)) {
1526 this.x += x.x;
1527 this.y += x.y;
1528 } else if (!isNil(x[0])) {
1529 this.x += x[0];
1530 this.y += x[1];
1531 } else {
1532 this.x += x;
1533 this.y += y;
1534 }
1535 return this;
1536 };
1537
1538 Position.prototype.add = function add(x, y) {
1539 var nx = void 0,
1540 ny = void 0;
1541 if (!isNil(x.x)) {
1542 nx = this.x + x.x;
1543 ny = this.y + x.y;
1544 } else if (!isNil(x[0])) {
1545 nx = this.x + x[0];
1546 ny = this.y + x[1];
1547 } else {
1548 nx = this.x + x;
1549 ny = this.y + y;
1550 }
1551 return new this.constructor(nx, ny);
1552 };
1553
1554 Position.prototype._sub = function _sub(x, y) {
1555 if (!isNil(x.x)) {
1556 this.x -= x.x;
1557 this.y -= x.y;
1558 } else if (!isNil(x[0])) {
1559 this.x -= x[0];
1560 this.y -= x[1];
1561 } else {
1562 this.x -= x;
1563 this.y -= y;
1564 }
1565 return this;
1566 };
1567
1568 Position.prototype._substract = function _substract() {
1569 return this._sub.apply(this, arguments);
1570 };
1571
1572 Position.prototype.sub = function sub(x, y) {
1573 var nx = void 0,
1574 ny = void 0;
1575 if (!isNil(x.x)) {
1576 nx = this.x - x.x;
1577 ny = this.y - x.y;
1578 } else if (!isNil(x[0])) {
1579 nx = this.x - x[0];
1580 ny = this.y - x[1];
1581 } else {
1582 nx = this.x - x;
1583 ny = this.y - y;
1584 }
1585 return new this.constructor(nx, ny);
1586 };
1587
1588 Position.prototype.substract = function substract() {
1589 return this.sub.apply(this, arguments);
1590 };
1591
1592 Position.prototype.multi = function multi(ratio) {
1593 return new this.constructor(this.x * ratio, this.y * ratio);
1594 };
1595
1596 Position.prototype._multi = function _multi(ratio) {
1597 this.x *= ratio;
1598 this.y *= ratio;
1599 return this;
1600 };
1601
1602 Position.prototype.div = function div(n) {
1603 return this.multi(1 / n);
1604 };
1605
1606 Position.prototype._div = function _div(n) {
1607 return this._multi(1 / n);
1608 };
1609
1610 Position.prototype.equals = function equals(c) {
1611 if (!(c instanceof this.constructor)) {
1612 return false;
1613 }
1614 return this.x === c.x && this.y === c.y;
1615 };
1616
1617 Position.prototype._isNaN = function _isNaN() {
1618 return isNaN(this.x) || isNaN(this.y);
1619 };
1620
1621 Position.prototype.isZero = function isZero() {
1622 return this.x === 0 && this.y === 0;
1623 };
1624
1625 Position.prototype.toArray = function toArray$$1() {
1626 return [this.x, this.y];
1627 };
1628
1629 Position.prototype.toFixed = function toFixed(n) {
1630 return new this.constructor(this.x.toFixed(n), this.y.toFixed(n));
1631 };
1632
1633 Position.prototype.toJSON = function toJSON() {
1634 return {
1635 x: this.x,
1636 y: this.y
1637 };
1638 };
1639
1640 return Position;
1641}();
1642
1643var Point = function (_Position) {
1644 inherits(Point, _Position);
1645
1646 function Point() {
1647 classCallCheck(this, Point);
1648 return possibleConstructorReturn(this, _Position.apply(this, arguments));
1649 }
1650
1651 Point.prototype.closeTo = function closeTo(p, delta) {
1652 if (!delta) {
1653 delta = 0;
1654 }
1655 return this.x >= p.x - delta && this.x <= p.x + delta && this.y >= p.y - delta && this.y <= p.y + delta;
1656 };
1657
1658 Point.prototype.distanceTo = function distanceTo(point) {
1659 var x = point.x - this.x,
1660 y = point.y - this.y;
1661 return Math.sqrt(x * x + y * y);
1662 };
1663
1664 Point.prototype.mag = function mag() {
1665 return Math.sqrt(this.x * this.x + this.y * this.y);
1666 };
1667
1668 Point.prototype.unit = function unit() {
1669 return this.copy()._unit();
1670 };
1671
1672 Point.prototype._unit = function _unit() {
1673 this._div(this.mag());
1674 return this;
1675 };
1676
1677 Point.prototype.perp = function perp() {
1678 return this.copy()._perp();
1679 };
1680
1681 Point.prototype._perp = function _perp() {
1682 var y = this.y;
1683 this.y = this.x;
1684 this.x = -y;
1685 return this;
1686 };
1687
1688 Point.prototype.angleWith = function angleWith(b) {
1689 return this.angleWithSep(b.x, b.y);
1690 };
1691
1692 Point.prototype.angleWithSep = function angleWithSep(x, y) {
1693 return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
1694 };
1695
1696 Point.prototype._rotate = function _rotate(angle) {
1697 var cos = Math.cos(angle),
1698 sin = Math.sin(angle),
1699 x = cos * this.x - sin * this.y,
1700 y = sin * this.x + cos * this.y;
1701 this.x = x;
1702 this.y = y;
1703 return this;
1704 };
1705
1706 Point.prototype.rotate = function rotate(a) {
1707 return this.copy()._rotate(a);
1708 };
1709
1710 return Point;
1711}(Position);
1712
1713var Size = function () {
1714 function Size(width, height) {
1715 classCallCheck(this, Size);
1716
1717 if (isNumber(width) && isNumber(height)) {
1718 this.width = width;
1719
1720 this.height = height;
1721 } else if (isNumber(width['width'])) {
1722 this.width = width.width;
1723 this.height = width.height;
1724 } else if (Array.isArray(width)) {
1725 this.width = width[0];
1726 this.height = width[1];
1727 }
1728 }
1729
1730 Size.prototype.copy = function copy() {
1731 return new Size(this['width'], this['height']);
1732 };
1733
1734 Size.prototype.add = function add(x, y) {
1735 var w = void 0,
1736 h = void 0;
1737 if (x instanceof Size) {
1738 w = this.width + x.width;
1739 h = this.height + x.height;
1740 } else {
1741 w = this.width + x;
1742 h = this.height + y;
1743 }
1744 return new Size(w, h);
1745 };
1746
1747 Size.prototype.equals = function equals(size) {
1748 return this['width'] === size['width'] && this['height'] === size['height'];
1749 };
1750
1751 Size.prototype.multi = function multi(ratio) {
1752 return new Size(this['width'] * ratio, this['height'] * ratio);
1753 };
1754
1755 Size.prototype._multi = function _multi(ratio) {
1756 this['width'] *= ratio;
1757 this['height'] *= ratio;
1758 return this;
1759 };
1760
1761 Size.prototype._round = function _round() {
1762 this['width'] = Math.round(this['width']);
1763 this['height'] = Math.round(this['height']);
1764 return this;
1765 };
1766
1767 Size.prototype.toPoint = function toPoint() {
1768 return new Point(this['width'], this['height']);
1769 };
1770
1771 Size.prototype.toArray = function toArray$$1() {
1772 return [this['width'], this['height']];
1773 };
1774
1775 Size.prototype.toJSON = function toJSON() {
1776 return {
1777 'width': this['width'],
1778 'height': this['height']
1779 };
1780 };
1781
1782 return Size;
1783}();
1784
1785function trim(str) {
1786 return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
1787}
1788
1789var specialPattern = /[\b\t\r\v\f]/igm;
1790
1791function escapeSpecialChars(str) {
1792 if (!isString(str)) {
1793 return str;
1794 }
1795 return str.replace(specialPattern, '');
1796}
1797
1798function splitWords(chr) {
1799 return trim(chr).split(/\s+/);
1800}
1801
1802var rulerCtx = typeof document !== 'undefined' ? document.createElement('canvas').getContext('2d') : null;
1803
1804function stringWidth(text, font) {
1805 if (stringWidth.node) {
1806 return stringWidth.node(text, font);
1807 }
1808 rulerCtx.font = font;
1809 return rulerCtx.measureText(text).width;
1810}
1811
1812var fontHeight = {};
1813
1814function stringLength(text, font) {
1815 if (stringLength.node) {
1816 return stringLength.node(text, font);
1817 } else {
1818 var w = stringWidth(text, font);
1819 if (!font) {
1820 font = '_default_';
1821 }
1822 if (!fontHeight[font]) {
1823 fontHeight[font] = getFontHeight(font);
1824 }
1825 return new Size(w, fontHeight[font]);
1826 }
1827}
1828
1829function getFontHeight(font) {
1830 var domRuler = getDomRuler();
1831 if (font !== '_default_') {
1832 domRuler.style.font = font;
1833 }
1834 domRuler.innerHTML = '秦';
1835 var h = domRuler.clientHeight;
1836
1837 removeDomNode(domRuler);
1838 return h;
1839}
1840
1841function splitContent(content, font, wrapWidth, textWidth) {
1842 if (!content || content.length === 0) {
1843 return [{ 'text': '', 'width': 0 }];
1844 }
1845 var width = isNil(textWidth) ? stringWidth(content, font) : textWidth;
1846 var chrWidth = width / content.length,
1847 minChrCount = Math.floor(wrapWidth / chrWidth / 2);
1848 if (chrWidth >= wrapWidth || minChrCount <= 0) {
1849 return [{ 'text': '', 'width': wrapWidth }];
1850 }
1851 if (width <= wrapWidth) return [{ 'text': content, 'width': width }];
1852 var result = [];
1853 var testStr = content.substring(0, minChrCount),
1854 prew = chrWidth * minChrCount;
1855 for (var i = minChrCount, l = content.length; i < l; i++) {
1856 var chr = content[i];
1857 var w = stringWidth(testStr + chr);
1858 if (w >= wrapWidth) {
1859 result.push({ 'text': testStr, 'width': prew });
1860 testStr = content.substring(i, minChrCount + i);
1861 i += minChrCount - 1;
1862 prew = chrWidth * minChrCount;
1863 } else {
1864 testStr += chr;
1865 prew = w;
1866 }
1867 if (i >= l - 1) {
1868 prew = stringWidth(testStr);
1869 result.push({ 'text': testStr, 'width': prew });
1870 }
1871 }
1872 return result;
1873}
1874
1875var contentExpRe = /\{([\w_]+)\}/g;
1876
1877function replaceVariable(str, props) {
1878 if (!isString(str)) {
1879 return str;
1880 }
1881 return str.replace(contentExpRe, function (str, key) {
1882 if (!props) {
1883 return '';
1884 }
1885 var value = props[key];
1886 if (isNil(value)) {
1887 return '';
1888 } else if (Array.isArray(value)) {
1889 return value.join();
1890 }
1891 return value;
1892 });
1893}
1894
1895function getAlignPoint(size, horizontalAlignment, verticalAlignment) {
1896 var width = size['width'],
1897 height = size['height'];
1898 var alignW = void 0,
1899 alignH = void 0;
1900 if (horizontalAlignment === 'left') {
1901 alignW = -width;
1902 } else if (horizontalAlignment === 'right') {
1903 alignW = 0;
1904 } else {
1905 alignW = -width / 2;
1906 }
1907 if (verticalAlignment === 'top') {
1908 alignH = -height;
1909 } else if (verticalAlignment === 'bottom') {
1910 alignH = 0;
1911 } else {
1912 alignH = -height / 2;
1913 }
1914 return new Point(alignW, alignH);
1915}
1916
1917function getFont(style) {
1918 if (style['textFont']) {
1919 return style['textFont'];
1920 } else {
1921 return (style['textStyle'] && style['textStyle'] !== 'normal' ? style['textStyle'] + ' ' : '') + (style['textWeight'] && style['textWeight'] !== 'normal' ? style['textWeight'] + ' ' : '') + style['textSize'] + 'px ' + (style['textFaceName'][0] === '"' ? style['textFaceName'] : '"' + style['textFaceName'] + '"');
1922 }
1923}
1924
1925function splitTextToRow(text, style) {
1926 var font = getFont(style),
1927 lineSpacing = style['textLineSpacing'] || 0,
1928 size = stringLength(text, font),
1929 textWidth = size['width'],
1930 textHeight = size['height'],
1931 wrapChar = style['textWrapCharacter'],
1932 textRows = [];
1933 var wrapWidth = style['textWrapWidth'];
1934 if (!wrapWidth || wrapWidth > textWidth) {
1935 wrapWidth = textWidth;
1936 }
1937 if (!isString(text)) {
1938 text += '';
1939 }
1940 var actualWidth = 0;
1941 if (wrapChar && text.indexOf(wrapChar) >= 0) {
1942 var texts = text.split(wrapChar);
1943 for (var i = 0, l = texts.length; i < l; i++) {
1944 var t = texts[i];
1945 var tWidth = stringWidth(t, font);
1946 if (tWidth > wrapWidth) {
1947 var contents = splitContent(t, font, wrapWidth, tWidth);
1948 for (var ii = 0, ll = contents.length; ii < ll; ii++) {
1949 var w = contents[ii].width;
1950 if (w > actualWidth) {
1951 actualWidth = w;
1952 }
1953 textRows.push({
1954 'text': contents[ii].text,
1955 'size': new Size(w, textHeight)
1956 });
1957 }
1958 } else {
1959 if (tWidth > actualWidth) {
1960 actualWidth = tWidth;
1961 }
1962 textRows.push({
1963 'text': t,
1964 'size': new Size(tWidth, textHeight)
1965 });
1966 }
1967 }
1968 } else if (textWidth > wrapWidth) {
1969 var _contents = splitContent(text, font, wrapWidth, textWidth);
1970 for (var _i = 0; _i < _contents.length; _i++) {
1971 var _w = _contents[_i].width;
1972 if (_w > actualWidth) {
1973 actualWidth = _w;
1974 }
1975 textRows.push({
1976 'text': _contents[_i].text,
1977 'size': new Size(_w, textHeight)
1978 });
1979 }
1980 } else {
1981 if (textWidth > actualWidth) {
1982 actualWidth = textWidth;
1983 }
1984 textRows.push({
1985 'text': text,
1986 'size': size
1987 });
1988 }
1989
1990 var rowNum = textRows.length;
1991 var textSize = new Size(actualWidth, textHeight * rowNum + lineSpacing * (rowNum - 1));
1992 return {
1993 'total': rowNum,
1994 'size': textSize,
1995 'rows': textRows,
1996 'rawSize': size
1997 };
1998}
1999
2000var strings = Object.freeze({
2001 trim: trim,
2002 escapeSpecialChars: escapeSpecialChars,
2003 splitWords: splitWords,
2004 stringWidth: stringWidth,
2005 stringLength: stringLength,
2006 getFontHeight: getFontHeight,
2007 splitContent: splitContent,
2008 replaceVariable: replaceVariable,
2009 getAlignPoint: getAlignPoint,
2010 getFont: getFont,
2011 splitTextToRow: splitTextToRow
2012});
2013
2014var first = function first(props) {
2015 return props[0];
2016};
2017
2018var testProp = IS_NODE ? first : function (props) {
2019
2020 var style = document.documentElement.style;
2021
2022 for (var i = 0; i < props.length; i++) {
2023 if (props[i] in style) {
2024 return props[i];
2025 }
2026 }
2027 return false;
2028};
2029
2030var TRANSFORM = testProp(['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']);
2031
2032var TRANSFORMORIGIN = testProp(['transformOrigin', 'WebkitTransformOrigin', 'OTransformOrigin', 'MozTransformOrigin', 'msTransformOrigin']);
2033
2034var TRANSITION = testProp(['transition', 'WebkitTransition', 'OTransition', 'MozTransition', 'msTransition']);
2035
2036var CSSFILTER = testProp(['filter', 'WebkitFilter', 'OFilter', 'MozFilter', 'msFilter']);
2037
2038function createEl(tagName, className) {
2039 var el = document.createElement(tagName);
2040 if (className) {
2041 setClass(el, className);
2042 }
2043 return el;
2044}
2045
2046function createElOn(tagName, style, container) {
2047 var el = createEl(tagName);
2048 if (style) {
2049 setStyle(el, style);
2050 }
2051 if (container) {
2052 container.appendChild(el);
2053 }
2054 return el;
2055}
2056
2057function removeDomNode(node) {
2058 if (!node) {
2059 return this;
2060 }
2061 if (Browser$1.ielt9 || Browser$1.ie9) {
2062 var d = createEl('div');
2063 d.appendChild(node);
2064 d.innerHTML = '';
2065 d = null;
2066 } else if (node.parentNode) {
2067 node.parentNode.removeChild(node);
2068 }
2069 return this;
2070}
2071
2072function addDomEvent(obj, typeArr, handler, context) {
2073 if (!obj || !obj.addEventListener || !typeArr || !handler) {
2074 return this;
2075 }
2076 var eventHandler = function eventHandler(e) {
2077 if (!e) {
2078 e = window.event;
2079 }
2080 handler.call(context || obj, e);
2081 return;
2082 };
2083 var types = typeArr.split(' ');
2084 for (var i = types.length - 1; i >= 0; i--) {
2085 var type = types[i];
2086 if (!type) {
2087 continue;
2088 }
2089
2090 if (!obj['Z__' + type]) {
2091 obj['Z__' + type] = [];
2092 }
2093 var hit = listensDomEvent(obj, type, handler);
2094 if (hit >= 0) {
2095 removeDomEvent(obj, type, handler);
2096 }
2097 obj['Z__' + type].push({
2098 callback: eventHandler,
2099 src: handler
2100 });
2101
2102 if (type === 'mousewheel' && Browser$1.gecko) {
2103 type = 'DOMMouseScroll';
2104 }
2105 obj.addEventListener(type, eventHandler, false);
2106 }
2107 return this;
2108}
2109
2110function removeDomEvent(obj, typeArr, handler) {
2111 function doRemove(type, callback) {
2112 if (type === 'mousewheel' && Browser$1.gecko) {
2113 type = 'DOMMouseScroll';
2114 }
2115 obj.removeEventListener(type, callback, false);
2116 }
2117 if (!obj || !obj.removeEventListener || !typeArr) {
2118 return this;
2119 }
2120 var types = typeArr.split(' ');
2121 for (var i = types.length - 1; i >= 0; i--) {
2122 var type = types[i];
2123 if (!type) {
2124 continue;
2125 }
2126
2127 if (!handler && obj['Z__' + type]) {
2128 var handlers = obj['Z__' + type];
2129 for (var j = 0, jlen = handlers.length; j < jlen; j++) {
2130 doRemove(handlers[j].callback);
2131 }
2132 delete obj['Z__' + type];
2133 return this;
2134 }
2135 var hit = listensDomEvent(obj, type, handler);
2136 if (hit < 0) {
2137 return this;
2138 }
2139 var hitHandler = obj['Z__' + type][hit];
2140 doRemove(type, hitHandler.callback);
2141 obj['Z__' + type].splice(hit, 1);
2142 }
2143 return this;
2144}
2145
2146function listensDomEvent(obj, type, handler) {
2147 if (!obj || !obj['Z__' + type] || !handler) {
2148 return -1;
2149 }
2150 var handlers = obj['Z__' + type];
2151 for (var i = 0, len = handlers.length; i < len; i++) {
2152 if (handlers[i].src === handler) {
2153 return i;
2154 }
2155 }
2156 return -1;
2157}
2158
2159function preventDefault(event) {
2160 if (event.preventDefault) {
2161 event.preventDefault();
2162 } else {
2163 event.returnValue = false;
2164 }
2165 return this;
2166}
2167
2168function stopPropagation(e) {
2169 if (e.stopPropagation) {
2170 e.stopPropagation();
2171 } else {
2172 e.cancelBubble = true;
2173 }
2174 return this;
2175}
2176
2177function preventSelection(dom) {
2178 dom.onselectstart = function () {
2179 return false;
2180 };
2181 dom.ondragstart = function () {
2182 return false;
2183 };
2184 dom.setAttribute('unselectable', 'on');
2185 return this;
2186}
2187
2188function offsetDom(dom, offset) {
2189 if (!dom) {
2190 return null;
2191 }
2192
2193 if (Browser$1.any3d) {
2194 setTransform(dom, offset);
2195 } else {
2196 dom.style.left = offset.x + 'px';
2197 dom.style.top = offset.y + 'px';
2198 }
2199 return offset;
2200}
2201
2202function computeDomPosition(dom) {
2203 var style = window.getComputedStyle(dom);
2204 var padding = [parseInt(style['padding-left']), parseInt(style['padding-top'])];
2205 var rect = dom.getBoundingClientRect();
2206
2207 var offsetWidth = dom.offsetWidth,
2208 offsetHeight = dom.offsetHeight;
2209 var scaleX = offsetWidth ? rect.width / offsetWidth : 1,
2210 scaleY = offsetHeight ? rect.height / offsetHeight : 1;
2211 dom.__position = [rect.left + padding[0], rect.top + padding[1], scaleX, scaleY];
2212 return dom.__position;
2213}
2214
2215function getEventContainerPoint(ev, dom) {
2216 if (!ev) {
2217 ev = window.event;
2218 }
2219 var domPos = dom.__position;
2220 if (!domPos) {
2221 domPos = computeDomPosition(dom);
2222 }
2223
2224 return new Point(ev.clientX / domPos[2] - domPos[0] - dom.clientLeft, ev.clientY / domPos[3] - domPos[1] - dom.clientTop);
2225}
2226
2227function endsWith(str, suffix) {
2228 var l = str.length - suffix.length;
2229 return l >= 0 && str.indexOf(suffix, l) === l;
2230}
2231
2232function setStyle(dom, strCss) {
2233 var cssText = dom.style.cssText;
2234 if (!endsWith(cssText, ';')) {
2235 cssText += ';';
2236 }
2237 dom.style.cssText = cssText + strCss;
2238 return this;
2239}
2240
2241function hasClass(el, name) {
2242 if (el.classList !== undefined) {
2243 return el.classList.contains(name);
2244 }
2245 var className = getClass(el);
2246 return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
2247}
2248
2249function addClass(el, name) {
2250 if (el.classList !== undefined && !hasClass(el, name)) {
2251 var classes = splitWords(name);
2252 for (var i = 0, len = classes.length; i < len; i++) {
2253 el.classList.add(classes[i]);
2254 }
2255 } else {
2256 var className = getClass(el);
2257 setClass(el, (className ? className + ' ' : '') + name);
2258 }
2259 return this;
2260}
2261
2262function setClass(el, name) {
2263 if (isNil(el.className.baseVal)) {
2264 el.className = name;
2265 } else {
2266 el.className.baseVal = name;
2267 }
2268 return this;
2269}
2270
2271function getClass(el) {
2272 return isNil(el.className.baseVal) ? el.className : el.className.baseVal;
2273}
2274
2275function setOpacity(el, value) {
2276 el.style.opacity = value;
2277 return this;
2278}
2279
2280function setTransform(el, offset) {
2281 var pos = offset || new Point(0, 0);
2282 el.style[TRANSFORM] = Browser$1.any3d ? 'translate3d(' + pos.x + 'px,' + pos.y + 'px,0px)' : 'translate(' + pos.x + 'px,' + pos.y + 'px)';
2283
2284 return this;
2285}
2286
2287function setTransformMatrix(el, m) {
2288 var text = 'matrix(' + (isString(m) ? m : m.join()) + ')';
2289 if (el.style[TRANSFORM] !== text) {
2290 el.style[TRANSFORM] = text;
2291 }
2292 return this;
2293}
2294
2295function removeTransform(el) {
2296 if (el.style[TRANSFORM]) {
2297 el.style[TRANSFORM] = '';
2298 }
2299 return this;
2300}
2301
2302function isHTML(str) {
2303 return (/<[a-z\][\s\S]*>/i.test(str)
2304 );
2305}
2306
2307function measureDom(parentTag, dom) {
2308 var ruler = getDomRuler(parentTag);
2309 if (isString(dom)) {
2310 ruler.innerHTML = dom;
2311 } else {
2312 ruler.appendChild(dom);
2313 }
2314 var result = new Size(ruler.clientWidth, ruler.clientHeight);
2315 removeDomNode(ruler);
2316 return result;
2317}
2318
2319function getDomRuler(tag) {
2320 var span = document.createElement(tag);
2321 span.style.cssText = 'position:absolute;left:-10000px;top:-10000px;';
2322 document.body.appendChild(span);
2323 return span;
2324}
2325
2326var on = addDomEvent;
2327
2328var off = removeDomEvent;
2329
2330var dom = Object.freeze({
2331 TRANSFORM: TRANSFORM,
2332 TRANSFORMORIGIN: TRANSFORMORIGIN,
2333 TRANSITION: TRANSITION,
2334 CSSFILTER: CSSFILTER,
2335 createEl: createEl,
2336 createElOn: createElOn,
2337 removeDomNode: removeDomNode,
2338 addDomEvent: addDomEvent,
2339 removeDomEvent: removeDomEvent,
2340 listensDomEvent: listensDomEvent,
2341 preventDefault: preventDefault,
2342 stopPropagation: stopPropagation,
2343 preventSelection: preventSelection,
2344 offsetDom: offsetDom,
2345 computeDomPosition: computeDomPosition,
2346 getEventContainerPoint: getEventContainerPoint,
2347 setStyle: setStyle,
2348 hasClass: hasClass,
2349 addClass: addClass,
2350 setClass: setClass,
2351 getClass: getClass,
2352 setOpacity: setOpacity,
2353 setTransform: setTransform,
2354 setTransformMatrix: setTransformMatrix,
2355 removeTransform: removeTransform,
2356 isHTML: isHTML,
2357 measureDom: measureDom,
2358 getDomRuler: getDomRuler,
2359 on: on,
2360 off: off
2361});
2362
2363var Ajax = {
2364 jsonp: function jsonp(url, callback) {
2365 var name = '_maptalks_jsonp_' + UID();
2366 if (url.match(/\?/)) url += '&callback=' + name;else url += '?callback=' + name;
2367
2368 var script = document.createElement('script');
2369 script.type = 'text/javascript';
2370 script.src = url;
2371
2372 window[name] = function (data) {
2373 callback(null, data);
2374 document.getElementsByTagName('head')[0].removeChild(script);
2375 script = null;
2376 delete window[name];
2377 };
2378
2379 document.getElementsByTagName('head')[0].appendChild(script);
2380 return this;
2381 },
2382
2383 get: function get(url, options, cb) {
2384 if (isFunction(options)) {
2385 var t = cb;
2386 cb = options;
2387 options = t;
2388 }
2389 if (IS_NODE && Ajax.get.node) {
2390 return Ajax.get.node(url, cb, options);
2391 }
2392 var client = Ajax._getClient(cb);
2393 client.open('GET', url, true);
2394 if (options) {
2395 for (var k in options.headers) {
2396 client.setRequestHeader(k, options.headers[k]);
2397 }
2398 client.withCredentials = options.credentials === 'include';
2399 if (options['responseType']) {
2400 client.responseType = options['responseType'];
2401 }
2402 }
2403 client.send(null);
2404 return client;
2405 },
2406
2407 post: function post(url, options, cb) {
2408 var postData = void 0;
2409 if (!isString(url)) {
2410 var t = cb;
2411 postData = options;
2412 options = url;
2413 url = options.url;
2414 cb = t;
2415 } else {
2416 if (isFunction(options)) {
2417 var _t = cb;
2418 cb = options;
2419 options = _t;
2420 }
2421 options = options || {};
2422 postData = options.postData;
2423 }
2424 if (IS_NODE && Ajax.post.node) {
2425 options.url = url;
2426 return Ajax.post.node(options, postData, cb);
2427 }
2428 var client = Ajax._getClient(cb);
2429 client.open('POST', options.url, true);
2430 if (!options.headers) {
2431 options.headers = {};
2432 }
2433 if (!options.headers['Content-Type']) {
2434 options.headers['Content-Type'] = 'application/x-www-form-urlencoded';
2435 }
2436 if ('setRequestHeader' in client) {
2437 for (var p in options.headers) {
2438 if (options.headers.hasOwnProperty(p)) {
2439 client.setRequestHeader(p, options.headers[p]);
2440 }
2441 }
2442 }
2443 if (!isString(postData)) {
2444 postData = JSON.stringify(postData);
2445 }
2446 client.send(postData);
2447 return client;
2448 },
2449
2450 _wrapCallback: function _wrapCallback(client, cb) {
2451 return function () {
2452 if (client.readyState === 4) {
2453 if (client.status === 200) {
2454 if (client.responseType === 'arraybuffer') {
2455 var response = client.response;
2456 if (response.byteLength === 0) {
2457 cb(new Error('http status 200 returned without content.'));
2458 } else {
2459 cb(null, {
2460 data: client.response,
2461 cacheControl: client.getResponseHeader('Cache-Control'),
2462 expires: client.getResponseHeader('Expires'),
2463 contentType: client.getResponseHeader('Content-Type')
2464 });
2465 }
2466 } else {
2467 cb(null, client.responseText);
2468 }
2469 } else {
2470 cb(new Error(client.statusText + ',' + client.status));
2471 }
2472 }
2473 };
2474 },
2475
2476 _getClient: function _getClient(cb) {
2477 var client = void 0;
2478 try {
2479 client = new XMLHttpRequest();
2480 } catch (e) {
2481 try {
2482 client = new ActiveXObject('Msxml2.XMLHTTP');
2483 } catch (e) {
2484 try {
2485 client = new ActiveXObject('Microsoft.XMLHTTP');
2486 } catch (e) {}
2487 }
2488 }
2489 client.onreadystatechange = Ajax._wrapCallback(client, cb);
2490 return client;
2491 },
2492 getArrayBuffer: function getArrayBuffer(url, options, cb) {
2493 if (isFunction(options)) {
2494 var t = cb;
2495 cb = options;
2496 options = t;
2497 }
2498 if (!options) {
2499 options = {};
2500 }
2501 options['responseType'] = 'arraybuffer';
2502 return Ajax.get(url, options, cb);
2503 },
2504 getImage: function getImage(img, url, options) {
2505 return Ajax.getArrayBuffer(url, options, function (err, imgData) {
2506 if (err) {
2507 if (img.onerror) {
2508 img.onerror(err);
2509 }
2510 } else if (imgData) {
2511 var URL = window.URL || window.webkitURL;
2512 var onload = img.onload;
2513 img.onload = function () {
2514 if (onload) {
2515 onload();
2516 }
2517 URL.revokeObjectURL(img.src);
2518 };
2519 var blob = new Blob([new Uint8Array(imgData.data)], { type: imgData.contentType });
2520 img.cacheControl = imgData.cacheControl;
2521 img.expires = imgData.expires;
2522 img.src = imgData.data.byteLength ? URL.createObjectURL(blob) : emptyImageUrl;
2523 }
2524 });
2525 }
2526};
2527
2528Ajax.getJSON = function (url, options, cb) {
2529 if (isFunction(options)) {
2530 var t = cb;
2531 cb = options;
2532 options = t;
2533 }
2534 var callback = function callback(err, resp) {
2535 var data = resp ? parseJSON(resp) : null;
2536 cb(err, data);
2537 };
2538 if (options && options['jsonp']) {
2539 return Ajax.jsonp(url, callback);
2540 }
2541 return Ajax.get(url, options, callback);
2542};
2543
2544var DEFAULT_STROKE_COLOR = '#000';
2545var DEFAULT_FILL_COLOR = 'rgba(255,255,255,0)';
2546var DEFAULT_TEXT_COLOR = '#000';
2547
2548var hitTesting = false;
2549
2550var Canvas = {
2551 setHitTesting: function setHitTesting(testing) {
2552 hitTesting = testing;
2553 },
2554 createCanvas: function createCanvas(width, height, canvasClass) {
2555 var canvas = void 0;
2556 if (!IS_NODE) {
2557 canvas = createEl('canvas');
2558 canvas.width = width;
2559 canvas.height = height;
2560 } else {
2561 canvas = new canvasClass(width, height);
2562 }
2563 return canvas;
2564 },
2565 prepareCanvasFont: function prepareCanvasFont(ctx, style) {
2566 ctx.textBaseline = 'top';
2567 ctx.font = getFont(style);
2568 var fill = style['textFill'];
2569 if (!fill) {
2570 fill = DEFAULT_TEXT_COLOR;
2571 }
2572 ctx.fillStyle = Canvas.getRgba(fill, style['textOpacity']);
2573 },
2574 prepareCanvas: function prepareCanvas(ctx, style, resources, testing) {
2575 if (!style) {
2576 return;
2577 }
2578 var strokeWidth = style['lineWidth'];
2579 if (!isNil(strokeWidth) && ctx.lineWidth !== strokeWidth) {
2580 ctx.lineWidth = strokeWidth;
2581 }
2582 var strokeColor = style['linePatternFile'] || style['lineColor'] || DEFAULT_STROKE_COLOR;
2583 if (testing) {
2584 ctx.strokeStyle = '#000';
2585 } else if (isImageUrl(strokeColor) && resources) {
2586 var patternOffset = void 0;
2587 if (style['linePatternDx'] || style['linePatternDy']) {
2588 patternOffset = [style['linePatternDx'], style['linePatternDy']];
2589 }
2590 Canvas._setStrokePattern(ctx, strokeColor, strokeWidth, patternOffset, resources);
2591
2592 style['lineDasharray'] = [];
2593 } else if (isGradient(strokeColor)) {
2594 if (style['lineGradientExtent']) {
2595 ctx.strokeStyle = Canvas._createGradient(ctx, strokeColor, style['lineGradientExtent']);
2596 } else {
2597 ctx.strokeStyle = DEFAULT_STROKE_COLOR;
2598 }
2599 } else {
2600 ctx.strokeStyle = strokeColor;
2601 }
2602 if (style['lineJoin']) {
2603 ctx.lineJoin = style['lineJoin'];
2604 }
2605 if (style['lineCap']) {
2606 ctx.lineCap = style['lineCap'];
2607 }
2608 if (ctx.setLineDash && isArrayHasData(style['lineDasharray'])) {
2609 ctx.setLineDash(style['lineDasharray']);
2610 }
2611 var fill = style['polygonPatternFile'] || style['polygonFill'] || DEFAULT_FILL_COLOR;
2612 if (testing) {
2613 ctx.fillStyle = '#000';
2614 } else if (isImageUrl(fill) && resources) {
2615 var fillImgUrl = extractImageUrl(fill);
2616 var fillTexture = resources.getImage([fillImgUrl, null, null]);
2617 if (!fillTexture) {
2618 fillTexture = resources.getImage([fillImgUrl + '-texture', null, strokeWidth]);
2619 }
2620 if (isSVG(fillImgUrl) && fillTexture instanceof Image && (Browser$1.edge || Browser$1.ie)) {
2621 var w = fillTexture.width || 20,
2622 h = fillTexture.height || 20;
2623 var canvas = Canvas.createCanvas(w, h);
2624 Canvas.image(canvas.getContext('2d'), fillTexture, 0, 0, w, h);
2625 fillTexture = canvas;
2626 }
2627 if (!fillTexture) {
2628 if (typeof console !== 'undefined') {
2629 console.warn('img not found for', fillImgUrl);
2630 }
2631 } else {
2632 ctx.fillStyle = ctx.createPattern(fillTexture, 'repeat');
2633 if (style['polygonPatternDx'] || style['polygonPatternDy']) {
2634 ctx.fillStyle['polygonPatternOffset'] = [style['polygonPatternDx'], style['polygonPatternDy']];
2635 }
2636 }
2637 } else if (isGradient(fill)) {
2638 if (style['polygonGradientExtent']) {
2639 ctx.fillStyle = Canvas._createGradient(ctx, fill, style['polygonGradientExtent']);
2640 } else {
2641 ctx.fillStyle = 'rgba(255,255,255,0)';
2642 }
2643 } else {
2644 ctx.fillStyle = fill;
2645 }
2646 },
2647 _createGradient: function _createGradient(ctx, g, extent) {
2648 var gradient = null,
2649 places = g['places'];
2650 var min = extent.getMin(),
2651 max = extent.getMax(),
2652 width = extent.getWidth(),
2653 height = extent.getHeight();
2654 if (!g['type'] || g['type'] === 'linear') {
2655 if (!places) {
2656 places = [min.x, min.y, max.x, min.y];
2657 } else {
2658 if (places.length !== 4) {
2659 throw new Error('A linear gradient\'s places should have 4 numbers.');
2660 }
2661 places = [min.x + places[0] * width, min.y + places[1] * height, min.x + places[2] * width, min.y + places[3] * height];
2662 }
2663 gradient = ctx.createLinearGradient.apply(ctx, places);
2664 } else if (g['type'] === 'radial') {
2665 if (!places) {
2666 var c = extent.getCenter()._round();
2667 places = [c.x, c.y, Math.abs(c.x - min.x), c.x, c.y, 0];
2668 } else {
2669 if (places.length !== 6) {
2670 throw new Error('A radial gradient\'s places should have 6 numbers.');
2671 }
2672 places = [min.x + places[0] * width, min.y + places[1] * height, width * places[2], min.x + places[3] * width, min.y + places[4] * height, width * places[5]];
2673 }
2674 gradient = ctx.createRadialGradient.apply(ctx, places);
2675 }
2676 g['colorStops'].forEach(function (stop) {
2677 gradient.addColorStop.apply(gradient, stop);
2678 });
2679 return gradient;
2680 },
2681 _setStrokePattern: function _setStrokePattern(ctx, strokePattern, strokeWidth, linePatternOffset, resources) {
2682 var imgUrl = extractImageUrl(strokePattern);
2683 var imageTexture = void 0;
2684 if (IS_NODE) {
2685 imageTexture = resources.getImage([imgUrl, null, strokeWidth]);
2686 } else {
2687 var key = imgUrl + '-texture-' + strokeWidth;
2688 imageTexture = resources.getImage(key);
2689 if (!imageTexture) {
2690 var imageRes = resources.getImage([imgUrl, null, null]);
2691 if (imageRes) {
2692 var w = void 0;
2693 if (!imageRes.width || !imageRes.height) {
2694 w = strokeWidth;
2695 } else {
2696 w = Math.round(imageRes.width * strokeWidth / imageRes.height);
2697 }
2698 var patternCanvas = Canvas.createCanvas(w, strokeWidth, ctx.canvas.constructor);
2699 Canvas.image(patternCanvas.getContext('2d'), imageRes, 0, 0, w, strokeWidth);
2700 resources.addResource([key, null, strokeWidth], patternCanvas);
2701 imageTexture = patternCanvas;
2702 }
2703 }
2704 }
2705 if (imageTexture) {
2706 ctx.strokeStyle = ctx.createPattern(imageTexture, 'repeat');
2707 ctx.strokeStyle['linePatternOffset'] = linePatternOffset;
2708 } else if (typeof console !== 'undefined') {
2709 console.warn('img not found for', imgUrl);
2710 }
2711 },
2712 clearRect: function clearRect(ctx, x1, y1, x2, y2) {
2713 ctx.canvas._drawn = false;
2714 ctx.clearRect(x1, y1, x2, y2);
2715 },
2716 fillCanvas: function fillCanvas(ctx, fillOpacity, x, y) {
2717 if (hitTesting) {
2718 fillOpacity = 1;
2719 }
2720 ctx.canvas._drawn = true;
2721 if (fillOpacity === 0) {
2722 return;
2723 }
2724 var isPattern = Canvas._isPattern(ctx.fillStyle);
2725
2726 var offset = ctx.fillStyle && ctx.fillStyle['polygonPatternOffset'];
2727 var dx = offset ? offset[0] : 0,
2728 dy = offset ? offset[1] : 0;
2729
2730 if (isNil(fillOpacity)) {
2731 fillOpacity = 1;
2732 }
2733 var alpha = void 0;
2734 if (fillOpacity < 1) {
2735 alpha = ctx.globalAlpha;
2736 ctx.globalAlpha *= fillOpacity;
2737 }
2738 if (isPattern) {
2739 x = x || 0;
2740 y = y || 0;
2741
2742 ctx.translate(x + dx, y + dy);
2743 }
2744 ctx.fill();
2745 if (isPattern) {
2746 ctx.translate(-x - dx, -y - dy);
2747 }
2748 if (fillOpacity < 1) {
2749 ctx.globalAlpha = alpha;
2750 }
2751 },
2752 getRgba: function getRgba(color, op) {
2753 if (isNil(op)) {
2754 op = 1;
2755 }
2756 if (color[0] !== '#') {
2757 return color;
2758 }
2759 var r = void 0,
2760 g = void 0,
2761 b = void 0;
2762 if (color.length === 7) {
2763 r = parseInt(color.substring(1, 3), 16);
2764 g = parseInt(color.substring(3, 5), 16);
2765 b = parseInt(color.substring(5, 7), 16);
2766 } else {
2767 r = parseInt(color.substring(1, 2), 16) * 17;
2768 g = parseInt(color.substring(2, 3), 16) * 17;
2769 b = parseInt(color.substring(3, 4), 16) * 17;
2770 }
2771 return 'rgba(' + r + ',' + g + ',' + b + ',' + op + ')';
2772 },
2773 image: function image(ctx, img, x, y, width, height) {
2774 ctx.canvas._drawn = true;
2775 try {
2776 if (isNumber(width) && isNumber(height)) {
2777 ctx.drawImage(img, x, y, width, height);
2778 } else {
2779 ctx.drawImage(img, x, y);
2780 }
2781 } catch (error) {
2782 if (console) {
2783 console.warn('error when drawing image on canvas:', error);
2784 console.warn(img);
2785 }
2786 }
2787 },
2788 text: function text(ctx, _text, pt, style, textDesc) {
2789 Canvas._textOnMultiRow(ctx, textDesc['rows'], style, pt, textDesc['size'], textDesc['rawSize']);
2790 },
2791 _textOnMultiRow: function _textOnMultiRow(ctx, texts, style, point, splitTextSize, textSize) {
2792 var ptAlign = getAlignPoint(splitTextSize, style['textHorizontalAlignment'], style['textVerticalAlignment']),
2793 lineHeight = textSize['height'] + style['textLineSpacing'],
2794 basePoint = point.add(0, ptAlign.y),
2795 maxHeight = style['textMaxHeight'];
2796 var text = void 0,
2797 rowAlign = void 0,
2798 height = 0;
2799 for (var i = 0, len = texts.length; i < len; i++) {
2800 text = texts[i]['text'];
2801 rowAlign = getAlignPoint(texts[i]['size'], style['textHorizontalAlignment'], style['textVerticalAlignment']);
2802 Canvas._textOnLine(ctx, text, basePoint.add(rowAlign.x, i * lineHeight), style['textHaloRadius'], style['textHaloFill'], style['textHaloOpacity']);
2803 if (maxHeight > 0) {
2804 height += lineHeight;
2805 if (height + textSize['height'] >= maxHeight) {
2806 break;
2807 }
2808 }
2809 }
2810 },
2811 _textOnLine: function _textOnLine(ctx, text, pt, textHaloRadius, textHaloFill, textHaloAlpha) {
2812 if (hitTesting) {
2813 textHaloAlpha = 1;
2814 }
2815 var drawHalo = textHaloAlpha !== 0 && textHaloRadius !== 0;
2816
2817 ctx.textBaseline = 'top';
2818 var gco = void 0,
2819 fill = void 0;
2820 var shadowBlur = ctx.shadowBlur,
2821 shadowOffsetX = ctx.shadowOffsetX,
2822 shadowOffsetY = ctx.shadowOffsetY;
2823 if (drawHalo) {
2824 var alpha = ctx.globalAlpha;
2825
2826 ctx.globalAlpha *= textHaloAlpha;
2827
2828 ctx.miterLimit = 2;
2829 ctx.lineJoin = 'round';
2830 ctx.lineCap = 'round';
2831 ctx.lineWidth = textHaloRadius * 2;
2832 ctx.strokeStyle = textHaloFill;
2833 ctx.strokeText(text, Math.round(pt.x), Math.round(pt.y));
2834 ctx.miterLimit = 10;
2835
2836 ctx.globalAlpha = alpha;
2837
2838 gco = ctx.globalCompositeOperation;
2839 ctx.globalCompositeOperation = 'destination-out';
2840 fill = ctx.fillStyle;
2841 ctx.fillStyle = '#000';
2842 }
2843
2844 if (shadowBlur && drawHalo) {
2845 ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;
2846 }
2847 Canvas.fillText(ctx, text, pt);
2848 if (gco) {
2849 ctx.globalCompositeOperation = gco;
2850 Canvas.fillText(ctx, text, pt, fill);
2851 if (shadowBlur) {
2852 ctx.shadowBlur = shadowBlur;
2853 ctx.shadowOffsetX = shadowOffsetX;
2854 ctx.shadowOffsetY = shadowOffsetY;
2855 }
2856 }
2857 },
2858 fillText: function fillText(ctx, text, point, rgba) {
2859 ctx.canvas._drawn = true;
2860 if (rgba) {
2861 ctx.fillStyle = rgba;
2862 }
2863 ctx.fillText(text, Math.round(point.x), Math.round(point.y));
2864 },
2865 _stroke: function _stroke(ctx, strokeOpacity, x, y) {
2866 if (hitTesting) {
2867 strokeOpacity = 1;
2868 }
2869 ctx.canvas._drawn = true;
2870 if (strokeOpacity === 0) {
2871 return;
2872 }
2873 var offset = ctx.strokeStyle && ctx.strokeStyle['linePatternOffset'];
2874 var dx = offset ? offset[0] : 0,
2875 dy = offset ? offset[1] : 0;
2876
2877 var isPattern = Canvas._isPattern(ctx.strokeStyle) && (!isNil(x) && !isNil(y) || !isNil(dx) && !isNil(dy));
2878
2879 if (isNil(strokeOpacity)) {
2880 strokeOpacity = 1;
2881 }
2882 var alpha = void 0;
2883 if (strokeOpacity < 1) {
2884 alpha = ctx.globalAlpha;
2885 ctx.globalAlpha *= strokeOpacity;
2886 }
2887 if (isPattern) {
2888 x = x || 0;
2889 y = y || 0;
2890
2891 ctx.translate(x + dx, y + dy);
2892 }
2893 ctx.stroke();
2894 if (isPattern) {
2895 ctx.translate(-x - dx, -y - dy);
2896 }
2897 if (strokeOpacity < 1) {
2898 ctx.globalAlpha = alpha;
2899 }
2900 },
2901 _path: function _path(ctx, points, lineDashArray, lineOpacity, ignoreStrokePattern) {
2902 if (!isArrayHasData(points)) {
2903 return;
2904 }
2905
2906 function fillWithPattern(p1, p2) {
2907 var degree = computeDegree(p1.x, p1.y, p2.x, p2.y);
2908 ctx.save();
2909 ctx.translate(p1.x, p1.y - ctx.lineWidth / 2 / Math.cos(degree));
2910 ctx.rotate(degree);
2911 Canvas._stroke(ctx, lineOpacity);
2912 ctx.restore();
2913 }
2914
2915 var isDashed = isArrayHasData(lineDashArray);
2916 var isPatternLine = ignoreStrokePattern === true ? false : Canvas._isPattern(ctx.strokeStyle);
2917 var point = void 0,
2918 prePoint = void 0,
2919 nextPoint = void 0;
2920 for (var i = 0, len = points.length; i < len; i++) {
2921 point = points[i];
2922 if (!isDashed || ctx.setLineDash) {
2923 ctx.lineTo(point.x, point.y);
2924 if (isPatternLine && i > 0) {
2925 prePoint = points[i - 1];
2926 fillWithPattern(prePoint, point);
2927 ctx.beginPath();
2928 ctx.moveTo(point.x, point.y);
2929 }
2930 } else if (isDashed) {
2931 if (i === len - 1) {
2932 break;
2933 }
2934 nextPoint = points[i + 1];
2935 drawDashLine(ctx, point, nextPoint, lineDashArray, isPatternLine);
2936 }
2937 }
2938 },
2939 path: function path(ctx, points, lineOpacity, fillOpacity, lineDashArray) {
2940 if (!isArrayHasData(points)) {
2941 return;
2942 }
2943 ctx.beginPath();
2944 ctx.moveTo(points[0].x, points[0].y);
2945 Canvas._path(ctx, points, lineDashArray, lineOpacity);
2946 Canvas._stroke(ctx, lineOpacity);
2947 },
2948 polygon: function polygon(ctx, points, lineOpacity, fillOpacity, lineDashArray, smoothness) {
2949 if (!isArrayHasData(points)) {
2950 return;
2951 }
2952 function fillPolygon(points, i, op) {
2953 Canvas.fillCanvas(ctx, op, points[i][0].x, points[i][0].y);
2954 }
2955 var isPatternLine = Canvas._isPattern(ctx.strokeStyle),
2956 fillFirst = isArrayHasData(lineDashArray) && !ctx.setLineDash || isPatternLine && !smoothness;
2957 if (!isArrayHasData(points[0])) {
2958 points = [points];
2959 }
2960 var op = void 0,
2961 i = void 0,
2962 len = void 0;
2963 if (fillFirst) {
2964 ctx.save();
2965 for (i = 0, len = points.length; i < len; i++) {
2966 if (!isArrayHasData(points[i])) {
2967 continue;
2968 }
2969 Canvas._ring(ctx, points[i], null, 0, true);
2970 op = fillOpacity;
2971 if (i > 0) {
2972 ctx.globalCompositeOperation = 'destination-out';
2973 op = 1;
2974 }
2975 fillPolygon(points, i, op);
2976 if (i > 0) {
2977 ctx.globalCompositeOperation = 'source-over';
2978 } else if (len > 1) {
2979 ctx.fillStyle = '#fff';
2980 }
2981 Canvas._stroke(ctx, 0);
2982 }
2983 ctx.restore();
2984 }
2985 for (i = 0, len = points.length; i < len; i++) {
2986 if (!isArrayHasData(points[i])) {
2987 continue;
2988 }
2989
2990 if (smoothness) {
2991 Canvas.paintSmoothLine(ctx, points[i], lineOpacity, smoothness, true);
2992 ctx.closePath();
2993 } else {
2994 Canvas._ring(ctx, points[i], lineDashArray, lineOpacity);
2995 }
2996
2997 if (!fillFirst) {
2998 op = fillOpacity;
2999 if (i > 0) {
3000 ctx.globalCompositeOperation = 'destination-out';
3001 op = 1;
3002 }
3003 fillPolygon(points, i, op);
3004 if (i > 0) {
3005 ctx.globalCompositeOperation = 'source-over';
3006 } else if (len > 1) {
3007 ctx.fillStyle = '#fff';
3008 }
3009 }
3010 Canvas._stroke(ctx, lineOpacity);
3011 }
3012 },
3013 _ring: function _ring(ctx, ring, lineDashArray, lineOpacity, ignorePattern) {
3014 var isPattern = Canvas._isPattern(ctx.strokeStyle);
3015 if (!ignorePattern && isPattern && !ring[0].equals(ring[ring.length - 1])) {
3016 ring = ring.concat([ring[0]]);
3017 }
3018 ctx.beginPath();
3019 ctx.moveTo(ring[0].x, ring[0].y);
3020 Canvas._path(ctx, ring, lineDashArray, lineOpacity, ignorePattern);
3021 if (!isPattern) {
3022 ctx.closePath();
3023 }
3024 },
3025 paintSmoothLine: function paintSmoothLine(ctx, points, lineOpacity, smoothValue, close, tailIdx, tailRatio) {
3026 if (!points) {
3027 return;
3028 }
3029 if (points.length <= 2 || !smoothValue) {
3030 Canvas.path(ctx, points, lineOpacity);
3031 return;
3032 }
3033
3034 function interpolate(t0, t1, x1, y1, bx1, by1, bx2, by2, x2, y2) {
3035 var u0 = 1.0 - t0;
3036 var u1 = 1.0 - t1;
3037
3038 var qxa = x1 * u0 * u0 + bx1 * 2 * t0 * u0 + bx2 * t0 * t0;
3039 var qxb = x1 * u1 * u1 + bx1 * 2 * t1 * u1 + bx2 * t1 * t1;
3040 var qxc = bx1 * u0 * u0 + bx2 * 2 * t0 * u0 + x2 * t0 * t0;
3041 var qxd = bx1 * u1 * u1 + bx2 * 2 * t1 * u1 + x2 * t1 * t1;
3042
3043 var qya = y1 * u0 * u0 + by1 * 2 * t0 * u0 + by2 * t0 * t0;
3044 var qyb = y1 * u1 * u1 + by1 * 2 * t1 * u1 + by2 * t1 * t1;
3045 var qyc = by1 * u0 * u0 + by2 * 2 * t0 * u0 + y2 * t0 * t0;
3046 var qyd = by1 * u1 * u1 + by2 * 2 * t1 * u1 + y2 * t1 * t1;
3047
3048 var xb = qxa * u1 + qxc * t1;
3049 var xc = qxb * u0 + qxd * t0;
3050 var xd = qxb * u1 + qxd * t1;
3051
3052 var yb = qya * u1 + qyc * t1;
3053 var yc = qyb * u0 + qyd * t0;
3054 var yd = qyb * u1 + qyd * t1;
3055
3056 return [xb, yb, xc, yc, xd, yd];
3057 }
3058
3059 function getCubicControlPoints(x0, y0, x1, y1, x2, y2, x3, y3, smoothValue, t) {
3060 var xc1 = (x0 + x1) / 2.0,
3061 yc1 = (y0 + y1) / 2.0;
3062 var xc2 = (x1 + x2) / 2.0,
3063 yc2 = (y1 + y2) / 2.0;
3064 var xc3 = (x2 + x3) / 2.0,
3065 yc3 = (y2 + y3) / 2.0;
3066
3067 var len1 = Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
3068 var len2 = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
3069 var len3 = Math.sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
3070
3071 var k1 = len1 / (len1 + len2);
3072 var k2 = len2 / (len2 + len3);
3073
3074 var xm1 = xc1 + (xc2 - xc1) * k1,
3075 ym1 = yc1 + (yc2 - yc1) * k1;
3076
3077 var xm2 = xc2 + (xc3 - xc2) * k2,
3078 ym2 = yc2 + (yc3 - yc2) * k2;
3079
3080 var ctrl1X = xm1 + (xc2 - xm1) * smoothValue + x1 - xm1,
3081 ctrl1Y = ym1 + (yc2 - ym1) * smoothValue + y1 - ym1,
3082 ctrl2X = xm2 + (xc2 - xm2) * smoothValue + x2 - xm2,
3083 ctrl2Y = ym2 + (yc2 - ym2) * smoothValue + y2 - ym2;
3084
3085 var ctrlPoints = [ctrl1X, ctrl1Y, ctrl2X, ctrl2Y];
3086 if (t < 1) {
3087 return interpolate(0, t, x1, y1, ctrl1X, ctrl1Y, ctrl2X, ctrl2Y, x2, y2);
3088 } else {
3089 return ctrlPoints;
3090 }
3091 }
3092 var count = points.length;
3093 var l = close ? count : count - 1;
3094
3095 ctx.beginPath();
3096 ctx.moveTo(points[0].x, points[0].y);
3097 if (tailRatio !== undefined) l -= Math.max(l - tailIdx - 1, 0);
3098 var preCtrlPoints = void 0;
3099 for (var i = 0; i < l; i++) {
3100 var x1 = points[i].x,
3101 y1 = points[i].y;
3102
3103 var x0 = void 0,
3104 y0 = void 0,
3105 x2 = void 0,
3106 y2 = void 0,
3107 x3 = void 0,
3108 y3 = void 0;
3109 if (i - 1 < 0) {
3110 if (!close) {
3111 x0 = points[i + 1].x;
3112 y0 = points[i + 1].y;
3113 } else {
3114 x0 = points[l - 1].x;
3115 y0 = points[l - 1].y;
3116 }
3117 } else {
3118 x0 = points[i - 1].x;
3119 y0 = points[i - 1].y;
3120 }
3121 if (i + 1 < count) {
3122 x2 = points[i + 1].x;
3123 y2 = points[i + 1].y;
3124 } else {
3125 x2 = points[i + 1 - count].x;
3126 y2 = points[i + 1 - count].y;
3127 }
3128 if (i + 2 < count) {
3129 x3 = points[i + 2].x;
3130 y3 = points[i + 2].y;
3131 } else if (!close) {
3132 x3 = points[i].x;
3133 y3 = points[i].y;
3134 } else {
3135 x3 = points[i + 2 - count].x;
3136 y3 = points[i + 2 - count].y;
3137 }
3138
3139 var ctrlPoints = getCubicControlPoints(x0, y0, x1, y1, x2, y2, x3, y3, smoothValue, i === l - 1 ? tailRatio : 1);
3140 if (i === l - 1 && tailRatio >= 0 && tailRatio < 1) {
3141 ctx.bezierCurveTo(ctrlPoints[0], ctrlPoints[1], ctrlPoints[2], ctrlPoints[3], ctrlPoints[4], ctrlPoints[5]);
3142 points.splice(l - 1, count - (l - 1) - 1);
3143 var lastPoint = new Point(ctrlPoints[4], ctrlPoints[5]);
3144 lastPoint.prevCtrlPoint = new Point(ctrlPoints[2], ctrlPoints[3]);
3145 points.push(lastPoint);
3146 count = points.length;
3147 } else {
3148 ctx.bezierCurveTo(ctrlPoints[0], ctrlPoints[1], ctrlPoints[2], ctrlPoints[3], x2, y2);
3149 }
3150 points[i].nextCtrlPoint = ctrlPoints.slice(0, 2);
3151 points[i].prevCtrlPoint = preCtrlPoints ? preCtrlPoints.slice(2) : null;
3152 preCtrlPoints = ctrlPoints;
3153 }
3154 if (!close && points[1].prevCtrlPoint) {
3155 points[0].nextCtrlPoint = points[1].prevCtrlPoint;
3156 delete points[0].prevCtrlPoint;
3157 }
3158 if (!points[count - 1].prevCtrlPoint) {
3159 points[count - 1].prevCtrlPoint = points[count - 2].nextCtrlPoint;
3160 }
3161 Canvas._stroke(ctx, lineOpacity);
3162 },
3163 _arcBetween: function _arcBetween(ctx, p1, p2, degree) {
3164 var a = degree,
3165 dist = p1.distanceTo(p2),
3166 r = dist / 2 / Math.sin(a / 2);
3167
3168 var p1p2 = Math.asin((p2.y - p1.y) / dist);
3169 if (p1.x > p2.x) {
3170 p1p2 = Math.PI - p1p2;
3171 }
3172
3173 var cp2 = 90 * Math.PI / 180 - a / 2,
3174 da = p1p2 - cp2;
3175
3176 var dx = Math.cos(da) * r,
3177 dy = Math.sin(da) * r,
3178 cx = p1.x + dx,
3179 cy = p1.y + dy;
3180
3181 var startAngle = Math.asin((p2.y - cy) / r);
3182 if (cx > p2.x) {
3183 startAngle = Math.PI - startAngle;
3184 }
3185 var endAngle = startAngle + a;
3186
3187 ctx.beginPath();
3188 ctx.arc(cx, cy, r, startAngle, endAngle);
3189 return [cx, cy];
3190 },
3191 _lineTo: function _lineTo(ctx, p) {
3192 ctx.lineTo(p.x, p.y);
3193 },
3194 bezierCurveAndFill: function bezierCurveAndFill(ctx, points, lineOpacity, fillOpacity) {
3195 ctx.beginPath();
3196 var start = points[0];
3197 ctx.moveTo(start.x, start.y);
3198 var args = [ctx];
3199 args.push.apply(args, points.splice(1));
3200 Canvas._bezierCurveTo.apply(Canvas, args);
3201 Canvas.fillCanvas(ctx, fillOpacity);
3202 Canvas._stroke(ctx, lineOpacity);
3203 },
3204 _bezierCurveTo: function _bezierCurveTo(ctx, p1, p2, p3) {
3205 ctx.bezierCurveTo(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);
3206 },
3207 ellipse: function ellipse(ctx, pt, width, height, lineOpacity, fillOpacity) {
3208 function bezierEllipse(x, y, a, b) {
3209 var k = 0.5522848,
3210 ox = a * k,
3211 oy = b * k;
3212 ctx.moveTo(x - a, y);
3213 ctx.bezierCurveTo(x - a, y - oy, x - ox, y - b, x, y - b);
3214 ctx.bezierCurveTo(x + ox, y - b, x + a, y - oy, x + a, y);
3215 ctx.bezierCurveTo(x + a, y + oy, x + ox, y + b, x, y + b);
3216 ctx.bezierCurveTo(x - ox, y + b, x - a, y + oy, x - a, y);
3217 ctx.closePath();
3218 }
3219 ctx.beginPath();
3220 if (width === height) {
3221 ctx.arc(pt.x, pt.y, width, 0, 2 * Math.PI);
3222 } else if (ctx.ellipse) {
3223 ctx.ellipse(pt.x, pt.y, width, height, 0, 0, Math.PI / 180 * 360);
3224 } else {
3225 bezierEllipse(pt.x, pt.y, width, height);
3226 }
3227 Canvas.fillCanvas(ctx, fillOpacity, pt.x - width, pt.y - height);
3228 Canvas._stroke(ctx, lineOpacity, pt.x - width, pt.y - height);
3229 },
3230 rectangle: function rectangle(ctx, pt, size, lineOpacity, fillOpacity) {
3231 ctx.beginPath();
3232 ctx.rect(pt.x, pt.y, size['width'], size['height']);
3233 Canvas.fillCanvas(ctx, fillOpacity, pt.x, pt.y);
3234 Canvas._stroke(ctx, lineOpacity, pt.x, pt.y);
3235 },
3236 sector: function sector(ctx, pt, size, angles, lineOpacity, fillOpacity) {
3237 var rad = Math.PI / 180;
3238 var startAngle = angles[0],
3239 endAngle = angles[1];
3240
3241 function sector(ctx, x, y, radius, startAngle, endAngle) {
3242 var sDeg = rad * -endAngle;
3243 var eDeg = rad * -startAngle;
3244 ctx.beginPath();
3245 ctx.moveTo(x, y);
3246 ctx.arc(x, y, radius, sDeg, eDeg);
3247 ctx.lineTo(x, y);
3248 Canvas.fillCanvas(ctx, fillOpacity, x - radius, y - radius);
3249 Canvas._stroke(ctx, lineOpacity, x - radius, y - radius);
3250 }
3251 sector(ctx, pt.x, pt.y, size, startAngle, endAngle);
3252 },
3253 _isPattern: function _isPattern(style) {
3254 return !isString(style) && !('addColorStop' in style);
3255 },
3256 drawCross: function drawCross(ctx, p, lineWidth, color) {
3257 ctx.canvas._drawn = true;
3258 ctx.strokeStyle = color;
3259 ctx.lineWidth = lineWidth;
3260 ctx.beginPath();
3261 ctx.moveTo(p.x - 5, p.y);
3262 ctx.lineTo(p.x + 5, p.y);
3263 ctx.moveTo(p.x, p.y - 5);
3264 ctx.lineTo(p.x, p.y + 5);
3265 ctx.stroke();
3266 },
3267 copy: function copy(canvas, c) {
3268 var target = c || createEl('canvas');
3269 target.width = canvas.width;
3270 target.height = canvas.height;
3271 target.getContext('2d').drawImage(canvas, 0, 0);
3272 return target;
3273 }
3274};
3275
3276function drawDashLine(ctx, startPoint, endPoint, dashArray) {
3277 var fromX = startPoint.x,
3278 fromY = startPoint.y,
3279 toX = endPoint.x,
3280 toY = endPoint.y;
3281 var pattern = dashArray;
3282 var lt = function lt(a, b) {
3283 return a <= b;
3284 };
3285 var gt = function gt(a, b) {
3286 return a >= b;
3287 };
3288 var capmin = function capmin(a, b) {
3289 return Math.min(a, b);
3290 };
3291 var capmax = function capmax(a, b) {
3292 return Math.max(a, b);
3293 };
3294
3295 var checkX = {
3296 thereYet: gt,
3297 cap: capmin
3298 };
3299 var checkY = {
3300 thereYet: gt,
3301 cap: capmin
3302 };
3303
3304 if (fromY - toY > 0) {
3305 checkY.thereYet = lt;
3306 checkY.cap = capmax;
3307 }
3308 if (fromX - toX > 0) {
3309 checkX.thereYet = lt;
3310 checkX.cap = capmax;
3311 }
3312
3313 ctx.moveTo(fromX, fromY);
3314 var offsetX = fromX;
3315 var offsetY = fromY;
3316 var idx = 0,
3317 dash = true;
3318 var ang = void 0,
3319 len = void 0;
3320 while (!(checkX.thereYet(offsetX, toX) && checkY.thereYet(offsetY, toY))) {
3321 ang = Math.atan2(toY - fromY, toX - fromX);
3322 len = pattern[idx];
3323
3324 offsetX = checkX.cap(toX, offsetX + Math.cos(ang) * len);
3325 offsetY = checkY.cap(toY, offsetY + Math.sin(ang) * len);
3326
3327 if (dash) {
3328 ctx.lineTo(offsetX, offsetY);
3329 } else {
3330 ctx.moveTo(offsetX, offsetY);
3331 }
3332
3333 idx = (idx + 1) % pattern.length;
3334 dash = !dash;
3335 }
3336}
3337
3338var prefix = 'data:image/';
3339function isImageUrl(url) {
3340 return url.length > prefix.length && url.substring(0, prefix.length) === prefix || isCssUrl(url);
3341}
3342
3343function extractImageUrl(url) {
3344 if (url.substring(0, prefix.length) === prefix) {
3345 return url;
3346 }
3347 return extractCssUrl(url);
3348}
3349
3350var Eventable = function Eventable(Base) {
3351 return function (_Base) {
3352 inherits(_class, _Base);
3353
3354 function _class() {
3355 classCallCheck(this, _class);
3356 return possibleConstructorReturn(this, _Base.apply(this, arguments));
3357 }
3358
3359 _class.prototype.on = function on$$1(eventsOn, handler, context) {
3360 if (!eventsOn) {
3361 return this;
3362 }
3363 if (!isString(eventsOn)) {
3364 return this._switch('on', eventsOn, handler);
3365 }
3366 if (!handler) {
3367 return this;
3368 }
3369 if (!this._eventMap) {
3370 this._eventMap = {};
3371 }
3372 var eventTypes = eventsOn.toLowerCase().split(' ');
3373 var evtType = void 0;
3374 if (!context) {
3375 context = this;
3376 }
3377 var handlerChain = void 0;
3378 for (var ii = 0, ll = eventTypes.length; ii < ll; ii++) {
3379 evtType = eventTypes[ii];
3380 handlerChain = this._eventMap[evtType];
3381 if (!handlerChain) {
3382 handlerChain = [];
3383 this._eventMap[evtType] = handlerChain;
3384 }
3385 var l = handlerChain.length;
3386 if (l > 0) {
3387 for (var i = 0; i < l; i++) {
3388 if (handler === handlerChain[i].handler && handlerChain[i].context === context) {
3389 return this;
3390 }
3391 }
3392 }
3393 handlerChain.push({
3394 handler: handler,
3395 context: context
3396 });
3397 }
3398 return this;
3399 };
3400
3401 _class.prototype.addEventListener = function addEventListener() {
3402 return this.on.apply(this, arguments);
3403 };
3404
3405 _class.prototype.once = function once(eventTypes, handler, context) {
3406 if (!isString(eventTypes)) {
3407 var once = {};
3408 for (var p in eventTypes) {
3409 if (eventTypes.hasOwnProperty(p)) {
3410 once[p] = this._wrapOnceHandler(p, eventTypes[p], context);
3411 }
3412 }
3413 return this._switch('on', once);
3414 }
3415 var evetTypes = eventTypes.split(' ');
3416 for (var i = 0, l = evetTypes.length; i < l; i++) {
3417 this.on(evetTypes[i], this._wrapOnceHandler(evetTypes[i], handler, context));
3418 }
3419 return this;
3420 };
3421
3422 _class.prototype.off = function off$$1(eventsOff, handler, context) {
3423 if (!this._eventMap || !eventsOff) {
3424 return this;
3425 }
3426 if (!isString(eventsOff)) {
3427 return this._switch('off', eventsOff, handler);
3428 }
3429 if (!handler) {
3430 return this;
3431 }
3432 var eventTypes = eventsOff.split(' ');
3433 var eventType = void 0,
3434 listeners = void 0,
3435 wrapKey = void 0;
3436 if (!context) {
3437 context = this;
3438 }
3439 for (var j = 0, jl = eventTypes.length; j < jl; j++) {
3440 eventType = eventTypes[j].toLowerCase();
3441 wrapKey = 'Z__' + eventType;
3442 listeners = this._eventMap[eventType];
3443 if (!listeners) {
3444 return this;
3445 }
3446 for (var i = listeners.length - 1; i >= 0; i--) {
3447 var listener = listeners[i];
3448 if ((handler === listener.handler || handler === listener.handler[wrapKey]) && listener.context === context) {
3449 delete listener.handler[wrapKey];
3450 listeners.splice(i, 1);
3451 }
3452 }
3453 }
3454 return this;
3455 };
3456
3457 _class.prototype.removeEventListener = function removeEventListener() {
3458 return this.off.apply(this, arguments);
3459 };
3460
3461 _class.prototype.listens = function listens(eventType, handler, context) {
3462 if (!this._eventMap || !isString(eventType)) {
3463 return 0;
3464 }
3465 var handlerChain = this._eventMap[eventType.toLowerCase()];
3466 if (!handlerChain || !handlerChain.length) {
3467 return 0;
3468 }
3469 var count = 0;
3470 for (var i = 0, len = handlerChain.length; i < len; i++) {
3471 if (handler) {
3472 if (handler === handlerChain[i].handler && (isNil(context) || handlerChain[i].context === context)) {
3473 return 1;
3474 }
3475 } else {
3476 count++;
3477 }
3478 }
3479 return count;
3480 };
3481
3482 _class.prototype.copyEventListeners = function copyEventListeners(target) {
3483 var eventMap = target._eventMap;
3484 if (!eventMap) {
3485 return this;
3486 }
3487 var handlerChain = void 0;
3488 for (var eventType in eventMap) {
3489 handlerChain = eventMap[eventType];
3490 for (var i = 0, len = handlerChain.length; i < len; i++) {
3491 this.on(eventType, handlerChain[i].handler, handlerChain[i].context);
3492 }
3493 }
3494 return this;
3495 };
3496
3497 _class.prototype.fire = function fire() {
3498 if (this._eventParent) {
3499 return this._eventParent.fire.apply(this._eventParent, arguments);
3500 }
3501 return this._fire.apply(this, arguments);
3502 };
3503
3504 _class.prototype._wrapOnceHandler = function _wrapOnceHandler(evtType, handler, context) {
3505 var me = this;
3506 var key = 'Z__' + evtType;
3507 var called = false;
3508 var fn = function onceHandler() {
3509 if (called) {
3510 return;
3511 }
3512 delete fn[key];
3513 called = true;
3514 if (context) {
3515 handler.apply(context, arguments);
3516 } else {
3517 handler.apply(this, arguments);
3518 }
3519 me.off(evtType, onceHandler, this);
3520 };
3521 fn[key] = handler;
3522 return fn;
3523 };
3524
3525 _class.prototype._switch = function _switch(to, eventKeys, context) {
3526 for (var p in eventKeys) {
3527 if (eventKeys.hasOwnProperty(p)) {
3528 this[to](p, eventKeys[p], context);
3529 }
3530 }
3531 return this;
3532 };
3533
3534 _class.prototype._clearListeners = function _clearListeners(eventType) {
3535 if (!this._eventMap || !isString(eventType)) {
3536 return;
3537 }
3538 var handlerChain = this._eventMap[eventType.toLowerCase()];
3539 if (!handlerChain) {
3540 return;
3541 }
3542 this._eventMap[eventType] = null;
3543 };
3544
3545 _class.prototype._clearAllListeners = function _clearAllListeners() {
3546 this._eventMap = null;
3547 };
3548
3549 _class.prototype._setEventParent = function _setEventParent(parent) {
3550 this._eventParent = parent;
3551 return this;
3552 };
3553
3554 _class.prototype._fire = function _fire(eventType, param) {
3555 if (!this._eventMap) {
3556 return this;
3557 }
3558 var handlerChain = this._eventMap[eventType.toLowerCase()];
3559 if (!handlerChain) {
3560 return this;
3561 }
3562 if (!param) {
3563 param = {};
3564 }
3565 param['type'] = eventType;
3566 param['target'] = this;
3567
3568 var queue = handlerChain.slice(0);
3569 var context = void 0,
3570 bubble = void 0,
3571 passed = void 0;
3572 for (var i = 0, len = queue.length; i < len; i++) {
3573 if (!queue[i]) {
3574 continue;
3575 }
3576 context = queue[i].context;
3577 bubble = true;
3578 passed = extend({}, param);
3579 if (context) {
3580 bubble = queue[i].handler.call(context, passed);
3581 } else {
3582 bubble = queue[i].handler(passed);
3583 }
3584
3585 if (bubble === false) {
3586 if (param['domEvent']) {
3587 stopPropagation(param['domEvent']);
3588 }
3589 }
3590 }
3591 return this;
3592 };
3593
3594 return _class;
3595 }(Base);
3596};
3597
3598var Handler = function () {
3599 function Handler(target) {
3600 classCallCheck(this, Handler);
3601
3602 this.target = target;
3603 }
3604
3605 Handler.prototype.enable = function enable() {
3606 if (this._enabled) {
3607 return this;
3608 }
3609 this._enabled = true;
3610 this.addHooks();
3611 return this;
3612 };
3613
3614 Handler.prototype.disable = function disable() {
3615 if (!this._enabled) {
3616 return this;
3617 }
3618 this._enabled = false;
3619 this.removeHooks();
3620 return this;
3621 };
3622
3623 Handler.prototype.enabled = function enabled() {
3624 return !!this._enabled;
3625 };
3626
3627 Handler.prototype.remove = function remove() {
3628 this.disable();
3629 delete this.target;
3630 delete this.dom;
3631 };
3632
3633 return Handler;
3634}();
3635
3636var Handler$1 = Eventable(Handler);
3637
3638var Class = function () {
3639 function Class(options) {
3640 classCallCheck(this, Class);
3641
3642 if (!this || !this.setOptions) {
3643 throw new Error('Class instance is being created without "new" operator.');
3644 }
3645 this.setOptions(options);
3646 this.callInitHooks();
3647 }
3648
3649 Class.prototype.callInitHooks = function callInitHooks() {
3650 var proto = Object.getPrototypeOf(this);
3651 this._visitInitHooks(proto);
3652 return this;
3653 };
3654
3655 Class.prototype.setOptions = function setOptions(options) {
3656 if (!this.hasOwnProperty('options')) {
3657 this.options = this.options ? Object.create(this.options) : {};
3658 }
3659 if (!options) {
3660 return this;
3661 }
3662 for (var i in options) {
3663 this.options[i] = options[i];
3664 }
3665 return this;
3666 };
3667
3668 Class.prototype.config = function config(conf) {
3669 if (!conf) {
3670 var config = {};
3671 for (var p in this.options) {
3672 if (this.options.hasOwnProperty(p)) {
3673 config[p] = this.options[p];
3674 }
3675 }
3676 return config;
3677 } else {
3678 if (arguments.length === 2) {
3679 var t = {};
3680 t[conf] = arguments[1];
3681 conf = t;
3682 }
3683 for (var i in conf) {
3684 this.options[i] = conf[i];
3685
3686 if (this[i] && this[i] instanceof Handler$1) {
3687 if (conf[i]) {
3688 this[i].enable();
3689 } else {
3690 this[i].disable();
3691 }
3692 }
3693 }
3694
3695 this.onConfig(conf);
3696 }
3697 return this;
3698 };
3699
3700 Class.prototype.onConfig = function onConfig() {};
3701
3702 Class.prototype._visitInitHooks = function _visitInitHooks(proto) {
3703 if (this._initHooksCalled) {
3704 return;
3705 }
3706 var parentProto = Object.getPrototypeOf(proto);
3707 if (parentProto._visitInitHooks) {
3708 parentProto._visitInitHooks.call(this, parentProto);
3709 }
3710 this._initHooksCalled = true;
3711 var hooks = proto._initHooks;
3712 if (hooks && hooks !== parentProto._initHooks) {
3713 for (var i = 0; i < hooks.length; i++) {
3714 hooks[i].call(this);
3715 }
3716 }
3717 };
3718
3719 Class.addInitHook = function addInitHook(fn) {
3720 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
3721 args[_key - 1] = arguments[_key];
3722 }
3723
3724 var init = typeof fn === 'function' ? fn : function () {
3725 this[fn].apply(this, args);
3726 };
3727 var proto = this.prototype;
3728 var parentProto = Object.getPrototypeOf(proto);
3729 if (!proto._initHooks || proto._initHooks === parentProto._initHooks) {
3730 proto._initHooks = [];
3731 }
3732 proto._initHooks.push(init);
3733 return this;
3734 };
3735
3736 Class.include = function include() {
3737 for (var _len2 = arguments.length, sources = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3738 sources[_key2] = arguments[_key2];
3739 }
3740
3741 for (var i = 0; i < sources.length; i++) {
3742 extend(this.prototype, sources[i]);
3743 }
3744 return this;
3745 };
3746
3747 Class.mergeOptions = function mergeOptions(options) {
3748 var proto = this.prototype;
3749 var parentProto = Object.getPrototypeOf(proto);
3750 if (!proto.options || proto.options === parentProto.options) {
3751 proto.options = proto.options ? Object.create(proto.options) : {};
3752 }
3753 extend(proto.options, options);
3754 return this;
3755 };
3756
3757 return Class;
3758}();
3759
3760var registeredTypes = {};
3761
3762var JSONAble = (function (Base) {
3763 return function (_Base) {
3764 inherits(_class, _Base);
3765
3766 function _class() {
3767 classCallCheck(this, _class);
3768 return possibleConstructorReturn(this, _Base.apply(this, arguments));
3769 }
3770
3771 _class.registerJSONType = function registerJSONType(type) {
3772 if (!type) {
3773 return this;
3774 }
3775 registeredTypes[type] = this;
3776 return this;
3777 };
3778
3779 _class.getJSONClass = function getJSONClass(type) {
3780 if (!type) {
3781 return null;
3782 }
3783 return registeredTypes[type];
3784 };
3785
3786 _class.prototype.getJSONType = function getJSONType() {
3787 if (this._jsonType === undefined) {
3788 var clazz = Object.getPrototypeOf(this).constructor;
3789 for (var p in registeredTypes) {
3790 if (registeredTypes[p] === clazz) {
3791 this._jsonType = p;
3792 break;
3793 }
3794 }
3795 }
3796 if (!this._jsonType) {
3797 throw new Error('Found an unregistered geometry class!');
3798 }
3799 return this._jsonType;
3800 };
3801
3802 return _class;
3803 }(Base);
3804});
3805
3806var Handlerable = function (Base) {
3807 return function (_Base) {
3808 inherits(_class, _Base);
3809
3810 function _class() {
3811 classCallCheck(this, _class);
3812 return possibleConstructorReturn(this, _Base.apply(this, arguments));
3813 }
3814
3815 _class.prototype.addHandler = function addHandler(name, handlerClass) {
3816 if (!handlerClass) {
3817 return this;
3818 }
3819 if (!this._handlers) {
3820 this._handlers = [];
3821 }
3822
3823 if (this[name]) {
3824 this[name].enable();
3825 return this;
3826 }
3827
3828 var handler = this[name] = new handlerClass(this);
3829
3830 this._handlers.push(handler);
3831
3832 if (this.options[name]) {
3833 handler.enable();
3834 }
3835 return this;
3836 };
3837
3838 _class.prototype.removeHandler = function removeHandler(name) {
3839 if (!name) {
3840 return this;
3841 }
3842 var handler = this[name];
3843 if (handler) {
3844 var hit = this._handlers.indexOf(handler);
3845 if (hit >= 0) {
3846 this._handlers.splice(hit, 1);
3847 }
3848 this[name].remove();
3849 delete this[name];
3850 }
3851 return this;
3852 };
3853
3854 _class.prototype._clearHandlers = function _clearHandlers() {
3855 for (var i = 0, len = this._handlers.length; i < len; i++) {
3856 this._handlers[i].remove();
3857 }
3858 this._handlers = [];
3859 };
3860
3861 return _class;
3862 }(Base);
3863};
3864
3865var START_EVENTS = 'touchstart mousedown';
3866var MOVE_EVENTS = {
3867 mousedown: 'mousemove',
3868 touchstart: 'touchmove',
3869 pointerdown: 'touchmove',
3870 MSPointerDown: 'touchmove'
3871};
3872var END_EVENTS = {
3873 mousedown: 'mouseup',
3874 touchstart: 'touchend',
3875 pointerdown: 'touchend',
3876 MSPointerDown: 'touchend'
3877};
3878
3879var DragHandler = function (_Handler) {
3880 inherits(DragHandler, _Handler);
3881
3882 function DragHandler(dom) {
3883 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3884 classCallCheck(this, DragHandler);
3885
3886 var _this = possibleConstructorReturn(this, _Handler.call(this, null));
3887
3888 _this.dom = dom;
3889 _this.options = options;
3890 return _this;
3891 }
3892
3893 DragHandler.prototype.enable = function enable() {
3894 if (!this.dom) {
3895 return this;
3896 }
3897
3898 this._onMouseDown = function (e) {
3899 return this.onMouseDown(e);
3900 };
3901 on(this.dom, START_EVENTS, this._onMouseDown, this);
3902 return this;
3903 };
3904
3905 DragHandler.prototype.disable = function disable() {
3906 if (!this.dom) {
3907 return this;
3908 }
3909 this._offEvents();
3910 off(this.dom, START_EVENTS, this._onMouseDown);
3911 delete this._onMouseDown;
3912 return this;
3913 };
3914
3915 DragHandler.prototype.onMouseDown = function onMouseDown(event) {
3916 if (!this.options['rightclick'] && event.button === 2) {
3917 return;
3918 }
3919 if (event.touches && event.touches.length > 1) {
3920 return;
3921 }
3922 if (this.options['cancelOn'] && this.options['cancelOn'](event) === true) {
3923 return;
3924 }
3925 var dom = this.dom;
3926 if (dom.setCapture) {
3927 dom.setCapture();
3928 } else if (window.captureEvents) {
3929 window.captureEvents(window['Event'].MOUSEMOVE | window['Event'].MOUSEUP);
3930 }
3931 dom['ondragstart'] = function () {
3932 return false;
3933 };
3934 delete this.moved;
3935 var actual = event.touches ? event.touches[0] : event;
3936 this.startPos = new Point(actual.clientX, actual.clientY);
3937 on(document, MOVE_EVENTS[event.type], this.onMouseMove, this);
3938 on(document, END_EVENTS[event.type], this.onMouseUp, this);
3939 if (!this.options['ignoreMouseleave']) {
3940 on(this.dom, 'mouseleave', this.onMouseUp, this);
3941 }
3942 this.fire('mousedown', {
3943 'domEvent': event,
3944 'mousePos': new Point(actual.clientX, actual.clientY)
3945 });
3946 };
3947
3948 DragHandler.prototype.onMouseMove = function onMouseMove(event) {
3949 if (event.touches && event.touches.length > 1) {
3950 if (this.moved) {
3951 this.interupted = true;
3952 this.onMouseUp(event);
3953 }
3954 return;
3955 }
3956 var actual = event.touches ? event.touches[0] : event;
3957
3958 var newPos = new Point(actual.clientX, actual.clientY),
3959 offset = newPos.sub(this.startPos);
3960 if (!offset.x && !offset.y) {
3961 return;
3962 }
3963 if (!this.moved) {
3964 this.fire('dragstart', {
3965 'domEvent': event,
3966 'mousePos': this.startPos.copy()
3967 });
3968 this.moved = true;
3969 } else {
3970 this.fire('dragging', {
3971 'domEvent': event,
3972 'mousePos': new Point(actual.clientX, actual.clientY)
3973 });
3974 }
3975 };
3976
3977 DragHandler.prototype.onMouseUp = function onMouseUp(event) {
3978 var actual = event.changedTouches ? event.changedTouches[0] : event;
3979 this._offEvents();
3980 var param = {
3981 'domEvent': event
3982 };
3983 if (isNumber(actual.clientX)) {
3984 param['mousePos'] = new Point(parseInt(actual.clientX, 0), parseInt(actual.clientY, 0));
3985 }
3986 if (this.moved) {
3987 param.interupted = this.interupted;
3988 this.fire('dragend', param);
3989 delete this.interupted;
3990 delete this.moved;
3991 }
3992
3993 this.fire('mouseup', param);
3994 };
3995
3996 DragHandler.prototype._offEvents = function _offEvents() {
3997 var dom = this.dom;
3998 off(dom, 'mouseleave', this.onMouseUp, this);
3999 if (typeof document === 'undefined' || typeof window === 'undefined') {
4000 return;
4001 }
4002 for (var i in MOVE_EVENTS) {
4003 off(document, MOVE_EVENTS[i], this.onMouseMove, this);
4004 off(document, END_EVENTS[i], this.onMouseUp, this);
4005 }
4006
4007 if (dom['releaseCapture']) {
4008 dom['releaseCapture']();
4009 } else if (window.captureEvents) {
4010 window.captureEvents(window['Event'].MOUSEMOVE | window['Event'].MOUSEUP);
4011 }
4012 };
4013
4014 return DragHandler;
4015}(Handler$1);
4016
4017var Coordinate = function (_Position) {
4018 inherits(Coordinate, _Position);
4019
4020 function Coordinate() {
4021 classCallCheck(this, Coordinate);
4022 return possibleConstructorReturn(this, _Position.apply(this, arguments));
4023 }
4024
4025 Coordinate.toNumberArrays = function toNumberArrays(coordinates) {
4026 if (!Array.isArray(coordinates)) {
4027 return [coordinates.x, coordinates.y];
4028 }
4029 return forEachCoord(coordinates, function (coord) {
4030 return [coord.x, coord.y];
4031 });
4032 };
4033
4034 Coordinate.toCoordinates = function toCoordinates(coordinates) {
4035 if (isNumber(coordinates[0]) && isNumber(coordinates[1])) {
4036 return new Coordinate(coordinates);
4037 }
4038 var result = [];
4039 for (var i = 0, len = coordinates.length; i < len; i++) {
4040 var child = coordinates[i];
4041 if (Array.isArray(child)) {
4042 if (isNumber(child[0])) {
4043 result.push(new Coordinate(child));
4044 } else {
4045 result.push(Coordinate.toCoordinates(child));
4046 }
4047 } else {
4048 result.push(new Coordinate(child));
4049 }
4050 }
4051 return result;
4052 };
4053
4054 return Coordinate;
4055}(Position);
4056
4057var CRS = function () {
4058 function CRS(type, properties) {
4059 classCallCheck(this, CRS);
4060
4061 this.type = type;
4062 this.properties = properties;
4063 }
4064
4065 CRS.createProj4 = function createProj4(proj) {
4066 return new CRS('proj4', {
4067 'proj': proj
4068 });
4069 };
4070
4071 CRS.fromProjectionCode = function fromProjectionCode(code) {
4072 if (!code) {
4073 return null;
4074 }
4075 code = code.toUpperCase().replace(':', '');
4076 return CRS[code] || null;
4077 };
4078
4079 return CRS;
4080}();
4081
4082CRS.WGS84 = CRS.createProj4('+proj=longlat +datum=WGS84 +no_defs');
4083
4084CRS.EPSG4326 = CRS.WGS84;
4085
4086CRS.EPSG3857 = CRS.createProj4('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs');
4087
4088CRS.IDENTITY = CRS.createProj4('+proj=identity +no_defs');
4089
4090CRS.CGCS2000 = CRS.createProj4('+proj=longlat +datum=CGCS2000');
4091
4092CRS.EPSG4490 = CRS.CGCS2000;
4093
4094CRS.BD09LL = CRS.createProj4('+proj=longlat +datum=BD09');
4095
4096CRS.GCJ02 = CRS.createProj4('+proj=longlat +datum=GCJ02');
4097
4098var Extent = function () {
4099 function Extent(p1, p2, p3, p4) {
4100 classCallCheck(this, Extent);
4101
4102 this._clazz = Coordinate;
4103 var l = arguments.length;
4104 var proj = l > 0 ? arguments[l - 1] : null;
4105 if (proj && proj.unproject) {
4106 this.projection = arguments[l - 1];
4107 }
4108 this._dirty = true;
4109 this._initialize(p1, p2, p3, p4);
4110 }
4111
4112 Extent.prototype._initialize = function _initialize(p1, p2, p3, p4) {
4113 this.xmin = null;
4114
4115 this.xmax = null;
4116
4117 this.ymin = null;
4118
4119 this.ymax = null;
4120 if (isNil(p1)) {
4121 return;
4122 }
4123 var projection = this.projection;
4124
4125 if (isNumber(p1) && isNumber(p2) && isNumber(p3) && isNumber(p4)) {
4126 if (projection) {
4127 this['xmin'] = p1;
4128 this['ymin'] = p2;
4129 this['xmax'] = p3;
4130 this['ymax'] = p4;
4131 } else {
4132 this['xmin'] = Math.min(p1, p3);
4133 this['ymin'] = Math.min(p2, p4);
4134 this['xmax'] = Math.max(p1, p3);
4135 this['ymax'] = Math.max(p2, p4);
4136 }
4137 return;
4138 } else if (Array.isArray(p1)) {
4139 if (projection) {
4140 this['xmin'] = p1[0];
4141 this['ymin'] = p1[1];
4142 this['xmax'] = p1[2];
4143 this['ymax'] = p1[3];
4144 } else {
4145 this['xmin'] = Math.min(p1[0], p1[2]);
4146 this['ymin'] = Math.min(p1[1], p1[3]);
4147 this['xmax'] = Math.max(p1[0], p1[2]);
4148 this['ymax'] = Math.max(p1[1], p1[3]);
4149 }
4150 } else if (isNumber(p1.x) && isNumber(p2.x) && isNumber(p1.y) && isNumber(p2.y)) {
4151 if (projection) {
4152 this['xmin'] = p1.x;
4153 this['ymin'] = p1.y;
4154 this['xmax'] = p2.x;
4155 this['ymax'] = p2.y;
4156 } else {
4157 if (p1.x > p2.x) {
4158 this['xmin'] = p2.x;
4159 this['xmax'] = p1.x;
4160 } else {
4161 this['xmin'] = p1.x;
4162 this['xmax'] = p2.x;
4163 }
4164 if (p1.y > p2.y) {
4165 this['ymin'] = p2.y;
4166 this['ymax'] = p1.y;
4167 } else {
4168 this['ymin'] = p1.y;
4169 this['ymax'] = p2.y;
4170 }
4171 }
4172 } else if (isNumber(p1['xmin']) && isNumber(p1['xmax']) && isNumber(p1['ymin']) && isNumber(p1['ymax'])) {
4173 this['xmin'] = p1['xmin'];
4174 this['ymin'] = p1['ymin'];
4175 this['xmax'] = p1['xmax'];
4176 this['ymax'] = p1['ymax'];
4177 }
4178 };
4179
4180 Extent.prototype._add = function _add(p) {
4181 this._dirty = true;
4182 if (!isNil(p.x)) {
4183 this['xmin'] += p.x;
4184 this['ymin'] += p.y;
4185 this['xmax'] += p.x;
4186 this['ymax'] += p.y;
4187 } else if (!isNil(p.xmin)) {
4188 this['xmin'] += p.xmin;
4189 this['ymin'] += p.ymin;
4190 this['xmax'] += p.xmax;
4191 this['ymax'] += p.ymax;
4192 } else if (!isNil(p[0])) {
4193 this['xmin'] += p[0];
4194 this['ymin'] += p[1];
4195 this['xmax'] += p[0];
4196 this['ymax'] += p[1];
4197 }
4198 return this;
4199 };
4200
4201 Extent.prototype.add = function add() {
4202 var e = new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
4203 return e._add.apply(e, arguments);
4204 };
4205
4206 Extent.prototype._sub = function _sub(p) {
4207 this._dirty = true;
4208 if (!isNil(p.x)) {
4209 this['xmin'] -= p.x;
4210 this['ymin'] -= p.y;
4211 this['xmax'] -= p.x;
4212 this['ymax'] -= p.y;
4213 } else if (!isNil(p.xmin)) {
4214 this['xmin'] -= p.xmin;
4215 this['ymin'] -= p.ymin;
4216 this['xmax'] -= p.xmax;
4217 this['ymax'] -= p.ymax;
4218 } else if (!isNil(p[0])) {
4219 this['xmin'] -= p[0];
4220 this['ymin'] -= p[1];
4221 this['xmax'] -= p[0];
4222 this['ymax'] -= p[1];
4223 }
4224 return this;
4225 };
4226
4227 Extent.prototype._substract = function _substract() {
4228 return this._sub.apply(this, arguments);
4229 };
4230
4231 Extent.prototype.sub = function sub() {
4232 var e = new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
4233 return e._sub.apply(e, arguments);
4234 };
4235
4236 Extent.prototype.substract = function substract() {
4237 return this.sub.apply(this, arguments);
4238 };
4239
4240 Extent.prototype.round = function round() {
4241 return new this.constructor(Math.round(this['xmin']), Math.round(this['ymin']), Math.round(this['xmax']), Math.round(this['ymax']), this.projection);
4242 };
4243
4244 Extent.prototype._round = function _round() {
4245 this._dirty = true;
4246 this['xmin'] = Math.round(this['xmin']);
4247 this['ymin'] = Math.round(this['ymin']);
4248 this['xmax'] = Math.round(this['xmax']);
4249 this['ymax'] = Math.round(this['ymax']);
4250 return this;
4251 };
4252
4253 Extent.prototype.getMin = function getMin() {
4254 return new this._clazz(this['xmin'], this['ymin']);
4255 };
4256
4257 Extent.prototype.getMax = function getMax() {
4258 return new this._clazz(this['xmax'], this['ymax']);
4259 };
4260
4261 Extent.prototype.getCenter = function getCenter() {
4262 return new this._clazz((this['xmin'] + this['xmax']) / 2, (this['ymin'] + this['ymax']) / 2);
4263 };
4264
4265 Extent.prototype.isValid = function isValid() {
4266 return isNumber(this['xmin']) && isNumber(this['ymin']) && isNumber(this['xmax']) && isNumber(this['ymax']);
4267 };
4268
4269 Extent.prototype.equals = function equals(ext2) {
4270 return this['xmin'] === ext2['xmin'] && this['xmax'] === ext2['xmax'] && this['ymin'] === ext2['ymin'] && this['ymax'] === ext2['ymax'];
4271 };
4272
4273 Extent.prototype.intersects = function intersects(ext2) {
4274 this._project(this);
4275 this._project(ext2);
4276 var rxmin = Math.max(this['pxmin'], ext2['pxmin']);
4277 var rymin = Math.max(this['pymin'], ext2['pymin']);
4278 var rxmax = Math.min(this['pxmax'], ext2['pxmax']);
4279 var rymax = Math.min(this['pymax'], ext2['pymax']);
4280 var intersects = !(rxmin > rxmax || rymin > rymax);
4281 return intersects;
4282 };
4283
4284 Extent.prototype.within = function within(extent) {
4285 this._project(this);
4286 this._project(extent);
4287 return this.pxmin >= extent.pxmin && this.pxmax <= extent.pxmax && this.pymin >= extent.pymin && this.pymax <= extent.pymax;
4288 };
4289
4290 Extent.prototype.contains = function contains(c) {
4291 if (!c) {
4292 return false;
4293 }
4294 this._project(this);
4295 var proj = this.projection;
4296 if (Array.isArray(c)) {
4297 c = new this._clazz(c);
4298 }
4299 if (proj) {
4300 c = proj.project(c);
4301 }
4302 return c.x >= this.pxmin && c.x <= this.pxmax && c.y >= this.pymin && c.y <= this.pymax;
4303 };
4304
4305 Extent.prototype.getWidth = function getWidth() {
4306 return Math.abs(this['xmax'] - this['xmin']);
4307 };
4308
4309 Extent.prototype.getHeight = function getHeight() {
4310 return Math.abs(this['ymax'] - this['ymin']);
4311 };
4312
4313 Extent.prototype.getSize = function getSize() {
4314 return new Size(this.getWidth(), this.getHeight());
4315 };
4316
4317 Extent.prototype.__combine = function __combine(extent) {
4318 if (!(extent instanceof this.constructor)) {
4319 extent = new this.constructor(extent, extent);
4320 }
4321 this._project(extent);
4322 this._project(this);
4323 var xmin = this['pxmin'];
4324 if (!isNumber(xmin)) {
4325 xmin = extent['pxmin'];
4326 } else if (isNumber(extent['pxmin'])) {
4327 if (xmin > extent['pxmin']) {
4328 xmin = extent['pxmin'];
4329 }
4330 }
4331
4332 var xmax = this['pxmax'];
4333 if (!isNumber(xmax)) {
4334 xmax = extent['pxmax'];
4335 } else if (isNumber(extent['pxmax'])) {
4336 if (xmax < extent['pxmax']) {
4337 xmax = extent['pxmax'];
4338 }
4339 }
4340
4341 var ymin = this['pymin'];
4342 if (!isNumber(ymin)) {
4343 ymin = extent['pymin'];
4344 } else if (isNumber(extent['pymin'])) {
4345 if (ymin > extent['pymin']) {
4346 ymin = extent['pymin'];
4347 }
4348 }
4349
4350 var ymax = this['pymax'];
4351 if (!isNumber(ymax)) {
4352 ymax = extent['pymax'];
4353 } else if (isNumber(extent['pymax'])) {
4354 if (ymax < extent['pymax']) {
4355 ymax = extent['pymax'];
4356 }
4357 }
4358 var proj = this.projection;
4359 if (proj) {
4360 var min = proj.unproject(new this._clazz(xmin, ymin)),
4361 max = proj.unproject(new this._clazz(xmax, ymax));
4362 xmin = min.x;
4363 ymin = min.y;
4364 xmax = max.x;
4365 ymax = max.y;
4366 }
4367 return [xmin, ymin, xmax, ymax];
4368 };
4369
4370 Extent.prototype._combine = function _combine(extent) {
4371 if (!extent) {
4372 return this;
4373 }
4374 var ext = this.__combine(extent);
4375 this['xmin'] = ext[0];
4376 this['ymin'] = ext[1];
4377 this['xmax'] = ext[2];
4378 this['ymax'] = ext[3];
4379 this._dirty = true;
4380 return this;
4381 };
4382
4383 Extent.prototype.combine = function combine(extent) {
4384 if (!extent) {
4385 return this;
4386 }
4387 var ext = this.__combine(extent);
4388 return new this.constructor(ext[0], ext[1], ext[2], ext[3], this.projection);
4389 };
4390
4391 Extent.prototype.intersection = function intersection(extent) {
4392 if (!this.intersects(extent)) {
4393 return null;
4394 }
4395 var min = new this._clazz(Math.max(this['pxmin'], extent['pxmin']), Math.max(this['pymin'], extent['pymin'])),
4396 max = new this._clazz(Math.min(this['pxmax'], extent['pxmax']), Math.min(this['pymax'], extent['pymax']));
4397 var proj = this.projection;
4398 if (proj) {
4399 min = proj.unproject(min);
4400 max = proj.unproject(max);
4401 }
4402 return new this.constructor(min, max, proj);
4403 };
4404
4405 Extent.prototype.expand = function expand(distance) {
4406 var w = void 0,
4407 h = void 0;
4408 if (!isNumber(distance)) {
4409 w = distance['width'] || distance['x'] || distance[0] || 0;
4410 h = distance['height'] || distance['y'] || distance[1] || 0;
4411 } else {
4412 w = h = distance;
4413 }
4414 return new this.constructor(this['xmin'] - w, this['ymin'] - h, this['xmax'] + w, this['ymax'] + h, this.projection);
4415 };
4416
4417 Extent.prototype._expand = function _expand(distance) {
4418 var w = void 0,
4419 h = void 0;
4420 if (!isNumber(distance)) {
4421 w = distance['width'] || distance['x'] || distance[0] || 0;
4422 h = distance['height'] || distance['y'] || distance[1] || 0;
4423 } else {
4424 w = h = distance;
4425 }
4426 this['xmin'] -= w;
4427 this['ymin'] -= h;
4428 this['xmax'] += w;
4429 this['ymax'] += h;
4430 this._dirty = true;
4431 return this;
4432 };
4433
4434 Extent.prototype.toJSON = function toJSON() {
4435 return {
4436 'xmin': this['xmin'],
4437 'ymin': this['ymin'],
4438 'xmax': this['xmax'],
4439 'ymax': this['ymax']
4440 };
4441 };
4442
4443 Extent.prototype.toArray = function toArray$$1() {
4444 var xmin = this['xmin'],
4445 ymin = this['ymin'],
4446 xmax = this['xmax'],
4447 ymax = this['ymax'];
4448 return [new this._clazz([xmin, ymax]), new this._clazz([xmax, ymax]), new this._clazz([xmax, ymin]), new this._clazz([xmin, ymin]), new this._clazz([xmin, ymax])];
4449 };
4450
4451 Extent.prototype.toString = function toString() {
4452 return this.xmin + ',' + this.ymin + ',' + this.xmax + ',' + this.ymax;
4453 };
4454
4455 Extent.prototype.copy = function copy() {
4456 return new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
4457 };
4458
4459 Extent.prototype.convertTo = function convertTo(fn) {
4460 if (!this.isValid()) {
4461 return null;
4462 }
4463 var e = new this.constructor();
4464 var coord = new this._clazz(this.xmin, this.ymax);
4465 e._combine(fn(coord));
4466 coord.x = this.xmax;
4467 e._combine(fn(coord));
4468 coord.y = this.ymin;
4469 e._combine(fn(coord));
4470 coord.x = this.xmin;
4471 e._combine(fn(coord));
4472 return e;
4473 };
4474
4475 Extent.prototype._project = function _project(ext) {
4476 if (!ext || !ext.isValid()) {
4477 return;
4478 }
4479 var proj = this.projection;
4480 if (proj) {
4481 if (ext._dirty) {
4482 var minmax = [ext.getMin(), ext.getMax()];
4483 minmax = proj.projectCoords(minmax);
4484 var min = minmax[0],
4485 max = minmax[1];
4486 ext.pxmin = Math.min(min.x, max.x);
4487 ext.pymin = Math.min(min.y, max.y);
4488 ext.pxmax = Math.max(min.x, max.x);
4489 ext.pymax = Math.max(min.y, max.y);
4490 }
4491 delete ext._dirty;
4492 } else {
4493 ext.pxmin = ext.xmin;
4494 ext.pxmax = ext.xmax;
4495 ext.pymin = ext.ymin;
4496 ext.pymax = ext.ymax;
4497 }
4498 };
4499
4500 return Extent;
4501}();
4502
4503var PointExtent = function (_Extent) {
4504 inherits(PointExtent, _Extent);
4505
4506 function PointExtent(p1, p2, p3, p4) {
4507 classCallCheck(this, PointExtent);
4508
4509 var _this = possibleConstructorReturn(this, _Extent.call(this, p1, p2, p3, p4));
4510
4511 _this._clazz = Point;
4512 return _this;
4513 }
4514
4515 return PointExtent;
4516}(Extent);
4517
4518var Transformation = function () {
4519 function Transformation(matrix) {
4520 classCallCheck(this, Transformation);
4521
4522 this.matrix = matrix;
4523 }
4524
4525 Transformation.prototype.transform = function transform(coordinates, scale) {
4526 return new Point(this.matrix[0] * (coordinates.x - this.matrix[2]) / scale, this.matrix[1] * (coordinates.y - this.matrix[3]) / scale);
4527 };
4528
4529 Transformation.prototype.untransform = function untransform(point, scale) {
4530 return new Coordinate(point.x * scale / this.matrix[0] + this.matrix[2], point.y * scale / this.matrix[1] + this.matrix[3]);
4531 };
4532
4533 return Transformation;
4534}();
4535
4536var Common = {
4537 project: function project() {},
4538 unproject: function unproject() {},
4539 projectCoords: function projectCoords(coordinates) {
4540 var _this = this;
4541
4542 if (!coordinates) {
4543 return [];
4544 }
4545 if (!Array.isArray(coordinates)) {
4546 return this.project(coordinates);
4547 }
4548 if (coordinates.length === 0) {
4549 return [];
4550 }
4551 if (!this.isSphere()) {
4552 return forEachCoord(coordinates, this.project, this);
4553 }
4554 if (Array.isArray(coordinates[0])) {
4555 return coordinates.map(function (coords) {
4556 return _this.projectCoords(coords);
4557 });
4558 } else {
4559 var circum = this.getCircum();
4560 var extent = this.getSphereExtent(),
4561 sx = extent.sx,
4562 sy = extent.sy;
4563 var wrapX = void 0,
4564 wrapY = void 0;
4565 var pre = coordinates[0],
4566 current = void 0,
4567 dx = void 0,
4568 dy = void 0,
4569 p = void 0;
4570 var prj = [this.project(pre)];
4571 for (var i = 1, l = coordinates.length; i < l; i++) {
4572 current = coordinates[i];
4573 dx = current.x - pre.x;
4574 dy = current.y - pre.y;
4575 p = this.project(current);
4576 if (Math.abs(dx) > 180) {
4577 if (wrapX === undefined) {
4578 wrapX = current.x < pre.x;
4579 }
4580 if (wrapX) {
4581 p._add(-circum.x * sign(dx) * sx, 0);
4582 current._add(-360 * sign(dx), 0);
4583 }
4584 }
4585 if (Math.abs(dy) > 90) {
4586 if (wrapY === undefined) {
4587 wrapY = current.y < pre.y;
4588 }
4589 if (wrapY) {
4590 p._add(0, -circum.y * sign(dy) * sy);
4591 current._add(0, -180 * sign(dy));
4592 }
4593 }
4594 pre = current;
4595 prj.push(p);
4596 }
4597 return prj;
4598 }
4599 },
4600 unprojectCoords: function unprojectCoords(projCoords) {
4601 if (!projCoords) {
4602 return [];
4603 }
4604 if (!Array.isArray(projCoords)) {
4605 return this.unproject(projCoords);
4606 }
4607 return forEachCoord(projCoords, this.unproject, this);
4608 },
4609 isSphere: function isSphere() {
4610 return !!this.sphere;
4611 },
4612 isOutSphere: function isOutSphere(pcoord) {
4613 if (!this.isSphere()) {
4614 return false;
4615 }
4616 var extent = this.getSphereExtent();
4617 return !extent.contains(pcoord);
4618 },
4619 wrapCoord: function wrapCoord(pcoord) {
4620 if (!this.isSphere()) {
4621 return pcoord;
4622 }
4623 var extent = this.getSphereExtent();
4624 var wrapped = new Coordinate(pcoord);
4625 if (!extent.contains(wrapped)) {
4626 wrapped.x = wrap(pcoord.x, extent.xmin, extent.xmax);
4627 wrapped.y = wrap(pcoord.y, extent.ymin, extent.ymax);
4628 }
4629 return wrapped;
4630 },
4631 getCircum: function getCircum() {
4632 if (!this.circum && this.isSphere()) {
4633 var extent = this.getSphereExtent();
4634 this.circum = {
4635 x: extent.getWidth(),
4636 y: extent.getHeight()
4637 };
4638 }
4639 return this.circum;
4640 },
4641 getSphereExtent: function getSphereExtent() {
4642 if (!this.extent && this.isSphere()) {
4643 var max = this.project(new Coordinate(180, 90)),
4644 min = this.project(new Coordinate(-180, -90));
4645 this.extent = new Extent(min, max, this);
4646 this.extent.sx = max.x > min.x ? 1 : -1;
4647 this.extent.sy = max.y > min.y ? 1 : -1;
4648 }
4649 return this.extent;
4650 }
4651};
4652
4653var Common$1 = {
4654 measureLength: function measureLength(c1, c2) {
4655 if (!Array.isArray(c1)) {
4656 return this.measureLenBetween(c1, c2);
4657 }
4658 var len = 0;
4659 for (var i = 0, l = c1.length; i < l - 1; i++) {
4660 len += this.measureLenBetween(c1[i], c1[i + 1]);
4661 }
4662 return len;
4663 }
4664};
4665
4666var Identity = extend({
4667 'measure': 'IDENTITY',
4668
4669 measureLenBetween: function measureLenBetween(c1, c2) {
4670 if (!c1 || !c2) {
4671 return 0;
4672 }
4673 try {
4674 return Math.sqrt(Math.pow(c1.x - c2.x, 2) + Math.pow(c1.y - c2.y, 2));
4675 } catch (err) {
4676 return 0;
4677 }
4678 },
4679
4680 measureArea: function measureArea(coordinates) {
4681 if (!Array.isArray(coordinates)) {
4682 return 0;
4683 }
4684 var area = 0;
4685 for (var i = 0, len = coordinates.length; i < len; i++) {
4686 var c1 = coordinates[i];
4687 var c2 = null;
4688 if (i === len - 1) {
4689 c2 = coordinates[0];
4690 } else {
4691 c2 = coordinates[i + 1];
4692 }
4693 area += c1.x * c2.y - c1.y * c2.x;
4694 }
4695 return Math.abs(area / 2);
4696 },
4697
4698 locate: function locate(c, xDist, yDist) {
4699 c = new Coordinate(c.x, c.y);
4700 return this._locate(c, xDist, yDist);
4701 },
4702
4703 _locate: function _locate(c, xDist, yDist) {
4704 if (!c) {
4705 return null;
4706 }
4707 if (!xDist) {
4708 xDist = 0;
4709 }
4710 if (!yDist) {
4711 yDist = 0;
4712 }
4713 if (!xDist && !yDist) {
4714 return c;
4715 }
4716 c.x = c.x + xDist;
4717 c.y = c.y + yDist;
4718 return c;
4719 },
4720
4721 rotate: function rotate(c, pivot, angle) {
4722 c = new Coordinate(c.x, c.y);
4723 return this._rotate(c, pivot, angle);
4724 },
4725
4726 _rotate: function () {
4727 var tmp = new Point(0, 0);
4728 return function (c, pivot, angle) {
4729 tmp.x = c.x - pivot.x;
4730 tmp.y = c.y - pivot.y;
4731 tmp._rotate(angle * Math.PI / 180);
4732 return c._add(tmp.x, tmp.y);
4733 };
4734 }()
4735}, Common$1);
4736
4737var Sphere = function () {
4738 function Sphere(radius) {
4739 classCallCheck(this, Sphere);
4740
4741 this.radius = radius;
4742 }
4743
4744 Sphere.prototype.measureLenBetween = function measureLenBetween(c1, c2) {
4745 if (!c1 || !c2) {
4746 return 0;
4747 }
4748 var b = toRadian(c1.y);
4749 var d = toRadian(c2.y),
4750 e = b - d,
4751 f = toRadian(c1.x) - toRadian(c2.x);
4752 b = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(e / 2), 2) + Math.cos(b) * Math.cos(d) * Math.pow(Math.sin(f / 2), 2)));
4753 b *= this.radius;
4754 return Math.round(b * 1E5) / 1E5;
4755 };
4756
4757 Sphere.prototype.measureArea = function measureArea(coordinates) {
4758 var a = toRadian(this.radius);
4759 var b = 0,
4760 c = coordinates,
4761 d = c.length;
4762 if (d < 3) {
4763 return 0;
4764 }
4765 var i = void 0;
4766 for (i = 0; i < d - 1; i++) {
4767 var e = c[i],
4768 f = c[i + 1];
4769 b += e.x * a * Math.cos(toRadian(e.y)) * f.y * a - f.x * a * Math.cos(toRadian(f.y)) * e.y * a;
4770 }
4771 d = c[i];
4772 c = c[0];
4773 b += d.x * a * Math.cos(toRadian(d.y)) * c.y * a - c.x * a * Math.cos(toRadian(c.y)) * d.y * a;
4774 return 0.5 * Math.abs(b);
4775 };
4776
4777 Sphere.prototype.locate = function locate(c, xDist, yDist) {
4778 c = new Coordinate(c.x, c.y);
4779 return this._locate(c, xDist, yDist);
4780 };
4781
4782 Sphere.prototype._locate = function _locate(c, xDist, yDist) {
4783 if (!c) {
4784 return null;
4785 }
4786 if (!xDist) {
4787 xDist = 0;
4788 }
4789 if (!yDist) {
4790 yDist = 0;
4791 }
4792 if (!xDist && !yDist) {
4793 return c;
4794 }
4795 var x = void 0,
4796 y = void 0;
4797 var ry = toRadian(c.y);
4798 if (yDist !== 0) {
4799 var dy = Math.abs(yDist);
4800 var sy = Math.sin(dy / (2 * this.radius)) * 2;
4801 ry = ry + sy * (yDist > 0 ? 1 : -1);
4802 y = wrap(ry * 180 / Math.PI, -90, 90);
4803 } else {
4804 y = c.y;
4805 }
4806 if (xDist !== 0) {
4807 var dx = Math.abs(xDist);
4808 var rx = toRadian(c.x);
4809 var sx = 2 * Math.sqrt(Math.pow(Math.sin(dx / (2 * this.radius)), 2) / Math.pow(Math.cos(ry), 2));
4810 rx = rx + sx * (xDist > 0 ? 1 : -1);
4811 x = wrap(rx * 180 / Math.PI, -180, 180);
4812 } else {
4813 x = c.x;
4814 }
4815 c.x = x;
4816 c.y = y;
4817 return c;
4818 };
4819
4820 Sphere.prototype.rotate = function rotate(c, pivot, angle) {
4821 c = new Coordinate(c);
4822 return this._rotate(c, pivot, angle);
4823 };
4824
4825 Sphere.prototype._rotate = function _rotate(c, pivot, angle) {
4826 var initialAngle = rhumbBearing(pivot, c);
4827 var finalAngle = initialAngle - angle;
4828 var distance = this.measureLenBetween(pivot, c);
4829 c.x = pivot.x;
4830 c.y = pivot.y;
4831 return calculateRhumbDestination(c, distance, finalAngle, this.radius);
4832 };
4833
4834 return Sphere;
4835}();
4836
4837function rhumbBearing(start, end) {
4838 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4839
4840 var bear360 = void 0;
4841 if (options.final) bear360 = calculateRhumbBearing(end, start);else bear360 = calculateRhumbBearing(start, end);
4842
4843 var bear180 = bear360 > 180 ? -(360 - bear360) : bear360;
4844
4845 return bear180;
4846}
4847
4848function calculateRhumbBearing(from, to) {
4849 var phi1 = toRadian(from.y);
4850 var phi2 = toRadian(to.y);
4851 var deltaLambda = toRadian(to.x - from.x);
4852
4853 if (deltaLambda > Math.PI) deltaLambda -= 2 * Math.PI;
4854 if (deltaLambda < -Math.PI) deltaLambda += 2 * Math.PI;
4855
4856 var deltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
4857
4858 var theta = Math.atan2(deltaLambda, deltaPsi);
4859
4860 return (toDegree(theta) + 360) % 360;
4861}
4862
4863function calculateRhumbDestination(origin, distance, bearing, radius) {
4864
4865 var delta = distance / radius;
4866 var lambda1 = origin.x * Math.PI / 180;
4867 var phi1 = toRadian(origin.y);
4868 var theta = toRadian(bearing);
4869
4870 var DeltaPhi = delta * Math.cos(theta);
4871 var phi2 = phi1 + DeltaPhi;
4872
4873 if (Math.abs(phi2) > Math.PI / 2) phi2 = phi2 > 0 ? Math.PI - phi2 : -Math.PI - phi2;
4874
4875 var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
4876 var q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);
4877 var DeltaLambda = delta * Math.sin(theta) / q;
4878 var lambda2 = lambda1 + DeltaLambda;
4879
4880 origin.x = (lambda2 * 180 / Math.PI + 540) % 360 - 180;
4881 origin.y = phi2 * 180 / Math.PI;
4882 return origin;
4883}
4884
4885var WGS84Sphere = extend({
4886 'measure': 'EPSG:4326',
4887 sphere: new Sphere(6378137),
4888 measureLenBetween: function measureLenBetween() {
4889 return this.sphere.measureLenBetween.apply(this.sphere, arguments);
4890 },
4891 measureArea: function measureArea() {
4892 return this.sphere.measureArea.apply(this.sphere, arguments);
4893 },
4894 _locate: function _locate() {
4895 return this.sphere._locate.apply(this.sphere, arguments);
4896 },
4897 locate: function locate() {
4898 return this.sphere.locate.apply(this.sphere, arguments);
4899 },
4900 _rotate: function _rotate() {
4901 return this.sphere._rotate.apply(this.sphere, arguments);
4902 },
4903 rotate: function rotate() {
4904 return this.sphere.rotate.apply(this.sphere, arguments);
4905 }
4906}, Common$1);
4907
4908var BaiduSphere = extend({
4909 'measure': 'BAIDU',
4910 sphere: new Sphere(6370996.81),
4911 measureLenBetween: function measureLenBetween() {
4912 return this.sphere.measureLenBetween.apply(this.sphere, arguments);
4913 },
4914 measureArea: function measureArea() {
4915 return this.sphere.measureArea.apply(this.sphere, arguments);
4916 },
4917 _locate: function _locate() {
4918 return this.sphere._locate.apply(this.sphere, arguments);
4919 },
4920 locate: function locate() {
4921 return this.sphere.locate.apply(this.sphere, arguments);
4922 },
4923 _rotate: function _rotate() {
4924 return this.sphere._rotate.apply(this.sphere, arguments);
4925 },
4926 rotate: function rotate() {
4927 return this.sphere.rotate.apply(this.sphere, arguments);
4928 }
4929}, Common$1);
4930
4931var DEFAULT$1 = WGS84Sphere;
4932
4933var measurers = {};
4934
4935function registerMeasurer(m) {
4936 measurers[m.measure] = m;
4937}
4938
4939registerMeasurer(Identity);
4940registerMeasurer(WGS84Sphere);
4941registerMeasurer(BaiduSphere);
4942
4943var Measurer = {
4944 getInstance: function getInstance(name) {
4945 if (!name) {
4946 return DEFAULT$1;
4947 }
4948 for (var p in measurers) {
4949 if (hasOwn(measurers, p)) {
4950 var mName = measurers[p]['measure'];
4951 if (!mName) {
4952 continue;
4953 }
4954 if (name.toLowerCase() === mName.toLowerCase()) {
4955 return measurers[p];
4956 }
4957 }
4958 }
4959 return null;
4960 }
4961};
4962
4963var index$2 = Object.freeze({
4964 Identity: Identity,
4965 DEFAULT: DEFAULT$1,
4966 Measurer: Measurer,
4967 WGS84Sphere: WGS84Sphere,
4968 BaiduSphere: BaiduSphere
4969});
4970
4971var EPSG3857 = extend({}, Common, {
4972 code: 'EPSG:3857',
4973 rad: Math.PI / 180,
4974 metersPerDegree: 6378137 * Math.PI / 180,
4975 maxLatitude: 85.0511287798,
4976
4977 project: function project(lnglat) {
4978 var rad = this.rad,
4979 metersPerDegree = this.metersPerDegree,
4980 max = this.maxLatitude;
4981 var lng = lnglat.x,
4982 lat = Math.max(Math.min(max, lnglat.y), -max);
4983 var c = void 0;
4984 if (lat === 0) {
4985 c = 0;
4986 } else {
4987 c = Math.log(Math.tan((90 + lat) * rad / 2)) / rad;
4988 }
4989 return new Coordinate(lng * metersPerDegree, c * metersPerDegree);
4990 },
4991
4992 unproject: function unproject(pLnglat) {
4993 var x = pLnglat.x,
4994 y = pLnglat.y;
4995 var rad = this.rad,
4996 metersPerDegree = this.metersPerDegree;
4997 var c = void 0;
4998 if (y === 0) {
4999 c = 0;
5000 } else {
5001 c = y / metersPerDegree;
5002 c = (2 * Math.atan(Math.exp(c * rad)) - Math.PI / 2) / rad;
5003 }
5004 return new Coordinate(wrap(x / metersPerDegree, -180, 180), wrap(c, -this.maxLatitude, this.maxLatitude));
5005 }
5006}, WGS84Sphere);
5007
5008var PROJ4326 = extend({}, Common, {
5009 code: 'EPSG:4326',
5010 project: function project(p) {
5011 return new Coordinate(p);
5012 },
5013 unproject: function unproject(p) {
5014 return new Coordinate(p);
5015 }
5016}, WGS84Sphere);
5017
5018var Projection_EPSG4490 = extend({}, PROJ4326, {
5019 code: 'EPSG:4490'
5020});
5021
5022var Projection_Baidu = extend({}, Common, {
5023 code: 'BAIDU',
5024
5025 project: function project(p) {
5026 return this.convertLL2MC(p);
5027 },
5028
5029 unproject: function unproject(p) {
5030 return this.convertMC2LL(p);
5031 }
5032}, BaiduSphere, {
5033 EARTHRADIUS: 6370996.81,
5034 MCBAND: [12890594.86, 8362377.87, 5591021, 3481989.83, 1678043.12, 0],
5035 LLBAND: [75, 60, 45, 30, 15, 0],
5036 MC2LL: [[1.410526172116255e-8, 0.00000898305509648872, -1.9939833816331, 200.9824383106796, -187.2403703815547, 91.6087516669843, -23.38765649603339, 2.57121317296198, -0.03801003308653, 17337981.2], [-7.435856389565537e-9, 0.000008983055097726239, -0.78625201886289, 96.32687599759846, -1.85204757529826, -59.36935905485877, 47.40033549296737, -16.50741931063887, 2.28786674699375, 10260144.86], [-3.030883460898826e-8, 0.00000898305509983578, 0.30071316287616, 59.74293618442277, 7.357984074871, -25.38371002664745, 13.45380521110908, -3.29883767235584, 0.32710905363475, 6856817.37], [-1.981981304930552e-8, 0.000008983055099779535, 0.03278182852591, 40.31678527705744, 0.65659298677277, -4.44255534477492, 0.85341911805263, 0.12923347998204, -0.04625736007561, 4482777.06], [3.09191371068437e-9, 0.000008983055096812155, 0.00006995724062, 23.10934304144901, -0.00023663490511, -0.6321817810242, -0.00663494467273, 0.03430082397953, -0.00466043876332, 2555164.4], [2.890871144776878e-9, 0.000008983055095805407, -3.068298e-8, 7.47137025468032, -0.00000353937994, -0.02145144861037, -0.00001234426596, 0.00010322952773, -0.00000323890364, 826088.5]],
5037 LL2MC: [[-0.0015702102444, 111320.7020616939, 1704480524535203, -10338987376042340, 26112667856603880, -35149669176653700, 26595700718403920, -10725012454188240, 1800819912950474, 82.5], [0.0008277824516172526, 111320.7020463578, 647795574.6671607, -4082003173.641316, 10774905663.51142, -15171875531.51559, 12053065338.62167, -5124939663.577472, 913311935.9512032, 67.5], [0.00337398766765, 111320.7020202162, 4481351.045890365, -23393751.19931662, 79682215.47186455, -115964993.2797253, 97236711.15602145, -43661946.33752821, 8477230.501135234, 52.5], [0.00220636496208, 111320.7020209128, 51751.86112841131, 3796837.749470245, 992013.7397791013, -1221952.21711287, 1340652.697009075, -620943.6990984312, 144416.9293806241, 37.5], [-0.0003441963504368392, 111320.7020576856, 278.2353980772752, 2485758.690035394, 6070.750963243378, 54821.18345352118, 9540.606633304236, -2710.55326746645, 1405.483844121726, 22.5], [-0.0003218135878613132, 111320.7020701615, 0.00369383431289, 823725.6402795718, 0.46104986909093, 2351.343141331292, 1.58060784298199, 8.77738589078284, 0.37238884252424, 7.45]],
5038
5039 convertMC2LL: function convertMC2LL(cB) {
5040 var cC = {
5041 x: Math.abs(cB.x),
5042 y: Math.abs(cB.y)
5043 };
5044 var cE = void 0;
5045 for (var cD = 0, len = this.MCBAND.length; cD < len; cD++) {
5046 if (cC.y >= this.MCBAND[cD]) {
5047 cE = this.MC2LL[cD];
5048 break;
5049 }
5050 }
5051 var T = this.convertor(cB, cE);
5052 var result = new Coordinate(T.x, T.y);
5053 return result;
5054 },
5055 convertLL2MC: function convertLL2MC(T) {
5056 var cD = void 0,
5057 cC = void 0,
5058 len = void 0;
5059 T.x = this.getLoop(T.x, -180, 180);
5060 T.y = this.getRange(T.y, -74, 74);
5061 var cB = new Coordinate(T.x, T.y);
5062 for (cC = 0, len = this.LLBAND.length; cC < len; cC++) {
5063 if (cB.y >= this.LLBAND[cC]) {
5064 cD = this.LL2MC[cC];
5065 break;
5066 }
5067 }
5068 if (!cD) {
5069 for (cC = this.LLBAND.length - 1; cC >= 0; cC--) {
5070 if (cB.y <= -this.LLBAND[cC]) {
5071 cD = this.LL2MC[cC];
5072 break;
5073 }
5074 }
5075 }
5076 var cE = this.convertor(T, cD);
5077 var result = new Coordinate(cE.x, cE.y);
5078 return result;
5079 },
5080 convertor: function convertor(cC, cD) {
5081 if (!cC || !cD) {
5082 return null;
5083 }
5084 var T = cD[0] + cD[1] * Math.abs(cC.x);
5085 var cB = Math.abs(cC.y) / cD[9];
5086 var cE = cD[2] + cD[3] * cB + cD[4] * cB * cB + cD[5] * cB * cB * cB + cD[6] * cB * cB * cB * cB + cD[7] * cB * cB * cB * cB * cB + cD[8] * cB * cB * cB * cB * cB * cB;
5087 T *= cC.x < 0 ? -1 : 1;
5088 cE *= cC.y < 0 ? -1 : 1;
5089 return new Coordinate(T, cE);
5090 },
5091 toRadians: function toRadians(T) {
5092 return Math.PI * T / 180;
5093 },
5094 toDegrees: function toDegrees(T) {
5095 return 180 * T / Math.PI;
5096 },
5097 getRange: function getRange(cC, cB, T) {
5098 if (cB != null) {
5099 cC = Math.max(cC, cB);
5100 }
5101 if (T != null) {
5102 cC = Math.min(cC, T);
5103 }
5104 return cC;
5105 },
5106 getLoop: function getLoop(cC, cB, T) {
5107 while (cC > T) {
5108 cC -= T - cB;
5109 }
5110 while (cC < cB) {
5111 cC += T - cB;
5112 }
5113 return cC;
5114 }
5115});
5116
5117var Projection_IDENTITY = extend({}, Common, {
5118 code: 'IDENTITY',
5119 project: function project(p) {
5120 return p.copy();
5121 },
5122 unproject: function unproject(p) {
5123 return p.copy();
5124 }
5125}, Identity);
5126
5127var DEFAULT = EPSG3857;
5128
5129var projections = Object.freeze({
5130 EPSG3857: EPSG3857,
5131 DEFAULT: DEFAULT,
5132 EPSG4326: PROJ4326,
5133 EPSG4490: Projection_EPSG4490,
5134 BAIDU: Projection_Baidu,
5135 IDENTITY: Projection_IDENTITY,
5136 Common: Common
5137});
5138
5139var Renderable = (function (Base) {
5140 return function (_Base) {
5141 inherits(_class, _Base);
5142
5143 function _class() {
5144 classCallCheck(this, _class);
5145 return possibleConstructorReturn(this, _Base.apply(this, arguments));
5146 }
5147
5148 _class.registerRenderer = function registerRenderer(name, clazz) {
5149 var proto = this.prototype;
5150 var parentProto = Object.getPrototypeOf(proto);
5151 if (!proto._rendererClasses || proto._rendererClasses === parentProto._rendererClasses) {
5152 proto._rendererClasses = proto._rendererClasses ? Object.create(proto._rendererClasses) : {};
5153 }
5154 proto._rendererClasses[name.toLowerCase()] = clazz;
5155 return this;
5156 };
5157
5158 _class.getRendererClass = function getRendererClass(name) {
5159 var proto = this.prototype;
5160 if (!proto._rendererClasses) {
5161 return null;
5162 }
5163 return proto._rendererClasses[name.toLowerCase()];
5164 };
5165
5166 return _class;
5167 }(Base);
5168});
5169
5170var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5171
5172
5173
5174
5175
5176function createCommonjsModule(fn, module) {
5177 return module = { exports: {} }, fn(module, module.exports), module.exports;
5178}
5179
5180var zousanMin = createCommonjsModule(function (module) {
5181 !function (t) {
5182 "use strict";
5183 function e(t) {
5184 if (t) {
5185 var e = this;t(function (t) {
5186 e.resolve(t);
5187 }, function (t) {
5188 e.reject(t);
5189 });
5190 }
5191 }function n(t, e) {
5192 if ("function" == typeof t.y) try {
5193 var n = t.y.call(i, e);t.p.resolve(n);
5194 } catch (o) {
5195 t.p.reject(o);
5196 } else t.p.resolve(e);
5197 }function o(t, e) {
5198 if ("function" == typeof t.n) try {
5199 var n = t.n.call(i, e);t.p.resolve(n);
5200 } catch (o) {
5201 t.p.reject(o);
5202 } else t.p.reject(e);
5203 }var r,
5204 i,
5205 c = "fulfilled",
5206 u = "rejected",
5207 s = "undefined",
5208 f = function () {
5209 function e() {
5210 for (; n.length - o;) {
5211 try {
5212 n[o]();
5213 } catch (e) {
5214 t.console && t.console.error(e);
5215 }n[o++] = i, o == r && (n.splice(0, r), o = 0);
5216 }
5217 }var n = [],
5218 o = 0,
5219 r = 1024,
5220 c = function () {
5221 if ((typeof MutationObserver === "undefined" ? "undefined" : _typeof(MutationObserver)) !== s) {
5222 var t = document.createElement("div"),
5223 n = new MutationObserver(e);return n.observe(t, { attributes: !0 }), function () {
5224 t.setAttribute("a", 0);
5225 };
5226 }return (typeof setImmediate === "undefined" ? "undefined" : _typeof(setImmediate)) !== s ? function () {
5227 setImmediate(e);
5228 } : function () {
5229 setTimeout(e, 0);
5230 };
5231 }();return function (t) {
5232 n.push(t), n.length - o == 1 && c();
5233 };
5234 }();e.prototype = { resolve: function resolve(t) {
5235 if (this.state === r) {
5236 if (t === this) return this.reject(new TypeError("Attempt to resolve promise with self"));var e = this;if (t && ("function" == typeof t || "object" == (typeof t === "undefined" ? "undefined" : _typeof(t)))) try {
5237 var o = !0,
5238 i = t.then;if ("function" == typeof i) return void i.call(t, function (t) {
5239 o && (o = !1, e.resolve(t));
5240 }, function (t) {
5241 o && (o = !1, e.reject(t));
5242 });
5243 } catch (u) {
5244 return void (o && this.reject(u));
5245 }this.state = c, this.v = t, e.c && f(function () {
5246 for (var o = 0, r = e.c.length; r > o; o++) {
5247 n(e.c[o], t);
5248 }
5249 });
5250 }
5251 }, reject: function reject(n) {
5252 if (this.state === r) {
5253 this.state = u, this.v = n;var i = this.c;i ? f(function () {
5254 for (var t = 0, e = i.length; e > t; t++) {
5255 o(i[t], n);
5256 }
5257 }) : !e.suppressUncaughtRejectionError && t.console && t.console.log("You upset Zousan. Please catch rejections: ", n, n ? n.stack : null);
5258 }
5259 }, then: function then(t, i) {
5260 var u = new e(),
5261 s = { y: t, n: i, p: u };if (this.state === r) this.c ? this.c.push(s) : this.c = [s];else {
5262 var l = this.state,
5263 a = this.v;f(function () {
5264 l === c ? n(s, a) : o(s, a);
5265 });
5266 }return u;
5267 }, "catch": function _catch(t) {
5268 return this.then(null, t);
5269 }, "finally": function _finally(t) {
5270 return this.then(t, t);
5271 }, timeout: function timeout(t, n) {
5272 n = n || "Timeout";var o = this;return new e(function (e, r) {
5273 setTimeout(function () {
5274 r(Error(n));
5275 }, t), o.then(function (t) {
5276 e(t);
5277 }, function (t) {
5278 r(t);
5279 });
5280 });
5281 } }, e.resolve = function (t) {
5282 var n = new e();return n.resolve(t), n;
5283 }, e.reject = function (t) {
5284 var n = new e();return n.reject(t), n;
5285 }, e.all = function (t) {
5286 function n(n, c) {
5287 n && "function" == typeof n.then || (n = e.resolve(n)), n.then(function (e) {
5288 o[c] = e, r++, r == t.length && i.resolve(o);
5289 }, function (t) {
5290 i.reject(t);
5291 });
5292 }for (var o = [], r = 0, i = new e(), c = 0; c < t.length; c++) {
5293 n(t[c], c);
5294 }return t.length || i.resolve(o), i;
5295 }, 'object' != s && module.exports && (module.exports = e), t.define && t.define.amd && t.define([], function () {
5296 return e;
5297 }), t.Zousan = e, e.soon = f;
5298 }("undefined" != typeof commonjsGlobal ? commonjsGlobal : commonjsGlobal);
5299});
5300
5301var promise = void 0;
5302
5303if (typeof Promise !== 'undefined') {
5304 promise = Promise;
5305} else {
5306 promise = zousanMin;
5307}
5308
5309var Promise$1 = promise;
5310
5311var CanvasRenderer = function (_Class) {
5312 inherits(CanvasRenderer, _Class);
5313
5314 function CanvasRenderer(layer) {
5315 classCallCheck(this, CanvasRenderer);
5316
5317 var _this = possibleConstructorReturn(this, _Class.call(this));
5318
5319 _this.layer = layer;
5320 _this._painted = false;
5321 _this._drawTime = 0;
5322 _this.setToRedraw();
5323 return _this;
5324 }
5325
5326 CanvasRenderer.prototype.render = function render(framestamp) {
5327 var _this2 = this;
5328
5329 this.prepareRender();
5330 if (!this.getMap() || !this.layer.isVisible()) {
5331 return;
5332 }
5333 if (!this.resources) {
5334 this.resources = new ResourceCache();
5335 }
5336 if (this.checkResources) {
5337 var resources = this.checkResources();
5338 if (resources.length > 0) {
5339 this._loadingResource = true;
5340 this.loadResources(resources).then(function () {
5341 _this2._loadingResource = false;
5342 if (_this2.layer) {
5343 _this2.layer.fire('resourceload');
5344 _this2.setToRedraw();
5345 }
5346 });
5347 } else {
5348 this._tryToDraw(framestamp);
5349 }
5350 } else {
5351 this._tryToDraw(framestamp);
5352 }
5353 };
5354
5355 CanvasRenderer.prototype.testIfNeedRedraw = function testIfNeedRedraw() {
5356 var map = this.getMap();
5357 if (this._loadingResource) {
5358 return false;
5359 }
5360 if (this._toRedraw) {
5361 return true;
5362 }
5363 if (map.isInteracting() && !this.drawOnInteracting) {
5364 return false;
5365 }
5366 if (this.needToRedraw()) {
5367 return true;
5368 }
5369 return false;
5370 };
5371
5372 CanvasRenderer.prototype.needToRedraw = function needToRedraw() {
5373 var map = this.getMap();
5374 if (map.isInteracting()) {
5375 return !(!map.getPitch() && map.isMoving() && !map.isZooming() && !map.isRotating() && !this.layer.options['forceRenderOnMoving']);
5376 }
5377 return false;
5378 };
5379
5380 CanvasRenderer.prototype.onSkipDrawOnInteracting = function onSkipDrawOnInteracting() {};
5381
5382 CanvasRenderer.prototype.isRenderComplete = function isRenderComplete() {
5383 return !!this._renderComplete;
5384 };
5385
5386 CanvasRenderer.prototype.mustRenderOnInteracting = function mustRenderOnInteracting() {
5387 return !this._painted || this.checkResources && this.checkResources().length > 0;
5388 };
5389
5390 CanvasRenderer.prototype.setToRedraw = function setToRedraw() {
5391 this._toRedraw = true;
5392 return this;
5393 };
5394
5395 CanvasRenderer.prototype.setCanvasUpdated = function setCanvasUpdated() {
5396 this._canvasUpdated = true;
5397 return this;
5398 };
5399
5400 CanvasRenderer.prototype.isCanvasUpdated = function isCanvasUpdated() {
5401 return !!this._canvasUpdated;
5402 };
5403
5404 CanvasRenderer.prototype.remove = function remove() {
5405 this.onRemove();
5406 delete this._loadingResource;
5407 delete this.southWest;
5408 delete this.canvas;
5409 delete this.context;
5410 delete this.canvasExtent2D;
5411 delete this._extent2D;
5412 delete this.resources;
5413 delete this.layer;
5414 };
5415
5416 CanvasRenderer.prototype.onRemove = function onRemove() {};
5417
5418 CanvasRenderer.prototype.onAdd = function onAdd() {};
5419
5420 CanvasRenderer.prototype.getMap = function getMap() {
5421 if (!this.layer) {
5422 return null;
5423 }
5424 return this.layer.getMap();
5425 };
5426
5427 CanvasRenderer.prototype.getCanvasImage = function getCanvasImage() {
5428 var map = this.getMap();
5429 this._canvasUpdated = false;
5430 if (this._renderZoom !== map.getZoom() || !this.canvas || !this._extent2D) {
5431 return null;
5432 }
5433 if (this.isBlank()) {
5434 return null;
5435 }
5436 if (this.layer.isEmpty && this.layer.isEmpty()) {
5437 return null;
5438 }
5439
5440 var containerPoint = map._pointToContainerPoint(this.southWest)._add(0, -map.height);
5441 return {
5442 'image': this.canvas,
5443 'layer': this.layer,
5444 'point': containerPoint };
5445 };
5446
5447 CanvasRenderer.prototype.clear = function clear() {
5448 this.clearCanvas();
5449 };
5450
5451 CanvasRenderer.prototype.isBlank = function isBlank() {
5452 if (!this._painted) {
5453 return true;
5454 }
5455 return false;
5456 };
5457
5458 CanvasRenderer.prototype.show = function show() {
5459 this.setToRedraw();
5460 };
5461
5462 CanvasRenderer.prototype.hide = function hide() {
5463 this.clear();
5464 this.setToRedraw();
5465 };
5466
5467 CanvasRenderer.prototype.setZIndex = function setZIndex() {
5468 this.setToRedraw();
5469 };
5470
5471 CanvasRenderer.prototype.hitDetect = function hitDetect(point) {
5472 if (!this.context || this.layer.isEmpty && this.layer.isEmpty() || this.isBlank() || this._errorThrown) {
5473 return false;
5474 }
5475 var map = this.getMap();
5476 var r = Browser$1.retina ? 2 : 1;
5477 var size = map.getSize();
5478 if (point.x < 0 || point.x > size['width'] * r || point.y < 0 || point.y > size['height'] * r) {
5479 return false;
5480 }
5481 try {
5482 var imgData = this.context.getImageData(r * point.x, r * point.y, 1, 1).data;
5483 if (imgData[3] > 0) {
5484 return true;
5485 }
5486 } catch (error) {
5487 if (!this._errorThrown) {
5488 if (console) {
5489 console.warn('hit detect failed with tainted canvas, some geometries have external resources in another domain:\n', error);
5490 }
5491 this._errorThrown = true;
5492 }
5493
5494 return false;
5495 }
5496 return false;
5497 };
5498
5499 CanvasRenderer.prototype.loadResources = function loadResources(resourceUrls) {
5500 if (!this.resources) {
5501 this.resources = new ResourceCache();
5502 }
5503 var resources = this.resources,
5504 promises = [];
5505 if (isArrayHasData(resourceUrls)) {
5506 var cache = {};
5507 for (var i = resourceUrls.length - 1; i >= 0; i--) {
5508 var url = resourceUrls[i];
5509 if (!url || !url.length || cache[url.join('-')]) {
5510 continue;
5511 }
5512 cache[url.join('-')] = 1;
5513 if (!resources.isResourceLoaded(url, true)) {
5514 promises.push(new Promise$1(this._promiseResource(url)));
5515 }
5516 }
5517 }
5518 return Promise$1.all(promises);
5519 };
5520
5521 CanvasRenderer.prototype.prepareRender = function prepareRender() {
5522 delete this._renderComplete;
5523 var map = this.getMap();
5524 this._renderZoom = map.getZoom();
5525 this.canvasExtent2D = this._extent2D = map._get2DExtent();
5526
5527 this.southWest = map._containerPointToPoint(new Point(0, map.height));
5528 };
5529
5530 CanvasRenderer.prototype.createCanvas = function createCanvas() {
5531 if (this.canvas) {
5532 return;
5533 }
5534 var map = this.getMap();
5535 var size = map.getSize();
5536 var r = Browser$1.retina ? 2 : 1,
5537 w = r * size.width,
5538 h = r * size.height;
5539 if (this.layer._canvas) {
5540 var canvas = this.layer._canvas;
5541 canvas.width = w;
5542 canvas.height = h;
5543 if (canvas.style) {
5544 canvas.style.width = size.width + 'px';
5545 canvas.style.height = size.height + 'px';
5546 }
5547 this.canvas = this.layer._canvas;
5548 } else {
5549 this.canvas = Canvas.createCanvas(w, h, map.CanvasClass);
5550 }
5551
5552 this.onCanvasCreate();
5553 };
5554
5555 CanvasRenderer.prototype.onCanvasCreate = function onCanvasCreate() {};
5556
5557 CanvasRenderer.prototype.createContext = function createContext() {
5558 if (this.gl && this.gl.canvas === this.canvas || this.context) {
5559 return;
5560 }
5561 this.context = this.canvas.getContext('2d');
5562 if (this.layer.options['globalCompositeOperation']) {
5563 this.context.globalCompositeOperation = this.layer.options['globalCompositeOperation'];
5564 }
5565 if (Browser$1.retina) {
5566 var r = 2;
5567 this.context.scale(r, r);
5568 }
5569 };
5570
5571 CanvasRenderer.prototype.resetCanvasTransform = function resetCanvasTransform() {
5572 if (!this.context) {
5573 return;
5574 }
5575 var r = Browser$1.retina ? 2 : 1;
5576 this.context.setTransform(r, 0, 0, r, 0, 0);
5577 };
5578
5579 CanvasRenderer.prototype.resizeCanvas = function resizeCanvas(canvasSize) {
5580 var canvas = this.canvas;
5581 if (!canvas) {
5582 return;
5583 }
5584 var size = canvasSize || this.getMap().getSize();
5585 var r = Browser$1.retina ? 2 : 1;
5586 if (canvas.width === r * size.width && canvas.height === r * size.height) {
5587 return;
5588 }
5589
5590 canvas.height = r * size.height;
5591 canvas.width = r * size.width;
5592 if (Browser$1.retina && this.context) {
5593 this.context.scale(r, r);
5594 }
5595 if (this.layer._canvas && canvas.style) {
5596 canvas.style.width = size.width + 'px';
5597 canvas.style.height = size.height + 'px';
5598 }
5599 };
5600
5601 CanvasRenderer.prototype.clearCanvas = function clearCanvas() {
5602 if (!this.context) {
5603 return;
5604 }
5605 Canvas.clearRect(this.context, 0, 0, this.canvas.width, this.canvas.height);
5606 };
5607
5608 CanvasRenderer.prototype.prepareCanvas = function prepareCanvas() {
5609 if (!this.canvas) {
5610 this.createCanvas();
5611 this.createContext();
5612
5613 this.layer.fire('canvascreate', {
5614 'context': this.context,
5615 'gl': this.gl
5616 });
5617 } else {
5618 this.clearCanvas();
5619 this.resizeCanvas();
5620 this.resetCanvasTransform();
5621 }
5622 delete this._maskExtent;
5623 var mask = this.layer.getMask();
5624
5625 if (!mask) {
5626 this.layer.fire('renderstart', {
5627 'context': this.context,
5628 'gl': this.gl
5629 });
5630 return null;
5631 }
5632 var maskExtent2D = this._maskExtent = mask._getPainter().get2DExtent();
5633 if (!maskExtent2D.intersects(this._extent2D)) {
5634 this.layer.fire('renderstart', {
5635 'context': this.context,
5636 'gl': this.gl
5637 });
5638 return maskExtent2D;
5639 }
5640
5641 this.layer.fire('renderstart', {
5642 'context': this.context,
5643 'gl': this.gl
5644 });
5645 return maskExtent2D;
5646 };
5647
5648 CanvasRenderer.prototype.clipCanvas = function clipCanvas(context) {
5649 var mask = this.layer.getMask();
5650 if (!mask) {
5651 return false;
5652 }
5653 var old = this.southWest;
5654 var map = this.getMap();
5655
5656 this.southWest = map._containerPointToPoint(new Point(0, map.height));
5657 context.save();
5658 if (Browser$1.retina) {
5659 context.save();
5660 context.scale(2, 2);
5661 }
5662 mask._getPainter().paint(null, context);
5663 if (Browser$1.retina) {
5664 context.restore();
5665 }
5666 context.clip();
5667 this.southWest = old;
5668 return true;
5669 };
5670
5671 CanvasRenderer.prototype.getViewExtent = function getViewExtent() {
5672 return {
5673 'extent': this._extent2D,
5674 'maskExtent': this._maskExtent,
5675 'zoom': this._renderZoom,
5676 'southWest': this.southWest
5677 };
5678 };
5679
5680 CanvasRenderer.prototype.completeRender = function completeRender() {
5681 if (this.getMap()) {
5682 this._renderComplete = true;
5683
5684 this.layer.fire('renderend', {
5685 'context': this.context,
5686 'gl': this.gl
5687 });
5688 this.setCanvasUpdated();
5689 }
5690 };
5691
5692 CanvasRenderer.prototype.getEvents = function getEvents() {
5693 return {
5694 '_zoomstart': this.onZoomStart,
5695 '_zooming': this.onZooming,
5696 '_zoomend': this.onZoomEnd,
5697 '_resize': this.onResize,
5698 '_movestart': this.onMoveStart,
5699 '_moving': this.onMoving,
5700 '_moveend': this.onMoveEnd,
5701 '_dragrotatestart': this.onDragRotateStart,
5702 '_dragrotating': this.onDragRotating,
5703 '_dragrotateend': this.onDragRotateEnd,
5704 '_spatialreferencechange': this.onSpatialReferenceChange
5705 };
5706 };
5707
5708 CanvasRenderer.prototype.onZoomStart = function onZoomStart() {};
5709
5710 CanvasRenderer.prototype.onZoomEnd = function onZoomEnd() {
5711 this.setToRedraw();
5712 };
5713
5714 CanvasRenderer.prototype.onZooming = function onZooming() {};
5715
5716 CanvasRenderer.prototype.onMoveStart = function onMoveStart() {};
5717
5718 CanvasRenderer.prototype.onMoving = function onMoving() {};
5719
5720 CanvasRenderer.prototype.onMoveEnd = function onMoveEnd() {
5721 this.setToRedraw();
5722 };
5723
5724 CanvasRenderer.prototype.onResize = function onResize() {
5725 delete this._extent2D;
5726 this.resizeCanvas();
5727 this.setToRedraw();
5728 };
5729
5730 CanvasRenderer.prototype.onDragRotateStart = function onDragRotateStart() {};
5731
5732 CanvasRenderer.prototype.onDragRotating = function onDragRotating() {};
5733
5734 CanvasRenderer.prototype.onDragRotateEnd = function onDragRotateEnd() {
5735 this.setToRedraw();
5736 };
5737
5738 CanvasRenderer.prototype.onSpatialReferenceChange = function onSpatialReferenceChange() {};
5739
5740 CanvasRenderer.prototype.getDrawTime = function getDrawTime() {
5741 return this._drawTime;
5742 };
5743
5744 CanvasRenderer.prototype._tryToDraw = function _tryToDraw(framestamp) {
5745 this._toRedraw = false;
5746 if (!this.canvas && this.layer.isEmpty && this.layer.isEmpty()) {
5747 this._renderComplete = true;
5748
5749 return;
5750 }
5751 this._drawAndRecord(framestamp);
5752 };
5753
5754 CanvasRenderer.prototype._drawAndRecord = function _drawAndRecord(framestamp) {
5755 if (!this.getMap()) {
5756 return;
5757 }
5758 var painted = this._painted;
5759 this._painted = true;
5760 var t = now();
5761 this.draw(framestamp);
5762 t = now() - t;
5763
5764 this._drawTime = painted ? t : t / 2;
5765 if (painted && this.layer.options['logDrawTime']) {
5766 console.log(this.layer.getId(), 'frameTimeStamp:', framestamp, 'drawTime:', this._drawTime);
5767 }
5768 };
5769
5770 CanvasRenderer.prototype._promiseResource = function _promiseResource(url) {
5771 var me = this,
5772 resources = this.resources,
5773 crossOrigin = this.layer.options['crossOrigin'];
5774 return function (resolve) {
5775 if (resources.isResourceLoaded(url, true)) {
5776 resolve(url);
5777 return;
5778 }
5779 var img = new Image();
5780 if (!isNil(crossOrigin)) {
5781 img['crossOrigin'] = crossOrigin;
5782 }
5783 if (isSVG(url[0]) && !IS_NODE) {
5784 if (url[1]) {
5785 url[1] *= 2;
5786 }
5787 if (url[2]) {
5788 url[2] *= 2;
5789 }
5790 }
5791 img.onload = function () {
5792 me._cacheResource(url, img);
5793 resolve(url);
5794 };
5795 img.onabort = function (err) {
5796 if (console) {
5797 console.warn('image loading aborted: ' + url[0]);
5798 }
5799 if (err) {
5800 if (console) {
5801 console.warn(err);
5802 }
5803 }
5804 resolve(url);
5805 };
5806 img.onerror = function (err) {
5807 if (err && typeof console !== 'undefined') {
5808 console.warn(err);
5809 }
5810 resources.markErrorResource(url);
5811 resolve(url);
5812 };
5813 loadImage(img, url);
5814 };
5815 };
5816
5817 CanvasRenderer.prototype._cacheResource = function _cacheResource(url, img) {
5818 if (!this.layer || !this.resources) {
5819 return;
5820 }
5821 var w = url[1],
5822 h = url[2];
5823 if (this.layer.options['cacheSvgOnCanvas'] && isSVG(url[0]) === 1 && (Browser$1.edge || Browser$1.ie)) {
5824 if (isNil(w)) {
5825 w = img.width || this.layer.options['defaultIconSize'][0];
5826 }
5827 if (isNil(h)) {
5828 h = img.height || this.layer.options['defaultIconSize'][1];
5829 }
5830 var canvas = Canvas.createCanvas(w, h);
5831 Canvas.image(canvas.getContext('2d'), img, 0, 0, w, h);
5832 img = canvas;
5833 }
5834 this.resources.addResource(url, img);
5835 };
5836
5837 return CanvasRenderer;
5838}(Class);
5839
5840var ResourceCache = function () {
5841 function ResourceCache() {
5842 classCallCheck(this, ResourceCache);
5843
5844 this.resources = {};
5845 this._errors = {};
5846 }
5847
5848 ResourceCache.prototype.addResource = function addResource(url, img) {
5849 this.resources[url[0]] = {
5850 image: img,
5851 width: +url[1],
5852 height: +url[2]
5853 };
5854 };
5855
5856 ResourceCache.prototype.isResourceLoaded = function isResourceLoaded(url, checkSVG) {
5857 if (!url) {
5858 return false;
5859 }
5860 var imgUrl = this._getImgUrl(url);
5861 if (this._errors[imgUrl]) {
5862 return true;
5863 }
5864 var img = this.resources[imgUrl];
5865 if (!img) {
5866 return false;
5867 }
5868 if (checkSVG && isSVG(url[0]) && (+url[1] > img.width || +url[2] > img.height)) {
5869 return false;
5870 }
5871 return true;
5872 };
5873
5874 ResourceCache.prototype.getImage = function getImage(url) {
5875 var imgUrl = this._getImgUrl(url);
5876 if (!this.isResourceLoaded(url) || this._errors[imgUrl]) {
5877 return null;
5878 }
5879 return this.resources[imgUrl].image;
5880 };
5881
5882 ResourceCache.prototype.markErrorResource = function markErrorResource(url) {
5883 this._errors[this._getImgUrl(url)] = 1;
5884 };
5885
5886 ResourceCache.prototype.merge = function merge(res) {
5887 if (!res) {
5888 return this;
5889 }
5890 for (var p in res.resources) {
5891 var img = res.resources[p];
5892 this.addResource([p, img.width, img.height], img.image);
5893 }
5894 return this;
5895 };
5896
5897 ResourceCache.prototype.forEach = function forEach(fn) {
5898 if (!this.resources) {
5899 return this;
5900 }
5901 for (var p in this.resources) {
5902 if (hasOwn(this.resources, p)) {
5903 fn(p, this.resources[p]);
5904 }
5905 }
5906 return this;
5907 };
5908
5909 ResourceCache.prototype._getImgUrl = function _getImgUrl(url) {
5910 if (!Array.isArray(url)) {
5911 return url;
5912 }
5913 return url[0];
5914 };
5915
5916 return ResourceCache;
5917}();
5918
5919var options$1 = {
5920 'attribution': null,
5921 'minZoom': null,
5922 'maxZoom': null,
5923 'visible': true,
5924 'opacity': 1,
5925
5926 'globalCompositeOperation': null,
5927 'renderer': 'canvas',
5928 'debugOutline': '#0f0',
5929 'cssFilter': null,
5930 'forceRenderOnMoving': false,
5931 'forceRenderOnZooming': false,
5932 'forceRenderOnRotating': false
5933};
5934
5935var Layer = function (_JSONAble) {
5936 inherits(Layer, _JSONAble);
5937
5938 function Layer(id, options) {
5939 classCallCheck(this, Layer);
5940
5941 var canvas = void 0;
5942 if (options) {
5943 canvas = options.canvas;
5944 delete options.canvas;
5945 }
5946
5947 var _this = possibleConstructorReturn(this, _JSONAble.call(this, options));
5948
5949 if (canvas) {
5950 _this._canvas = canvas;
5951 }
5952 _this.setId(id);
5953 if (options) {
5954 _this.setZIndex(options.zIndex);
5955 }
5956 return _this;
5957 }
5958
5959 Layer.prototype.load = function load() {
5960 if (!this.getMap()) {
5961 return this;
5962 }
5963 if (this.onLoad()) {
5964 this._initRenderer();
5965 var zIndex = this.getZIndex();
5966 if (!isNil(zIndex)) {
5967 this._renderer.setZIndex(zIndex);
5968 if (!this.isCanvasRender()) {
5969 this._renderer.render();
5970 }
5971 }
5972 this.onLoadEnd();
5973 }
5974 return this;
5975 };
5976
5977 Layer.prototype.getId = function getId() {
5978 return this._id;
5979 };
5980
5981 Layer.prototype.setId = function setId(id) {
5982 var old = this._id;
5983 if (!isNil(id)) {
5984 id = id + '';
5985 }
5986 this._id = id;
5987
5988 this.fire('idchange', {
5989 'old': old,
5990 'new': id
5991 });
5992 return this;
5993 };
5994
5995 Layer.prototype.addTo = function addTo(map) {
5996 map.addLayer(this);
5997 return this;
5998 };
5999
6000 Layer.prototype.setZIndex = function setZIndex(zIndex) {
6001 this._zIndex = zIndex;
6002 if (this.map) {
6003 this.map._sortLayersByZIndex();
6004 }
6005 if (this._renderer) {
6006 this._renderer.setZIndex(zIndex);
6007 }
6008 return this;
6009 };
6010
6011 Layer.prototype.getZIndex = function getZIndex() {
6012 return this._zIndex || 0;
6013 };
6014
6015 Layer.prototype.getMinZoom = function getMinZoom() {
6016 var map = this.getMap();
6017 var minZoom = this.options['minZoom'];
6018 return map ? Math.max(map.getMinZoom(), minZoom || 0) : minZoom;
6019 };
6020
6021 Layer.prototype.getMaxZoom = function getMaxZoom() {
6022 var map = this.getMap();
6023 var maxZoom = this.options['maxZoom'];
6024 return map ? Math.min(map.getMaxZoom(), isNil(maxZoom) ? Infinity : maxZoom) : maxZoom;
6025 };
6026
6027 Layer.prototype.getOpacity = function getOpacity() {
6028 return this.options['opacity'];
6029 };
6030
6031 Layer.prototype.setOpacity = function setOpacity(op) {
6032 this.config('opacity', op);
6033 return this;
6034 };
6035
6036 Layer.prototype.isCanvasRender = function isCanvasRender() {
6037 var renderer = this._getRenderer();
6038 return renderer && renderer instanceof CanvasRenderer;
6039 };
6040
6041 Layer.prototype.getMap = function getMap() {
6042 if (this.map) {
6043 return this.map;
6044 }
6045 return null;
6046 };
6047
6048 Layer.prototype.getProjection = function getProjection() {
6049 var map = this.getMap();
6050 return map ? map.getProjection() : null;
6051 };
6052
6053 Layer.prototype.bringToFront = function bringToFront() {
6054 var layers = this._getLayerList();
6055 if (!layers.length) {
6056 return this;
6057 }
6058 var topLayer = layers[layers.length - 1];
6059 if (layers.length === 1 || topLayer === this) {
6060 return this;
6061 }
6062 var max = topLayer.getZIndex();
6063 this.setZIndex(max + 1);
6064 return this;
6065 };
6066
6067 Layer.prototype.bringToBack = function bringToBack() {
6068 var layers = this._getLayerList();
6069 if (!layers.length) {
6070 return this;
6071 }
6072 var bottomLayer = layers[0];
6073 if (layers.length === 1 || bottomLayer === this) {
6074 return this;
6075 }
6076 var min = bottomLayer.getZIndex();
6077 this.setZIndex(min - 1);
6078 return this;
6079 };
6080
6081 Layer.prototype.show = function show() {
6082 var _this2 = this;
6083
6084 if (!this.options['visible']) {
6085 this.options['visible'] = true;
6086 var renderer = this.getRenderer();
6087 if (renderer) {
6088 renderer.show();
6089 }
6090
6091 var map = this.getMap();
6092 if (renderer && map) {
6093 map.once('renderend', function () {
6094 _this2.fire('show');
6095 });
6096 } else {
6097 this.fire('show');
6098 }
6099 }
6100 return this;
6101 };
6102
6103 Layer.prototype.hide = function hide() {
6104 var _this3 = this;
6105
6106 if (this.options['visible']) {
6107 this.options['visible'] = false;
6108 var renderer = this.getRenderer();
6109 if (renderer) {
6110 renderer.hide();
6111 }
6112
6113 var map = this.getMap();
6114 if (renderer && map) {
6115 map.once('renderend', function () {
6116 _this3.fire('hide');
6117 });
6118 } else {
6119 this.fire('hide');
6120 }
6121 }
6122
6123 return this;
6124 };
6125
6126 Layer.prototype.isVisible = function isVisible() {
6127 if (isNumber(this.options['opacity']) && this.options['opacity'] <= 0) {
6128 return false;
6129 }
6130 var map = this.getMap();
6131 if (map) {
6132 var zoom = map.getZoom();
6133 if (!isNil(this.options['maxZoom']) && this.options['maxZoom'] < zoom || !isNil(this.options['minZoom']) && this.options['minZoom'] > zoom) {
6134 return false;
6135 }
6136 }
6137
6138 if (isNil(this.options['visible'])) {
6139 this.options['visible'] = true;
6140 }
6141 return this.options['visible'];
6142 };
6143
6144 Layer.prototype.remove = function remove() {
6145 if (this.map) {
6146 this.map.removeLayer(this);
6147 }
6148 return this;
6149 };
6150
6151 Layer.prototype.getMask = function getMask() {
6152 return this._mask;
6153 };
6154
6155 Layer.prototype.setMask = function setMask(mask) {
6156 if (!(mask.type === 'Point' && mask._isVectorMarker() || mask.type === 'Polygon')) {
6157 throw new Error('Mask for a layer must be a marker with vector marker symbol or a Polygon.');
6158 }
6159
6160 if (mask.type === 'Point') {
6161 mask.updateSymbol({
6162 'markerLineColor': 'rgba(0, 0, 0, 0)',
6163 'markerFillOpacity': 0
6164 });
6165 } else {
6166 mask.setSymbol({
6167 'lineColor': 'rgba(0, 0, 0, 0)',
6168 'polygonOpacity': 0
6169 });
6170 }
6171 mask._bindLayer(this);
6172 this._mask = mask;
6173 if (!this.getMap() || this.getMap().isZooming()) {
6174 return this;
6175 }
6176 var renderer = this._getRenderer();
6177 if (renderer && renderer.setToRedraw) {
6178 this._getRenderer().setToRedraw();
6179 }
6180 return this;
6181 };
6182
6183 Layer.prototype.removeMask = function removeMask() {
6184 delete this._mask;
6185 if (!this.getMap() || this.getMap().isZooming()) {
6186 return this;
6187 }
6188 var renderer = this._getRenderer();
6189 if (renderer && renderer.setToRedraw) {
6190 this._getRenderer().setToRedraw();
6191 }
6192 return this;
6193 };
6194
6195 Layer.prototype.onLoad = function onLoad() {
6196 return true;
6197 };
6198
6199 Layer.prototype.onLoadEnd = function onLoadEnd() {};
6200
6201 Layer.prototype.isLoaded = function isLoaded() {
6202 return !!this._loaded;
6203 };
6204
6205 Layer.prototype.getRenderer = function getRenderer() {
6206 return this._getRenderer();
6207 };
6208
6209 Layer.prototype.onConfig = function onConfig(conf) {
6210 if (isNumber(conf['opacity']) || conf['cssFilter']) {
6211 var renderer = this.getRenderer();
6212 if (renderer) {
6213 renderer.setToRedraw();
6214 }
6215 }
6216 };
6217
6218 Layer.prototype.onAdd = function onAdd() {};
6219
6220 Layer.prototype.onRemove = function onRemove() {};
6221
6222 Layer.prototype._bindMap = function _bindMap(map, zIndex) {
6223 if (!map) {
6224 return;
6225 }
6226 this.map = map;
6227 if (!isNil(zIndex)) {
6228 this.setZIndex(zIndex);
6229 }
6230 this._switchEvents('on', this);
6231
6232 this.onAdd();
6233
6234 this.fire('add');
6235 };
6236
6237 Layer.prototype._initRenderer = function _initRenderer() {
6238 var renderer = this.options['renderer'];
6239 if (!this.constructor.getRendererClass) {
6240 return;
6241 }
6242 var clazz = this.constructor.getRendererClass(renderer);
6243 if (!clazz) {
6244 throw new Error('Invalid renderer for Layer(' + this.getId() + '):' + renderer);
6245 }
6246 this._renderer = new clazz(this);
6247 this._renderer.layer = this;
6248 this._renderer.setZIndex(this.getZIndex());
6249 this._switchEvents('on', this._renderer);
6250
6251 if (this._renderer.onAdd) {
6252 this._renderer.onAdd();
6253 }
6254
6255 this.fire('renderercreate', {
6256 'renderer': this._renderer
6257 });
6258 };
6259
6260 Layer.prototype._doRemove = function _doRemove() {
6261 this._loaded = false;
6262 this.onRemove();
6263
6264 this._switchEvents('off', this);
6265 if (this._renderer) {
6266 this._switchEvents('off', this._renderer);
6267 this._renderer.remove();
6268 delete this._renderer;
6269 }
6270 delete this._mask;
6271 delete this.map;
6272 };
6273
6274 Layer.prototype._switchEvents = function _switchEvents(to, emitter) {
6275 if (emitter && emitter.getEvents) {
6276 this.getMap()[to](emitter.getEvents(), emitter);
6277 }
6278 };
6279
6280 Layer.prototype._getRenderer = function _getRenderer() {
6281 return this._renderer;
6282 };
6283
6284 Layer.prototype._getLayerList = function _getLayerList() {
6285 if (!this.map) {
6286 return [];
6287 }
6288 return this.map._layers;
6289 };
6290
6291 Layer.prototype._getMask2DExtent = function _getMask2DExtent() {
6292 if (!this._mask || !this.getMap()) {
6293 return null;
6294 }
6295 var painter = this._mask._getPainter();
6296 if (!painter) {
6297 return null;
6298 }
6299 return painter.get2DExtent();
6300 };
6301
6302 return Layer;
6303}(JSONAble(Eventable(Renderable(Class))));
6304
6305Layer.mergeOptions(options$1);
6306
6307var fire = Layer.prototype.fire;
6308
6309Layer.prototype.fire = function (eventType, param) {
6310 if (eventType === 'layerload') {
6311 this._loaded = true;
6312 }
6313 if (this.map) {
6314 if (!param) {
6315 param = {};
6316 }
6317 param['type'] = eventType;
6318 param['target'] = this;
6319 this.map._onLayerEvent(param);
6320 }
6321 return fire.apply(this, arguments);
6322};
6323
6324var DefaultSpatialRef = {
6325 'EPSG:3857': {
6326 'resolutions': function () {
6327 var resolutions = [];
6328 var d = 2 * 6378137 * Math.PI;
6329 for (var i = 0; i < 21; i++) {
6330 resolutions[i] = d / (256 * Math.pow(2, i));
6331 }
6332 return resolutions;
6333 }(),
6334 'fullExtent': {
6335 'top': 6378137 * Math.PI,
6336 'left': -6378137 * Math.PI,
6337 'bottom': -6378137 * Math.PI,
6338 'right': 6378137 * Math.PI
6339 }
6340 },
6341 'EPSG:4326': {
6342 'fullExtent': {
6343 'top': 90,
6344 'left': -180,
6345 'bottom': -90,
6346 'right': 180
6347 },
6348 'resolutions': function () {
6349 var resolutions = [];
6350 for (var i = 0; i < 20; i++) {
6351 resolutions[i] = 180 / (Math.pow(2, i) * 128);
6352 }
6353 return resolutions;
6354 }()
6355 },
6356 'BAIDU': {
6357 'resolutions': function () {
6358 var res = Math.pow(2, 18);
6359 var resolutions = [];
6360 for (var i = 0; i < 20; i++) {
6361 resolutions[i] = res;
6362 res *= 0.5;
6363 }
6364 resolutions[0] = null;
6365 resolutions[1] = null;
6366 resolutions[2] = null;
6367 return resolutions;
6368 }(),
6369 'fullExtent': {
6370 'top': 33554432,
6371 'left': -33554432,
6372 'bottom': -33554432,
6373 'right': 33554432
6374 }
6375 },
6376 'IDENTITY': {
6377 'resolutions': function () {
6378 var res = Math.pow(2, 8);
6379 var resolutions = [];
6380 for (var i = 0; i < 18; i++) {
6381 resolutions[i] = res;
6382 res *= 0.5;
6383 }
6384 return resolutions;
6385 }(),
6386 'fullExtent': {
6387 'top': 200000,
6388 'left': -200000,
6389 'bottom': -200000,
6390 'right': 200000
6391 }
6392 }
6393};
6394
6395DefaultSpatialRef['EPSG:4490'] = DefaultSpatialRef['EPSG:4326'];
6396
6397var SpatialReference = function () {
6398 function SpatialReference() {
6399 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6400 classCallCheck(this, SpatialReference);
6401
6402 this.options = options;
6403 this._initSpatialRef();
6404 }
6405
6406 SpatialReference.getProjectionInstance = function getProjectionInstance(prjName) {
6407 if (!prjName) {
6408 return null;
6409 }
6410 if (isObject(prjName)) {
6411 return prjName;
6412 }
6413 prjName = (prjName + '').toLowerCase();
6414 for (var p in projections) {
6415 if (hasOwn(projections, p)) {
6416 var code = projections[p]['code'];
6417 if (code && code.toLowerCase() === prjName) {
6418 return projections[p];
6419 }
6420 }
6421 }
6422 return null;
6423 };
6424
6425 SpatialReference.equals = function equals(sp1, sp2) {
6426 if (!sp1 && !sp2) {
6427 return true;
6428 } else if (!sp1 || !sp2) {
6429 return false;
6430 }
6431 if (sp1.projection !== sp2.projection) {
6432 return false;
6433 }
6434 var f1 = sp1.fullExtent,
6435 f2 = sp2.fullExtent;
6436 if (f1 && f2) {
6437 if (f1.top !== f2.top || f1.bottom !== f2.bottom || f1.left !== f2.left || f1.right !== f2.right) {
6438 return false;
6439 }
6440 }
6441 var r1 = sp1.resolutions,
6442 r2 = sp2.resolutions;
6443 if (r1 && r2) {
6444 if (r1.length !== r2.length) {
6445 return false;
6446 }
6447 for (var i = 0; i < r1.length; i++) {
6448 if (r1[i] !== r2[i]) {
6449 return false;
6450 }
6451 }
6452 }
6453 return true;
6454 };
6455
6456 SpatialReference.prototype._initSpatialRef = function _initSpatialRef() {
6457 var projection = this.options['projection'];
6458 if (projection) {
6459 projection = SpatialReference.getProjectionInstance(projection);
6460 } else {
6461 projection = DEFAULT;
6462 }
6463 if (!projection) {
6464 throw new Error('must provide a valid projection in map\'s spatial reference.');
6465 }
6466 projection = extend({}, Common, projection);
6467 if (!projection.measureLength) {
6468 extend(projection, Measurer.DEFAULT);
6469 }
6470 this._projection = projection;
6471 var defaultSpatialRef = void 0,
6472 resolutions = this.options['resolutions'];
6473 if (!resolutions) {
6474 if (projection['code']) {
6475 defaultSpatialRef = DefaultSpatialRef[projection['code']];
6476 if (defaultSpatialRef) {
6477 resolutions = defaultSpatialRef['resolutions'];
6478 }
6479 }
6480 if (!resolutions) {
6481 throw new Error('must provide valid resolutions in map\'s spatial reference.');
6482 }
6483 }
6484 this._resolutions = resolutions;
6485 var fullExtent = this.options['fullExtent'];
6486 if (!fullExtent) {
6487 if (projection['code']) {
6488 defaultSpatialRef = DefaultSpatialRef[projection['code']];
6489 if (defaultSpatialRef) {
6490 fullExtent = defaultSpatialRef['fullExtent'];
6491 }
6492 }
6493 if (!fullExtent) {
6494 throw new Error('must provide a valid fullExtent in map\'s spatial reference.');
6495 }
6496 }
6497 if (!isNil(fullExtent['left'])) {
6498 this._fullExtent = new Extent(new Coordinate(fullExtent['left'], fullExtent['top']), new Coordinate(fullExtent['right'], fullExtent['bottom']));
6499 } else {
6500 this._fullExtent = new Extent(fullExtent);
6501 fullExtent['left'] = fullExtent['xmin'];
6502 fullExtent['right'] = fullExtent['xmax'];
6503 fullExtent['top'] = fullExtent['ymax'];
6504 fullExtent['bottom'] = fullExtent['ymin'];
6505 }
6506
6507 if (isNil(fullExtent['top']) || isNil(fullExtent['bottom']) || isNil(fullExtent['left']) || isNil(fullExtent['right'])) {
6508 throw new Error('must provide valid top/bottom/left/right in fullExtent.');
6509 }
6510
6511 extend(this._fullExtent, fullExtent);
6512
6513 this._projection.fullExtent = fullExtent;
6514
6515 var a = fullExtent['right'] >= fullExtent['left'] ? 1 : -1,
6516 b = fullExtent['top'] >= fullExtent['bottom'] ? -1 : 1;
6517 this._transformation = new Transformation([a, b, 0, 0]);
6518 };
6519
6520 SpatialReference.prototype.getResolutions = function getResolutions() {
6521 return this._resolutions || [];
6522 };
6523
6524 SpatialReference.prototype.getResolution = function getResolution(zoom) {
6525 var z = zoom | 0;
6526 if (z < 0) {
6527 z = 0;
6528 } else if (z > this._resolutions.length - 1) {
6529 z = this._resolutions.length - 1;
6530 }
6531 var res = this._resolutions[z];
6532 if (!isInteger(zoom) && z !== this._resolutions.length - 1) {
6533 var next = this._resolutions[z + 1];
6534 return res + (next - res) * (zoom - z);
6535 }
6536 return res;
6537 };
6538
6539 SpatialReference.prototype.getProjection = function getProjection() {
6540 return this._projection;
6541 };
6542
6543 SpatialReference.prototype.getFullExtent = function getFullExtent() {
6544 return this._fullExtent;
6545 };
6546
6547 SpatialReference.prototype.getTransformation = function getTransformation() {
6548 return this._transformation;
6549 };
6550
6551 SpatialReference.prototype.getMinZoom = function getMinZoom() {
6552 for (var i = 0; i < this._resolutions.length; i++) {
6553 if (!isNil(this._resolutions[i])) {
6554 return i;
6555 }
6556 }
6557 return 0;
6558 };
6559
6560 SpatialReference.prototype.getMaxZoom = function getMaxZoom() {
6561 for (var i = this._resolutions.length - 1; i >= 0; i--) {
6562 if (!isNil(this._resolutions[i])) {
6563 return i;
6564 }
6565 }
6566 return this._resolutions.length - 1;
6567 };
6568
6569 SpatialReference.prototype.getZoomDirection = function getZoomDirection() {
6570 return sign(this._resolutions[this.getMinZoom()] - this._resolutions[this.getMaxZoom()]);
6571 };
6572
6573 SpatialReference.prototype.toJSON = function toJSON() {
6574 if (!this.json) {
6575 this.json = {
6576 'resolutions': this._resolutions,
6577 'fullExtent': {
6578 'top': this._fullExtent.top,
6579 'left': this._fullExtent.left,
6580 'bottom': this._fullExtent.bottom,
6581 'right': this._fullExtent.right
6582 },
6583 'projection': this._projection.code
6584 };
6585 }
6586 return this.json;
6587 };
6588
6589 return SpatialReference;
6590}();
6591
6592var options = {
6593 'maxVisualPitch': 60,
6594 'maxPitch': 80,
6595 'centerCross': false,
6596
6597 'zoomInCenter': false,
6598 'zoomAnimation': function () {
6599 return !IS_NODE;
6600 }(),
6601 'zoomAnimationDuration': 330,
6602
6603 'panAnimation': function () {
6604 return !IS_NODE;
6605 }(),
6606
6607 'panAnimationDuration': 600,
6608
6609 'zoomable': true,
6610 'enableInfoWindow': true,
6611
6612 'hitDetect': function () {
6613 return !Browser$1.mobile;
6614 }(),
6615
6616 'hitDetectLimit': 5,
6617
6618 'fpsOnInteracting': 25,
6619
6620 'layerCanvasLimitOnInteracting': -1,
6621
6622 'maxZoom': null,
6623 'minZoom': null,
6624 'maxExtent': null,
6625
6626 'checkSize': true,
6627
6628 'renderer': 'canvas'
6629};
6630
6631var Map = function (_Handlerable) {
6632 inherits(Map, _Handlerable);
6633
6634 function Map(container, options) {
6635 classCallCheck(this, Map);
6636
6637 if (!options) {
6638 throw new Error('Invalid options when creating map.');
6639 }
6640 if (!options['center']) {
6641 throw new Error('Invalid center when creating map.');
6642 }
6643
6644 var opts = extend({}, options);
6645 var zoom = opts['zoom'];
6646 delete opts['zoom'];
6647 var center = new Coordinate(opts['center']);
6648 delete opts['center'];
6649
6650 var baseLayer = opts['baseLayer'];
6651 delete opts['baseLayer'];
6652 var layers = opts['layers'];
6653 delete opts['layers'];
6654
6655 var _this = possibleConstructorReturn(this, _Handlerable.call(this, opts));
6656
6657 Object.defineProperty(_this, 'id', {
6658 value: UID(),
6659 writable: false
6660 });
6661
6662 _this._loaded = false;
6663 _this._initContainer(container);
6664
6665 _this._panels = {};
6666
6667 _this._baseLayer = null;
6668 _this._layers = [];
6669
6670 _this._zoomLevel = zoom;
6671 _this._center = center;
6672
6673 _this.setSpatialReference(opts['spatialReference'] || opts['view']);
6674
6675 _this._mapViewPoint = new Point(0, 0);
6676
6677 _this._initRenderer();
6678 _this._updateMapSize(_this._getContainerDomSize());
6679
6680 if (baseLayer) {
6681 _this.setBaseLayer(baseLayer);
6682 }
6683 if (layers) {
6684 _this.addLayer(layers);
6685 }
6686
6687 _this._Load();
6688 return _this;
6689 }
6690
6691 Map.addOnLoadHook = function addOnLoadHook(fn) {
6692 var args = Array.prototype.slice.call(arguments, 1);
6693 var onload = typeof fn === 'function' ? fn : function () {
6694 this[fn].apply(this, args);
6695 };
6696 this.prototype._onLoadHooks = this.prototype._onLoadHooks || [];
6697 this.prototype._onLoadHooks.push(onload);
6698 return this;
6699 };
6700
6701 Map.prototype.isLoaded = function isLoaded() {
6702 return !!this._loaded;
6703 };
6704
6705 Map.prototype.getContainer = function getContainer() {
6706 return this._containerDOM;
6707 };
6708
6709 Map.prototype.getSpatialReference = function getSpatialReference() {
6710 return this._spatialReference;
6711 };
6712
6713 Map.prototype.setSpatialReference = function setSpatialReference(ref) {
6714 var oldRef = this.options['spatialReference'];
6715 if (this._loaded && SpatialReference.equals(oldRef, ref)) {
6716 return this;
6717 }
6718 ref = extend({}, ref);
6719 this._center = this.getCenter();
6720 this.options['spatialReference'] = ref;
6721 this._spatialReference = new SpatialReference(ref);
6722 if (this.options['spatialReference'] && isFunction(this.options['spatialReference']['projection'])) {
6723 var projection = this._spatialReference.getProjection();
6724
6725 this.options['spatialReference']['projection'] = projection['code'];
6726 }
6727 this._resetMapStatus();
6728
6729 this._fireEvent('spatialreferencechange', {
6730 'old': oldRef,
6731 'new': extend({}, this.options['spatialReference'])
6732 });
6733 return this;
6734 };
6735
6736 Map.prototype.onConfig = function onConfig(conf) {
6737 var ref = conf['spatialReference'] || conf['view'];
6738 if (!isNil(ref)) {
6739 this.setSpatialReference(ref);
6740 }
6741 return this;
6742 };
6743
6744 Map.prototype.getProjection = function getProjection() {
6745 if (!this._spatialReference) {
6746 return null;
6747 }
6748 return this._spatialReference.getProjection();
6749 };
6750
6751 Map.prototype.getFullExtent = function getFullExtent() {
6752 if (!this._spatialReference) {
6753 return null;
6754 }
6755 return this._spatialReference.getFullExtent();
6756 };
6757
6758 Map.prototype.setCursor = function setCursor(cursor) {
6759 delete this._cursor;
6760 this._trySetCursor(cursor);
6761 this._cursor = cursor;
6762 return this;
6763 };
6764
6765 Map.prototype.resetCursor = function resetCursor() {
6766 return this.setCursor(null);
6767 };
6768
6769 Map.prototype.getCenter = function getCenter() {
6770 if (!this._loaded || !this._prjCenter) {
6771 return this._center;
6772 }
6773 var projection = this.getProjection();
6774 return projection.unproject(this._prjCenter);
6775 };
6776
6777 Map.prototype.setCenter = function setCenter(center) {
6778 if (!center) {
6779 return this;
6780 }
6781 center = new Coordinate(center);
6782 if (!this._verifyExtent(center)) {
6783 return this;
6784 }
6785 if (!this._loaded) {
6786 this._center = center;
6787 return this;
6788 }
6789 this.onMoveStart();
6790 var projection = this.getProjection();
6791 var _pcenter = projection.project(center);
6792 this._setPrjCenter(_pcenter);
6793 this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));
6794 return this;
6795 };
6796
6797 Map.prototype.getSize = function getSize() {
6798 if (isNil(this.width) || isNil(this.height)) {
6799 return this._getContainerDomSize();
6800 }
6801 return new Size(this.width, this.height);
6802 };
6803
6804 Map.prototype.getContainerExtent = function getContainerExtent() {
6805 var visualHeight = this.height;
6806 var pitch = this.getPitch(),
6807 maxVisualPitch = this.options['maxVisualPitch'];
6808 if (maxVisualPitch && pitch > maxVisualPitch) {
6809 visualHeight = this._getVisualHeight(maxVisualPitch);
6810 }
6811 return new PointExtent(0, this.height - visualHeight, this.width, this.height);
6812 };
6813
6814 Map.prototype._getVisualHeight = function _getVisualHeight(maxVisualPitch) {
6815 var pitch = this.getPitch();
6816 var visualDistance = this.height / 2 * Math.tan(maxVisualPitch * Math.PI / 180);
6817 return this.height / 2 + visualDistance * Math.tan((90 - pitch) * Math.PI / 180);
6818 };
6819
6820 Map.prototype.getExtent = function getExtent() {
6821 return this._pointToExtent(this._get2DExtent());
6822 };
6823
6824 Map.prototype.getProjExtent = function getProjExtent() {
6825 var extent2D = this._get2DExtent();
6826 return new Extent(this._pointToPrj(extent2D.getMin()), this._pointToPrj(extent2D.getMax()));
6827 };
6828
6829 Map.prototype.getPrjExtent = function getPrjExtent() {
6830 return this.getProjExtent();
6831 };
6832
6833 Map.prototype.getMaxExtent = function getMaxExtent() {
6834 if (!this.options['maxExtent']) {
6835 return null;
6836 }
6837 return new Extent(this.options['maxExtent'], this.getProjection());
6838 };
6839
6840 Map.prototype.setMaxExtent = function setMaxExtent(extent) {
6841 if (extent) {
6842 var maxExt = new Extent(extent, this.getProjection());
6843 this.options['maxExtent'] = maxExt;
6844 var center = this.getCenter();
6845 if (!this._verifyExtent(center)) {
6846 this.panTo(maxExt.getCenter());
6847 }
6848 } else {
6849 delete this.options['maxExtent'];
6850 }
6851 return this;
6852 };
6853
6854 Map.prototype.getZoom = function getZoom() {
6855 return this._zoomLevel;
6856 };
6857
6858 Map.prototype.getZoomForScale = function getZoomForScale(scale, fromZoom, isFraction) {
6859 var zoom = this.getZoom();
6860 if (isNil(fromZoom)) {
6861 fromZoom = zoom;
6862 }
6863 if (scale === 1 && fromZoom === zoom) {
6864 return zoom;
6865 }
6866 var res = this._getResolution(fromZoom),
6867 targetRes = res / scale;
6868 var scaleZoom = this.getZoomFromRes(targetRes);
6869 if (isFraction) {
6870 return scaleZoom;
6871 } else {
6872 var delta = 1E-6;
6873 return this.getSpatialReference().getZoomDirection() < 0 ? Math.ceil(scaleZoom - delta) : Math.floor(scaleZoom + delta);
6874 }
6875 };
6876
6877 Map.prototype.getZoomFromRes = function getZoomFromRes(res) {
6878 var resolutions = this._getResolutions(),
6879 minRes = this._getResolution(this.getMinZoom()),
6880 maxRes = this._getResolution(this.getMaxZoom());
6881 if (minRes <= maxRes) {
6882 if (res <= minRes) {
6883 return this.getMinZoom();
6884 } else if (res >= maxRes) {
6885 return this.getMaxZoom();
6886 }
6887 } else if (res >= minRes) {
6888 return this.getMinZoom();
6889 } else if (res <= maxRes) {
6890 return this.getMaxZoom();
6891 }
6892
6893 var l = resolutions.length;
6894 for (var i = 0; i < l - 1; i++) {
6895 if (!resolutions[i]) {
6896 continue;
6897 }
6898 var gap = resolutions[i + 1] - resolutions[i];
6899 var test = res - resolutions[i];
6900 if (sign(gap) === sign(test) && Math.abs(gap) >= Math.abs(test)) {
6901 return i + test / gap;
6902 }
6903 }
6904 return l - 1;
6905 };
6906
6907 Map.prototype.setZoom = function setZoom(zoom) {
6908 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 'animation': true };
6909
6910 if (isNaN(zoom) || isNil(zoom)) {
6911 return this;
6912 }
6913 if (this._loaded && this.options['zoomAnimation'] && options['animation']) {
6914 this._zoomAnimation(zoom);
6915 } else {
6916 this._zoom(zoom);
6917 }
6918 return this;
6919 };
6920
6921 Map.prototype.getMaxZoom = function getMaxZoom() {
6922 if (!isNil(this.options['maxZoom'])) {
6923 return this.options['maxZoom'];
6924 }
6925 return this.getMaxNativeZoom();
6926 };
6927
6928 Map.prototype.setMaxZoom = function setMaxZoom(maxZoom) {
6929 var viewMaxZoom = this.getMaxNativeZoom();
6930 if (maxZoom > viewMaxZoom) {
6931 maxZoom = viewMaxZoom;
6932 }
6933 if (maxZoom !== null && maxZoom < this._zoomLevel) {
6934 this.setZoom(maxZoom);
6935 }
6936 this.options['maxZoom'] = maxZoom;
6937 return this;
6938 };
6939
6940 Map.prototype.getMinZoom = function getMinZoom() {
6941 if (!isNil(this.options['minZoom'])) {
6942 return this.options['minZoom'];
6943 }
6944 return this._spatialReference.getMinZoom();
6945 };
6946
6947 Map.prototype.setMinZoom = function setMinZoom(minZoom) {
6948 if (minZoom !== null) {
6949 var viewMinZoom = this._spatialReference.getMinZoom();
6950 if (minZoom < viewMinZoom) {
6951 minZoom = viewMinZoom;
6952 }
6953 if (minZoom > this._zoomLevel) {
6954 this.setZoom(minZoom);
6955 }
6956 }
6957 this.options['minZoom'] = minZoom;
6958 return this;
6959 };
6960
6961 Map.prototype.getMaxNativeZoom = function getMaxNativeZoom() {
6962 var ref = this.getSpatialReference();
6963 if (!ref) {
6964 return null;
6965 }
6966 return ref.getMaxZoom();
6967 };
6968
6969 Map.prototype.getGLZoom = function getGLZoom() {
6970 return this.getMaxNativeZoom() / 2;
6971 };
6972
6973 Map.prototype.getGLScale = function getGLScale(zoom) {
6974 if (isNil(zoom)) {
6975 zoom = this.getZoom();
6976 }
6977 return this.getScale(zoom) / this.getScale(this.getGLZoom());
6978 };
6979
6980 Map.prototype.zoomIn = function zoomIn() {
6981 return this.setZoom(this.getZoom() + 1);
6982 };
6983
6984 Map.prototype.zoomOut = function zoomOut() {
6985 return this.setZoom(this.getZoom() - 1);
6986 };
6987
6988 Map.prototype.isZooming = function isZooming() {
6989 return !!this._zooming;
6990 };
6991
6992 Map.prototype.isInteracting = function isInteracting() {
6993 return this.isZooming() || this.isMoving() || this.isRotating();
6994 };
6995
6996 Map.prototype.setCenterAndZoom = function setCenterAndZoom(center, zoom) {
6997 if (!isNil(zoom) && this._zoomLevel !== zoom) {
6998 this.setCenter(center);
6999 this.setZoom(zoom, { animation: false });
7000 } else {
7001 this.setCenter(center);
7002 }
7003 return this;
7004 };
7005
7006 Map.prototype.getFitZoom = function getFitZoom(extent) {
7007 var _this2 = this;
7008
7009 if (!extent || !(extent instanceof Extent)) {
7010 return this._zoomLevel;
7011 }
7012
7013 if (extent['xmin'] === extent['xmax'] && extent['ymin'] === extent['ymax']) {
7014 return this.getMaxZoom();
7015 }
7016 var size = this.getSize();
7017 var containerExtent = extent.convertTo(function (p) {
7018 return _this2.coordToContainerPoint(p);
7019 });
7020 var w = containerExtent.getWidth(),
7021 h = containerExtent.getHeight();
7022 var scaleX = size['width'] / w,
7023 scaleY = size['height'] / h;
7024 var scale = this.getSpatialReference().getZoomDirection() < 0 ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);
7025 var zoom = this.getZoomForScale(scale);
7026 return zoom;
7027 };
7028
7029 Map.prototype.getView = function getView() {
7030 return {
7031 'center': this.getCenter().toArray(),
7032 'zoom': this.getZoom(),
7033 'pitch': this.getPitch(),
7034 'bearing': this.getBearing()
7035 };
7036 };
7037
7038 Map.prototype.setView = function setView(view) {
7039 if (!view) {
7040 return this;
7041 }
7042 if (view['center']) {
7043 this.setCenter(view['center']);
7044 }
7045 if (view['zoom']) {
7046 this.setZoom(view['zoom'], { 'animation': false });
7047 }
7048 if (view['pitch']) {
7049 this.setPitch(view['pitch']);
7050 }
7051 if (view['bearing']) {
7052 this.setBearing(view['bearing']);
7053 }
7054 return this;
7055 };
7056
7057 Map.prototype.getResolution = function getResolution(zoom) {
7058 return this._getResolution(zoom);
7059 };
7060
7061 Map.prototype.getScale = function getScale(zoom) {
7062 var z = isNil(zoom) ? this.getZoom() : zoom;
7063 var max = this._getResolution(this.getMaxNativeZoom()),
7064 res = this._getResolution(z);
7065 return res / max;
7066 };
7067
7068 Map.prototype.fitExtent = function fitExtent(extent, zoomOffset) {
7069 if (!extent) {
7070 return this;
7071 }
7072 extent = new Extent(extent, this.getProjection());
7073 var zoom = this.getFitZoom(extent) + (zoomOffset || 0);
7074 var center = extent.getCenter();
7075 return this.setCenterAndZoom(center, zoom);
7076 };
7077
7078 Map.prototype.getBaseLayer = function getBaseLayer() {
7079 return this._baseLayer;
7080 };
7081
7082 Map.prototype.setBaseLayer = function setBaseLayer(baseLayer) {
7083 var isChange = false;
7084 if (this._baseLayer) {
7085 isChange = true;
7086
7087 this._fireEvent('baselayerchangestart');
7088 this._baseLayer.remove();
7089 }
7090 if (!baseLayer) {
7091 delete this._baseLayer;
7092
7093 this._fireEvent('baselayerchangeend');
7094
7095 this._fireEvent('setbaselayer');
7096 return this;
7097 }
7098
7099 this._baseLayer = baseLayer;
7100 baseLayer._bindMap(this, -1);
7101
7102 function onbaseLayerload() {
7103 this._fireEvent('baselayerload');
7104 if (isChange) {
7105 isChange = false;
7106 this._fireEvent('baselayerchangeend');
7107 }
7108 }
7109 this._baseLayer.on('layerload', onbaseLayerload, this);
7110 if (this._loaded) {
7111 this._baseLayer.load();
7112 }
7113 this._fireEvent('setbaselayer');
7114 return this;
7115 };
7116
7117 Map.prototype.removeBaseLayer = function removeBaseLayer() {
7118 if (this._baseLayer) {
7119 this._baseLayer.remove();
7120 delete this._baseLayer;
7121
7122 this._fireEvent('baselayerremove');
7123 }
7124 return this;
7125 };
7126
7127 Map.prototype.getLayers = function getLayers(filter) {
7128 return this._getLayers(function (layer) {
7129 if (layer === this._baseLayer || layer.getId().indexOf(INTERNAL_LAYER_PREFIX) >= 0) {
7130 return false;
7131 }
7132 if (filter) {
7133 return filter(layer);
7134 }
7135 return true;
7136 });
7137 };
7138
7139 Map.prototype.getLayer = function getLayer(id) {
7140 if (!id) {
7141 return null;
7142 }
7143 var layer = this._layerCache ? this._layerCache[id] : null;
7144 if (layer) {
7145 return layer;
7146 }
7147 var baseLayer = this.getBaseLayer();
7148 if (baseLayer && baseLayer.getId() === id) {
7149 return baseLayer;
7150 }
7151 return null;
7152 };
7153
7154 Map.prototype.addLayer = function addLayer(layers) {
7155 if (!layers) {
7156 return this;
7157 }
7158 if (!Array.isArray(layers)) {
7159 layers = Array.prototype.slice.call(arguments, 0);
7160 return this.addLayer(layers);
7161 }
7162 if (!this._layerCache) {
7163 this._layerCache = {};
7164 }
7165 var mapLayers = this._layers;
7166 for (var i = 0, len = layers.length; i < len; i++) {
7167 var layer = layers[i];
7168 var id = layer.getId();
7169 if (isNil(id)) {
7170 throw new Error('Invalid id for the layer: ' + id);
7171 }
7172 if (layer.getMap() === this) {
7173 continue;
7174 }
7175 if (this._layerCache[id]) {
7176 throw new Error('Duplicate layer id in the map: ' + id);
7177 }
7178 this._layerCache[id] = layer;
7179 layer._bindMap(this);
7180 mapLayers.push(layer);
7181 if (this._loaded) {
7182 layer.load();
7183 }
7184 }
7185
7186 this._sortLayersByZIndex();
7187
7188 this._fireEvent('addlayer', {
7189 'layers': layers
7190 });
7191 return this;
7192 };
7193
7194 Map.prototype.removeLayer = function removeLayer(layers) {
7195 if (!layers) {
7196 return this;
7197 }
7198 if (!Array.isArray(layers)) {
7199 return this.removeLayer([layers]);
7200 }
7201 var removed = [];
7202 for (var i = 0, len = layers.length; i < len; i++) {
7203 var layer = layers[i];
7204 if (!(layer instanceof Layer)) {
7205 layer = this.getLayer(layer);
7206 }
7207 if (!layer) {
7208 continue;
7209 }
7210 var map = layer.getMap();
7211 if (!map || map !== this) {
7212 continue;
7213 }
7214 removed.push(layer);
7215 this._removeLayer(layer, this._layers);
7216 if (this._loaded) {
7217 layer._doRemove();
7218 }
7219 var id = layer.getId();
7220 if (this._layerCache) {
7221 delete this._layerCache[id];
7222 }
7223 }
7224 if (removed.length > 0) {
7225 this.once('frameend', function () {
7226 removed.forEach(function (layer) {
7227 layer.fire('remove');
7228 });
7229 });
7230 }
7231
7232 this._fireEvent('removelayer', {
7233 'layers': layers
7234 });
7235 return this;
7236 };
7237
7238 Map.prototype.sortLayers = function sortLayers(layers) {
7239 if (!layers || !Array.isArray(layers)) {
7240 return this;
7241 }
7242 var layersToOrder = [];
7243 var minZ = Number.MAX_VALUE;
7244 for (var i = 0, l = layers.length; i < l; i++) {
7245 var layer = layers[i];
7246 if (isString(layers[i])) {
7247 layer = this.getLayer(layer);
7248 }
7249 if (!(layer instanceof Layer) || !layer.getMap() || layer.getMap() !== this) {
7250 throw new Error('It must be a layer added to this map to order.');
7251 }
7252 if (layer.getZIndex() < minZ) {
7253 minZ = layer.getZIndex();
7254 }
7255 layersToOrder.push(layer);
7256 }
7257 for (var _i = 0, _l = layersToOrder.length; _i < _l; _i++) {
7258 layersToOrder[_i].setZIndex(minZ + _i);
7259 }
7260
7261 return this;
7262 };
7263
7264 Map.prototype.toDataURL = function toDataURL(options) {
7265 if (!options) {
7266 options = {};
7267 }
7268 var mimeType = options['mimeType'];
7269 if (!mimeType) {
7270 mimeType = 'image/png';
7271 }
7272 var save = options['save'];
7273 var renderer = this._getRenderer();
7274 if (renderer && renderer.toDataURL) {
7275 var file = options['fileName'];
7276 if (!file) {
7277 file = 'export';
7278 }
7279 var dataURL = renderer.toDataURL(mimeType);
7280 if (save && dataURL) {
7281 var imgURL = void 0;
7282 if (typeof Blob !== 'undefined' && typeof atob !== 'undefined') {
7283 var blob = b64toBlob(dataURL.replace(/^data:image\/(png|jpeg|jpg);base64,/, ''), mimeType);
7284 imgURL = URL.createObjectURL(blob);
7285 } else {
7286 imgURL = dataURL;
7287 }
7288 var dlLink = document.createElement('a');
7289 dlLink.download = file;
7290 dlLink.href = imgURL;
7291
7292 document.body.appendChild(dlLink);
7293 dlLink.click();
7294 document.body.removeChild(dlLink);
7295 }
7296 return dataURL;
7297 }
7298 return null;
7299 };
7300
7301 Map.prototype.coordinateToPoint = function coordinateToPoint(coordinate, zoom) {
7302 var prjCoord = this.getProjection().project(coordinate);
7303 return this._prjToPoint(prjCoord, zoom);
7304 };
7305
7306 Map.prototype.coordToPoint = function coordToPoint(coordinate, zoom) {
7307 return this.coordinateToPoint(coordinate, zoom);
7308 };
7309
7310 Map.prototype.pointToCoordinate = function pointToCoordinate(point, zoom) {
7311 var prjCoord = this._pointToPrj(point, zoom);
7312 return this.getProjection().unproject(prjCoord);
7313 };
7314
7315 Map.prototype.pointToCoord = function pointToCoord(point, zoom) {
7316 return this.pointToCoordinate(point, zoom);
7317 };
7318
7319 Map.prototype.coordinateToViewPoint = function coordinateToViewPoint(coordinate) {
7320 return this._prjToViewPoint(this.getProjection().project(coordinate));
7321 };
7322
7323 Map.prototype.coordToViewPoint = function coordToViewPoint(coordinate) {
7324 return this.coordinateToViewPoint(coordinate);
7325 };
7326
7327 Map.prototype.viewPointToCoordinate = function viewPointToCoordinate(viewPoint) {
7328 return this.getProjection().unproject(this._viewPointToPrj(viewPoint));
7329 };
7330
7331 Map.prototype.viewPointToCoord = function viewPointToCoord(viewPoint) {
7332 return this.viewPointToCoordinate(viewPoint);
7333 };
7334
7335 Map.prototype.coordinateToContainerPoint = function coordinateToContainerPoint(coordinate, zoom) {
7336 var pCoordinate = this.getProjection().project(coordinate);
7337 return this._prjToContainerPoint(pCoordinate, zoom);
7338 };
7339
7340 Map.prototype.coordToContainerPoint = function coordToContainerPoint(coordinate, zoom) {
7341 return this.coordinateToContainerPoint(coordinate, zoom);
7342 };
7343
7344 Map.prototype.containerPointToCoordinate = function containerPointToCoordinate(containerPoint) {
7345 var pCoordinate = this._containerPointToPrj(containerPoint);
7346 return this.getProjection().unproject(pCoordinate);
7347 };
7348
7349 Map.prototype.containerPointToCoord = function containerPointToCoord(containerPoint) {
7350 return this.containerPointToCoordinate(containerPoint);
7351 };
7352
7353 Map.prototype.containerPointToViewPoint = function containerPointToViewPoint(containerPoint) {
7354 return containerPoint.sub(this.getViewPoint());
7355 };
7356
7357 Map.prototype.viewPointToContainerPoint = function viewPointToContainerPoint(viewPoint) {
7358 return viewPoint.add(this.getViewPoint());
7359 };
7360
7361 Map.prototype.containerToExtent = function containerToExtent(containerExtent) {
7362 var extent2D = new PointExtent(this._containerPointToPoint(containerExtent.getMin()), this._containerPointToPoint(containerExtent.getMax()));
7363 return this._pointToExtent(extent2D);
7364 };
7365
7366 Map.prototype.checkSize = function checkSize() {
7367 var justStart = now() - this._initTime < 1500 && this.width === 0 || this.height === 0;
7368
7369 var watched = this._getContainerDomSize(),
7370 oldHeight = this.height,
7371 oldWidth = this.width;
7372 if (watched['width'] === oldWidth && watched['height'] === oldHeight) {
7373 return this;
7374 }
7375 var center = this.getCenter();
7376 this._updateMapSize(watched);
7377 var resizeOffset = new Point((oldWidth - watched.width) / 2, (oldHeight - watched.height) / 2);
7378 this._offsetCenterByPixel(resizeOffset);
7379
7380 this._mapViewCoord = this._getPrjCenter();
7381 var hided = watched['width'] === 0 || watched['height'] === 0 || oldWidth === 0 || oldHeight === 0;
7382
7383 if (justStart || hided) {
7384 this._noEvent = true;
7385 this.setCenter(center);
7386 delete this._noEvent;
7387 }
7388
7389 this._fireEvent('resize');
7390
7391 return this;
7392 };
7393
7394 Map.prototype.distanceToPixel = function distanceToPixel(xDist, yDist, zoom) {
7395 var projection = this.getProjection();
7396 if (!projection) {
7397 return null;
7398 }
7399 var scale = this.getScale() / this.getScale(zoom);
7400 var center = this.getCenter(),
7401 target = projection.locate(center, xDist, yDist);
7402 var p0 = this.coordToContainerPoint(center),
7403 p1 = this.coordToContainerPoint(target);
7404 p1._sub(p0)._multi(scale)._abs();
7405 return new Size(p1.x, p1.y);
7406 };
7407
7408 Map.prototype.distanceToPoint = function distanceToPoint(xDist, yDist, zoom) {
7409 var projection = this.getProjection();
7410 if (!projection) {
7411 return null;
7412 }
7413 var center = this.getCenter(),
7414 target = projection.locate(center, xDist, yDist);
7415 var p0 = this.coordToPoint(center, zoom),
7416 p1 = this.coordToPoint(target, zoom);
7417 p1._sub(p0)._abs();
7418 return p1;
7419 };
7420
7421 Map.prototype.pixelToDistance = function pixelToDistance(width, height) {
7422 var projection = this.getProjection();
7423 if (!projection) {
7424 return null;
7425 }
7426 var fullExt = this.getFullExtent();
7427 var d = fullExt['top'] > fullExt['bottom'] ? -1 : 1;
7428 var target = new Point(this.width / 2 + width, this.height / 2 + d * height);
7429 var coord = this.containerPointToCoord(target);
7430 return projection.measureLength(this.getCenter(), coord);
7431 };
7432
7433 Map.prototype.pointToDistance = function pointToDistance(dx, dy, zoom) {
7434 var projection = this.getProjection();
7435 if (!projection) {
7436 return null;
7437 }
7438 var c = this._prjToPoint(this._getPrjCenter(), zoom);
7439 c._add(dx, dy);
7440 var target = this.pointToCoord(c, zoom);
7441 return projection.measureLength(this.getCenter(), target);
7442 };
7443
7444 Map.prototype.locate = function locate(coordinate, dx, dy) {
7445 return this.getProjection()._locate(new Coordinate(coordinate), dx, dy);
7446 };
7447
7448 Map.prototype.locateByPoint = function locateByPoint(coordinate, px, py) {
7449 var point = this.coordToContainerPoint(coordinate);
7450 return this.containerPointToCoord(point._add(px, py));
7451 };
7452
7453 Map.prototype.getMainPanel = function getMainPanel() {
7454 return this._getRenderer().getMainPanel();
7455 };
7456
7457 Map.prototype.getPanels = function getPanels() {
7458 return this._panels;
7459 };
7460
7461 Map.prototype.remove = function remove() {
7462 if (this.isRemoved()) {
7463 return this;
7464 }
7465 this._fireEvent('removestart');
7466 this._removeDomEvents();
7467 this._clearHandlers();
7468 this.removeBaseLayer();
7469 var layers = this.getLayers();
7470 for (var i = 0; i < layers.length; i++) {
7471 layers[i].remove();
7472 }
7473 if (this._getRenderer()) {
7474 this._getRenderer().remove();
7475 }
7476 if (this._containerDOM.innerHTML) {
7477 this._containerDOM.innerHTML = '';
7478 }
7479 delete this._panels;
7480 delete this._containerDOM;
7481 delete this.renderer;
7482 this._fireEvent('removeend');
7483 this._clearAllListeners();
7484 return this;
7485 };
7486
7487 Map.prototype.isRemoved = function isRemoved() {
7488 return !this._containerDOM;
7489 };
7490
7491 Map.prototype.isMoving = function isMoving() {
7492 return !!this._moving;
7493 };
7494
7495 Map.prototype.onMoveStart = function onMoveStart(param) {
7496 this._originCenter = this.getCenter();
7497 this._moving = true;
7498 this._trySetCursor('move');
7499
7500 this._fireEvent('movestart', this._parseEvent(param ? param['domEvent'] : null, 'movestart'));
7501 };
7502
7503 Map.prototype.onMoving = function onMoving(param) {
7504 this._fireEvent('moving', this._parseEvent(param ? param['domEvent'] : null, 'moving'));
7505 };
7506
7507 Map.prototype.onMoveEnd = function onMoveEnd(param) {
7508 this._moving = false;
7509 this._trySetCursor('default');
7510
7511 this._fireEvent('moveend', param && param['domEvent'] ? this._parseEvent(param['domEvent'], 'moveend') : param);
7512 if (!this._verifyExtent(this.getCenter())) {
7513 var moveTo = this._originCenter;
7514 if (!this._verifyExtent(moveTo)) {
7515 moveTo = this.getMaxExtent().getCenter();
7516 }
7517 this.panTo(moveTo);
7518 }
7519 };
7520
7521 Map.prototype.onDragRotateStart = function onDragRotateStart(param) {
7522 this._dragRotating = true;
7523
7524 this._fireEvent('dragrotatestart', this._parseEvent(param ? param['domEvent'] : null, 'dragrotatestart'));
7525 };
7526
7527 Map.prototype.onDragRotating = function onDragRotating(param) {
7528 this._fireEvent('dragrotating', this._parseEvent(param ? param['domEvent'] : null, 'dragrotating'));
7529 };
7530
7531 Map.prototype.onDragRotateEnd = function onDragRotateEnd(param) {
7532 this._dragRotating = false;
7533
7534 this._fireEvent('dragrotateend', this._parseEvent(param ? param['domEvent'] : null, 'dragrotateend'));
7535 };
7536
7537 Map.prototype.isDragRotating = function isDragRotating() {
7538 return !!this._dragRotating;
7539 };
7540
7541 Map.prototype.getRenderer = function getRenderer() {
7542 return this._getRenderer();
7543 };
7544
7545 Map.prototype._initContainer = function _initContainer(container) {
7546 if (isString(container)) {
7547 this._containerDOM = document.getElementById(container);
7548 if (!this._containerDOM) {
7549 throw new Error('Invalid container when creating map: \'' + container + '\'');
7550 }
7551 } else {
7552 this._containerDOM = container;
7553 if (IS_NODE) {
7554 this.CanvasClass = this._containerDOM.constructor;
7555 }
7556 }
7557
7558 if (this._containerDOM.childNodes && this._containerDOM.childNodes.length > 0) {
7559 if (this._containerDOM.childNodes[0].className === 'maptalks-wrapper') {
7560 throw new Error('Container is already loaded with another map instance, use map.remove() to clear it.');
7561 }
7562 }
7563 };
7564
7565 Map.prototype._trySetCursor = function _trySetCursor(cursor) {
7566 if (!this._cursor && !this._priorityCursor) {
7567 if (!cursor) {
7568 cursor = 'default';
7569 }
7570 this._setCursorToPanel(cursor);
7571 }
7572 return this;
7573 };
7574
7575 Map.prototype._setPriorityCursor = function _setPriorityCursor(cursor) {
7576 if (!cursor) {
7577 var hasCursor = false;
7578 if (this._priorityCursor) {
7579 hasCursor = true;
7580 }
7581 delete this._priorityCursor;
7582 if (hasCursor) {
7583 this.setCursor(this._cursor);
7584 }
7585 } else {
7586 this._priorityCursor = cursor;
7587 this._setCursorToPanel(cursor);
7588 }
7589 return this;
7590 };
7591
7592 Map.prototype._setCursorToPanel = function _setCursorToPanel(cursor) {
7593 var panel = this.getMainPanel();
7594 if (panel && panel.style && panel.style.cursor !== cursor) {
7595 panel.style.cursor = cursor;
7596 }
7597 };
7598
7599 Map.prototype._get2DExtent = function _get2DExtent(zoom) {
7600 var _this3 = this;
7601
7602 var cExtent = this.getContainerExtent();
7603 return cExtent.convertTo(function (c) {
7604 return _this3._containerPointToPoint(c, zoom);
7605 });
7606 };
7607
7608 Map.prototype._pointToExtent = function _pointToExtent(extent2D) {
7609 var min2d = extent2D.getMin(),
7610 max2d = extent2D.getMax();
7611 var fullExtent = this.getFullExtent();
7612
7613 var _ref = !fullExtent || fullExtent.left <= fullExtent.right ? [min2d.x, max2d.x] : [max2d.x, min2d.x],
7614 minx = _ref[0],
7615 maxx = _ref[1];
7616
7617 var _ref2 = !fullExtent || fullExtent.top > fullExtent.bottom ? [max2d.y, min2d.y] : [min2d.y, max2d.y],
7618 miny = _ref2[0],
7619 maxy = _ref2[1];
7620
7621 var min = new Coordinate(minx, miny),
7622 max = new Coordinate(maxx, maxy);
7623 return new Extent(this.pointToCoord(min), this.pointToCoord(max), this.getProjection());
7624 };
7625
7626 Map.prototype._removeLayer = function _removeLayer(layer, layerList) {
7627 if (!layer || !layerList) {
7628 return;
7629 }
7630 var index = layerList.indexOf(layer);
7631 if (index > -1) {
7632 layerList.splice(index, 1);
7633 }
7634 };
7635
7636 Map.prototype._sortLayersByZIndex = function _sortLayersByZIndex() {
7637 if (!this._layers) {
7638 return;
7639 }
7640 for (var i = 0, l = this._layers.length; i < l; i++) {
7641 this._layers[i]._order = i;
7642 }
7643 this._layers.sort(function (a, b) {
7644 var c = a.getZIndex() - b.getZIndex();
7645 if (c === 0) {
7646 return a._order - b._order;
7647 }
7648 return c;
7649 });
7650 };
7651
7652 Map.prototype._fireEvent = function _fireEvent(eventName, param) {
7653 if (this._noEvent) {
7654 return;
7655 }
7656
7657 this.fire('_' + eventName, param);
7658 this.fire(eventName, param);
7659 };
7660
7661 Map.prototype._Load = function _Load() {
7662 this._resetMapStatus();
7663 if (this.options['pitch']) {
7664 this.setPitch(this.options['pitch']);
7665 delete this.options['pitch'];
7666 }
7667 if (this.options['bearing']) {
7668 this.setBearing(this.options['bearing']);
7669 delete this.options['bearing'];
7670 }
7671 this._loadAllLayers();
7672 this._getRenderer().onLoad();
7673 this._loaded = true;
7674 this._callOnLoadHooks();
7675 this._initTime = now();
7676 };
7677
7678 Map.prototype._initRenderer = function _initRenderer() {
7679 var renderer = this.options['renderer'];
7680 var clazz = Map.getRendererClass(renderer);
7681 this._renderer = new clazz(this);
7682 this._renderer.load();
7683 };
7684
7685 Map.prototype._getRenderer = function _getRenderer() {
7686 return this._renderer;
7687 };
7688
7689 Map.prototype._loadAllLayers = function _loadAllLayers() {
7690 function loadLayer(layer) {
7691 if (layer) {
7692 layer.load();
7693 }
7694 }
7695 if (this._baseLayer) {
7696 this._baseLayer.load();
7697 }
7698 this._eachLayer(loadLayer, this.getLayers());
7699 };
7700
7701 Map.prototype._getLayers = function _getLayers(filter) {
7702 var layers = this._baseLayer ? [this._baseLayer].concat(this._layers) : this._layers;
7703 var result = [];
7704 for (var i = 0; i < layers.length; i++) {
7705 if (!filter || filter.call(this, layers[i])) {
7706 result.push(layers[i]);
7707 }
7708 }
7709 return result;
7710 };
7711
7712 Map.prototype._eachLayer = function _eachLayer(fn) {
7713 if (arguments.length < 2) {
7714 return;
7715 }
7716 var layerLists = Array.prototype.slice.call(arguments, 1);
7717 if (layerLists && !Array.isArray(layerLists)) {
7718 layerLists = [layerLists];
7719 }
7720 var layers = [];
7721 for (var i = 0, len = layerLists.length; i < len; i++) {
7722 layers = layers.concat(layerLists[i]);
7723 }
7724 for (var j = 0, jlen = layers.length; j < jlen; j++) {
7725 fn.call(fn, layers[j]);
7726 }
7727 };
7728
7729 Map.prototype._onLayerEvent = function _onLayerEvent(param) {
7730 if (!param) {
7731 return;
7732 }
7733 if (param['type'] === 'idchange') {
7734 delete this._layerCache[param['old']];
7735 this._layerCache[param['new']] = param['target'];
7736 }
7737 };
7738
7739 Map.prototype._resetMapStatus = function _resetMapStatus() {
7740 var maxZoom = this.getMaxZoom(),
7741 minZoom = this.getMinZoom();
7742 var viewMaxZoom = this._spatialReference.getMaxZoom(),
7743 viewMinZoom = this._spatialReference.getMinZoom();
7744 if (isNil(maxZoom) || maxZoom === -1 || maxZoom > viewMaxZoom) {
7745 this.setMaxZoom(viewMaxZoom);
7746 }
7747 if (isNil(minZoom) || minZoom === -1 || minZoom < viewMinZoom) {
7748 this.setMinZoom(viewMinZoom);
7749 }
7750 maxZoom = this.getMaxZoom();
7751 minZoom = this.getMinZoom();
7752 if (maxZoom < minZoom) {
7753 this.setMaxZoom(minZoom);
7754 }
7755 if (isNil(this._zoomLevel) || this._zoomLevel > maxZoom) {
7756 this._zoomLevel = maxZoom;
7757 }
7758 if (this._zoomLevel < minZoom) {
7759 this._zoomLevel = minZoom;
7760 }
7761 delete this._prjCenter;
7762 var projection = this.getProjection();
7763 this._prjCenter = projection.project(this._center);
7764 this._calcMatrices();
7765 var renderer = this._getRenderer();
7766 if (renderer) {
7767 renderer.resetContainer();
7768 }
7769 };
7770
7771 Map.prototype._getContainerDomSize = function _getContainerDomSize() {
7772 if (!this._containerDOM) {
7773 return null;
7774 }
7775 var containerDOM = this._containerDOM;
7776 var width = void 0,
7777 height = void 0;
7778 if (!isNil(containerDOM.width) && !isNil(containerDOM.height)) {
7779 width = containerDOM.width;
7780 height = containerDOM.height;
7781 if (Browser$1.retina && containerDOM['layer']) {
7782 width /= 2;
7783 height /= 2;
7784 }
7785 } else if (!isNil(containerDOM.clientWidth) && !isNil(containerDOM.clientHeight)) {
7786 width = parseInt(containerDOM.clientWidth, 0);
7787 height = parseInt(containerDOM.clientHeight, 0);
7788 } else {
7789 throw new Error('can not get size of container');
7790 }
7791 return new Size(width, height);
7792 };
7793
7794 Map.prototype._updateMapSize = function _updateMapSize(mSize) {
7795 this.width = mSize['width'];
7796 this.height = mSize['height'];
7797 this._getRenderer().updateMapSize(mSize);
7798 this._calcMatrices();
7799 return this;
7800 };
7801
7802 Map.prototype._getPrjCenter = function _getPrjCenter() {
7803 return this._prjCenter;
7804 };
7805
7806 Map.prototype._setPrjCenter = function _setPrjCenter(pcenter) {
7807 this._prjCenter = pcenter;
7808 if (this.isInteracting() && !this.isMoving()) {
7809 this._mapViewCoord = pcenter;
7810 }
7811 this._calcMatrices();
7812 };
7813
7814 Map.prototype._setPrjCoordAtContainerPoint = function _setPrjCoordAtContainerPoint(coordinate, point) {
7815 if (point.x === this.width / 2 && point.y === this.height / 2) {
7816 return this;
7817 }
7818 var t = this._containerPointToPoint(point)._sub(this._prjToPoint(this._getPrjCenter()));
7819 var pcenter = this._pointToPrj(this._prjToPoint(coordinate).sub(t));
7820 this._setPrjCenter(pcenter);
7821 return this;
7822 };
7823
7824 Map.prototype._verifyExtent = function _verifyExtent(center) {
7825 if (!center) {
7826 return false;
7827 }
7828 var maxExt = this.getMaxExtent();
7829 if (!maxExt) {
7830 return true;
7831 }
7832 return maxExt.contains(center);
7833 };
7834
7835 Map.prototype._offsetCenterByPixel = function _offsetCenterByPixel(pixel) {
7836 var pos = new Point(this.width / 2 - pixel.x, this.height / 2 - pixel.y);
7837 var pCenter = this._containerPointToPrj(pos);
7838 this._setPrjCenter(pCenter);
7839 return pCenter;
7840 };
7841
7842 Map.prototype.offsetPlatform = function offsetPlatform(offset) {
7843 if (!offset) {
7844 return this._mapViewPoint;
7845 } else {
7846 this._getRenderer().offsetPlatform(offset);
7847 this._mapViewCoord = this._getPrjCenter();
7848 this._mapViewPoint = this._mapViewPoint.add(offset);
7849 return this;
7850 }
7851 };
7852
7853 Map.prototype.getViewPoint = function getViewPoint() {
7854 var offset = this._getViewPointFrameOffset();
7855 var panelOffset = this.offsetPlatform();
7856 if (offset) {
7857 panelOffset = panelOffset.add(offset);
7858 }
7859 return panelOffset;
7860 };
7861
7862 Map.prototype._getViewPointFrameOffset = function _getViewPointFrameOffset() {
7863 if (this.isZooming()) {
7864 return null;
7865 }
7866 var pcenter = this._getPrjCenter();
7867 if (this._mapViewCoord && !this._mapViewCoord.equals(pcenter)) {
7868 return this._prjToContainerPoint(this._mapViewCoord).sub(this._prjToContainerPoint(pcenter));
7869 }
7870 return null;
7871 };
7872
7873 Map.prototype._resetMapViewPoint = function _resetMapViewPoint() {
7874 this._mapViewPoint = new Point(0, 0);
7875
7876 this._mapViewCoord = this._getPrjCenter();
7877 };
7878
7879 Map.prototype._getResolution = function _getResolution(zoom) {
7880 if (isNil(zoom)) {
7881 zoom = this.getZoom();
7882 }
7883 return this._spatialReference.getResolution(zoom);
7884 };
7885
7886 Map.prototype._getResolutions = function _getResolutions() {
7887 return this._spatialReference.getResolutions();
7888 };
7889
7890 Map.prototype._prjToPoint = function _prjToPoint(pCoord, zoom) {
7891 zoom = isNil(zoom) ? this.getZoom() : zoom;
7892 return this._spatialReference.getTransformation().transform(pCoord, this._getResolution(zoom));
7893 };
7894
7895 Map.prototype._pointToPrj = function _pointToPrj(point, zoom) {
7896 zoom = isNil(zoom) ? this.getZoom() : zoom;
7897 return this._spatialReference.getTransformation().untransform(point, this._getResolution(zoom));
7898 };
7899
7900 Map.prototype._pointToPoint = function _pointToPoint(point, zoom) {
7901 if (!isNil(zoom)) {
7902 return point.multi(this._getResolution(zoom) / this._getResolution());
7903 }
7904 return point.copy();
7905 };
7906
7907 Map.prototype._pointToPointAtZoom = function _pointToPointAtZoom(point, zoom) {
7908 if (!isNil(zoom)) {
7909 return point.multi(this._getResolution() / this._getResolution(zoom));
7910 }
7911 return point.copy();
7912 };
7913
7914 Map.prototype._containerPointToPrj = function _containerPointToPrj(containerPoint) {
7915 return this._pointToPrj(this._containerPointToPoint(containerPoint));
7916 };
7917
7918 Map.prototype._viewPointToPrj = function _viewPointToPrj(viewPoint) {
7919 return this._containerPointToPrj(this.viewPointToContainerPoint(viewPoint));
7920 };
7921
7922 Map.prototype._prjToContainerPoint = function _prjToContainerPoint(pCoordinate, zoom) {
7923 return this._pointToContainerPoint(this._prjToPoint(pCoordinate, zoom), zoom);
7924 };
7925
7926 Map.prototype._prjToViewPoint = function _prjToViewPoint(pCoordinate) {
7927 var containerPoint = this._prjToContainerPoint(pCoordinate);
7928 return this._containerPointToViewPoint(containerPoint);
7929 };
7930
7931 Map.prototype._containerPointToViewPoint = function _containerPointToViewPoint(containerPoint) {
7932 if (!containerPoint) {
7933 return null;
7934 }
7935 return containerPoint._sub(this.getViewPoint());
7936 };
7937
7938 Map.prototype._viewPointToPoint = function _viewPointToPoint(viewPoint, zoom) {
7939 return this._containerPointToPoint(this.viewPointToContainerPoint(viewPoint), zoom);
7940 };
7941
7942 Map.prototype._pointToViewPoint = function _pointToViewPoint(point, zoom) {
7943 return this._prjToViewPoint(this._pointToPrj(point, zoom));
7944 };
7945
7946 Map.prototype._callOnLoadHooks = function _callOnLoadHooks() {
7947 var proto = Map.prototype;
7948 if (!proto._onLoadHooks) {
7949 return;
7950 }
7951 for (var i = 0, l = proto._onLoadHooks.length; i < l; i++) {
7952 proto._onLoadHooks[i].call(this);
7953 }
7954 };
7955
7956 return Map;
7957}(Handlerable(Eventable(Renderable(Class))));
7958
7959Map.mergeOptions(options);
7960
7961var MapDoubleClickZoomHandler = function (_Handler) {
7962 inherits(MapDoubleClickZoomHandler, _Handler);
7963
7964 function MapDoubleClickZoomHandler() {
7965 classCallCheck(this, MapDoubleClickZoomHandler);
7966 return possibleConstructorReturn(this, _Handler.apply(this, arguments));
7967 }
7968
7969 MapDoubleClickZoomHandler.prototype.addHooks = function addHooks() {
7970 if (!this.target) {
7971 return;
7972 }
7973 this.target.on('_dblclick', this._onDoubleClick, this);
7974 };
7975
7976 MapDoubleClickZoomHandler.prototype.removeHooks = function removeHooks() {
7977 if (!this.target) {
7978 return;
7979 }
7980 this.target.off('_dblclick', this._onDoubleClick, this);
7981 };
7982
7983 MapDoubleClickZoomHandler.prototype._onDoubleClick = function _onDoubleClick(param) {
7984 var map = this.target;
7985 if (map.options['doubleClickZoom']) {
7986 var oldZoom = map.getZoom(),
7987 zoom = param['domEvent']['shiftKey'] ? Math.ceil(oldZoom) - 1 : Math.floor(oldZoom) + 1;
7988 map._zoomAnimation(zoom, param['containerPoint']);
7989 }
7990 };
7991
7992 return MapDoubleClickZoomHandler;
7993}(Handler$1);
7994
7995Map.mergeOptions({
7996 'doubleClickZoom': true
7997});
7998
7999Map.addOnLoadHook('addHandler', 'doubleClickZoom', MapDoubleClickZoomHandler);
8000
8001var MapDragHandler = function (_Handler) {
8002 inherits(MapDragHandler, _Handler);
8003
8004 function MapDragHandler() {
8005 classCallCheck(this, MapDragHandler);
8006 return possibleConstructorReturn(this, _Handler.apply(this, arguments));
8007 }
8008
8009 MapDragHandler.prototype.addHooks = function addHooks() {
8010 var map = this.target;
8011 if (!map) {
8012 return;
8013 }
8014 var dom = map._panels.mapWrapper || map._containerDOM;
8015 this._dragHandler = new DragHandler(dom, {
8016 'cancelOn': this._cancelOn.bind(this),
8017 'rightclick': true
8018 });
8019 this._dragHandler.on('mousedown', this._onMouseDown, this).on('dragstart', this._onDragStart, this).on('dragging', this._onDragging, this).on('dragend', this._onDragEnd, this).enable();
8020 };
8021
8022 MapDragHandler.prototype.removeHooks = function removeHooks() {
8023 this._dragHandler.off('mousedown', this._onMouseDown, this).off('dragstart', this._onDragStart, this).off('dragging', this._onDragging, this).off('dragend', this._onDragEnd, this);
8024 this._dragHandler.remove();
8025 delete this._dragHandler;
8026 };
8027
8028 MapDragHandler.prototype._cancelOn = function _cancelOn(domEvent) {
8029 if (this.target.isZooming() || this._ignore(domEvent)) {
8030 return true;
8031 }
8032 return false;
8033 };
8034
8035 MapDragHandler.prototype._ignore = function _ignore(param) {
8036 if (!param) {
8037 return false;
8038 }
8039 if (param.domEvent) {
8040 param = param.domEvent;
8041 }
8042 return this.target._ignoreEvent(param);
8043 };
8044
8045 MapDragHandler.prototype._onMouseDown = function _onMouseDown(param) {
8046 delete this.startDragTime;
8047 delete this._mode;
8048 if (param.domEvent.button === 2 || param.domEvent.ctrlKey) {
8049 if (this.target.options['dragRotate'] || this.target.options['dragPitch']) {
8050 this._mode = 'rotatePitch';
8051 }
8052 } else if (this.target.options['dragPan']) {
8053 this._mode = 'move';
8054 }
8055 this.target._stopAnim(this.target._animPlayer);
8056 preventDefault(param['domEvent']);
8057 };
8058
8059 MapDragHandler.prototype._onDragStart = function _onDragStart(param) {
8060 this.startDragTime = now();
8061 if (this._mode === 'move') {
8062 this._moveStart(param);
8063 } else if (this._mode === 'rotatePitch') {
8064 this._rotateStart(param);
8065 }
8066 };
8067
8068 MapDragHandler.prototype._onDragging = function _onDragging(param) {
8069 var map = this.target;
8070 if (map._isEventOutMap(param['domEvent'])) {
8071 return;
8072 }
8073 if (this._mode === 'move') {
8074 this._moving(param);
8075 } else if (this._mode === 'rotatePitch') {
8076 this._rotating(param);
8077 }
8078 };
8079
8080 MapDragHandler.prototype._onDragEnd = function _onDragEnd(param) {
8081 if (this._mode === 'move') {
8082 this._moveEnd(param);
8083 } else if (this._mode === 'rotatePitch') {
8084 this._rotateEnd(param);
8085 }
8086 delete this.startDragTime;
8087 delete this.startBearing;
8088 };
8089
8090 MapDragHandler.prototype._start = function _start(param) {
8091 this.preX = param['mousePos'].x;
8092 this.preY = param['mousePos'].y;
8093 this.startX = this.preX;
8094 this.startY = this.preY;
8095 };
8096
8097 MapDragHandler.prototype._moveStart = function _moveStart(param) {
8098 this._start(param);
8099 var map = this.target;
8100 map.onMoveStart(param);
8101 var p = getEventContainerPoint(map._getActualEvent(param.domEvent), map.getContainer());
8102 this.startPrjCoord = map._containerPointToPrj(p);
8103 };
8104
8105 MapDragHandler.prototype._moving = function _moving(param) {
8106 if (!this.startDragTime) {
8107 return;
8108 }
8109 var map = this.target;
8110 var p = getEventContainerPoint(map._getActualEvent(param.domEvent), map.getContainer());
8111 map._setPrjCoordAtContainerPoint(this.startPrjCoord, p);
8112 map.onMoving(param);
8113 };
8114
8115 MapDragHandler.prototype._moveEnd = function _moveEnd(param) {
8116 if (!this.startDragTime) {
8117 return;
8118 }
8119 var map = this.target;
8120 var t = now() - this.startDragTime;
8121 var mx = param['mousePos'].x,
8122 my = param['mousePos'].y;
8123 var dx = mx - this.startX;
8124 var dy = my - this.startY;
8125
8126 this._clear();
8127
8128 if (map.options['panAnimation'] && !param.interupted && map._verifyExtent(map.getCenter()) && t < 280 && Math.abs(dy) + Math.abs(dx) > 5) {
8129 t = 5 * t * (Math.abs(dx) + Math.abs(dy)) / 500;
8130 map.panBy(new Point(dx, dy), { 'duration': t });
8131 } else {
8132 map.onMoveEnd(param);
8133 }
8134 };
8135
8136 MapDragHandler.prototype._rotateStart = function _rotateStart(param) {
8137 this._start(param);
8138 delete this._rotateMode;
8139 this.startBearing = this.target.getBearing();
8140 this.target.onDragRotateStart(param);
8141 this._db = 0;
8142 };
8143
8144 MapDragHandler.prototype._rotating = function _rotating(param) {
8145 var map = this.target;
8146 var mx = param['mousePos'].x,
8147 my = param['mousePos'].y;
8148 var prePitch = map.getPitch(),
8149 preBearing = map.getBearing();
8150 var dx = Math.abs(mx - this.preX),
8151 dy = Math.abs(my - this.preY);
8152
8153 if (!this._rotateMode) {
8154 if (map.options['dragRotatePitch']) {
8155 this._rotateMode = 'rotate_pitch';
8156 } else if (dx > dy) {
8157 this._rotateMode = 'rotate';
8158 } else if (dx < dy) {
8159 this._rotateMode = 'pitch';
8160 } else {
8161 this._rotateMode = 'rotate';
8162 }
8163 }
8164
8165 if (this._rotateMode === 'pitch' && prePitch === 0 && dy < 10) {
8166 return;
8167 }
8168
8169 if (this._rotateMode.indexOf('rotate') >= 0 && map.options['dragRotate']) {
8170
8171 var db = 0;
8172 if (map.options['dragPitch'] || dx > dy) {
8173 db = -0.6 * (this.preX - mx);
8174 } else if (mx > map.width / 2) {
8175 db = 0.6 * (this.preY - my);
8176 } else {
8177 db = -0.6 * (this.preY - my);
8178 }
8179 var bearing = map.getBearing() + db;
8180 this._db = this._db || 0;
8181 this._db += db;
8182
8183 map.setBearing(bearing);
8184 }
8185 if (this._rotateMode.indexOf('pitch') >= 0 && map.options['dragPitch']) {
8186 map.setPitch(map.getPitch() + (this.preY - my) * 0.4);
8187 }
8188 this.preX = mx;
8189 this.preY = my;
8190 if (map.getBearing() !== preBearing || map.getPitch() !== prePitch) {
8191 map.onDragRotating(param);
8192 }
8193 };
8194
8195 MapDragHandler.prototype._rotateEnd = function _rotateEnd(param) {
8196 var map = this.target;
8197 var bearing = map.getBearing();
8198 this._clear();
8199 var t = now() - this.startDragTime;
8200 map.onDragRotateEnd(param);
8201 if (Math.abs(bearing - this.startBearing) > 20 && (this._rotateMode === 'rotate' || this._rotateMode === 'rotate_pitch') && !param.interupted && t < 400) {
8202 var _bearing = map.getBearing();
8203 map.animateTo({
8204 'bearing': _bearing + this._db / 2
8205 }, {
8206 'easing': 'out',
8207 'duration': 800
8208 });
8209 }
8210 };
8211
8212 MapDragHandler.prototype._clear = function _clear() {
8213 delete this.startPrjCoord;
8214 delete this.preX;
8215 delete this.preY;
8216 delete this.startX;
8217 delete this.startY;
8218 };
8219
8220 return MapDragHandler;
8221}(Handler$1);
8222
8223Map.mergeOptions({
8224 'draggable': true,
8225 'dragPan': true,
8226 'dragRotatePitch': true,
8227 'dragRotate': true,
8228 'dragPitch': true
8229});
8230
8231Map.addOnLoadHook('addHandler', 'draggable', MapDragHandler);
8232
8233function clipLine(points, bounds, round, noCut) {
8234 var parts = [];
8235 var k = 0,
8236 segment = void 0;
8237 for (var j = 0, l = points.length; j < l - 1; j++) {
8238 segment = clipSegment(points[j], points[j + 1], bounds, j, round, noCut);
8239
8240 if (!segment) {
8241 continue;
8242 }
8243
8244 parts[k] = parts[k] || [];
8245 parts[k].push({
8246 'point': segment[0],
8247 'index': j
8248 });
8249
8250 if (segment[1] !== points[j + 1] || j === l - 2) {
8251 parts[k].push({
8252 'point': segment[1],
8253 'index': j + 1
8254 });
8255 k++;
8256 }
8257 }
8258 return parts;
8259}
8260
8261var _lastCode = void 0;
8262
8263function clipSegment(a, b, bounds, useLastCode, round, noCut) {
8264 var codeA = useLastCode ? _lastCode : _getBitCode(a, bounds),
8265 codeB = _getBitCode(b, bounds),
8266 codeOut = void 0,
8267 p = void 0,
8268 newCode = void 0;
8269
8270 _lastCode = codeB;
8271
8272 while (true) {
8273 if (!(codeA | codeB)) {
8274 return [a, b];
8275 }
8276
8277 if (codeA & codeB) {
8278 return false;
8279 }
8280
8281 if (noCut) {
8282 return [a, b];
8283 }
8284
8285 codeOut = codeA || codeB;
8286 p = _getEdgeIntersection(a, b, codeOut, bounds, round);
8287 newCode = _getBitCode(p, bounds);
8288
8289 if (codeOut === codeA) {
8290 a = p;
8291 codeA = newCode;
8292 } else {
8293 b = p;
8294 codeB = newCode;
8295 }
8296 }
8297}
8298
8299function clipPolygon(points, bounds, round) {
8300 var edges = [1, 4, 2, 8];
8301 var clippedPoints = void 0,
8302 i = void 0,
8303 j = void 0,
8304 k = void 0,
8305 a = void 0,
8306 b = void 0,
8307 len = void 0,
8308 edge = void 0,
8309 p = void 0;
8310
8311 for (i = 0, len = points.length; i < len; i++) {
8312 points[i]._code = _getBitCode(points[i], bounds);
8313 }
8314
8315 for (k = 0; k < 4; k++) {
8316 edge = edges[k];
8317 clippedPoints = [];
8318
8319 for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {
8320 a = points[i];
8321 b = points[j];
8322
8323 if (!(a._code & edge)) {
8324 if (b._code & edge) {
8325 p = _getEdgeIntersection(b, a, edge, bounds, round);
8326 p._code = _getBitCode(p, bounds);
8327 clippedPoints.push(p);
8328 }
8329 clippedPoints.push(a);
8330 } else if (!(b._code & edge)) {
8331 p = _getEdgeIntersection(b, a, edge, bounds, round);
8332 p._code = _getBitCode(p, bounds);
8333 clippedPoints.push(p);
8334 }
8335 }
8336 points = clippedPoints;
8337 }
8338
8339 return points;
8340}
8341
8342
8343
8344
8345
8346function _getEdgeIntersection(a, b, code, bounds, round) {
8347 var dx = b.x - a.x,
8348 dy = b.y - a.y,
8349 min = bounds.getMin(),
8350 max = bounds.getMax();
8351 var x = void 0,
8352 y = void 0;
8353
8354 if (code & 8) {
8355 x = a.x + dx * (max.y - a.y) / dy;
8356 y = max.y;
8357 } else if (code & 4) {
8358 x = a.x + dx * (min.y - a.y) / dy;
8359 y = min.y;
8360 } else if (code & 2) {
8361 x = max.x;
8362 y = a.y + dy * (max.x - a.x) / dx;
8363 } else if (code & 1) {
8364 x = min.x;
8365 y = a.y + dy * (min.x - a.x) / dx;
8366 }
8367
8368 var p = new Point(x, y);
8369 if (round) {
8370 p._round();
8371 }
8372 return p;
8373}
8374
8375function _getBitCode(p, bounds) {
8376 var code = 0;
8377
8378 if (p.x < bounds.getMin().x) {
8379 code |= 1;
8380 } else if (p.x > bounds.getMax().x) {
8381 code |= 2;
8382 }
8383
8384 if (p.y < bounds.getMin().y) {
8385 code |= 4;
8386 } else if (p.y > bounds.getMax().y) {
8387 code |= 8;
8388 }
8389
8390 return code;
8391}
8392
8393function withInEllipse(point, center, southeast, tolerance) {
8394 point = new Point(point);
8395 var a = Math.abs(southeast.x - center.x),
8396 b = Math.abs(southeast.y - center.y),
8397 c = Math.sqrt(Math.abs(a * a - b * b)),
8398 xfocus = a >= b;
8399 var f1 = void 0,
8400 f2 = void 0,
8401 d = void 0;
8402 if (xfocus) {
8403 f1 = new Point(center.x - c, center.y);
8404 f2 = new Point(center.x + c, center.y);
8405 d = a * 2;
8406 } else {
8407 f1 = new Point(center.x, center.y - c);
8408 f2 = new Point(center.x, center.y + c);
8409 d = b * 2;
8410 }
8411
8412 return point.distanceTo(f1) + point.distanceTo(f2) <= d + 2 * tolerance;
8413}
8414
8415var Symbolizer = function () {
8416 function Symbolizer() {
8417 classCallCheck(this, Symbolizer);
8418 }
8419
8420 Symbolizer.prototype.getMap = function getMap() {
8421 return this.geometry.getMap();
8422 };
8423
8424 Symbolizer.prototype.getPainter = function getPainter() {
8425 return this.painter;
8426 };
8427
8428 Symbolizer.testColor = function testColor(prop) {
8429 if (!prop || !isString(prop)) {
8430 return false;
8431 }
8432 if (COLOR_PROPERTIES.indexOf(prop) >= 0) {
8433 return true;
8434 }
8435 return false;
8436 };
8437
8438 return Symbolizer;
8439}();
8440
8441var CanvasSymbolizer = function (_Symbolizer) {
8442 inherits(CanvasSymbolizer, _Symbolizer);
8443
8444 function CanvasSymbolizer() {
8445 classCallCheck(this, CanvasSymbolizer);
8446 return possibleConstructorReturn(this, _Symbolizer.apply(this, arguments));
8447 }
8448
8449 CanvasSymbolizer.prototype._prepareContext = function _prepareContext(ctx) {
8450 if (isNumber(this.symbol['opacity'])) {
8451 if (ctx.globalAlpha !== this.symbol['opacity']) {
8452 ctx.globalAlpha = this.symbol['opacity'];
8453 }
8454 } else if (ctx.globalAlpha !== 1) {
8455 ctx.globalAlpha = 1;
8456 }
8457 };
8458
8459 CanvasSymbolizer.prototype.prepareCanvas = function prepareCanvas(ctx, style, resources) {
8460 Canvas.prepareCanvas(ctx, style, resources, this.getPainter().isHitTesting());
8461 };
8462
8463 CanvasSymbolizer.prototype.remove = function remove() {};
8464
8465 CanvasSymbolizer.prototype.setZIndex = function setZIndex() {};
8466
8467 CanvasSymbolizer.prototype.show = function show() {};
8468
8469 CanvasSymbolizer.prototype.hide = function hide() {};
8470
8471 CanvasSymbolizer.prototype._defineStyle = function _defineStyle(style) {
8472 return function () {
8473 var _this2 = this;
8474
8475 var arr = [],
8476 prop = {};
8477 return loadFunctionTypes(style, function () {
8478 var map = _this2.getMap();
8479 return set$1(arr, map.getZoom(), extend({}, _this2.geometry.getProperties(), setProp(prop, map.getBearing(), map.getPitch(), map.getZoom())));
8480 });
8481 }.bind(this)();
8482 };
8483
8484 return CanvasSymbolizer;
8485}(Symbolizer);
8486
8487function set$1(arr, a0, a1) {
8488 arr[0] = a0;
8489 arr[1] = a1;
8490 return arr;
8491}
8492
8493function setProp(prop, b, p, z) {
8494 prop['{bearing}'] = b;
8495 prop['{pitch}'] = p;
8496 prop['{zoom}'] = z;
8497 return prop;
8498}
8499
8500var PointSymbolizer = function (_CanvasSymbolizer) {
8501 inherits(PointSymbolizer, _CanvasSymbolizer);
8502
8503 function PointSymbolizer(symbol, geometry, painter) {
8504 classCallCheck(this, PointSymbolizer);
8505
8506 var _this = possibleConstructorReturn(this, _CanvasSymbolizer.call(this));
8507
8508 _this.symbol = symbol;
8509 _this.geometry = geometry;
8510 _this.painter = painter;
8511 return _this;
8512 }
8513
8514 PointSymbolizer.prototype.get2DExtent = function get2DExtent() {
8515 var map = this.getMap();
8516 var glZoom = map.getGLZoom();
8517 var extent = new PointExtent();
8518 var renderPoints = this._getRenderPoints()[0];
8519 for (var i = renderPoints.length - 1; i >= 0; i--) {
8520 if (renderPoints[i]) {
8521 extent._combine(map._pointToPoint(renderPoints[i], glZoom));
8522 }
8523 }
8524 return extent;
8525 };
8526
8527 PointSymbolizer.prototype._rotateExtent = function _rotateExtent(fixedExtent, angle) {
8528 return fixedExtent.convertTo(function (p) {
8529 return p._rotate(angle);
8530 });
8531 };
8532
8533 PointSymbolizer.prototype._getRenderPoints = function _getRenderPoints() {
8534 return this.getPainter().getRenderPoints(this.getPlacement());
8535 };
8536
8537 PointSymbolizer.prototype._getRenderContainerPoints = function _getRenderContainerPoints(ignoreAltitude) {
8538 var painter = this.getPainter(),
8539 points = this._getRenderPoints()[0];
8540 if (painter.isSpriting()) {
8541 return points;
8542 }
8543 var dxdy = this.getDxDy();
8544 var cpoints = this.painter._pointContainerPoints(points, dxdy.x, dxdy.y, ignoreAltitude, true, this.getPlacement());
8545 if (!cpoints || !Array.isArray(cpoints[0])) {
8546 return cpoints;
8547 }
8548 var flat = [];
8549 for (var i = 0, l = cpoints.length; i < l; i++) {
8550 for (var ii = 0, ll = cpoints[i].length; ii < ll; ii++) {
8551 flat.push(cpoints[i][ii]);
8552 }
8553 }
8554 return flat;
8555 };
8556
8557 PointSymbolizer.prototype._getRotationAt = function _getRotationAt(i) {
8558 var r = this.getRotation();
8559 if (!r) {
8560 r = 0;
8561 }
8562 var rotations = this._getRenderPoints()[1];
8563 if (!rotations || !rotations[i]) {
8564 return r;
8565 }
8566
8567 var map = this.getMap();
8568 var p0 = rotations[i][0],
8569 p1 = rotations[i][1];
8570 if (map.isTransforming()) {
8571 var maxZoom = map.getGLZoom();
8572 p0 = map._pointToContainerPoint(rotations[i][0], maxZoom);
8573 p1 = map._pointToContainerPoint(rotations[i][1], maxZoom);
8574 }
8575 return r + computeDegree(p0.x, p0.y, p1.x, p1.y);
8576 };
8577
8578 PointSymbolizer.prototype._rotate = function _rotate(ctx, origin, rotation) {
8579 if (rotation) {
8580 var dxdy = this.getDxDy();
8581 var p = origin.sub(dxdy);
8582 ctx.save();
8583 ctx.translate(p.x, p.y);
8584 ctx.rotate(rotation);
8585 return this.getDxDy();
8586 }
8587 return null;
8588 };
8589
8590 return PointSymbolizer;
8591}(CanvasSymbolizer);
8592
8593var VectorMarkerSymbolizer = function (_PointSymbolizer) {
8594 inherits(VectorMarkerSymbolizer, _PointSymbolizer);
8595
8596 VectorMarkerSymbolizer.test = function test(symbol) {
8597 if (!symbol) {
8598 return false;
8599 }
8600 if (isNil(symbol['markerFile']) && !isNil(symbol['markerType']) && symbol['markerType'] !== 'path') {
8601 return true;
8602 }
8603 return false;
8604 };
8605
8606 function VectorMarkerSymbolizer(symbol, geometry, painter) {
8607 classCallCheck(this, VectorMarkerSymbolizer);
8608
8609 var _this = possibleConstructorReturn(this, _PointSymbolizer.call(this, symbol, geometry, painter));
8610
8611 _this._dynamic = hasFunctionDefinition(symbol);
8612 _this.style = _this._defineStyle(_this.translate());
8613 _this.strokeAndFill = _this._defineStyle(VectorMarkerSymbolizer.translateLineAndFill(_this.style));
8614 var lineWidth = _this.strokeAndFill['lineWidth'];
8615 if (lineWidth % 2 === 0) {
8616 _this.padding = 2;
8617 } else {
8618 _this.padding = 1.5;
8619 }
8620 return _this;
8621 }
8622
8623 VectorMarkerSymbolizer.prototype.symbolize = function symbolize(ctx, resources) {
8624 var style = this.style;
8625 if (!this.painter.isHitTesting() && (style['markerWidth'] === 0 || style['markerHeight'] === 0 || style['polygonOpacity'] === 0 && style['lineOpacity'] === 0)) {
8626 return;
8627 }
8628 var cookedPoints = this._getRenderContainerPoints();
8629 if (!isArrayHasData(cookedPoints)) {
8630 return;
8631 }
8632 this._prepareContext(ctx);
8633 if (this.getPainter().isSpriting() || this.geometry.getLayer().getMask() === this.geometry || this._dynamic || this.geometry.getLayer().options['cacheVectorOnCanvas'] === false) {
8634 this._drawMarkers(ctx, cookedPoints, resources);
8635 } else {
8636 this._drawMarkersWithCache(ctx, cookedPoints, resources);
8637 }
8638 };
8639
8640 VectorMarkerSymbolizer.prototype.getDxDy = function getDxDy() {
8641 var s = this.style;
8642 var dx = s['markerDx'],
8643 dy = s['markerDy'];
8644 return new Point(dx, dy);
8645 };
8646
8647 VectorMarkerSymbolizer.prototype._drawMarkers = function _drawMarkers(ctx, cookedPoints, resources) {
8648 var strokeAndFill = this.strokeAndFill;
8649 var gradient = isGradient(strokeAndFill['lineColor']) || isGradient(strokeAndFill['polygonFill']);
8650 if (!gradient) {
8651 this.prepareCanvas(ctx, strokeAndFill, resources);
8652 }
8653 for (var i = cookedPoints.length - 1; i >= 0; i--) {
8654 var point = cookedPoints[i];
8655 var origin = this._rotate(ctx, point, this._getRotationAt(i));
8656 if (origin) {
8657 point = origin;
8658 }
8659
8660 this._drawVectorMarker(ctx, point, resources);
8661 if (origin) {
8662 ctx.restore();
8663 }
8664 }
8665 };
8666
8667 VectorMarkerSymbolizer.prototype._drawMarkersWithCache = function _drawMarkersWithCache(ctx, cookedPoints, resources) {
8668 var stamp = this._stampSymbol();
8669 var image = resources.getImage(stamp);
8670 if (!image) {
8671 image = this._createMarkerImage(ctx, resources);
8672 resources.addResource([stamp, image.width, image.height], image);
8673 }
8674 var anchor = this._getAnchor(image.width, image.height);
8675 for (var i = cookedPoints.length - 1; i >= 0; i--) {
8676 var point = cookedPoints[i];
8677 var origin = this._rotate(ctx, point, this._getRotationAt(i));
8678 if (origin) {
8679 point = origin;
8680 }
8681 Canvas.image(ctx, image, point.x + anchor.x, point.y + anchor.y);
8682 if (origin) {
8683 ctx.restore();
8684 }
8685 }
8686 };
8687
8688 VectorMarkerSymbolizer.prototype._calMarkerSize = function _calMarkerSize() {
8689 if (!this._size) {
8690 var lineWidth = this.strokeAndFill['lineWidth'],
8691 shadow = 2 * (this.symbol['shadowBlur'] || 0),
8692 w = Math.round(this.style['markerWidth'] + lineWidth + 2 * shadow + this.padding * 2),
8693 h = Math.round(this.style['markerHeight'] + lineWidth + 2 * shadow + this.padding * 2);
8694 this._size = [w, h];
8695 }
8696 return this._size;
8697 };
8698
8699 VectorMarkerSymbolizer.prototype._createMarkerImage = function _createMarkerImage(ctx, resources) {
8700 var canvasClass = ctx.canvas.constructor,
8701 size = this._calMarkerSize(),
8702 canvas = Canvas.createCanvas(size[0], size[1], canvasClass),
8703 point = this._getCacheImageAnchor(size[0], size[1]);
8704 var context = canvas.getContext('2d');
8705 var gradient = isGradient(this.strokeAndFill['lineColor']) || isGradient(this.strokeAndFill['polygonFill']);
8706 if (!gradient) {
8707 this.prepareCanvas(context, this.strokeAndFill, resources);
8708 }
8709 this._drawVectorMarker(context, point, resources);
8710 return canvas;
8711 };
8712
8713 VectorMarkerSymbolizer.prototype._stampSymbol = function _stampSymbol() {
8714 if (!this._stamp) {
8715 this._stamp = [this.style['markerType'], isGradient(this.style['markerFill']) ? getGradientStamp(this.style['markerFill']) : this.style['markerFill'], this.style['markerFillOpacity'], this.style['markerFillPatternFile'], isGradient(this.style['markerLineColor']) ? getGradientStamp(this.style['markerLineColor']) : this.style['markerLineColor'], this.style['markerLineWidth'], this.style['markerLineOpacity'], this.style['markerLineDasharray'] ? this.style['markerLineDasharray'].join(',') : '', this.style['markerLinePatternFile'], this.style['markerWidth'], this.style['markerHeight'], this.style['markerHorizontalAlignment'], this.style['markerVerticalAlignment']].join('_');
8716 }
8717 return this._stamp;
8718 };
8719
8720 VectorMarkerSymbolizer.prototype._getAnchor = function _getAnchor(w, h) {
8721 var shadow = 2 * (this.symbol['shadowBlur'] || 0),
8722 margin = shadow + this.padding;
8723 var p = getAlignPoint(new Size(w, h), this.style['markerHorizontalAlignment'], this.style['markerVerticalAlignment']);
8724 if (p.x !== -w / 2) {
8725 p.x -= sign(p.x + w / 2) * margin;
8726 }
8727 if (p.y !== -h / 2) {
8728 p.y -= sign(p.y + h / 2) * margin;
8729 }
8730 return p;
8731 };
8732
8733 VectorMarkerSymbolizer.prototype._getCacheImageAnchor = function _getCacheImageAnchor(w, h) {
8734 var shadow = 2 * (this.symbol['shadowBlur'] || 0),
8735 margin = shadow + this.padding;
8736 var markerType = this.style['markerType'];
8737 if (markerType === 'bar' || markerType === 'pie' || markerType === 'pin') {
8738 return new Point(w / 2, h - margin);
8739 } else if (markerType === 'rectangle') {
8740 return new Point(margin, margin);
8741 } else {
8742 return new Point(w / 2, h / 2);
8743 }
8744 };
8745
8746 VectorMarkerSymbolizer.prototype._getGraidentExtent = function _getGraidentExtent(points) {
8747 var e = new PointExtent(),
8748 dxdy = this.getDxDy(),
8749 m = this.getFixedExtent();
8750 if (Array.isArray(points)) {
8751 for (var i = points.length - 1; i >= 0; i--) {
8752 e._combine(points[i]);
8753 }
8754 } else {
8755 e._combine(points);
8756 }
8757 e['xmin'] += m['xmin'] - dxdy.x;
8758 e['ymin'] += m['ymin'] - dxdy.y;
8759 e['xmax'] += m['xmax'] - dxdy.x;
8760 e['ymax'] += m['ymax'] - dxdy.y;
8761 return e;
8762 };
8763
8764 VectorMarkerSymbolizer.prototype._drawVectorMarker = function _drawVectorMarker(ctx, point, resources) {
8765 var style = this.style,
8766 strokeAndFill = this.strokeAndFill,
8767 markerType = style['markerType'].toLowerCase(),
8768 vectorArray = VectorMarkerSymbolizer._getVectorPoints(markerType, style['markerWidth'], style['markerHeight']),
8769 lineOpacity = strokeAndFill['lineOpacity'],
8770 fillOpacity = strokeAndFill['polygonOpacity'];
8771 var gradient = isGradient(strokeAndFill['lineColor']) || isGradient(strokeAndFill['polygonFill']);
8772 if (gradient) {
8773 var gradientExtent = void 0;
8774 if (isGradient(strokeAndFill['lineColor'])) {
8775 gradientExtent = this._getGraidentExtent(point);
8776 strokeAndFill['lineGradientExtent'] = gradientExtent.expand(strokeAndFill['lineWidth']);
8777 }
8778 if (isGradient(strokeAndFill['polygonFill'])) {
8779 if (!gradientExtent) {
8780 gradientExtent = this._getGraidentExtent(point);
8781 }
8782 strokeAndFill['polygonGradientExtent'] = gradientExtent;
8783 }
8784 this.prepareCanvas(ctx, strokeAndFill, resources);
8785 }
8786
8787 var width = style['markerWidth'],
8788 height = style['markerHeight'],
8789 hLineWidth = style['markerLineWidth'] / 2;
8790 if (markerType === 'ellipse') {
8791 Canvas.ellipse(ctx, point, width / 2, height / 2, lineOpacity, fillOpacity);
8792 } else if (markerType === 'cross' || markerType === 'x') {
8793 for (var j = vectorArray.length - 1; j >= 0; j--) {
8794 vectorArray[j]._add(point);
8795 }
8796
8797 Canvas.path(ctx, vectorArray.slice(0, 2), lineOpacity);
8798 Canvas.path(ctx, vectorArray.slice(2, 4), lineOpacity);
8799 } else if (markerType === 'diamond' || markerType === 'bar' || markerType === 'square' || markerType === 'rectangle' || markerType === 'triangle') {
8800 if (markerType === 'bar') {
8801 point = point.add(0, -hLineWidth);
8802 } else if (markerType === 'rectangle') {
8803 point = point.add(hLineWidth, hLineWidth);
8804 }
8805 for (var _j = vectorArray.length - 1; _j >= 0; _j--) {
8806 vectorArray[_j]._add(point);
8807 }
8808
8809 Canvas.polygon(ctx, vectorArray, lineOpacity, fillOpacity);
8810 } else if (markerType === 'pin') {
8811 point = point.add(0, -hLineWidth);
8812 for (var _j2 = vectorArray.length - 1; _j2 >= 0; _j2--) {
8813 vectorArray[_j2]._add(point);
8814 }
8815 var lineCap = ctx.lineCap;
8816 ctx.lineCap = 'round';
8817 Canvas.bezierCurveAndFill(ctx, vectorArray, lineOpacity, fillOpacity);
8818 ctx.lineCap = lineCap;
8819 } else if (markerType === 'pie') {
8820 point = point.add(0, -hLineWidth);
8821 var angle = Math.atan(width / 2 / height) * 180 / Math.PI;
8822 var _lineCap = ctx.lineCap;
8823 ctx.lineCap = 'round';
8824 Canvas.sector(ctx, point, height, [90 - angle, 90 + angle], lineOpacity, fillOpacity);
8825 ctx.lineCap = _lineCap;
8826 } else {
8827 throw new Error('unsupported markerType: ' + markerType);
8828 }
8829 };
8830
8831 VectorMarkerSymbolizer.prototype.getPlacement = function getPlacement() {
8832 return this.symbol['markerPlacement'];
8833 };
8834
8835 VectorMarkerSymbolizer.prototype.getRotation = function getRotation() {
8836 var r = this.style['markerRotation'];
8837 if (!isNumber(r)) {
8838 return null;
8839 }
8840
8841 return -r * Math.PI / 180;
8842 };
8843
8844 VectorMarkerSymbolizer.prototype.getFixedExtent = function getFixedExtent() {
8845 var dxdy = this.getDxDy(),
8846 padding = this.padding * 2;
8847 var size = this._calMarkerSize().map(function (d) {
8848 return d - padding;
8849 });
8850 var alignPoint = this._getAnchor(size[0], size[1]);
8851 var result = new PointExtent(dxdy.add(0, 0), dxdy.add(size[0], size[1]));
8852 result._add(alignPoint);
8853 var rotation = this.getRotation();
8854 if (rotation) {
8855 result = this._rotateExtent(result, rotation);
8856 }
8857
8858 return result;
8859 };
8860
8861 VectorMarkerSymbolizer.prototype.translate = function translate() {
8862 var s = this.symbol;
8863 var result = {
8864 'markerType': getValueOrDefault(s['markerType'], 'ellipse'),
8865 'markerFill': getValueOrDefault(s['markerFill'], '#00f'),
8866 'markerFillOpacity': getValueOrDefault(s['markerFillOpacity'], 1),
8867 'markerFillPatternFile': getValueOrDefault(s['markerFillPatternFile'], null),
8868 'markerLineColor': getValueOrDefault(s['markerLineColor'], '#000'),
8869 'markerLineWidth': getValueOrDefault(s['markerLineWidth'], 1),
8870 'markerLineOpacity': getValueOrDefault(s['markerLineOpacity'], 1),
8871 'markerLineDasharray': getValueOrDefault(s['markerLineDasharray'], []),
8872 'markerLinePatternFile': getValueOrDefault(s['markerLinePatternFile'], null),
8873
8874 'markerDx': getValueOrDefault(s['markerDx'], 0),
8875 'markerDy': getValueOrDefault(s['markerDy'], 0),
8876
8877 'markerWidth': getValueOrDefault(s['markerWidth'], 10),
8878 'markerHeight': getValueOrDefault(s['markerHeight'], 10),
8879
8880 'markerRotation': getValueOrDefault(s['markerRotation'], 0)
8881 };
8882 var markerType = result['markerType'];
8883 var ha = void 0,
8884 va = void 0;
8885 if (markerType === 'bar' || markerType === 'pie' || markerType === 'pin') {
8886 ha = 'middle';
8887 va = 'top';
8888 } else if (markerType === 'rectangle') {
8889 ha = 'right';
8890 va = 'bottom';
8891 } else {
8892 ha = 'middle';
8893 va = 'middle';
8894 }
8895
8896 result['markerHorizontalAlignment'] = getValueOrDefault(s['markerHorizontalAlignment'], ha);
8897 result['markerVerticalAlignment'] = getValueOrDefault(s['markerVerticalAlignment'], va);
8898 if (isNumber(s['markerOpacity'])) {
8899 if (isNumber(s['markerFillOpacity'])) {
8900 result['markerFillOpacity'] *= s['markerOpacity'];
8901 }
8902 if (isNumber(s['markerLineOpacity'])) {
8903 result['markerLineOpacity'] *= s['markerOpacity'];
8904 }
8905 }
8906 return result;
8907 };
8908
8909 VectorMarkerSymbolizer.translateLineAndFill = function translateLineAndFill(s) {
8910 var result = {
8911 'lineColor': s['markerLineColor'],
8912 'linePatternFile': s['markerLinePatternFile'],
8913 'lineWidth': s['markerLineWidth'],
8914 'lineOpacity': s['markerLineOpacity'],
8915 'lineDasharray': s['markerLineDasharray'],
8916 'lineCap': 'butt',
8917 'lineJoin': 'round',
8918 'polygonFill': s['markerFill'],
8919 'polygonPatternFile': s['markerFillPatternFile'],
8920 'polygonOpacity': s['markerFillOpacity']
8921 };
8922 if (result['lineWidth'] === 0) {
8923 result['lineOpacity'] = 0;
8924 }
8925 return result;
8926 };
8927
8928 VectorMarkerSymbolizer._getVectorPoints = function _getVectorPoints(markerType, width, height) {
8929 var hh = height / 2,
8930 hw = width / 2;
8931 var left = 0,
8932 top = 0;
8933 var v0 = void 0,
8934 v1 = void 0,
8935 v2 = void 0,
8936 v3 = void 0;
8937 if (markerType === 'triangle') {
8938 v0 = new Point(left, top - hh);
8939 v1 = new Point(left - hw, top + hh);
8940 v2 = new Point(left + hw, top + hh);
8941 return [v0, v1, v2];
8942 } else if (markerType === 'cross') {
8943 v0 = new Point(left - hw, top);
8944 v1 = new Point(left + hw, top);
8945 v2 = new Point(left, top - hh);
8946 v3 = new Point(left, top + hh);
8947 return [v0, v1, v2, v3];
8948 } else if (markerType === 'diamond') {
8949 v0 = new Point(left - hw, top);
8950 v1 = new Point(left, top - hh);
8951 v2 = new Point(left + hw, top);
8952 v3 = new Point(left, top + hh);
8953 return [v0, v1, v2, v3];
8954 } else if (markerType === 'square') {
8955 v0 = new Point(left - hw, top + hh);
8956 v1 = new Point(left + hw, top + hh);
8957 v2 = new Point(left + hw, top - hh);
8958 v3 = new Point(left - hw, top - hh);
8959 return [v0, v1, v2, v3];
8960 } else if (markerType === 'rectangle') {
8961 v0 = new Point(left, top);
8962 v1 = v0.add(width, 0);
8963 v2 = v0.add(width, height);
8964 v3 = v0.add(0, height);
8965 return [v0, v1, v2, v3];
8966 } else if (markerType === 'x') {
8967 v0 = new Point(left - hw, top + hh);
8968 v1 = new Point(left + hw, top - hh);
8969 v2 = new Point(left + hw, top + hh);
8970 v3 = new Point(left - hw, top - hh);
8971 return [v0, v1, v2, v3];
8972 } else if (markerType === 'bar') {
8973 v0 = new Point(left - hw, top - height);
8974 v1 = new Point(left + hw, top - height);
8975 v2 = new Point(left + hw, top);
8976 v3 = new Point(left - hw, top);
8977 return [v0, v1, v2, v3];
8978 } else if (markerType === 'pin') {
8979 var extWidth = height * Math.atan(hw / hh);
8980 v0 = new Point(left, top);
8981 v1 = new Point(left - extWidth, top - height);
8982 v2 = new Point(left + extWidth, top - height);
8983 v3 = new Point(left, top);
8984 return [v0, v1, v2, v3];
8985 }
8986 return [];
8987 };
8988
8989 return VectorMarkerSymbolizer;
8990}(PointSymbolizer);
8991
8992var DebugSymbolizer = function (_PointSymbolizer) {
8993 inherits(DebugSymbolizer, _PointSymbolizer);
8994
8995 function DebugSymbolizer() {
8996 classCallCheck(this, DebugSymbolizer);
8997 return possibleConstructorReturn(this, _PointSymbolizer.apply(this, arguments));
8998 }
8999
9000 DebugSymbolizer.prototype.getPlacement = function getPlacement() {
9001 return 'point';
9002 };
9003
9004 DebugSymbolizer.prototype.getDxDy = function getDxDy() {
9005 return new Point(0, 0);
9006 };
9007
9008 DebugSymbolizer.prototype.symbolize = function symbolize(ctx) {
9009 var geometry = this.geometry,
9010 layer = geometry.getLayer();
9011 if (!geometry.options['debug'] && layer && !layer.options['debug']) {
9012 return;
9013 }
9014 var map = this.getMap();
9015 if (!map || map.isZooming()) {
9016 return;
9017 }
9018 var color = layer.options['debugOutline'],
9019 op = 1;
9020 ctx.strokeStyle = color;
9021 ctx.fillStyle = color;
9022
9023 var outline = this.getPainter().getContainerExtent().toArray();
9024 Canvas.polygon(ctx, [outline], op, 0);
9025
9026 var points = this._getRenderContainerPoints(),
9027 id = this.geometry.getId(),
9028 cross = VectorMarkerSymbolizer._getVectorPoints('cross', 10, 10);
9029 for (var i = 0; i < points.length; i++) {
9030 var p = points[i];
9031 if (!isNil(id)) {
9032 Canvas.fillText(ctx, id, p.add(8, -4), color);
9033 }
9034 var c = [];
9035 for (var ii = 0; ii < cross.length; ii++) {
9036 c.push(cross[ii].add(p));
9037 }
9038 Canvas.path(ctx, c.slice(0, 2), op);
9039 Canvas.path(ctx, c.slice(2, 4), op);
9040 }
9041 };
9042
9043 return DebugSymbolizer;
9044}(PointSymbolizer);
9045
9046var ImageMarkerSymbolizer = function (_PointSymbolizer) {
9047 inherits(ImageMarkerSymbolizer, _PointSymbolizer);
9048
9049 ImageMarkerSymbolizer.test = function test(symbol) {
9050 if (!symbol) {
9051 return false;
9052 }
9053 if (!isNil(symbol['markerFile'])) {
9054 return true;
9055 }
9056 return false;
9057 };
9058
9059 function ImageMarkerSymbolizer(symbol, geometry, painter) {
9060 classCallCheck(this, ImageMarkerSymbolizer);
9061
9062 var _this = possibleConstructorReturn(this, _PointSymbolizer.call(this, symbol, geometry, painter));
9063
9064 _this.style = _this._defineStyle(_this.translate());
9065 return _this;
9066 }
9067
9068 ImageMarkerSymbolizer.prototype.symbolize = function symbolize(ctx, resources) {
9069 var style = this.style;
9070 if (!this.painter.isHitTesting() && (style['markerWidth'] === 0 || style['markerHeight'] === 0 || style['markerOpacity'] === 0)) {
9071 return;
9072 }
9073 var cookedPoints = this._getRenderContainerPoints();
9074 if (!isArrayHasData(cookedPoints)) {
9075 return;
9076 }
9077
9078 var img = this._getImage(resources);
9079 if (!img) {
9080 if (typeof console !== 'undefined') {
9081 console.warn('no img found for ' + (this.style['markerFile'] || this._url[0]));
9082 }
9083 return;
9084 }
9085 this._prepareContext(ctx);
9086 var width = style['markerWidth'];
9087 var height = style['markerHeight'];
9088 if (!isNumber(width) || !isNumber(height)) {
9089 width = img.width;
9090 height = img.height;
9091 style['markerWidth'] = width;
9092 style['markerHeight'] = height;
9093 var imgURL = [style['markerFile'], style['markerWidth'], style['markerHeight']];
9094 if (!resources.isResourceLoaded(imgURL)) {
9095 resources.addResource(imgURL, img);
9096 }
9097 var painter = this.getPainter();
9098 if (!painter.isSpriting()) {
9099 painter.removeCache();
9100 }
9101 }
9102 var alpha = void 0;
9103
9104 if (this.symbol['markerType'] !== 'path' && isNumber(style['markerOpacity']) && style['markerOpacity'] < 1) {
9105 alpha = ctx.globalAlpha;
9106 ctx.globalAlpha *= style['markerOpacity'];
9107 }
9108 var alignPoint = getAlignPoint(new Size(width, height), style['markerHorizontalAlignment'], style['markerVerticalAlignment']);
9109 for (var i = 0, len = cookedPoints.length; i < len; i++) {
9110 var p = cookedPoints[i];
9111 var origin = this._rotate(ctx, p, this._getRotationAt(i));
9112 if (origin) {
9113 p = origin;
9114 }
9115 Canvas.image(ctx, img, p.x + alignPoint.x, p.y + alignPoint.y, width, height);
9116 if (origin) {
9117 ctx.restore();
9118 }
9119 }
9120 if (alpha !== undefined) {
9121 ctx.globalAlpha = alpha;
9122 }
9123 };
9124
9125 ImageMarkerSymbolizer.prototype._getImage = function _getImage(resources) {
9126 var img = !resources ? null : resources.getImage([this.style['markerFile'], this.style['markerWidth'], this.style['markerHeight']]);
9127 return img;
9128 };
9129
9130 ImageMarkerSymbolizer.prototype.getPlacement = function getPlacement() {
9131 return this.symbol['markerPlacement'];
9132 };
9133
9134 ImageMarkerSymbolizer.prototype.getRotation = function getRotation() {
9135 var r = this.style['markerRotation'];
9136 if (!isNumber(r)) {
9137 return null;
9138 }
9139
9140 return -r * Math.PI / 180;
9141 };
9142
9143 ImageMarkerSymbolizer.prototype.getDxDy = function getDxDy() {
9144 var s = this.style;
9145 var dx = s['markerDx'],
9146 dy = s['markerDy'];
9147 return new Point(dx, dy);
9148 };
9149
9150 ImageMarkerSymbolizer.prototype.getFixedExtent = function getFixedExtent(resources) {
9151 var style = this.style;
9152 var url = style['markerFile'],
9153 img = resources ? resources.getImage(url) : null;
9154 var width = style['markerWidth'] || (img ? img.width : 0),
9155 height = style['markerHeight'] || (img ? img.height : 0);
9156 var dxdy = this.getDxDy();
9157 var alignPoint = getAlignPoint(new Size(width, height), style['markerHorizontalAlignment'], style['markerVerticalAlignment']);
9158 var result = new PointExtent(dxdy.add(0, 0), dxdy.add(width, height));
9159 result._add(alignPoint);
9160 var rotation = this.getRotation();
9161 if (rotation) {
9162 result = this._rotateExtent(result, rotation);
9163 }
9164 return result;
9165 };
9166
9167 ImageMarkerSymbolizer.prototype.translate = function translate() {
9168 var s = this.symbol;
9169 return {
9170 'markerFile': s['markerFile'],
9171 'markerOpacity': getValueOrDefault(s['markerOpacity'], 1),
9172 'markerWidth': getValueOrDefault(s['markerWidth'], null),
9173 'markerHeight': getValueOrDefault(s['markerHeight'], null),
9174 'markerRotation': getValueOrDefault(s['markerRotation'], 0),
9175
9176 'markerDx': getValueOrDefault(s['markerDx'], 0),
9177 'markerDy': getValueOrDefault(s['markerDy'], 0),
9178
9179 'markerHorizontalAlignment': getValueOrDefault(s['markerHorizontalAlignment'], 'middle'),
9180 'markerVerticalAlignment': getValueOrDefault(s['markerVerticalAlignment'], 'top') };
9181 };
9182
9183 return ImageMarkerSymbolizer;
9184}(PointSymbolizer);
9185
9186var StrokeAndFillSymbolizer = function (_CanvasSymbolizer) {
9187 inherits(StrokeAndFillSymbolizer, _CanvasSymbolizer);
9188
9189 StrokeAndFillSymbolizer.test = function test(symbol, geometry) {
9190 if (!symbol) {
9191 return false;
9192 }
9193 if (geometry && geometry.type === 'Point') {
9194 return false;
9195 }
9196 for (var p in symbol) {
9197 var f = p.slice(0, 4);
9198 if (f === 'line' || f === 'poly') {
9199 return true;
9200 }
9201 }
9202 return false;
9203 };
9204
9205 function StrokeAndFillSymbolizer(symbol, geometry, painter) {
9206 classCallCheck(this, StrokeAndFillSymbolizer);
9207
9208 var _this = possibleConstructorReturn(this, _CanvasSymbolizer.call(this));
9209
9210 _this.symbol = symbol;
9211 _this.geometry = geometry;
9212 _this.painter = painter;
9213 if (geometry.type === 'Point') {
9214 return possibleConstructorReturn(_this);
9215 }
9216 _this.style = _this._defineStyle(_this.translate());
9217 return _this;
9218 }
9219
9220 StrokeAndFillSymbolizer.prototype.symbolize = function symbolize(ctx, resources) {
9221 var style = this.style;
9222 if (style['polygonOpacity'] === 0 && style['lineOpacity'] === 0 && !this.painter.isHitTesting()) {
9223 return;
9224 }
9225 var paintParams = this._getPaintParams();
9226 if (!paintParams) {
9227 return;
9228 }
9229 this._prepareContext(ctx);
9230 var isGradient$$1 = isGradient(style['lineColor']),
9231 isPath = this.geometry.getJSONType() === 'Polygon' || this.geometry.type === 'LineString';
9232 if (isGradient$$1 && (style['lineColor']['places'] || !isPath)) {
9233 style['lineGradientExtent'] = this.getPainter().getContainerExtent()._expand(style['lineWidth']);
9234 }
9235 if (isGradient(style['polygonFill'])) {
9236 style['polygonGradientExtent'] = this.getPainter().getContainerExtent();
9237 }
9238
9239 var points = paintParams[0],
9240 isSplitted = this.geometry.getJSONType() === 'Polygon' && points.length > 0 && Array.isArray(points[0][0]) || this.geometry.type === 'LineString' && points.length > 0 && Array.isArray(points[0]);
9241
9242 if (isSplitted) {
9243 for (var i = 0; i < points.length; i++) {
9244 this.prepareCanvas(ctx, style, resources);
9245 if (isGradient$$1 && isPath && !style['lineColor']['places']) {
9246 this._createGradient(ctx, points[i], style['lineColor']);
9247 }
9248 var params = [ctx, points[i]];
9249 if (paintParams.length > 1) {
9250 params.push.apply(params, paintParams.slice(1));
9251 }
9252 params.push(style['lineOpacity'], style['polygonOpacity'], style['lineDasharray']);
9253 this.geometry._paintOn.apply(this.geometry, params);
9254 }
9255 } else {
9256 this.prepareCanvas(ctx, style, resources);
9257 if (isGradient$$1 && isPath && !style['lineColor']['places']) {
9258 this._createGradient(ctx, points, style['lineColor']);
9259 }
9260 var _params = [ctx];
9261 _params.push.apply(_params, paintParams);
9262 _params.push(style['lineOpacity'], style['polygonOpacity'], style['lineDasharray']);
9263 this.geometry._paintOn.apply(this.geometry, _params);
9264 }
9265
9266 if (ctx.setLineDash && Array.isArray(style['lineDasharray'])) {
9267 ctx.setLineDash([]);
9268 }
9269 };
9270
9271 StrokeAndFillSymbolizer.prototype.get2DExtent = function get2DExtent() {
9272 var map = this.getMap();
9273 var extent = this.geometry._getPrjExtent();
9274 if (!extent) {
9275 return null;
9276 }
9277
9278 if (!this._extMin || !this._extMax) {
9279 this._extMin = new Coordinate(0, 0);
9280 this._extMax = new Coordinate(0, 0);
9281 }
9282 this._extMin.x = extent['xmin'];
9283 this._extMin.y = extent['ymin'];
9284 this._extMax.x = extent['xmax'];
9285 this._extMax.y = extent['ymax'];
9286 var min = map._prjToPoint(this._extMin),
9287 max = map._prjToPoint(this._extMax);
9288 if (!this._pxExtent) {
9289 this._pxExtent = new PointExtent(min, max);
9290 } else {
9291 this._pxExtent['xmin'] = Math.min(min.x, max.x);
9292 this._pxExtent['xmax'] = Math.max(min.x, max.x);
9293 this._pxExtent['ymin'] = Math.min(min.y, max.y);
9294 this._pxExtent['ymax'] = Math.max(min.y, max.y);
9295 }
9296 return this._pxExtent;
9297 };
9298
9299 StrokeAndFillSymbolizer.prototype.getFixedExtent = function getFixedExtent() {
9300 var t = this.style['lineWidth'] / 2;
9301 return new PointExtent(-t, -t, t, t);
9302 };
9303
9304 StrokeAndFillSymbolizer.prototype._getPaintParams = function _getPaintParams() {
9305 return this.getPainter().getPaintParams(this.style['lineDx'], this.style['lineDy']);
9306 };
9307
9308 StrokeAndFillSymbolizer.prototype.translate = function translate() {
9309 var s = this.symbol;
9310 var result = {
9311 'lineColor': getValueOrDefault(s['lineColor'], '#000'),
9312 'lineWidth': getValueOrDefault(s['lineWidth'], 2),
9313 'lineOpacity': getValueOrDefault(s['lineOpacity'], 1),
9314 'lineDasharray': getValueOrDefault(s['lineDasharray'], []),
9315 'lineCap': getValueOrDefault(s['lineCap'], 'butt'),
9316 'lineJoin': getValueOrDefault(s['lineJoin'], 'miter'),
9317 'linePatternFile': getValueOrDefault(s['linePatternFile'], null),
9318 'lineDx': getValueOrDefault(s['lineDx'], 0),
9319 'lineDy': getValueOrDefault(s['lineDy'], 0),
9320 'polygonFill': getValueOrDefault(s['polygonFill'], null),
9321 'polygonOpacity': getValueOrDefault(s['polygonOpacity'], 1),
9322 'polygonPatternFile': getValueOrDefault(s['polygonPatternFile'], null),
9323 'polygonPatternDx': getValueOrDefault(s['polygonPatternDx'], 0),
9324 'polygonPatternDy': getValueOrDefault(s['polygonPatternDy'], 0),
9325 'linePatternDx': getValueOrDefault(s['linePatternDx'], 0),
9326 'linePatternDy': getValueOrDefault(s['linePatternDy'], 0)
9327 };
9328 if (result['lineWidth'] === 0) {
9329 result['lineOpacity'] = 0;
9330 }
9331
9332 if (this.geometry.type === 'LineString' && !result['polygonFill']) {
9333 result['polygonFill'] = result['lineColor'];
9334 }
9335 return result;
9336 };
9337
9338 StrokeAndFillSymbolizer.prototype._createGradient = function _createGradient(ctx, points, lineColor) {
9339 if (!Array.isArray(points)) {
9340 return;
9341 }
9342 var len = points.length;
9343 var grad = ctx.createLinearGradient(points[0].x, points[0].y, points[len - 1].x, points[len - 1].y);
9344 lineColor['colorStops'].forEach(function (stop) {
9345 grad.addColorStop.apply(grad, stop);
9346 });
9347 ctx.strokeStyle = grad;
9348 };
9349
9350 return StrokeAndFillSymbolizer;
9351}(CanvasSymbolizer);
9352
9353var CACHE_KEY = '___text_symbol_cache';
9354
9355var TextMarkerSymbolizer = function (_PointSymbolizer) {
9356 inherits(TextMarkerSymbolizer, _PointSymbolizer);
9357
9358 TextMarkerSymbolizer.test = function test(symbol) {
9359 if (!symbol) {
9360 return false;
9361 }
9362 if (!isNil(symbol['textName'])) {
9363 return true;
9364 }
9365 return false;
9366 };
9367
9368 function TextMarkerSymbolizer(symbol, geometry, painter) {
9369 classCallCheck(this, TextMarkerSymbolizer);
9370
9371 var _this = possibleConstructorReturn(this, _PointSymbolizer.call(this, symbol, geometry, painter));
9372
9373 _this._dynamic = hasFunctionDefinition(symbol);
9374 _this.style = _this._defineStyle(_this.translate());
9375 if (_this.style['textWrapWidth'] === 0) {
9376 return possibleConstructorReturn(_this);
9377 }
9378 _this.strokeAndFill = _this._defineStyle(_this.translateLineAndFill(_this.style));
9379 var textContent = replaceVariable(_this.style['textName'], _this.geometry.getProperties());
9380 if (!_this._dynamic) {
9381 _this._cacheKey = genCacheKey(textContent, _this.style);
9382 }
9383 _this._descText(textContent);
9384 return _this;
9385 }
9386
9387 TextMarkerSymbolizer.prototype.symbolize = function symbolize(ctx, resources) {
9388 if (!this.painter.isHitTesting() && (this.style['textSize'] === 0 || !this.style['textOpacity'] && (!this.style['textHaloRadius'] || !this.style['textHaloOpacity']) || this.style['textWrapWidth'] === 0)) {
9389 return;
9390 }
9391 var cookedPoints = this._getRenderContainerPoints();
9392 if (!isArrayHasData(cookedPoints)) {
9393 return;
9394 }
9395 var style = this.style,
9396 strokeAndFill = this.strokeAndFill;
9397 var textContent = replaceVariable(this.style['textName'], this.geometry.getProperties());
9398 this._descText(textContent);
9399 this._prepareContext(ctx);
9400 this.prepareCanvas(ctx, strokeAndFill, resources);
9401 Canvas.prepareCanvasFont(ctx, style);
9402 for (var i = 0, len = cookedPoints.length; i < len; i++) {
9403 var p = cookedPoints[i];
9404 var origin = this._rotate(ctx, p, this._getRotationAt(i));
9405 if (origin) {
9406 p = origin;
9407 }
9408 Canvas.text(ctx, textContent, p, style, this.textDesc);
9409 if (origin) {
9410 ctx.restore();
9411 }
9412 }
9413 };
9414
9415 TextMarkerSymbolizer.prototype.getPlacement = function getPlacement() {
9416 return this.symbol['textPlacement'];
9417 };
9418
9419 TextMarkerSymbolizer.prototype.getRotation = function getRotation() {
9420 var r = this.style['textRotation'];
9421 if (!isNumber(r)) {
9422 return null;
9423 }
9424
9425 return -r * Math.PI / 180;
9426 };
9427
9428 TextMarkerSymbolizer.prototype.getDxDy = function getDxDy() {
9429 var s = this.style;
9430 return new Point(s['textDx'], s['textDy']);
9431 };
9432
9433 TextMarkerSymbolizer.prototype.getFixedExtent = function getFixedExtent() {
9434 var dxdy = this.getDxDy(),
9435 style = this.style;
9436 var size = this.textDesc['size'];
9437 var alignPoint = getAlignPoint(size, style['textHorizontalAlignment'], style['textVerticalAlignment']);
9438 var alignW = alignPoint.x,
9439 alignH = alignPoint.y;
9440 if (style['textHaloRadius']) {
9441 var r = style['textHaloRadius'];
9442 size = size.add(r * 2, r * 2);
9443 }
9444 var result = new PointExtent(dxdy.add(alignW, alignH), dxdy.add(alignW + size['width'], alignH + size['height']));
9445 var rotation = this.getRotation();
9446 if (rotation) {
9447 result = this._rotateExtent(result, rotation);
9448 }
9449 return result;
9450 };
9451
9452 TextMarkerSymbolizer.prototype.translate = function translate() {
9453 var s = this.symbol;
9454 var result = {
9455 'textName': s['textName'],
9456 'textFaceName': getValueOrDefault(s['textFaceName'], 'monospace'),
9457 'textWeight': getValueOrDefault(s['textWeight'], 'normal'),
9458 'textStyle': getValueOrDefault(s['textStyle'], 'normal'),
9459 'textSize': getValueOrDefault(s['textSize'], 10),
9460 'textFont': getValueOrDefault(s['textFont'], null),
9461 'textFill': getValueOrDefault(s['textFill'], '#000'),
9462 'textOpacity': getValueOrDefault(s['textOpacity'], 1),
9463
9464 'textHaloFill': getValueOrDefault(s['textHaloFill'], '#ffffff'),
9465 'textHaloRadius': getValueOrDefault(s['textHaloRadius'], 0),
9466 'textHaloOpacity': getValueOrDefault(s['textHaloOpacity'], 1),
9467
9468 'textWrapWidth': getValueOrDefault(s['textWrapWidth'], null),
9469 'textWrapCharacter': getValueOrDefault(s['textWrapCharacter'], '\n'),
9470 'textLineSpacing': getValueOrDefault(s['textLineSpacing'], 0),
9471
9472 'textDx': getValueOrDefault(s['textDx'], 0),
9473 'textDy': getValueOrDefault(s['textDy'], 0),
9474
9475 'textHorizontalAlignment': getValueOrDefault(s['textHorizontalAlignment'], 'middle'),
9476 'textVerticalAlignment': getValueOrDefault(s['textVerticalAlignment'], 'middle'),
9477 'textAlign': getValueOrDefault(s['textAlign'], 'center'),
9478
9479 'textRotation': getValueOrDefault(s['textRotation'], 0),
9480
9481 'textMaxWidth': getValueOrDefault(s['textMaxWidth'], 0),
9482 'textMaxHeight': getValueOrDefault(s['textMaxHeight'], 0)
9483 };
9484
9485 if (result['textMaxWidth'] > 0 && (!result['textWrapWidth'] || result['textWrapWidth'] > result['textMaxWidth'])) {
9486 if (!result['textWrapWidth']) {
9487 result['textMaxHeight'] = 1;
9488 }
9489 result['textWrapWidth'] = result['textMaxWidth'];
9490 }
9491 return result;
9492 };
9493
9494 TextMarkerSymbolizer.prototype.translateLineAndFill = function translateLineAndFill(s) {
9495 return {
9496 'lineColor': s['textHaloRadius'] ? s['textHaloFill'] : s['textFill'],
9497 'lineWidth': s['textHaloRadius'],
9498 'lineOpacity': s['textOpacity'],
9499 'lineDasharray': null,
9500 'lineCap': 'butt',
9501 'lineJoin': 'round',
9502 'polygonFill': s['textFill'],
9503 'polygonOpacity': s['textOpacity']
9504 };
9505 };
9506
9507 TextMarkerSymbolizer.prototype._descText = function _descText(textContent) {
9508 if (this._dynamic) {
9509 this.textDesc = this._measureText(textContent);
9510 return;
9511 }
9512 this.textDesc = this._loadFromCache();
9513 if (!this.textDesc) {
9514 this.textDesc = this._measureText(textContent);
9515 this._storeToCache(this.textDesc);
9516 }
9517 };
9518
9519 TextMarkerSymbolizer.prototype._measureText = function _measureText(textContent) {
9520 var maxHeight = this.style['textMaxHeight'];
9521 var textDesc = splitTextToRow(textContent, this.style);
9522 if (maxHeight && maxHeight < textDesc.size.height) {
9523 textDesc.size.height = maxHeight;
9524 }
9525 return textDesc;
9526 };
9527
9528 TextMarkerSymbolizer.prototype._storeToCache = function _storeToCache(textDesc) {
9529 if (IS_NODE) {
9530 return;
9531 }
9532 if (!this.geometry[CACHE_KEY]) {
9533 this.geometry[CACHE_KEY] = {};
9534 }
9535 this.geometry[CACHE_KEY][this._cacheKey] = { 'desc': textDesc, 'active': true };
9536 };
9537
9538 TextMarkerSymbolizer.prototype._loadFromCache = function _loadFromCache() {
9539 if (!this.geometry[CACHE_KEY]) {
9540 return null;
9541 }
9542 var cache = this.geometry[CACHE_KEY][this._cacheKey];
9543 if (!cache) {
9544 return null;
9545 }
9546 cache.active = true;
9547 return cache.desc;
9548 };
9549
9550 return TextMarkerSymbolizer;
9551}(PointSymbolizer);
9552
9553TextMarkerSymbolizer.CACHE_KEY = CACHE_KEY;
9554
9555function genCacheKey(textContent, style) {
9556 var key = [textContent];
9557 for (var p in style) {
9558 if (style.hasOwnProperty(p) && p.length > 4 && p.substring(0, 4) === 'text') {
9559 key.push(p + '=' + style[p]);
9560 }
9561 }
9562 return key.join('-');
9563}
9564
9565var VectorPathMarkerSymbolizer = function (_ImageMarkerSymbolize) {
9566 inherits(VectorPathMarkerSymbolizer, _ImageMarkerSymbolize);
9567
9568 VectorPathMarkerSymbolizer.test = function test(symbol) {
9569 if (!symbol) {
9570 return false;
9571 }
9572 if (isNil(symbol['markerFile']) && symbol['markerType'] === 'path') {
9573 return true;
9574 }
9575 return false;
9576 };
9577
9578 function VectorPathMarkerSymbolizer(symbol, geometry, painter) {
9579 classCallCheck(this, VectorPathMarkerSymbolizer);
9580
9581 var _this = possibleConstructorReturn(this, _ImageMarkerSymbolize.call(this, symbol, geometry, painter));
9582
9583 _this.style = _this._defineStyle(_this.translate());
9584
9585 if (isNil(_this.style['markerWidth'])) {
9586 _this.style['markerWidth'] = 80;
9587 }
9588 if (isNil(_this.style['markerHeight'])) {
9589 _this.style['markerHeight'] = 80;
9590 }
9591 if (Browser$1.gecko) {
9592 _this._url = [getMarkerPathBase64(symbol, _this.style['markerWidth'], _this.style['markerHeight']), _this.style['markerWidth'], _this.style['markerHeight']];
9593 } else {
9594 _this._url = [getMarkerPathBase64(symbol), symbol['markerWidth'], symbol['markerHeight']];
9595 }
9596 return _this;
9597 }
9598
9599 VectorPathMarkerSymbolizer.prototype._prepareContext = function _prepareContext() {};
9600
9601 VectorPathMarkerSymbolizer.prototype._getImage = function _getImage(resources) {
9602 if (resources && resources.isResourceLoaded(this._url)) {
9603 return resources.getImage(this._url);
9604 }
9605 var image = new Image();
9606 image.src = this._url[0];
9607 if (resources) {
9608 resources.addResource(this._url, image);
9609 }
9610 return image;
9611 };
9612
9613 return VectorPathMarkerSymbolizer;
9614}(ImageMarkerSymbolizer);
9615
9616var defaultSymbol = {
9617 lineWidth: 1,
9618 polygonFill: '#fff',
9619 polygonOpacity: 0.5
9620};
9621
9622var DrawAltitudeSymbolizer = function (_PointSymbolizer) {
9623 inherits(DrawAltitudeSymbolizer, _PointSymbolizer);
9624
9625 DrawAltitudeSymbolizer.test = function test(symbol, geometry) {
9626 var layer = geometry.getLayer();
9627 if (!layer) {
9628 return false;
9629 }
9630 var type = geometry.getJSONType();
9631
9632 return type === 'Marker' || type === 'LineString';
9633 };
9634
9635 function DrawAltitudeSymbolizer(symbol, geometry, painter) {
9636 classCallCheck(this, DrawAltitudeSymbolizer);
9637
9638 var _this = possibleConstructorReturn(this, _PointSymbolizer.call(this, symbol, geometry, painter));
9639
9640 _this.style = geometry.getLayer().options['drawAltitude'];
9641 if (!_this.style || !isObject(_this.style)) {
9642 _this.style = {
9643 'lineWidth': 2
9644 };
9645 }
9646 if (!_this.style['lineWidth']) {
9647 _this.style['lineWidth'] = 0;
9648 }
9649 _this.dxdy = _this._defineStyle({
9650 'dx': symbol['textDx'] || symbol['markerDx'],
9651 'dy': symbol['textDy'] || symbol['markerDy']
9652 });
9653 return _this;
9654 }
9655
9656 DrawAltitudeSymbolizer.prototype.symbolize = function symbolize(ctx) {
9657 var layer = this.geometry.getLayer();
9658 if (!layer.options['drawAltitude']) {
9659 return;
9660 }
9661 var properties = this.geometry.getProperties();
9662 if (!properties || !properties[layer.options['altitudeProperty']]) {
9663 return;
9664 }
9665 var style = this._getStyle();
9666 this._prepareContext(ctx);
9667 if (this.geometry.type === 'LineString') {
9668 var paintParams = this._getPaintParams(style['lineDx'], style['lineDy']);
9669 if (!paintParams) {
9670 return;
9671 }
9672
9673 var groundPoints = this.getPainter().getPaintParams(style['lineDx'], style['lineDy'], true)[0];
9674 this._drawLineAltitude(ctx, paintParams[0], groundPoints);
9675 } else {
9676 var point = this._getRenderContainerPoints(),
9677 groundPoint = this._getRenderContainerPoints(true);
9678 if (!point || point.length === 0) {
9679 return;
9680 }
9681 this._drawMarkerAltitude(ctx, point[0], groundPoint[0]);
9682 }
9683 };
9684
9685 DrawAltitudeSymbolizer.prototype.getDxDy = function getDxDy() {
9686 var s = this.dxdy;
9687 return new Point(s['dx'] || 0, s['dy'] || 0);
9688 };
9689
9690 DrawAltitudeSymbolizer.prototype.get2DExtent = function get2DExtent() {
9691 if (this.geometry.type === 'LineString') {
9692 return StrokeAndFillSymbolizer.prototype.get2DExtent.apply(this);
9693 } else {
9694 return _PointSymbolizer.prototype.get2DExtent.call(this);
9695 }
9696 };
9697
9698 DrawAltitudeSymbolizer.prototype.getPlacement = function getPlacement() {
9699 return 'point';
9700 };
9701
9702 DrawAltitudeSymbolizer.prototype._getPaintParams = function _getPaintParams(dx, dy) {
9703 return this.getPainter().getPaintParams(dx || 0, dy || 0);
9704 };
9705
9706 DrawAltitudeSymbolizer.prototype._drawMarkerAltitude = function _drawMarkerAltitude(ctx, point, groundPoint) {
9707 var style = this._getStyle();
9708 this.prepareCanvas(ctx, style);
9709 Canvas.path(ctx, [point, groundPoint], style['lineOpacity'], null, style['lineDasharray']);
9710 };
9711
9712 DrawAltitudeSymbolizer.prototype._drawLineAltitude = function _drawLineAltitude(ctx, points, groundPoints) {
9713 var style = this._getStyle();
9714 var isSplitted = points.length > 0 && Array.isArray(points[0]);
9715
9716 if (isSplitted) {
9717 for (var i = 0; i < points.length; i++) {
9718 this._drawLine(ctx, points[i], groundPoints[i]);
9719 }
9720 } else {
9721 this._drawLine(ctx, points, groundPoints);
9722 }
9723
9724 if (ctx.setLineDash && Array.isArray(style['lineDasharray'])) {
9725 ctx.setLineDash([]);
9726 }
9727 };
9728
9729 DrawAltitudeSymbolizer.prototype._drawLine = function _drawLine(ctx, points, groundPoints) {
9730 var style = this._getStyle();
9731 this.prepareCanvas(ctx, style);
9732 for (var i = 0, l = points.length - 1; i < l; i++) {
9733 Canvas.polygon(ctx, [points[i], points[i + 1], groundPoints[i + 1], groundPoints[i]], style['lineOpacity'], style['polygonOpacity'], style['lineDasharray']);
9734 }
9735 };
9736
9737 DrawAltitudeSymbolizer.prototype._getStyle = function _getStyle() {
9738 var style = this.geometry.getLayer().options['drawAltitude'];
9739 if (!isObject(style)) {
9740 style = defaultSymbol;
9741 }
9742 if (!style['lineWidth']) {
9743 style['lineWidth'] = 0;
9744 style['lineOpacity'] = 0;
9745 }
9746 return style;
9747 };
9748
9749 return DrawAltitudeSymbolizer;
9750}(PointSymbolizer);
9751
9752
9753
9754var index$3 = Object.freeze({
9755 Symbolizer: Symbolizer,
9756 CanvasSymbolizer: CanvasSymbolizer,
9757 DebugSymbolizer: DebugSymbolizer,
9758 ImageMarkerSymbolizer: ImageMarkerSymbolizer,
9759 PointSymbolizer: PointSymbolizer,
9760 StrokeAndFillSymbolizer: StrokeAndFillSymbolizer,
9761 TextMarkerSymbolizer: TextMarkerSymbolizer,
9762 VectorMarkerSymbolizer: VectorMarkerSymbolizer,
9763 VectorPathMarkerSymbolizer: VectorPathMarkerSymbolizer,
9764 DrawAltitudeSymbolizer: DrawAltitudeSymbolizer
9765});
9766
9767var registerSymbolizers = [DrawAltitudeSymbolizer, StrokeAndFillSymbolizer, ImageMarkerSymbolizer, VectorPathMarkerSymbolizer, VectorMarkerSymbolizer, TextMarkerSymbolizer];
9768
9769var testCanvas = void 0;
9770
9771var Painter = function (_Class) {
9772 inherits(Painter, _Class);
9773
9774 function Painter(geometry) {
9775 classCallCheck(this, Painter);
9776
9777 var _this = possibleConstructorReturn(this, _Class.call(this));
9778
9779 _this.geometry = geometry;
9780 _this.symbolizers = _this._createSymbolizers();
9781 _this._altAtGLZoom = _this._getGeometryAltitude();
9782 return _this;
9783 }
9784
9785 Painter.prototype.getMap = function getMap() {
9786 return this.geometry.getMap();
9787 };
9788
9789 Painter.prototype.getLayer = function getLayer() {
9790 return this.geometry.getLayer();
9791 };
9792
9793 Painter.prototype._createSymbolizers = function _createSymbolizers() {
9794 var geoSymbol = this.getSymbol(),
9795 symbolizers = [],
9796 regSymbolizers = registerSymbolizers;
9797 var symbols = geoSymbol;
9798 if (!Array.isArray(geoSymbol)) {
9799 symbols = [geoSymbol];
9800 }
9801 for (var ii = symbols.length - 1; ii >= 0; ii--) {
9802 var symbol = symbols[ii];
9803 for (var i = regSymbolizers.length - 1; i >= 0; i--) {
9804 if (regSymbolizers[i].test(symbol, this.geometry)) {
9805 var symbolizer = new regSymbolizers[i](symbol, this.geometry, this);
9806 symbolizers.push(symbolizer);
9807 if (symbolizer instanceof PointSymbolizer) {
9808 this._hasPoint = true;
9809 }
9810 }
9811 }
9812 }
9813 if (!symbolizers.length) {
9814 if (console) {
9815 var id = this.geometry.getId();
9816 console.warn('invalid symbol for geometry(' + (this.geometry ? this.geometry.getType() + (id ? ':' + id : '') : '') + ') to draw : ' + JSON.stringify(geoSymbol));
9817 }
9818 }
9819 this._debugSymbolizer = new DebugSymbolizer(geoSymbol, this.geometry, this);
9820 return symbolizers;
9821 };
9822
9823 Painter.prototype.hasPoint = function hasPoint() {
9824 return !!this._hasPoint;
9825 };
9826
9827 Painter.prototype.getRenderPoints = function getRenderPoints(placement) {
9828 if (!this._renderPoints) {
9829 this._renderPoints = {};
9830 }
9831 if (!placement) {
9832 placement = 'center';
9833 }
9834 if (!this._renderPoints[placement]) {
9835 this._renderPoints[placement] = this.geometry._getRenderPoints(placement);
9836 }
9837 return this._renderPoints[placement];
9838 };
9839
9840 Painter.prototype.getPaintParams = function getPaintParams(dx, dy, ignoreAltitude) {
9841 var map = this.getMap(),
9842 geometry = this.geometry,
9843 res = map.getResolution(),
9844 pitched = map.getPitch() !== 0,
9845 rotated = map.getBearing() !== 0;
9846 var params = this._cachedParams;
9847
9848 var paintAsPath = geometry._paintAsPath && geometry._paintAsPath();
9849 if (paintAsPath && this._unsimpledParams && res <= this._unsimpledParams._res) {
9850 params = this._unsimpledParams;
9851 } else if (!params || params._res !== map.getResolution() || this._pitched !== pitched && geometry._redrawWhenPitch() || this._rotated !== rotated && geometry._redrawWhenRotate()) {
9852 params = geometry._getPaintParams();
9853 if (!params) {
9854 return null;
9855 }
9856 params._res = res;
9857
9858 if (!geometry._simplified && paintAsPath) {
9859 if (!this._unsimpledParams) {
9860 this._unsimpledParams = params;
9861 }
9862 if (res > this._unsimpledParams._res) {
9863 this._unsimpledParams._res = res;
9864 }
9865 }
9866 this._cachedParams = params;
9867 }
9868 if (!params) {
9869 return null;
9870 }
9871 this._pitched = pitched;
9872 this._rotated = rotated;
9873 var zoomScale = map.getGLScale(),
9874 tr = [],
9875 points = params[0];
9876
9877 var mapExtent = map.getContainerExtent();
9878 var cPoints = this._pointContainerPoints(points, dx, dy, ignoreAltitude, !mapExtent.contains(this._hitPoint));
9879 if (!cPoints) {
9880 return null;
9881 }
9882 tr.push(cPoints);
9883 for (var i = 1, l = params.length; i < l; i++) {
9884 if (isNumber(params[i]) || params[i] instanceof Size) {
9885 if (isNumber(params[i])) {
9886 tr.push(params[i] / zoomScale);
9887 } else {
9888 tr.push(params[i].multi(1 / zoomScale));
9889 }
9890 } else {
9891 tr.push(params[i]);
9892 }
9893 }
9894 return tr;
9895 };
9896
9897 Painter.prototype._pointContainerPoints = function _pointContainerPoints(points, dx, dy, ignoreAltitude, noClip, pointPlacement) {
9898 var cExtent = this.getContainerExtent();
9899 if (!cExtent) {
9900 return null;
9901 }
9902 var map = this.getMap(),
9903 glZoom = map.getGLZoom(),
9904 containerOffset = this.containerOffset;
9905 var cPoints = void 0;
9906 function pointContainerPoint(point, alt) {
9907 var p = map._pointToContainerPoint(point, glZoom, alt)._sub(containerOffset);
9908 if (dx || dy) {
9909 p._add(dx || 0, dy || 0);
9910 }
9911 return p;
9912 }
9913
9914 var altitude = this.getAltitude();
9915
9916 if (Array.isArray(points)) {
9917 var geometry = this.geometry;
9918 var clipped = void 0;
9919 if (!noClip && geometry.options['enableClip']) {
9920 clipped = this._clip(points, altitude);
9921 } else {
9922 clipped = {
9923 points: points,
9924 altitude: altitude
9925 };
9926 }
9927 var clipPoints = clipped.points;
9928 altitude = clipped.altitude;
9929 if (ignoreAltitude) {
9930 altitude = 0;
9931 }
9932 var alt = altitude;
9933 cPoints = [];
9934 for (var i = 0, l = clipPoints.length; i < l; i++) {
9935 var c = clipPoints[i];
9936 if (Array.isArray(c)) {
9937 var cring = [];
9938
9939 for (var ii = 0, ll = c.length; ii < ll; ii++) {
9940 var cc = c[ii];
9941 if (Array.isArray(altitude)) {
9942 if (altitude[i]) {
9943 alt = altitude[i][ii];
9944 } else {
9945 alt = 0;
9946 }
9947 }
9948 cring.push(pointContainerPoint(cc, alt));
9949 }
9950 cPoints.push(cring);
9951 } else {
9952 if (Array.isArray(altitude)) {
9953 if (pointPlacement === 'vertex-last') {
9954 alt = altitude[altitude.length - 1 - i];
9955 } else if (pointPlacement === 'line') {
9956 alt = (altitude[i] + altitude[i + 1]) / 2;
9957 } else {
9958 alt = altitude[i];
9959 }
9960 }
9961 cPoints.push(pointContainerPoint(c, alt));
9962 }
9963 }
9964 } else if (points instanceof Point) {
9965 if (ignoreAltitude) {
9966 altitude = 0;
9967 }
9968 cPoints = map._pointToContainerPoint(points, glZoom, altitude)._sub(containerOffset);
9969 if (dx || dy) {
9970 cPoints._add(dx, dy);
9971 }
9972 }
9973 return cPoints;
9974 };
9975
9976 Painter.prototype._clip = function _clip(points, altitude) {
9977 var map = this.getMap(),
9978 geometry = this.geometry,
9979 glZoom = map.getGLZoom();
9980 var lineWidth = this.getSymbol()['lineWidth'];
9981 if (!isNumber(lineWidth)) {
9982 lineWidth = 4;
9983 }
9984 var containerExtent = map.getContainerExtent();
9985 var extent2D = containerExtent.expand(lineWidth).convertTo(function (p) {
9986 return map._containerPointToPoint(p, glZoom);
9987 });
9988 if (map.getPitch() > 0 && altitude) {
9989 var c = map.cameraLookAt;
9990 var pos = map.cameraPosition;
9991
9992 extent2D = extent2D.combine(new Point(pos)._add(sign(c[0] - pos[0]), sign(c[1] - pos[1])));
9993 }
9994 var e = this.get2DExtent();
9995 var clipPoints = points;
9996 if (e.within(extent2D)) {
9997 return {
9998 points: clipPoints,
9999 altitude: altitude
10000 };
10001 }
10002 var smoothness = geometry.options['smoothness'];
10003
10004 if (geometry.getShell && this.geometry.getHoles && !smoothness) {
10005 if (!Array.isArray(points[0])) {
10006 clipPoints = clipPolygon(points, extent2D);
10007 } else {
10008 clipPoints = [];
10009 for (var i = 0; i < points.length; i++) {
10010 var part = clipPolygon(points[i], extent2D);
10011 if (part.length) {
10012 clipPoints.push(part);
10013 }
10014 }
10015 }
10016 } else if (geometry.getJSONType() === 'LineString') {
10017 if (!Array.isArray(points[0])) {
10018 clipPoints = clipLine(points, extent2D, false, !!smoothness);
10019 } else {
10020 clipPoints = [];
10021 for (var _i = 0; _i < points.length; _i++) {
10022 pushIn(clipPoints, clipLine(points[_i], extent2D, false, !!smoothness));
10023 }
10024 }
10025
10026 return this._interpolateSegAlt(clipPoints, points, altitude);
10027 }
10028
10029 return {
10030 points: clipPoints,
10031 altitude: altitude
10032 };
10033 };
10034
10035 Painter.prototype._interpolateSegAlt = function _interpolateSegAlt(clipSegs, orig, altitude) {
10036 if (!Array.isArray(altitude)) {
10037 var fn = function fn(cc) {
10038 return cc.point;
10039 };
10040 return {
10041 points: clipSegs.map(function (c) {
10042 if (Array.isArray(c)) {
10043 return c.map(fn);
10044 }
10045 return c.point;
10046 }),
10047 altitude: altitude
10048 };
10049 }
10050 var segsWithAlt = interpolateAlt(clipSegs, orig, altitude);
10051 altitude = [];
10052 var points = segsWithAlt.map(function (p) {
10053 if (Array.isArray(p)) {
10054 var alt = [];
10055 var cp = p.map(function (pp) {
10056 alt.push(pp.altitude);
10057 return pp.point;
10058 });
10059 altitude.push(alt);
10060 return cp;
10061 }
10062 altitude.push(p.altitude);
10063 return p.point;
10064 });
10065 return {
10066 points: points,
10067 altitude: altitude
10068 };
10069 };
10070
10071 Painter.prototype.getSymbol = function getSymbol() {
10072 return this.geometry._getInternalSymbol();
10073 };
10074
10075 Painter.prototype.paint = function paint(extent, context, offset) {
10076 if (!this.symbolizers) {
10077 return;
10078 }
10079 var renderer = this.getLayer()._getRenderer();
10080 if (!renderer || !renderer.context) {
10081 return;
10082 }
10083
10084 if (extent && !extent.intersects(this.get2DExtent(renderer.resources))) {
10085 return;
10086 }
10087 var map = this.getMap();
10088 var minAltitude = this.getMinAltitude();
10089 var frustumAlt = map.getFrustumAltitude();
10090 if (minAltitude && frustumAlt && frustumAlt < minAltitude) {
10091 return;
10092 }
10093 this.containerOffset = offset || map._pointToContainerPoint(renderer.southWest)._add(0, -map.height);
10094 this._beforePaint();
10095 var ctx = context || renderer.context;
10096 var contexts = [ctx, renderer.resources];
10097 for (var i = this.symbolizers.length - 1; i >= 0; i--) {
10098 this._prepareShadow(ctx, this.symbolizers[i].symbol);
10099 this.symbolizers[i].symbolize.apply(this.symbolizers[i], contexts);
10100 }
10101 this._afterPaint();
10102 this._painted = true;
10103 this._debugSymbolizer.symbolize.apply(this._debugSymbolizer, contexts);
10104 };
10105
10106 Painter.prototype.getSprite = function getSprite(resources, canvasClass) {
10107 if (this.geometry.type !== 'Point') {
10108 return null;
10109 }
10110 this._spriting = true;
10111 if (!this._sprite && this.symbolizers.length > 0) {
10112 var extent = new PointExtent();
10113 this.symbolizers.forEach(function (s) {
10114 var markerExtent = s.getFixedExtent(resources);
10115 extent._combine(markerExtent);
10116 });
10117 var origin = extent.getMin().multi(-1);
10118 var clazz = canvasClass || (this.getMap() ? this.getMap().CanvasClass : null);
10119 var canvas = Canvas.createCanvas(extent.getWidth(), extent.getHeight(), clazz);
10120 var bak = void 0;
10121 if (this._renderPoints) {
10122 bak = this._renderPoints;
10123 }
10124 var ctx = canvas.getContext('2d');
10125 var contexts = [ctx, resources];
10126 for (var i = this.symbolizers.length - 1; i >= 0; i--) {
10127 var dxdy = this.symbolizers[i].getDxDy();
10128 this._renderPoints = {
10129 'center': [[origin.add(dxdy)]]
10130 };
10131 this._prepareShadow(ctx, this.symbolizers[i].symbol);
10132 this.symbolizers[i].symbolize.apply(this.symbolizers[i], contexts);
10133 }
10134 if (bak) {
10135 this._renderPoints = bak;
10136 }
10137 this._sprite = {
10138 'canvas': canvas,
10139 'offset': extent.getCenter()
10140 };
10141 }
10142 this._spriting = false;
10143 return this._sprite;
10144 };
10145
10146 Painter.prototype.isSpriting = function isSpriting() {
10147 return !!this._spriting;
10148 };
10149
10150 Painter.prototype.hitTest = function hitTest(cp, tolerance) {
10151 if (!tolerance || tolerance < 0.5) {
10152 tolerance = 0.5;
10153 }
10154 if (!testCanvas) {
10155 testCanvas = Canvas.createCanvas(1, 1);
10156 }
10157 Canvas.setHitTesting(true);
10158 testCanvas.width = testCanvas.height = 2 * tolerance;
10159 var ctx = testCanvas.getContext('2d');
10160 this._hitPoint = cp.sub(tolerance, tolerance);
10161 try {
10162 this.paint(null, ctx, this._hitPoint);
10163 } catch (e) {
10164 throw e;
10165 } finally {
10166 Canvas.setHitTesting(false);
10167 }
10168 delete this._hitPoint;
10169 var imgData = ctx.getImageData(0, 0, testCanvas.width, testCanvas.height).data;
10170 for (var i = 3, l = imgData.length; i < l; i += 4) {
10171 if (imgData[i] > 0) {
10172 return true;
10173 }
10174 }
10175 return false;
10176 };
10177
10178 Painter.prototype.isHitTesting = function isHitTesting() {
10179 return !!this._hitPoint;
10180 };
10181
10182 Painter.prototype._prepareShadow = function _prepareShadow(ctx, symbol) {
10183 if (symbol['shadowBlur']) {
10184 ctx.shadowBlur = symbol['shadowBlur'];
10185 ctx.shadowColor = symbol['shadowColor'] || '#000';
10186 ctx.shadowOffsetX = symbol['shadowOffsetX'] || 0;
10187 ctx.shadowOffsetY = symbol['shadowOffsetY'] || 0;
10188 } else if (ctx.shadowBlur) {
10189 ctx.shadowBlur = null;
10190 ctx.shadowColor = null;
10191 ctx.shadowOffsetX = null;
10192 ctx.shadowOffsetY = null;
10193 }
10194 };
10195
10196 Painter.prototype._eachSymbolizer = function _eachSymbolizer(fn, context) {
10197 if (!this.symbolizers) {
10198 return;
10199 }
10200 if (!context) {
10201 context = this;
10202 }
10203 for (var i = this.symbolizers.length - 1; i >= 0; i--) {
10204 fn.apply(context, [this.symbolizers[i]]);
10205 }
10206 };
10207
10208 Painter.prototype.get2DExtent = function get2DExtent(resources) {
10209 this._verifyProjection();
10210 var map = this.getMap();
10211 resources = resources || this.getLayer()._getRenderer().resources;
10212 var zoom = map.getZoom();
10213 if (!this._extent2D || this._extent2D._zoom !== zoom) {
10214 delete this._extent2D;
10215 delete this._fixedExtent;
10216 if (this.symbolizers) {
10217 var extent = this._extent2D = new PointExtent();
10218 var fixedExt = this._fixedExtent = new PointExtent();
10219 for (var i = this.symbolizers.length - 1; i >= 0; i--) {
10220 var symbolizer = this.symbolizers[i];
10221 extent._combine(symbolizer.get2DExtent());
10222 if (symbolizer.getFixedExtent) {
10223 fixedExt._combine(symbolizer.getFixedExtent(resources));
10224 }
10225 }
10226 extent._zoom = zoom;
10227 }
10228 }
10229 return this._extent2D.add(this._fixedExtent);
10230 };
10231
10232 Painter.prototype.getContainerExtent = function getContainerExtent() {
10233 this._verifyProjection();
10234 var map = this.getMap();
10235 var zoom = map.getZoom();
10236 var glScale = map.getGLScale();
10237 if (!this._extent2D || this._extent2D._zoom !== zoom) {
10238 this.get2DExtent();
10239 }
10240 var altitude = this.getMinAltitude();
10241 var frustumAlt = map.getFrustumAltitude();
10242 if (altitude && frustumAlt && frustumAlt < altitude) {
10243 return null;
10244 }
10245 var extent = this._extent2D.convertTo(function (c) {
10246 return map._pointToContainerPoint(c, zoom, altitude / glScale);
10247 });
10248 var maxAltitude = this.getMaxAltitude();
10249 if (maxAltitude !== altitude) {
10250 var extent2 = this._extent2D.convertTo(function (c) {
10251 return map._pointToContainerPoint(c, zoom, maxAltitude / glScale);
10252 });
10253 extent._combine(extent2);
10254 }
10255 if (extent) {
10256 extent._add(this._fixedExtent);
10257 }
10258 var smoothness = this.geometry.options['smoothness'];
10259 if (smoothness) {
10260 extent._expand(extent.getWidth() * 0.15);
10261 }
10262 return extent;
10263 };
10264
10265 Painter.prototype.getFixedExtent = function getFixedExtent() {
10266 var map = this.getMap();
10267 var zoom = map.getZoom();
10268 if (!this._extent2D || this._extent2D._zoom !== zoom) {
10269 this.get2DExtent();
10270 }
10271 return this._fixedExtent;
10272 };
10273
10274 Painter.prototype.setZIndex = function setZIndex(change) {
10275 this._eachSymbolizer(function (symbolizer) {
10276 symbolizer.setZIndex(change);
10277 });
10278 };
10279
10280 Painter.prototype.show = function show() {
10281 if (!this._painted) {
10282 var layer = this.getLayer();
10283 if (!layer.isCanvasRender()) {
10284 this.paint();
10285 }
10286 } else {
10287 this.removeCache();
10288 this._eachSymbolizer(function (symbolizer) {
10289 symbolizer.show();
10290 });
10291 }
10292 };
10293
10294 Painter.prototype.hide = function hide() {
10295 this._eachSymbolizer(function (symbolizer) {
10296 symbolizer.hide();
10297 });
10298 };
10299
10300 Painter.prototype.repaint = function repaint() {
10301 this._altAtGLZoom = this._getGeometryAltitude();
10302 this.removeCache();
10303 var layer = this.getLayer();
10304 if (!layer) {
10305 return;
10306 }
10307 var renderer = layer.getRenderer();
10308 if (!renderer || !renderer.setToRedraw()) {
10309 return;
10310 }
10311 renderer.setToRedraw();
10312 };
10313
10314 Painter.prototype.refreshSymbol = function refreshSymbol() {
10315 this.removeCache();
10316 this._removeSymbolizers();
10317 this.symbolizers = this._createSymbolizers();
10318 };
10319
10320 Painter.prototype.remove = function remove() {
10321 this.removeCache();
10322 this._removeSymbolizers();
10323 };
10324
10325 Painter.prototype._removeSymbolizers = function _removeSymbolizers() {
10326 this._eachSymbolizer(function (symbolizer) {
10327 delete symbolizer.painter;
10328 symbolizer.remove();
10329 });
10330 delete this.symbolizers;
10331 };
10332
10333 Painter.prototype.removeCache = function removeCache() {
10334 delete this._renderPoints;
10335 delete this._paintParams;
10336 delete this._sprite;
10337 delete this._extent2D;
10338 delete this._fixedExtent;
10339 delete this._cachedParams;
10340 delete this._unsimpledParams;
10341 if (this.geometry) {
10342 delete this.geometry[TextMarkerSymbolizer.CACHE_KEY];
10343 }
10344 };
10345
10346 Painter.prototype.getAltitude = function getAltitude() {
10347 var propAlt = this._getAltitudeProperty();
10348 if (propAlt !== this._propAlt) {
10349 this._altAtGLZoom = this._getGeometryAltitude();
10350 }
10351 if (!this._altAtGLZoom) {
10352 return 0;
10353 }
10354 return this._altAtGLZoom;
10355 };
10356
10357 Painter.prototype.getMinAltitude = function getMinAltitude() {
10358 if (!this.minAltitude) {
10359 return 0;
10360 }
10361 return this.minAltitude;
10362 };
10363
10364 Painter.prototype.getMaxAltitude = function getMaxAltitude() {
10365 if (!this.maxAltitude) {
10366 return 0;
10367 }
10368 return this.maxAltitude;
10369 };
10370
10371 Painter.prototype._getGeometryAltitude = function _getGeometryAltitude() {
10372 var _this2 = this;
10373
10374 var map = this.getMap();
10375 if (!map) {
10376 return 0;
10377 }
10378 var altitude = this._getAltitudeProperty();
10379 this._propAlt = altitude;
10380 if (!altitude) {
10381 this.minAltitude = this.maxAltitude = 0;
10382 return 0;
10383 }
10384 var center = this.geometry.getCenter();
10385 if (Array.isArray(altitude)) {
10386 this.minAltitude = Number.MAX_VALUE;
10387 this.maxAltitude = Number.MIN_VALUE;
10388 return altitude.map(function (alt) {
10389 var a = _this2._meterToPoint(center, alt);
10390 if (a < _this2.minAltitude) {
10391 _this2.minAltitude = a;
10392 }
10393 if (a > _this2.maxAltitude) {
10394 _this2.maxAltitude = a;
10395 }
10396 return a;
10397 });
10398 } else {
10399 this.minAltitude = this.maxAltitude = this._meterToPoint(center, altitude);
10400 return this.minAltitude;
10401 }
10402 };
10403
10404 Painter.prototype._meterToPoint = function _meterToPoint(center, altitude) {
10405 var map = this.getMap();
10406 var z = map.getGLZoom();
10407 var target = map.locate(center, altitude, 0);
10408 var p0 = map.coordToPoint(center, z),
10409 p1 = map.coordToPoint(target, z);
10410 return Math.abs(p1.x - p0.x) * sign(altitude);
10411 };
10412
10413 Painter.prototype._getAltitudeProperty = function _getAltitudeProperty() {
10414 var geometry = this.geometry,
10415 layerOpts = geometry.getLayer().options,
10416 properties = geometry.getProperties();
10417 var altitude = layerOpts['enableAltitude'] ? properties ? properties[layerOpts['altitudeProperty']] : 0 : 0;
10418 return altitude;
10419 };
10420
10421 Painter.prototype._verifyProjection = function _verifyProjection() {
10422 var projection = this.geometry._getProjection();
10423 if (this._projCode && this._projCode !== projection.code) {
10424 this.removeCache();
10425 }
10426 this._projCode = projection.code;
10427 };
10428
10429 Painter.prototype._beforePaint = function _beforePaint() {
10430 var textcache = this.geometry[TextMarkerSymbolizer.CACHE_KEY];
10431 if (!textcache) {
10432 return;
10433 }
10434 for (var p in textcache) {
10435 if (hasOwn(textcache, p)) {
10436 textcache[p].active = false;
10437 }
10438 }
10439 };
10440
10441 Painter.prototype._afterPaint = function _afterPaint() {
10442 var textcache = this.geometry[TextMarkerSymbolizer.CACHE_KEY];
10443 if (!textcache) {
10444 return;
10445 }
10446 for (var p in textcache) {
10447 if (hasOwn(textcache, p)) {
10448 if (!textcache[p].active) {
10449 delete textcache[p];
10450 }
10451 }
10452 }
10453 };
10454
10455 return Painter;
10456}(Class);
10457
10458function interpolateAlt(points, orig, altitude) {
10459 if (!Array.isArray(altitude)) {
10460 return points;
10461 }
10462 var parts = [];
10463 for (var i = 0, l = points.length; i < l; i++) {
10464 if (Array.isArray(points[i])) {
10465 parts.push(interpolateAlt(points[i], orig, altitude));
10466 } else {
10467 var p = points[i];
10468 if (!p.point.equals(orig[p.index])) {
10469 var w0 = void 0,
10470 w1 = void 0;
10471 if (p.index === 0) {
10472 w0 = p.index;
10473 w1 = p.index + 1;
10474 } else {
10475 w0 = p.index - 1;
10476 w1 = p.index;
10477 }
10478
10479 var t0 = p.point.distanceTo(orig[w1]);
10480 var t = t0 / (t0 + orig[w0].distanceTo(p.point));
10481 var alt = interpolate(altitude[w0], altitude[w1], 1 - t);
10482 p.altitude = alt;
10483 parts.push(p);
10484 } else {
10485 p.altitude = altitude[p.index];
10486 parts.push(p);
10487 }
10488 }
10489 }
10490 return parts;
10491}
10492
10493var CollectionPainter = function (_Class) {
10494 inherits(CollectionPainter, _Class);
10495
10496 function CollectionPainter(geometry) {
10497 classCallCheck(this, CollectionPainter);
10498
10499 var _this = possibleConstructorReturn(this, _Class.call(this));
10500
10501 _this.geometry = geometry;
10502 return _this;
10503 }
10504
10505 CollectionPainter.prototype._eachPainter = function _eachPainter(fn) {
10506 var geometries = this.geometry.getGeometries();
10507 var painter = void 0;
10508 for (var i = 0, len = geometries.length; i < len; i++) {
10509 painter = geometries[i]._getPainter();
10510 if (!painter) {
10511 continue;
10512 }
10513 if (painter) {
10514 if (fn.call(this, painter) === false) {
10515 break;
10516 }
10517 }
10518 }
10519 };
10520
10521 CollectionPainter.prototype.paint = function paint(extent) {
10522 if (!this.geometry) {
10523 return;
10524 }
10525 this._eachPainter(function (painter) {
10526 painter.paint(extent);
10527 });
10528 };
10529
10530 CollectionPainter.prototype.get2DExtent = function get2DExtent(resources) {
10531 var extent = new PointExtent();
10532 this._eachPainter(function (painter) {
10533 extent = extent.combine(painter.get2DExtent(resources));
10534 });
10535 return extent;
10536 };
10537
10538 CollectionPainter.prototype.getContainerExtent = function getContainerExtent() {
10539 var extent = new PointExtent();
10540 this._eachPainter(function (painter) {
10541 extent = extent.combine(painter.getContainerExtent());
10542 });
10543 return extent;
10544 };
10545
10546 CollectionPainter.prototype.remove = function remove() {
10547 var args = arguments;
10548 this._eachPainter(function (painter) {
10549 painter.remove.apply(painter, args);
10550 });
10551 };
10552
10553 CollectionPainter.prototype.setZIndex = function setZIndex() {
10554 var args = arguments;
10555 this._eachPainter(function (painter) {
10556 painter.setZIndex.apply(painter, args);
10557 });
10558 };
10559
10560 CollectionPainter.prototype.show = function show() {
10561 var args = arguments;
10562 this._eachPainter(function (painter) {
10563 painter.show.apply(painter, args);
10564 });
10565 };
10566
10567 CollectionPainter.prototype.hide = function hide() {
10568 var args = arguments;
10569 this._eachPainter(function (painter) {
10570 painter.hide.apply(painter, args);
10571 });
10572 };
10573
10574 CollectionPainter.prototype.repaint = function repaint() {
10575 var args = arguments;
10576 this._eachPainter(function (painter) {
10577 painter.repaint.apply(painter, args);
10578 });
10579 };
10580
10581 CollectionPainter.prototype.refreshSymbol = function refreshSymbol() {
10582 var args = arguments;
10583 this._eachPainter(function (painter) {
10584 painter.refreshSymbol.apply(painter, args);
10585 });
10586 };
10587
10588 CollectionPainter.prototype.hasPoint = function hasPoint() {
10589 var result = false;
10590 this._eachPainter(function (painter) {
10591 if (painter.hasPoint()) {
10592 result = true;
10593 return false;
10594 }
10595 return true;
10596 });
10597 return result;
10598 };
10599
10600 CollectionPainter.prototype.getMinAltitude = function getMinAltitude() {
10601 var first = true;
10602 var result = 0;
10603 this._eachPainter(function (painter) {
10604 var alt = painter.getMinAltitude();
10605 if (first || alt < result) {
10606 first = false;
10607 result = alt;
10608 }
10609 });
10610 return result;
10611 };
10612
10613 CollectionPainter.prototype.getMaxAltitude = function getMaxAltitude() {
10614 var result = 0;
10615 this._eachPainter(function (painter) {
10616 var alt = painter.getMaxAltitude();
10617 if (alt > result) {
10618 result = alt;
10619 }
10620 });
10621 return result;
10622 };
10623
10624 return CollectionPainter;
10625}(Class);
10626
10627var options$2 = {
10628 'id': null,
10629 'visible': true,
10630 'editable': true,
10631 'cursor': null,
10632 'defaultProjection': 'EPSG:4326' };
10633
10634var Geometry = function (_JSONAble) {
10635 inherits(Geometry, _JSONAble);
10636
10637 function Geometry(options) {
10638 classCallCheck(this, Geometry);
10639
10640 var opts = extend({}, options);
10641 var symbol = opts['symbol'];
10642 var properties = opts['properties'];
10643 var id = opts['id'];
10644 delete opts['symbol'];
10645 delete opts['id'];
10646 delete opts['properties'];
10647
10648 var _this = possibleConstructorReturn(this, _JSONAble.call(this, opts));
10649
10650 if (symbol) {
10651 _this.setSymbol(symbol);
10652 }
10653 if (properties) {
10654 _this.setProperties(properties);
10655 }
10656 if (!isNil(id)) {
10657 _this.setId(id);
10658 }
10659 return _this;
10660 }
10661
10662 Geometry.prototype.getFirstCoordinate = function getFirstCoordinate() {
10663 if (this.type === 'GeometryCollection') {
10664 var geometries = this.getGeometries();
10665 if (!geometries.length) {
10666 return null;
10667 }
10668 return geometries[0].getFirstCoordinate();
10669 }
10670 var coordinates = this.getCoordinates();
10671 if (!Array.isArray(coordinates)) {
10672 return coordinates;
10673 }
10674 do {
10675 coordinates = coordinates[0];
10676 } while (Array.isArray(coordinates) && coordinates.length > 0);
10677 return coordinates;
10678 };
10679
10680 Geometry.prototype.getLastCoordinate = function getLastCoordinate() {
10681 if (this.type === 'GeometryCollection') {
10682 var geometries = this.getGeometries();
10683 if (!geometries.length) {
10684 return null;
10685 }
10686 return geometries[geometries.length - 1].getLastCoordinate();
10687 }
10688 var coordinates = this.getCoordinates();
10689 if (!Array.isArray(coordinates)) {
10690 return coordinates;
10691 }
10692 do {
10693 coordinates = coordinates[coordinates.length - 1];
10694 } while (Array.isArray(coordinates) && coordinates.length > 0);
10695 return coordinates;
10696 };
10697
10698 Geometry.prototype.addTo = function addTo(layer, fitview) {
10699 layer.addGeometry(this, fitview);
10700 return this;
10701 };
10702
10703 Geometry.prototype.getLayer = function getLayer() {
10704 if (!this._layer) {
10705 return null;
10706 }
10707 return this._layer;
10708 };
10709
10710 Geometry.prototype.getMap = function getMap() {
10711 if (!this._layer) {
10712 return null;
10713 }
10714 return this._layer.getMap();
10715 };
10716
10717 Geometry.prototype.getId = function getId() {
10718 return this._id;
10719 };
10720
10721 Geometry.prototype.setId = function setId(id) {
10722 var oldId = this.getId();
10723 this._id = id;
10724
10725 this._fireEvent('idchange', {
10726 'old': oldId,
10727 'new': id
10728 });
10729
10730 return this;
10731 };
10732
10733 Geometry.prototype.getProperties = function getProperties() {
10734 if (!this.properties) {
10735 if (this._getParent()) {
10736 return this._getParent().getProperties();
10737 }
10738 return null;
10739 }
10740 return this.properties;
10741 };
10742
10743 Geometry.prototype.setProperties = function setProperties(properties) {
10744 var old = this.properties;
10745 this.properties = isObject(properties) ? extend({}, properties) : properties;
10746 this._repaint();
10747
10748 this._fireEvent('propertieschange', {
10749 'old': old,
10750 'new': properties
10751 });
10752
10753 return this;
10754 };
10755
10756 Geometry.prototype.getType = function getType() {
10757 return this.type;
10758 };
10759
10760 Geometry.prototype.getSymbol = function getSymbol() {
10761 var s = this._symbol;
10762 if (s) {
10763 if (!Array.isArray(s)) {
10764 return extend({}, s);
10765 } else {
10766 return extendSymbol(s);
10767 }
10768 }
10769 return null;
10770 };
10771
10772 Geometry.prototype.setSymbol = function setSymbol(symbol) {
10773 this._symbol = this._prepareSymbol(symbol);
10774 this.onSymbolChanged();
10775 return this;
10776 };
10777
10778 Geometry.prototype.updateSymbol = function updateSymbol(props) {
10779 if (!props) {
10780 return this;
10781 }
10782 var s = this._getSymbol();
10783 if (s) {
10784 s = extendSymbol(s, props);
10785 } else {
10786 s = extendSymbol(this._getInternalSymbol(), props);
10787 }
10788 return this.setSymbol(s);
10789 };
10790
10791 Geometry.prototype.getCenter = function getCenter() {
10792 return this._computeCenter(this._getMeasurer());
10793 };
10794
10795 Geometry.prototype.getExtent = function getExtent() {
10796 var prjExt = this._getPrjExtent();
10797 if (prjExt) {
10798 var p = this._getProjection();
10799 var min = p.unproject(new Coordinate(prjExt['xmin'], prjExt['ymin'])),
10800 max = p.unproject(new Coordinate(prjExt['xmax'], prjExt['ymax']));
10801 return new Extent(min, max, this._getProjection());
10802 } else {
10803 return this._computeExtent(this._getMeasurer());
10804 }
10805 };
10806
10807 Geometry.prototype.getContainerExtent = function getContainerExtent() {
10808 var painter = this._getPainter();
10809 return painter ? painter.getContainerExtent() : null;
10810 };
10811
10812 Geometry.prototype.getSize = function getSize() {
10813 var extent = this.getContainerExtent();
10814 return extent ? extent.getSize() : null;
10815 };
10816
10817 Geometry.prototype.containsPoint = function containsPoint(containerPoint, t) {
10818 if (!this.getMap()) {
10819 throw new Error('The geometry is required to be added on a map to perform "containsPoint".');
10820 }
10821 if (containerPoint instanceof Coordinate) {
10822 containerPoint = this.getMap().coordToContainerPoint(containerPoint);
10823 }
10824 return this._containsPoint(containerPoint, t);
10825 };
10826
10827 Geometry.prototype._containsPoint = function _containsPoint(containerPoint, t) {
10828 var painter = this._getPainter();
10829 if (!painter) {
10830 return false;
10831 }
10832 if (isNil(t) && this._hitTestTolerance) {
10833 t = this._hitTestTolerance();
10834 }
10835 return painter.hitTest(containerPoint, t);
10836 };
10837
10838 Geometry.prototype.show = function show() {
10839 this.options['visible'] = true;
10840 if (this.getMap()) {
10841 var painter = this._getPainter();
10842 if (painter) {
10843 painter.show();
10844 }
10845
10846 this._fireEvent('show');
10847 }
10848 return this;
10849 };
10850
10851 Geometry.prototype.hide = function hide() {
10852 this.options['visible'] = false;
10853 if (this.getMap()) {
10854 this.onHide();
10855 var painter = this._getPainter();
10856 if (painter) {
10857 painter.hide();
10858 }
10859
10860 this._fireEvent('hide');
10861 }
10862 return this;
10863 };
10864
10865 Geometry.prototype.isVisible = function isVisible() {
10866 if (!this.options['visible']) {
10867 return false;
10868 }
10869 var symbol = this._getInternalSymbol();
10870 if (!symbol) {
10871 return true;
10872 }
10873 if (Array.isArray(symbol)) {
10874 if (!symbol.length) {
10875 return true;
10876 }
10877 for (var i = 0, l = symbol.length; i < l; i++) {
10878 if (isNil(symbol[i]['opacity']) || symbol[i]['opacity'] > 0) {
10879 return true;
10880 }
10881 }
10882 return false;
10883 } else {
10884 return isNil(symbol['opacity']) || isNumber(symbol['opacity']) && symbol['opacity'] > 0;
10885 }
10886 };
10887
10888 Geometry.prototype.getZIndex = function getZIndex() {
10889 return this.options['zIndex'] || 0;
10890 };
10891
10892 Geometry.prototype.setZIndex = function setZIndex(zIndex) {
10893 var old = this.options['zIndex'];
10894 this.options['zIndex'] = zIndex;
10895
10896 this._fireEvent('zindexchange', {
10897 'old': old,
10898 'new': zIndex
10899 });
10900
10901 return this;
10902 };
10903
10904 Geometry.prototype.setZIndexSilently = function setZIndexSilently(zIndex) {
10905 this.options['zIndex'] = zIndex;
10906 return this;
10907 };
10908
10909 Geometry.prototype.bringToFront = function bringToFront() {
10910 var layer = this.getLayer();
10911 if (!layer || !layer.getGeoMaxZIndex) {
10912 return this;
10913 }
10914 var topZ = layer.getGeoMaxZIndex();
10915 this.setZIndex(topZ + 1);
10916 return this;
10917 };
10918
10919 Geometry.prototype.bringToBack = function bringToBack() {
10920 var layer = this.getLayer();
10921 if (!layer || !layer.getGeoMinZIndex) {
10922 return this;
10923 }
10924 var bottomZ = layer.getGeoMinZIndex();
10925 this.setZIndex(bottomZ - 1);
10926 return this;
10927 };
10928
10929 Geometry.prototype.translate = function translate(x, y) {
10930 if (isNil(x)) {
10931 return this;
10932 }
10933 var offset = new Coordinate(x, y);
10934 if (offset.x === 0 && offset.y === 0) {
10935 return this;
10936 }
10937 var coordinates = this.getCoordinates();
10938 if (coordinates) {
10939 if (Array.isArray(coordinates)) {
10940 var translated = forEachCoord(coordinates, function (coord) {
10941 return coord.add(offset);
10942 });
10943 this.setCoordinates(translated);
10944 } else {
10945 this.setCoordinates(coordinates.add(offset));
10946 }
10947 }
10948 return this;
10949 };
10950
10951 Geometry.prototype.flash = function flash$$1(interval, count, cb, context) {
10952 return flash.call(this, interval, count, cb, context);
10953 };
10954
10955 Geometry.prototype.copy = function copy() {
10956 var json = this.toJSON();
10957 var ret = Geometry.fromJSON(json);
10958
10959 ret.options['visible'] = true;
10960 return ret;
10961 };
10962
10963 Geometry.prototype.remove = function remove() {
10964 var layer = this.getLayer();
10965 if (!layer) {
10966 return this;
10967 }
10968
10969 this._fireEvent('removestart');
10970
10971 this._unbind();
10972
10973 this._fireEvent('removeend');
10974
10975 this._fireEvent('remove');
10976 return this;
10977 };
10978
10979 Geometry.prototype.toGeoJSONGeometry = function toGeoJSONGeometry() {
10980 var gJson = this._exportGeoJSONGeometry();
10981 return gJson;
10982 };
10983
10984 Geometry.prototype.toGeoJSON = function toGeoJSON(opts) {
10985 if (!opts) {
10986 opts = {};
10987 }
10988 var feature = {
10989 'type': 'Feature',
10990 'geometry': null
10991 };
10992 if (isNil(opts['geometry']) || opts['geometry']) {
10993 var geoJSON = this._exportGeoJSONGeometry();
10994 feature['geometry'] = geoJSON;
10995 }
10996 var id = this.getId();
10997 if (!isNil(id)) {
10998 feature['id'] = id;
10999 }
11000 var properties = void 0;
11001 if (isNil(opts['properties']) || opts['properties']) {
11002 properties = this._exportProperties();
11003 }
11004 feature['properties'] = properties;
11005 return feature;
11006 };
11007
11008 Geometry.prototype.toJSON = function toJSON(options) {
11009 if (!options) {
11010 options = {};
11011 }
11012 var json = this._toJSON(options);
11013 var other = this._exportGraphicOptions(options);
11014 extend(json, other);
11015 return json;
11016 };
11017
11018 Geometry.prototype.getLength = function getLength() {
11019 return this._computeGeodesicLength(this._getMeasurer());
11020 };
11021
11022 Geometry.prototype.getArea = function getArea() {
11023 return this._computeGeodesicArea(this._getMeasurer());
11024 };
11025
11026 Geometry.prototype.rotate = function rotate(angle, pivot) {
11027 if (this.type === 'GeometryCollection') {
11028 var geometries = this.getGeometries();
11029 geometries.forEach(function (g) {
11030 return g.rotate(angle, pivot);
11031 });
11032 return this;
11033 }
11034 if (!pivot) {
11035 pivot = this.getCenter();
11036 } else {
11037 pivot = new Coordinate(pivot);
11038 }
11039 var measurer = this._getMeasurer();
11040 var coordinates = this.getCoordinates();
11041 if (!Array.isArray(coordinates)) {
11042 if (pivot.x !== coordinates.x || pivot.y !== coordinates.y) {
11043 var c = measurer._rotate(coordinates, pivot, angle);
11044 this.setCoordinates(c);
11045 }
11046 return this;
11047 }
11048 forEachCoord(coordinates, function (c) {
11049 return measurer._rotate(c, pivot, angle);
11050 });
11051 this.setCoordinates(coordinates);
11052 return this;
11053 };
11054
11055 Geometry.prototype._getConnectPoints = function _getConnectPoints() {
11056 return [this.getCenter()];
11057 };
11058
11059 Geometry.prototype._initOptions = function _initOptions(options) {
11060 var opts = extend({}, options);
11061 var symbol = opts['symbol'];
11062 var properties = opts['properties'];
11063 var id = opts['id'];
11064 delete opts['symbol'];
11065 delete opts['id'];
11066 delete opts['properties'];
11067 this.setOptions(opts);
11068 if (symbol) {
11069 this.setSymbol(symbol);
11070 }
11071 if (properties) {
11072 this.setProperties(properties);
11073 }
11074 if (!isNil(id)) {
11075 this.setId(id);
11076 }
11077 };
11078
11079 Geometry.prototype._bindLayer = function _bindLayer(layer) {
11080 if (this.getLayer()) {
11081 throw new Error('Geometry cannot be added to two or more layers at the same time.');
11082 }
11083 this._layer = layer;
11084 this._clearCache();
11085 this._clearProjection();
11086 };
11087
11088 Geometry.prototype._prepareSymbol = function _prepareSymbol(symbol) {
11089 if (Array.isArray(symbol)) {
11090 var cookedSymbols = [];
11091 for (var i = 0; i < symbol.length; i++) {
11092 cookedSymbols.push(convertResourceUrl(this._checkAndCopySymbol(symbol[i])));
11093 }
11094 return cookedSymbols;
11095 } else if (symbol) {
11096 symbol = this._checkAndCopySymbol(symbol);
11097 return convertResourceUrl(symbol);
11098 }
11099 return null;
11100 };
11101
11102 Geometry.prototype._checkAndCopySymbol = function _checkAndCopySymbol(symbol) {
11103 var s = {};
11104 for (var i in symbol) {
11105 if (NUMERICAL_PROPERTIES[i] && isString(symbol[i])) {
11106 s[i] = +symbol[i];
11107 } else {
11108 s[i] = symbol[i];
11109 }
11110 }
11111 return s;
11112 };
11113
11114 Geometry.prototype._getSymbol = function _getSymbol() {
11115 return this._symbol;
11116 };
11117
11118 Geometry.prototype._setExternSymbol = function _setExternSymbol(symbol) {
11119 this._externSymbol = this._prepareSymbol(symbol);
11120 this.onSymbolChanged();
11121 return this;
11122 };
11123
11124 Geometry.prototype._getInternalSymbol = function _getInternalSymbol() {
11125 if (this._symbol) {
11126 return this._symbol;
11127 } else if (this._externSymbol) {
11128 return this._externSymbol;
11129 } else if (this.options['symbol']) {
11130 return this.options['symbol'];
11131 }
11132 return null;
11133 };
11134
11135 Geometry.prototype._getPrjExtent = function _getPrjExtent() {
11136 var p = this._getProjection();
11137 this._verifyProjection();
11138 if (!this._extent && p) {
11139 this._extent = this._computePrjExtent(p);
11140 }
11141 return this._extent;
11142 };
11143
11144 Geometry.prototype._unbind = function _unbind() {
11145 var layer = this.getLayer();
11146 if (!layer) {
11147 return;
11148 }
11149
11150 if (this._animPlayer) {
11151 this._animPlayer.finish();
11152 }
11153 this._clearHandlers();
11154
11155 this._unbindMenu();
11156
11157 this._unbindInfoWindow();
11158
11159 if (this.isEditing()) {
11160 this.endEdit();
11161 }
11162 this._removePainter();
11163 if (this.onRemove) {
11164 this.onRemove();
11165 }
11166 if (layer.onRemoveGeometry) {
11167 layer.onRemoveGeometry(this);
11168 }
11169 delete this._layer;
11170 delete this._internalId;
11171 delete this._extent;
11172 };
11173
11174 Geometry.prototype._getInternalId = function _getInternalId() {
11175 return this._internalId;
11176 };
11177
11178 Geometry.prototype._setInternalId = function _setInternalId(id) {
11179 this._internalId = id;
11180 };
11181
11182 Geometry.prototype._getMeasurer = function _getMeasurer() {
11183 if (this._getProjection()) {
11184 return this._getProjection();
11185 }
11186 return SpatialReference.getProjectionInstance(this.options['defaultProjection']);
11187 };
11188
11189 Geometry.prototype._getProjection = function _getProjection() {
11190 var map = this.getMap();
11191 if (map) {
11192 return map.getProjection();
11193 }
11194 return null;
11195 };
11196
11197 Geometry.prototype._verifyProjection = function _verifyProjection() {
11198 var projection = this._getProjection();
11199 if (this._projCode && (!projection || this._projCode !== projection.code)) {
11200 this._clearProjection();
11201 }
11202 this._projCode = projection ? projection.code : null;
11203 };
11204
11205 Geometry.prototype._getExternalResources = function _getExternalResources() {
11206 var symbol = this._getInternalSymbol();
11207 return getExternalResources(symbol);
11208 };
11209
11210 Geometry.prototype._getPainter = function _getPainter() {
11211 if (!this._painter && this.getMap()) {
11212 if (GEOMETRY_COLLECTION_TYPES.indexOf(this.type) !== -1) {
11213 this._painter = new CollectionPainter(this);
11214 } else {
11215 this._painter = new Painter(this);
11216 }
11217 }
11218 return this._painter;
11219 };
11220
11221 Geometry.prototype._removePainter = function _removePainter() {
11222 if (this._painter) {
11223 this._painter.remove();
11224 }
11225 delete this._painter;
11226 };
11227
11228 Geometry.prototype._paint = function _paint(extent) {
11229 if (this._painter) {
11230 this._painter.paint(extent);
11231 }
11232 };
11233
11234 Geometry.prototype._clearCache = function _clearCache() {
11235 delete this._extent;
11236 };
11237
11238 Geometry.prototype._clearProjection = function _clearProjection() {
11239 delete this._extent;
11240 };
11241
11242 Geometry.prototype._repaint = function _repaint() {
11243 if (this._painter) {
11244 this._painter.repaint();
11245 }
11246 };
11247
11248 Geometry.prototype.onHide = function onHide() {
11249 this.closeMenu();
11250 this.closeInfoWindow();
11251 };
11252
11253 Geometry.prototype.onShapeChanged = function onShapeChanged() {
11254 this._clearCache();
11255 this._repaint();
11256
11257 this._fireEvent('shapechange');
11258 };
11259
11260 Geometry.prototype.onPositionChanged = function onPositionChanged() {
11261 this._clearCache();
11262 this._repaint();
11263
11264 this._fireEvent('positionchange');
11265 };
11266
11267 Geometry.prototype.onSymbolChanged = function onSymbolChanged() {
11268 if (this._painter) {
11269 this._painter.refreshSymbol();
11270 }
11271
11272 this._fireEvent('symbolchange');
11273 };
11274
11275 Geometry.prototype.onConfig = function onConfig(conf) {
11276 var properties = void 0;
11277 if (conf['properties']) {
11278 properties = conf['properties'];
11279 delete conf['properties'];
11280 }
11281 var needRepaint = false;
11282 for (var p in conf) {
11283 if (conf.hasOwnProperty(p)) {
11284 var prefix = p.slice(0, 5);
11285 if (prefix === 'arrow' || prefix === 'smoot') {
11286 needRepaint = true;
11287 break;
11288 }
11289 }
11290 }
11291 if (properties) {
11292 this.setProperties(properties);
11293 this._repaint();
11294 } else if (needRepaint) {
11295 this._repaint();
11296 }
11297 };
11298
11299 Geometry.prototype._setParent = function _setParent(geometry) {
11300 if (geometry) {
11301 this._parent = geometry;
11302 }
11303 };
11304
11305 Geometry.prototype._getParent = function _getParent() {
11306 return this._parent;
11307 };
11308
11309 Geometry.prototype._fireEvent = function _fireEvent(eventName, param) {
11310 if (this.getLayer() && this.getLayer()._onGeometryEvent) {
11311 if (!param) {
11312 param = {};
11313 }
11314 param['type'] = eventName;
11315 param['target'] = this;
11316 this.getLayer()._onGeometryEvent(param);
11317 }
11318 this.fire(eventName, param);
11319 };
11320
11321 Geometry.prototype._toJSON = function _toJSON(options) {
11322 return {
11323 'feature': this.toGeoJSON(options)
11324 };
11325 };
11326
11327 Geometry.prototype._exportGraphicOptions = function _exportGraphicOptions(options) {
11328 var json = {};
11329 if (isNil(options['options']) || options['options']) {
11330 json['options'] = this.config();
11331 }
11332 if (isNil(options['symbol']) || options['symbol']) {
11333 json['symbol'] = this.getSymbol();
11334 }
11335 if (isNil(options['infoWindow']) || options['infoWindow']) {
11336 if (this._infoWinOptions) {
11337 json['infoWindow'] = this._infoWinOptions;
11338 }
11339 }
11340 return json;
11341 };
11342
11343 Geometry.prototype._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
11344 var points = this.getCoordinates();
11345 var coordinates = Coordinate.toNumberArrays(points);
11346 return {
11347 'type': this.getType(),
11348 'coordinates': coordinates
11349 };
11350 };
11351
11352 Geometry.prototype._exportProperties = function _exportProperties() {
11353 var properties = null;
11354 var geoProperties = this.getProperties();
11355 if (!isNil(geoProperties)) {
11356 if (isObject(geoProperties)) {
11357 properties = extend({}, geoProperties);
11358 } else {
11359 properties = geoProperties;
11360 }
11361 }
11362 return properties;
11363 };
11364
11365 return Geometry;
11366}(JSONAble(Eventable(Handlerable(Class))));
11367
11368Geometry.mergeOptions(options$2);
11369
11370var EVENTS = 'mousedown ' + 'mouseup ' + 'mousemove ' + 'click ' + 'dblclick ' + 'contextmenu ' + 'touchstart ' + 'touchmove ' + 'touchend';
11371
11372var MapGeometryEventsHandler = function (_Handler) {
11373 inherits(MapGeometryEventsHandler, _Handler);
11374
11375 function MapGeometryEventsHandler() {
11376 classCallCheck(this, MapGeometryEventsHandler);
11377 return possibleConstructorReturn(this, _Handler.apply(this, arguments));
11378 }
11379
11380 MapGeometryEventsHandler.prototype.addHooks = function addHooks() {
11381 var map = this.target;
11382 var dom = map._panels.allLayers || map._containerDOM;
11383 on(dom, EVENTS, this._identifyGeometryEvents, this);
11384 };
11385
11386 MapGeometryEventsHandler.prototype.removeHooks = function removeHooks() {
11387 var map = this.target;
11388 var dom = map._panels.allLayers || map._containerDOM;
11389 off(dom, EVENTS, this._identifyGeometryEvents, this);
11390 };
11391
11392 MapGeometryEventsHandler.prototype._identifyGeometryEvents = function _identifyGeometryEvents(domEvent, type) {
11393 var map = this.target;
11394 if (map.isInteracting() || map._ignoreEvent(domEvent)) {
11395 return;
11396 }
11397 var layers = map._getLayers(function (layer) {
11398 if (layer.identify && layer.options['geometryEvents']) {
11399 return true;
11400 }
11401 return false;
11402 });
11403 if (!layers.length) {
11404 return;
11405 }
11406 var oneMoreEvent = null;
11407 var eventType = type || domEvent.type;
11408
11409 if (eventType === 'mousedown' || eventType === 'touchstart' && domEvent.touches.length === 1) {
11410 this._mouseDownTime = now();
11411 } else if ((eventType === 'click' || eventType === 'touchend') && this._mouseDownTime) {
11412 var downTime = this._mouseDownTime;
11413 delete this._mouseDownTime;
11414 var time = now();
11415 if (time - downTime > 300) {
11416 if (eventType === 'click') {
11417 return;
11418 }
11419 } else if (eventType === 'touchend') {
11420 oneMoreEvent = 'click';
11421 }
11422 }
11423
11424 var actual = domEvent.touches && domEvent.touches.length > 0 ? domEvent.touches[0] : domEvent.changedTouches && domEvent.changedTouches.length > 0 ? domEvent.changedTouches[0] : domEvent;
11425 if (!actual) {
11426 return;
11427 }
11428 var containerPoint = getEventContainerPoint(actual, map._containerDOM),
11429 coordinate = map.containerPointToCoordinate(containerPoint);
11430 if (eventType === 'touchstart') {
11431 preventDefault(domEvent);
11432 }
11433 var geometryCursorStyle = null;
11434 var identifyOptions = {
11435 'includeInternals': true,
11436
11437 'filter': function filter(geometry) {
11438 if (!(geometry instanceof Geometry)) {
11439 return false;
11440 }
11441 var eventToFire = geometry._getEventTypeToFire(domEvent);
11442 if (eventType === 'mousemove') {
11443 if (!geometryCursorStyle && geometry.options['cursor']) {
11444 geometryCursorStyle = geometry.options['cursor'];
11445 }
11446 if (!geometry.listens('mousemove') && !geometry.listens('mouseover') && !geometry.listens('mouseenter')) {
11447 return false;
11448 }
11449 } else if (!geometry.listens(eventToFire) && !geometry.listens(oneMoreEvent)) {
11450 return false;
11451 }
11452
11453 return true;
11454 },
11455 'count': 1,
11456 'coordinate': coordinate,
11457 'onlyVisible': map.options['onlyVisibleGeometryEvents'],
11458 'layers': layers
11459 };
11460 var callback = fireGeometryEvent.bind(this);
11461
11462 if (this._queryIdentifyTimeout) {
11463 cancelAnimFrame(this._queryIdentifyTimeout);
11464 }
11465 if (eventType === 'mousemove' || eventType === 'touchmove') {
11466 this._queryIdentifyTimeout = requestAnimFrame(function () {
11467 if (map.isInteracting()) {
11468 return;
11469 }
11470 map.identify(identifyOptions, callback);
11471 });
11472 } else {
11473 map.identify(identifyOptions, callback);
11474 }
11475
11476 function fireGeometryEvent(geometries) {
11477 var propagation = true;
11478 if (eventType === 'mousemove') {
11479 var geoMap = {};
11480 if (geometries.length > 0) {
11481 for (var i = geometries.length - 1; i >= 0; i--) {
11482 var geo = geometries[i];
11483 if (!(geo instanceof Geometry)) {
11484 continue;
11485 }
11486 var iid = geo._getInternalId();
11487 geoMap[iid] = geo;
11488 geo._onEvent(domEvent);
11489 if (!this._prevOverGeos || !this._prevOverGeos.geomap[iid]) {
11490 geo._onEvent(domEvent, 'mouseenter');
11491 }
11492 propagation = geo._onEvent(domEvent, 'mouseover');
11493 }
11494 }
11495
11496 map._setPriorityCursor(geometryCursorStyle);
11497
11498 var oldTargets = this._prevOverGeos && this._prevOverGeos.geos;
11499 this._prevOverGeos = {
11500 'geos': geometries,
11501 'geomap': geoMap
11502 };
11503 if (oldTargets && oldTargets.length > 0) {
11504 for (var _i = oldTargets.length - 1; _i >= 0; _i--) {
11505 var oldTarget = oldTargets[_i];
11506 if (!(oldTarget instanceof Geometry)) {
11507 continue;
11508 }
11509 var oldTargetId = oldTargets[_i]._getInternalId();
11510
11511 if (!geoMap[oldTargetId]) {
11512 propagation = oldTarget._onEvent(domEvent, 'mouseout');
11513 }
11514 }
11515 }
11516 } else {
11517 if (!geometries || !geometries.length) {
11518 return;
11519 }
11520 for (var _i2 = geometries.length - 1; _i2 >= 0; _i2--) {
11521 if (!(geometries[_i2] instanceof Geometry)) {
11522 continue;
11523 }
11524 propagation = geometries[_i2]._onEvent(domEvent);
11525 if (oneMoreEvent) {
11526 geometries[_i2]._onEvent(domEvent, oneMoreEvent);
11527 }
11528 break;
11529 }
11530 }
11531 if (propagation === false) {
11532 stopPropagation(domEvent);
11533 }
11534 }
11535 };
11536
11537 return MapGeometryEventsHandler;
11538}(Handler$1);
11539
11540Map.mergeOptions({
11541 'geometryEvents': true,
11542 'onlyVisibleGeometryEvents': true
11543});
11544
11545Map.addOnLoadHook('addHandler', 'geometryEvents', MapGeometryEventsHandler);
11546
11547var MapScrollWheelZoomHandler = function (_Handler) {
11548 inherits(MapScrollWheelZoomHandler, _Handler);
11549
11550 function MapScrollWheelZoomHandler() {
11551 classCallCheck(this, MapScrollWheelZoomHandler);
11552 return possibleConstructorReturn(this, _Handler.apply(this, arguments));
11553 }
11554
11555 MapScrollWheelZoomHandler.prototype.addHooks = function addHooks() {
11556 addDomEvent(this.target._containerDOM, 'mousewheel', this._onWheelScroll, this);
11557 };
11558
11559 MapScrollWheelZoomHandler.prototype.removeHooks = function removeHooks() {
11560 removeDomEvent(this.target._containerDOM, 'mousewheel', this._onWheelScroll);
11561 };
11562
11563 MapScrollWheelZoomHandler.prototype._onWheelScroll = function _onWheelScroll(evt) {
11564 var _this2 = this;
11565
11566 var map = this.target;
11567 if (map._ignoreEvent(evt) || !map.options['zoomable']) {
11568 return false;
11569 }
11570 preventDefault(evt);
11571 stopPropagation(evt);
11572 if (this._zooming) {
11573 this._requesting++;
11574 return false;
11575 }
11576 this._requesting = 0;
11577 var container = map._containerDOM;
11578 var levelValue = (evt.wheelDelta ? evt.wheelDelta : evt.detail) > 0 ? 1 : -1;
11579 if (evt.detail) {
11580 levelValue *= -1;
11581 }
11582 var zoom = map.getZoom();
11583 var nextZoom = zoom + levelValue;
11584 nextZoom = map._checkZoom(levelValue > 0 ? Math.ceil(nextZoom) : Math.floor(nextZoom));
11585 if (nextZoom === zoom) {
11586 return false;
11587 }
11588 this._zooming = true;
11589 var origin = map._checkZoomOrigin(getEventContainerPoint(evt, container));
11590 if (!this._delta) {
11591 map.onZoomStart(null, origin);
11592 this._origin = origin;
11593 this._delta = levelValue;
11594 this._startZoom = map.getZoom();
11595 }
11596 var duration = 90;
11597 map.animateTo({
11598 'zoom': nextZoom - this._delta * 1 / 2,
11599 'around': this._origin
11600 }, {
11601 'continueOnViewChanged': true,
11602 'easing': 'linear',
11603 'duration': duration,
11604 'wheelZoom': true
11605 }, function (frame) {
11606 if (frame.state.playState !== 'finished') {
11607 return;
11608 }
11609 if (_this2._requesting < 1 || Math.abs(nextZoom - _this2._startZoom) > 2 || nextZoom === map.getMaxZoom() || nextZoom === map.getMinZoom()) {
11610
11611 map.animateTo({
11612 'zoom': nextZoom,
11613 'around': _this2._origin
11614 }, {
11615 'continueOnViewChanged': true,
11616 'duration': 100
11617 }, function (frame) {
11618 if (frame.state.playState === 'finished') {
11619 setTimeout(function () {
11620 delete _this2._zooming;
11621 delete _this2._requesting;
11622 }, 200);
11623 }
11624 });
11625 delete _this2._startZoom;
11626 delete _this2._origin;
11627 delete _this2._delta;
11628 _this2._requesting = 0;
11629 } else if (!isNil(_this2._requesting)) {
11630 delete _this2._zooming;
11631 _this2._onWheelScroll(evt);
11632 }
11633 });
11634 return false;
11635 };
11636
11637 return MapScrollWheelZoomHandler;
11638}(Handler$1);
11639
11640Map.mergeOptions({
11641 'scrollWheelZoom': true
11642});
11643
11644Map.addOnLoadHook('addHandler', 'scrollWheelZoom', MapScrollWheelZoomHandler);
11645
11646var MapTouchZoomHandler = function (_Handler) {
11647 inherits(MapTouchZoomHandler, _Handler);
11648
11649 function MapTouchZoomHandler() {
11650 classCallCheck(this, MapTouchZoomHandler);
11651 return possibleConstructorReturn(this, _Handler.apply(this, arguments));
11652 }
11653
11654 MapTouchZoomHandler.prototype.addHooks = function addHooks() {
11655 addDomEvent(this.target.getContainer(), 'touchstart', this._onTouchStart, this);
11656 };
11657
11658 MapTouchZoomHandler.prototype.removeHooks = function removeHooks() {
11659 removeDomEvent(this.target.getContainer(), 'touchstart', this._onTouchStart);
11660 };
11661
11662 MapTouchZoomHandler.prototype._onTouchStart = function _onTouchStart(event) {
11663 var map = this.target;
11664 if (!event.touches || event.touches.length !== 2 || map.isInteracting()) {
11665 return;
11666 }
11667 var container = map.getContainer();
11668 var p1 = getEventContainerPoint(event.touches[0], container),
11669 p2 = getEventContainerPoint(event.touches[1], container);
11670
11671 this.preY = p1.y;
11672 this._startP1 = p1;
11673 this._startP2 = p2;
11674 this._startDist = p1.distanceTo(p2);
11675 this._startVector = p1.sub(p2);
11676 this._startZoom = map.getZoom();
11677 this._startBearing = map.getBearing();
11678
11679 addDomEvent(document, 'touchmove', this._onTouchMove, this);
11680 addDomEvent(document, 'touchend', this._onTouchEnd, this);
11681 preventDefault(event);
11682
11683 map._fireEvent('touchactstart');
11684 };
11685
11686 MapTouchZoomHandler.prototype._onTouchMove = function _onTouchMove(event) {
11687 var map = this.target;
11688 if (!event.touches || event.touches.length !== 2) {
11689 return;
11690 }
11691 var container = map.getContainer(),
11692 p1 = getEventContainerPoint(event.touches[0], container),
11693 p2 = getEventContainerPoint(event.touches[1], container),
11694 d1 = p1.sub(this._startP1),
11695 d2 = p2.sub(this._startP2),
11696 vector = p1.sub(p2),
11697 scale = p1.distanceTo(p2) / this._startDist,
11698 bearing = vector.angleWith(this._startVector) * 180 / Math.PI,
11699 preY = this.preY || p1.y,
11700 pitch = (preY - p1.y) * 0.4;
11701
11702 this.preY = p1.y;
11703 var param = {
11704 'domEvent': event,
11705 'mousePos': [p1, p2]
11706 };
11707 if (!this.mode) {
11708 if (map.options['touchRotate'] && Math.abs(bearing) > 8) {
11709 this.mode = map.options['touchZoomRotate'] ? 'rotate_zoom' : 'rotate';
11710 } else if (map.options['touchPitch'] && d1.y * d2.y > 0 && Math.abs(d1.y) > 10 && Math.abs(d2.y) > 10) {
11711 this.mode = 'pitch';
11712 } else if (map.options['zoomable'] && map.options['touchZoom'] && Math.abs(1 - scale) > 0.15) {
11713 this.mode = map.options['touchZoomRotate'] && map.options['touchRotate'] ? 'rotate_zoom' : 'zoom';
11714 }
11715 this._startTouching(param);
11716 }
11717 if (this.mode === 'zoom' || this.mode === 'rotate_zoom') {
11718 this._scale = scale;
11719 var res = map._getResolution(this._startZoom) / scale;
11720 var zoom = map.getZoomFromRes(res);
11721 map.onZooming(zoom, this._Origin);
11722 }
11723 if (this.mode === 'rotate' || this.mode === 'rotate_zoom') {
11724 map.setBearing(this._startBearing + bearing);
11725 map.onDragRotating(param);
11726 } else if (this.mode === 'pitch') {
11727 map.setPitch(map.getPitch() + pitch);
11728 map.onDragRotating(param);
11729 }
11730
11731 map._fireEvent('touchactinging');
11732 };
11733
11734 MapTouchZoomHandler.prototype._startTouching = function _startTouching(param) {
11735 var map = this.target;
11736 if (this.mode === 'zoom' || this.mode === 'rotate_zoom') {
11737 var size = map.getSize();
11738 this._Origin = new Point(size['width'] / 2, size['height'] / 2);
11739 map.onZoomStart(null, this._Origin);
11740 }
11741 if (this.mode === 'rotate' || this.mode === 'pitch' || this.mode === 'rotate_zoom') {
11742 map.onDragRotateStart(param);
11743 }
11744 };
11745
11746 MapTouchZoomHandler.prototype._onTouchEnd = function _onTouchEnd(event) {
11747 delete this.preY;
11748 var map = this.target;
11749
11750 off(document, 'touchmove', this._onTouchMove, this);
11751 off(document, 'touchend', this._onTouchEnd, this);
11752
11753 if (this.mode === 'zoom' || this.mode === 'rotate_zoom') {
11754 var scale = this._scale;
11755 var res = map._getResolution(this._startZoom) / scale;
11756 var zoom = map.getZoomFromRes(res);
11757 map.onZoomEnd(zoom, this._Origin);
11758 }
11759 if (this.mode === 'pitch' || this.mode === 'rotate' || this.mode === 'rotate_zoom') {
11760 map.onDragRotateEnd({
11761 'domEvent': event
11762 });
11763 }
11764 delete this.mode;
11765
11766 map._fireEvent('touchactend');
11767 };
11768
11769 return MapTouchZoomHandler;
11770}(Handler$1);
11771
11772Map.mergeOptions({
11773 'touchGesture': true,
11774 'touchZoom': true,
11775 'touchPitch': true,
11776 'touchRotate': true,
11777 'touchZoomRotate': false
11778});
11779
11780Map.addOnLoadHook('addHandler', 'touchGesture', MapTouchZoomHandler);
11781
11782var Easing = {
11783 in: function _in(t) {
11784 return Math.pow(t, 2);
11785 },
11786 out: function out(t) {
11787 return 1 - Easing.in(1 - t);
11788 },
11789 inAndOut: function inAndOut(t) {
11790 return 3 * t * t - 2 * t * t * t;
11791 },
11792 linear: function linear(t) {
11793 return t;
11794 },
11795 upAndDown: function upAndDown(t) {
11796 if (t < 0.5) {
11797 return Easing.inAndOut(2 * t);
11798 } else {
11799 return 1 - Easing.inAndOut(2 * (t - 0.5));
11800 }
11801 }
11802};
11803
11804var Frame = function Frame(state, styles) {
11805 classCallCheck(this, Frame);
11806
11807 this.state = state;
11808 this.styles = styles;
11809};
11810
11811var Player = function Player(animation, options, onFrame) {
11812 classCallCheck(this, Player);
11813
11814 this._animation = animation;
11815 this.options = options;
11816 this._onFrame = onFrame;
11817 this.playState = 'idle';
11818 this.ready = true;
11819 this.finished = false;
11820};
11821
11822var Animation = {
11823 speed: {
11824 'slow': 2000,
11825 'normal': 1000,
11826 'fast': 500
11827 },
11828
11829 _resolveStyles: function _resolveStyles(styles) {
11830 if (!styles) {
11831 return null;
11832 }
11833
11834 function resolveChild(child) {
11835 if (!Array.isArray(child)) {
11836 return Animation._resolveStyles(child);
11837 }
11838 var start = [],
11839 d = [],
11840 dest = [];
11841 for (var i = 0; i < child.length; i++) {
11842 var _styles = Animation._resolveStyles(child[i]);
11843 if (_styles) {
11844 start.push(_styles[0]);
11845 d.push(_styles[1]);
11846 dest.push(_styles[2]);
11847 }
11848 }
11849 if (!start.length) {
11850 return null;
11851 } else {
11852 return [start, d, dest];
11853 }
11854 }
11855
11856 function resolveVal(val) {
11857 var values = val;
11858 var clazz = void 0;
11859
11860 if (!Array.isArray(val)) {
11861 if (isNumber(val)) {
11862 values = [0, val];
11863 } else if (val instanceof Point || val instanceof Coordinate) {
11864 clazz = val.constructor;
11865 values = [new clazz(0, 0), val];
11866 } else {
11867 values = [val, val];
11868 }
11869 }
11870
11871 var v1 = values[0],
11872 v2 = values[1];
11873 if (isNumber(v1) && isNumber(v2)) {
11874 if (v1 === v2) {
11875 return null;
11876 }
11877 return [v1, v2 - v1, v2];
11878 } else if (Array.isArray(v1) || v1 instanceof Coordinate || v1 instanceof Point) {
11879 if (Array.isArray(v1)) {
11880 v1 = new Coordinate(v1);
11881 v2 = new Coordinate(v2);
11882 } else {
11883 clazz = v1.constructor;
11884 v1 = new clazz(v1);
11885 v2 = new clazz(v2);
11886 }
11887 if (v1.equals(v2)) {
11888 return null;
11889 }
11890 return [v1, v2.sub(v1), v2];
11891 } else {
11892 return [v1, 0, v2];
11893 }
11894 }
11895
11896 function isChild(val) {
11897 if (!Array.isArray(val) && val.constructor === Object) {
11898 return true;
11899 } else if (Array.isArray(val) && val[0].constructor === Object) {
11900 return true;
11901 }
11902 return false;
11903 }
11904
11905 var d = {},
11906 start = {},
11907 dest = {};
11908 for (var p in styles) {
11909 if (styles.hasOwnProperty(p)) {
11910 var values = styles[p];
11911
11912 if (!values) {
11913 continue;
11914 } else if (Array.isArray(values)) {
11915 if (isNil(values[0]) || isNil(values[1])) {
11916 continue;
11917 }
11918 }
11919 var childStyles = void 0;
11920 if (isChild(values)) {
11921 childStyles = resolveChild(values);
11922 } else {
11923 childStyles = resolveVal(values);
11924 }
11925 if (childStyles) {
11926 start[p] = childStyles[0];
11927 d[p] = childStyles[1];
11928 dest[p] = childStyles[2];
11929 }
11930 }
11931 }
11932 return [start, d, dest];
11933 },
11934 framing: function framing(styles, options) {
11935 if (!options) {
11936 options = {};
11937 }
11938 var easing = options['easing'] ? Easing[options['easing']] : Easing.linear;
11939 if (!easing) {
11940 easing = Easing.linear;
11941 }
11942 var dStyles = void 0,
11943 startStyles = void 0,
11944 destStyles = void 0;
11945 styles = Animation._resolveStyles(styles);
11946 if (styles) {
11947 startStyles = styles[0];
11948 dStyles = styles[1];
11949 destStyles = styles[2];
11950 }
11951 var deltaStyles = function deltaStyles(delta, _startStyles, _dStyles) {
11952 if (!_startStyles || !_dStyles) {
11953 return null;
11954 }
11955 var result = {};
11956 for (var p in _dStyles) {
11957 if (_dStyles.hasOwnProperty(p)) {
11958 if (_startStyles[p] === destStyles[p]) {
11959 result[p] = _startStyles[p];
11960 continue;
11961 }
11962 var s = _startStyles[p],
11963 d = _dStyles[p];
11964 if (isNumber(d)) {
11965 result[p] = s + delta * d;
11966 } else if (Array.isArray(d)) {
11967 var children = [];
11968 for (var i = 0; i < d.length; i++) {
11969 children.push(deltaStyles(delta, s[i], d[i]));
11970 }
11971 result[p] = children;
11972 } else {
11973 var clazz = d.constructor;
11974 if (clazz === Object) {
11975 result[p] = deltaStyles(delta, s, d);
11976 } else if (s instanceof Point || s instanceof Coordinate) {
11977 result[p] = s.add(d.multi(delta));
11978 }
11979 }
11980 }
11981 }
11982 return result;
11983 };
11984 return function (elapsed, duration) {
11985 var state = void 0,
11986 d = void 0;
11987 if (elapsed < 0) {
11988 state = {
11989 'playState': 'idle',
11990 'delta': 0
11991 };
11992 d = startStyles;
11993 } else if (elapsed < duration) {
11994 var delta = easing(elapsed / duration);
11995 state = {
11996 'playState': 'running',
11997 'delta': delta
11998 };
11999 d = deltaStyles(delta, startStyles, dStyles);
12000 } else {
12001 state = {
12002 'playState': 'finished',
12003 'delta': 1
12004 };
12005 d = destStyles;
12006 }
12007 state['startStyles'] = startStyles;
12008 state['destStyles'] = destStyles;
12009 state['progress'] = elapsed;
12010 state['remainingMs'] = duration - elapsed;
12011 return new Frame(state, d);
12012 };
12013 },
12014 _requestAnimFrame: function _requestAnimFrame(fn) {
12015 if (!this._frameQueue) {
12016 this._frameQueue = [];
12017 }
12018 this._frameQueue.push(fn);
12019 this._a();
12020 },
12021 _a: function _a() {
12022 if (!this._animationFrameId) {
12023 this._animationFrameId = requestAnimFrame(Animation._frameFn);
12024 }
12025 },
12026 _run: function _run() {
12027 if (this._frameQueue.length) {
12028 var running = this._frameQueue;
12029 this._frameQueue = [];
12030 for (var i = 0, len = running.length; i < len; i++) {
12031 running[i]();
12032 }
12033 if (this._frameQueue.length) {
12034 this._animationFrameId = requestAnimFrame(Animation._frameFn);
12035 } else {
12036 delete this._animationFrameId;
12037 }
12038 }
12039 },
12040 animate: function animate(styles, options, step) {
12041 if (!options) {
12042 options = {};
12043 }
12044 var animation = Animation.framing(styles, options);
12045 return new Player(animation, options, step);
12046 }
12047};
12048
12049Animation._frameFn = Animation._run.bind(Animation);
12050
12051extend(Player.prototype, {
12052 _prepare: function _prepare() {
12053 var options = this.options;
12054 var duration = options['speed'] || options['duration'];
12055 if (isString(duration)) {
12056 duration = Animation.speed[duration];
12057 if (!duration) {
12058 duration = +duration;
12059 }
12060 }
12061 if (!duration) {
12062 duration = Animation.speed['normal'];
12063 }
12064 this.duration = duration;
12065 this._framer = options['framer'] || Animation._requestAnimFrame.bind(Animation);
12066 },
12067 play: function play() {
12068 if (this.playState !== 'idle' && this.playState !== 'paused') {
12069 return this;
12070 }
12071 if (this.playState === 'idle') {
12072 this.currentTime = 0;
12073 this._prepare();
12074 }
12075 var t = now();
12076 if (!this.startTime) {
12077 var options = this.options;
12078 this.startTime = options['startTime'] ? options['startTime'] : t;
12079 }
12080 this._playStartTime = Math.max(t, this.startTime);
12081 if (this.playState === 'paused') {
12082 this._playStartTime -= this.currentTime;
12083 }
12084 this.playState = 'running';
12085 this._run();
12086 return this;
12087 },
12088 pause: function pause() {
12089 if (this.playState === 'paused') {
12090 return this;
12091 }
12092 this.playState = 'paused';
12093 this._run();
12094
12095 return this;
12096 },
12097 cancel: function cancel() {
12098 if (this.playState === 'idle') {
12099 return this;
12100 }
12101 this.playState = 'idle';
12102 this.finished = false;
12103 this._run();
12104 return this;
12105 },
12106 finish: function finish() {
12107 if (this.playState === 'finished') {
12108 return this;
12109 }
12110 this.playState = 'finished';
12111 this.finished = true;
12112 this._run();
12113 return this;
12114 },
12115 reverse: function reverse() {},
12116 _run: function _run() {
12117 var _this = this;
12118
12119 var onFrame = this._onFrame;
12120 var t = now();
12121 var elapsed = t - this._playStartTime;
12122 if (this.options['repeat'] && elapsed >= this.duration) {
12123 this._playStartTime = t;
12124 elapsed = 0;
12125 }
12126 if (this.playState !== 'running') {
12127 if (onFrame) {
12128 if (this.playState === 'finished') {
12129 elapsed = this.duration;
12130 } else if (this.playState === 'idle') {
12131 elapsed = 0;
12132 }
12133 var _frame = this._animation(elapsed, this.duration);
12134 _frame.state.playState = this.playState;
12135 onFrame(_frame);
12136 }
12137 return;
12138 }
12139
12140 var frame = this._animation(elapsed, this.duration);
12141 this.playState = frame.state['playState'];
12142
12143 if (this.playState === 'idle') {
12144 if (this.startTime > t) {
12145 setTimeout(this._run.bind(this), this.startTime - t);
12146 }
12147 } else if (this.playState === 'running') {
12148 this._framer(function () {
12149 if (_this.playState !== 'running') {
12150 return;
12151 }
12152 _this.currentTime = elapsed;
12153 if (onFrame) {
12154 onFrame(frame);
12155 }
12156 _this._run();
12157 });
12158 } else if (this.playState === 'finished') {
12159 this.finished = true;
12160
12161 if (onFrame) {
12162 onFrame(frame);
12163 }
12164 }
12165 }
12166});
12167
12168
12169
12170var Animation$1 = Object.freeze({
12171 Animation: Animation,
12172 Easing: Easing,
12173 Player: Player,
12174 Frame: Frame
12175});
12176
12177var simplify = createCommonjsModule(function (module) {
12178
12179 (function () {
12180 'use strict';
12181
12182 function getSqDist(p1, p2) {
12183
12184 var dx = p1.x - p2.x,
12185 dy = p1.y - p2.y;
12186
12187 return dx * dx + dy * dy;
12188 }
12189
12190 function getSqSegDist(p, p1, p2) {
12191
12192 var x = p1.x,
12193 y = p1.y,
12194 dx = p2.x - x,
12195 dy = p2.y - y;
12196
12197 if (dx !== 0 || dy !== 0) {
12198
12199 var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy);
12200
12201 if (t > 1) {
12202 x = p2.x;
12203 y = p2.y;
12204 } else if (t > 0) {
12205 x += dx * t;
12206 y += dy * t;
12207 }
12208 }
12209
12210 dx = p.x - x;
12211 dy = p.y - y;
12212
12213 return dx * dx + dy * dy;
12214 }
12215
12216 function simplifyRadialDist(points, sqTolerance) {
12217
12218 var prevPoint = points[0],
12219 newPoints = [prevPoint],
12220 point;
12221
12222 for (var i = 1, len = points.length; i < len; i++) {
12223 point = points[i];
12224
12225 if (getSqDist(point, prevPoint) > sqTolerance) {
12226 newPoints.push(point);
12227 prevPoint = point;
12228 }
12229 }
12230
12231 if (prevPoint !== point) newPoints.push(point);
12232
12233 return newPoints;
12234 }
12235
12236 function simplifyDPStep(points, first, last, sqTolerance, simplified) {
12237 var maxSqDist = sqTolerance,
12238 index;
12239
12240 for (var i = first + 1; i < last; i++) {
12241 var sqDist = getSqSegDist(points[i], points[first], points[last]);
12242
12243 if (sqDist > maxSqDist) {
12244 index = i;
12245 maxSqDist = sqDist;
12246 }
12247 }
12248
12249 if (maxSqDist > sqTolerance) {
12250 if (index - first > 1) simplifyDPStep(points, first, index, sqTolerance, simplified);
12251 simplified.push(points[index]);
12252 if (last - index > 1) simplifyDPStep(points, index, last, sqTolerance, simplified);
12253 }
12254 }
12255
12256 function simplifyDouglasPeucker(points, sqTolerance) {
12257 var last = points.length - 1;
12258
12259 var simplified = [points[0]];
12260 simplifyDPStep(points, 0, last, sqTolerance, simplified);
12261 simplified.push(points[last]);
12262
12263 return simplified;
12264 }
12265
12266 function simplify(points, tolerance, highestQuality) {
12267
12268 if (points.length <= 2) return points;
12269
12270 var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1;
12271
12272 points = highestQuality ? points : simplifyRadialDist(points, sqTolerance);
12273 points = simplifyDouglasPeucker(points, sqTolerance);
12274
12275 return points;
12276 }
12277
12278 if (false) undefined(function () {
12279 return simplify;
12280 });else {
12281 module.exports = simplify;
12282 module.exports.default = simplify;
12283 }
12284 })();
12285});
12286
12287var options$4 = {
12288 'smoothness': 0,
12289 'enableClip': true,
12290 'enableSimplify': true,
12291 'symbol': {
12292 'lineColor': '#000',
12293 'lineWidth': 2,
12294 'lineOpacity': 1,
12295
12296 'polygonFill': '#fff',
12297 'polygonOpacity': 1,
12298 'opacity': 1
12299 }
12300};
12301
12302var Path = function (_Geometry) {
12303 inherits(Path, _Geometry);
12304
12305 function Path() {
12306 classCallCheck(this, Path);
12307 return possibleConstructorReturn(this, _Geometry.apply(this, arguments));
12308 }
12309
12310 Path.prototype.getOutline = function getOutline() {
12311 var painter = this._getPainter();
12312 if (!painter) {
12313 return null;
12314 }
12315 var map = this.getMap();
12316 var extent = painter.getContainerExtent().convertTo(function (c) {
12317 return map.containerPointToCoord(c);
12318 });
12319 return new Polygon(extent.toArray(), {
12320 symbol: {
12321 'lineWidth': 1,
12322 'lineColor': '6b707b'
12323 }
12324 });
12325 };
12326
12327 Path.prototype.animateShow = function animateShow() {
12328 var _this2 = this;
12329
12330 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12331 var cb = arguments[1];
12332
12333 if (this._showPlayer) {
12334 this._showPlayer.finish();
12335 }
12336 if (isFunction(options)) {
12337 options = {};
12338 cb = options;
12339 }
12340 var coordinates = this.getCoordinates();
12341 if (coordinates.length === 0) {
12342 return this;
12343 }
12344 this._animIdx = 0;
12345 this._animLenSoFar = 0;
12346 this.show();
12347 var isPolygon = !!this.getShell;
12348 var animCoords = isPolygon ? this.getShell().concat(this.getShell()[0]) : this.getCoordinates();
12349 var projection = this._getProjection();
12350 this._aniShowCenter = projection.unproject(this._getPrjExtent().getCenter());
12351 var duration = options['duration'] || 1000,
12352 length = this.getLength(),
12353 easing = options['easing'] || 'out';
12354 this.setCoordinates([]);
12355 var player = this._showPlayer = Animation.animate({
12356 't': duration
12357 }, {
12358 'duration': duration,
12359 'easing': easing
12360 }, function (frame) {
12361 if (!_this2.getMap()) {
12362 if (player.playState !== 'finished') {
12363 player.finish();
12364 if (cb) {
12365 var _coordinates = _this2.getCoordinates();
12366 cb(frame, _coordinates[_coordinates.length - 1]);
12367 }
12368 }
12369 return;
12370 }
12371 var currentCoord = _this2._drawAnimShowFrame(frame.styles.t, duration, length, animCoords);
12372 if (frame.state.playState === 'finished') {
12373 delete _this2._showPlayer;
12374 delete _this2._aniShowCenter;
12375 delete _this2._animIdx;
12376 delete _this2._animLenSoFar;
12377 delete _this2._animTailRatio;
12378 _this2.setCoordinates(coordinates);
12379 }
12380 if (cb) {
12381 cb(frame, currentCoord);
12382 }
12383 });
12384 player.play();
12385 return player;
12386 };
12387
12388 Path.prototype._drawAnimShowFrame = function _drawAnimShowFrame(t, duration, length, coordinates) {
12389 if (t === 0) {
12390 return coordinates[0];
12391 }
12392 var map = this.getMap();
12393 var targetLength = t / duration * length;
12394 var segLen = 0;
12395 var i = void 0,
12396 l = void 0;
12397 for (i = this._animIdx, l = coordinates.length; i < l - 1; i++) {
12398 segLen = map.computeLength(coordinates[i], coordinates[i + 1]);
12399 if (this._animLenSoFar + segLen > targetLength) {
12400 break;
12401 }
12402 this._animLenSoFar += segLen;
12403 }
12404 this._animIdx = i;
12405 if (this._animIdx >= l - 1) {
12406 this.setCoordinates(coordinates);
12407 return coordinates[coordinates.length - 1];
12408 }
12409 var idx = this._animIdx;
12410 var p1 = coordinates[idx],
12411 p2 = coordinates[idx + 1],
12412 span = targetLength - this._animLenSoFar,
12413 r = span / segLen;
12414 this._animTailRatio = r;
12415 var x = p1.x + (p2.x - p1.x) * r,
12416 y = p1.y + (p2.y - p1.y) * r,
12417 targetCoord = new Coordinate(x, y);
12418 var isPolygon = !!this.getShell;
12419 if (!isPolygon && this.options['smoothness'] > 0) {
12420 var animCoords = coordinates.slice(0, this._animIdx + 3);
12421 this.setCoordinates(animCoords);
12422 } else {
12423 var _animCoords = coordinates.slice(0, this._animIdx + 1);
12424 _animCoords.push(targetCoord);
12425 if (isPolygon) {
12426 this.setCoordinates([this._aniShowCenter].concat(_animCoords));
12427 } else {
12428 this.setCoordinates(_animCoords);
12429 }
12430 }
12431 return targetCoord;
12432 };
12433
12434 Path.prototype._getCenterInExtent = function _getCenterInExtent(extent, coordinates, clipFn) {
12435 var meExtent = this.getExtent();
12436 if (!extent.intersects(meExtent)) {
12437 return null;
12438 }
12439 var clipped = clipFn(coordinates, extent);
12440 if (clipped.length === 0) {
12441 return null;
12442 }
12443 var sumx = 0,
12444 sumy = 0,
12445 counter = 0;
12446
12447 clipped.forEach(function (part) {
12448 if (Array.isArray(part)) {
12449 part.forEach(function (c) {
12450 if (c.point) {
12451 c = c.point;
12452 }
12453 sumx += c.x;
12454 sumy += c.y;
12455 counter++;
12456 });
12457 } else {
12458 if (part.point) {
12459 part = part.point;
12460 }
12461 sumx += part.x;
12462 sumy += part.y;
12463 counter++;
12464 }
12465 });
12466 var c = new Coordinate(sumx, sumy)._multi(1 / counter);
12467 c.count = counter;
12468 return c;
12469 };
12470
12471 Path.prototype._getPath2DPoints = function _getPath2DPoints(prjCoords, disableSimplify, zoom) {
12472 if (!isArrayHasData(prjCoords)) {
12473 return [];
12474 }
12475 var map = this.getMap(),
12476 isSimplify = !disableSimplify && this._shouldSimplify(),
12477 tolerance = 2 * map._getResolution(),
12478 isMulti = Array.isArray(prjCoords[0]);
12479 delete this._simplified;
12480 if (isSimplify && !isMulti) {
12481 var count = prjCoords.length;
12482 prjCoords = simplify(prjCoords, tolerance, false);
12483 this._simplified = prjCoords.length < count;
12484 }
12485 if (isNil(zoom)) {
12486 zoom = map.getZoom();
12487 }
12488 return forEachCoord(prjCoords, function (c) {
12489 return map._prjToPoint(c, zoom);
12490 });
12491 };
12492
12493 Path.prototype._shouldSimplify = function _shouldSimplify() {
12494 var layer = this.getLayer(),
12495 properties = this.getProperties();
12496 var hasAltitude = properties && layer.options['enableAltitude'] && !isNil(properties[layer.options['altitudeProperty']]);
12497 return layer && layer.options['enableSimplify'] && !hasAltitude && this.options['enableSimplify'];
12498 };
12499
12500 Path.prototype._setPrjCoordinates = function _setPrjCoordinates(prjPoints) {
12501 this._prjCoords = prjPoints;
12502 this.onShapeChanged();
12503 };
12504
12505 Path.prototype._getPrjCoordinates = function _getPrjCoordinates() {
12506 var projection = this._getProjection();
12507 if (!projection) {
12508 return null;
12509 }
12510 this._verifyProjection();
12511 if (!this._prjCoords) {
12512 this._prjCoords = this._projectCoords(this._coordinates);
12513 }
12514 return this._prjCoords;
12515 };
12516
12517 Path.prototype._updateCache = function _updateCache() {
12518 this._clearCache();
12519 var projection = this._getProjection();
12520 if (!projection) {
12521 return;
12522 }
12523 if (this._prjCoords) {
12524 this._coordinates = this._unprojectCoords(this._getPrjCoordinates());
12525 }
12526 };
12527
12528 Path.prototype._clearProjection = function _clearProjection() {
12529 this._prjCoords = null;
12530 _Geometry.prototype._clearProjection.call(this);
12531 };
12532
12533 Path.prototype._projectCoords = function _projectCoords(points) {
12534 var projection = this._getProjection();
12535 if (projection) {
12536 return projection.projectCoords(points);
12537 }
12538 return [];
12539 };
12540
12541 Path.prototype._unprojectCoords = function _unprojectCoords(prjPoints) {
12542 var projection = this._getProjection();
12543 if (projection) {
12544 return projection.unprojectCoords(prjPoints);
12545 }
12546 return [];
12547 };
12548
12549 Path.prototype._computeCenter = function _computeCenter() {
12550 var ring = this._coordinates;
12551 if (!isArrayHasData(ring)) {
12552 return null;
12553 }
12554 var sumx = 0,
12555 sumy = 0,
12556 counter = 0;
12557 var size = ring.length;
12558 for (var i = 0; i < size; i++) {
12559 if (ring[i]) {
12560 if (isNumber(ring[i].x) && isNumber(ring[i].y)) {
12561 sumx += ring[i].x;
12562 sumy += ring[i].y;
12563 counter++;
12564 }
12565 }
12566 }
12567 return new Coordinate(sumx / counter, sumy / counter);
12568 };
12569
12570 Path.prototype._computeExtent = function _computeExtent() {
12571 var shell = this._coordinates;
12572 if (!isArrayHasData(shell)) {
12573 return null;
12574 }
12575 var rings = [shell];
12576 if (this.hasHoles && this.hasHoles()) {
12577 rings.push.apply(rings, this.getHoles());
12578 }
12579 return this._coords2Extent(rings, this._getProjection());
12580 };
12581
12582 Path.prototype._computePrjExtent = function _computePrjExtent() {
12583 var coords = [this._getPrjCoordinates()];
12584 if (this.hasHoles && this.hasHoles()) {
12585 coords.push.apply(coords, this._getPrjHoles());
12586 }
12587 return this._coords2Extent(coords);
12588 };
12589
12590 Path.prototype._get2DLength = function _get2DLength() {
12591 var vertexes = this._getPath2DPoints(this._getPrjCoordinates(), true);
12592 var len = 0;
12593 for (var i = 1, l = vertexes.length; i < l; i++) {
12594 len += vertexes[i].distanceTo(vertexes[i - 1]);
12595 }
12596 return len;
12597 };
12598
12599 Path.prototype._hitTestTolerance = function _hitTestTolerance() {
12600 var symbol = this._getInternalSymbol();
12601 var w = void 0;
12602 if (Array.isArray(symbol)) {
12603 w = 0;
12604 for (var i = 0; i < symbol.length; i++) {
12605 if (isNumber(symbol[i]['lineWidth'])) {
12606 if (symbol[i]['lineWidth'] > w) {
12607 w = symbol[i]['lineWidth'];
12608 }
12609 }
12610 }
12611 } else {
12612 w = symbol['lineWidth'];
12613 }
12614 return isNumber(w) ? w / 2 : 1.5;
12615 };
12616
12617 Path.prototype._coords2Extent = function _coords2Extent(coords, proj) {
12618 var result = new Extent(proj);
12619 for (var i = 0, l = coords.length; i < l; i++) {
12620 for (var j = 0, ll = coords[i].length; j < ll; j++) {
12621 result._combine(coords[i][j]);
12622 }
12623 }
12624 return result;
12625 };
12626
12627 return Path;
12628}(Geometry);
12629
12630Path.mergeOptions(options$4);
12631
12632var JSON_TYPE = 'Polygon';
12633
12634var Polygon = function (_Path) {
12635 inherits(Polygon, _Path);
12636
12637 function Polygon(coordinates, opts) {
12638 classCallCheck(this, Polygon);
12639
12640 var _this = possibleConstructorReturn(this, _Path.call(this, opts));
12641
12642 _this.type = 'Polygon';
12643 if (coordinates) {
12644 _this.setCoordinates(coordinates);
12645 }
12646 return _this;
12647 }
12648
12649 Polygon.prototype.setCoordinates = function setCoordinates(coordinates) {
12650 if (!coordinates) {
12651 this._coordinates = null;
12652 this._holes = null;
12653 this._projectRings();
12654 return this;
12655 }
12656 var rings = Coordinate.toCoordinates(coordinates);
12657 var len = rings.length;
12658 if (!Array.isArray(rings[0])) {
12659 this._coordinates = this._trimRing(rings);
12660 } else {
12661 this._coordinates = this._trimRing(rings[0]);
12662 if (len > 1) {
12663 var holes = [];
12664 for (var i = 1; i < len; i++) {
12665 if (!rings[i]) {
12666 continue;
12667 }
12668 holes.push(this._trimRing(rings[i]));
12669 }
12670 this._holes = holes;
12671 }
12672 }
12673
12674 this._projectRings();
12675 return this;
12676 };
12677
12678 Polygon.prototype.getCoordinates = function getCoordinates() {
12679 if (!this._coordinates) {
12680 return [];
12681 }
12682 var holes = this.getHoles();
12683 var rings = [this._copyAndCloseRing(this._coordinates)];
12684 for (var i = 0, l = holes.length; i < l; i++) {
12685 rings.push(this._copyAndCloseRing(holes[i]));
12686 }
12687 return rings;
12688 };
12689
12690 Polygon.prototype.getCenterInExtent = function getCenterInExtent(extent) {
12691 return this._getCenterInExtent(extent, this.getShell(), clipPolygon);
12692 };
12693
12694 Polygon.prototype.getShell = function getShell() {
12695 return this._coordinates || [];
12696 };
12697
12698 Polygon.prototype.getHoles = function getHoles() {
12699 return this._holes || [];
12700 };
12701
12702 Polygon.prototype.hasHoles = function hasHoles() {
12703 return this.getHoles().length > 0;
12704 };
12705
12706 Polygon.prototype._projectRings = function _projectRings() {
12707 if (!this.getMap()) {
12708 this.onShapeChanged();
12709 return;
12710 }
12711 this._prjCoords = this._projectCoords(this._coordinates);
12712 this._prjHoles = this._projectCoords(this._holes);
12713 this.onShapeChanged();
12714 };
12715
12716 Polygon.prototype._cleanRing = function _cleanRing(ring) {
12717 for (var i = ring.length - 1; i >= 0; i--) {
12718 if (!ring[i]) {
12719 ring.splice(i, 1);
12720 }
12721 }
12722 };
12723
12724 Polygon.prototype._checkRing = function _checkRing(ring) {
12725 this._cleanRing(ring);
12726 if (!ring || !isArrayHasData(ring)) {
12727 return false;
12728 }
12729 var lastPoint = ring[ring.length - 1];
12730 var isClose = true;
12731 if (ring[0].x !== lastPoint.x || ring[0].y !== lastPoint.y) {
12732 isClose = false;
12733 }
12734 return isClose;
12735 };
12736
12737 Polygon.prototype._trimRing = function _trimRing(ring) {
12738 var isClose = this._checkRing(ring);
12739 if (isArrayHasData(ring) && isClose) {
12740 ring.splice(ring.length - 1, 1);
12741 }
12742 return ring;
12743 };
12744
12745 Polygon.prototype._copyAndCloseRing = function _copyAndCloseRing(ring) {
12746 ring = ring.slice(0);
12747 var isClose = this._checkRing(ring);
12748 if (isArrayHasData(ring) && !isClose) {
12749 ring.push(ring[0].copy());
12750 return ring;
12751 } else {
12752 return ring;
12753 }
12754 };
12755
12756 Polygon.prototype._getPrjShell = function _getPrjShell() {
12757 if (this.getJSONType() === JSON_TYPE) {
12758 return this._getPrjCoordinates();
12759 }
12760 var projection = this._getProjection();
12761 if (!projection) {
12762 return null;
12763 }
12764 this._verifyProjection();
12765 if (!this._prjShell) {
12766 this._prjShell = this._projectCoords(this.getShell());
12767 }
12768 return this._prjShell;
12769 };
12770
12771 Polygon.prototype._getPrjHoles = function _getPrjHoles() {
12772 var projection = this._getProjection();
12773 if (!projection) {
12774 return null;
12775 }
12776 this._verifyProjection();
12777 if (!this._prjHoles) {
12778 this._prjHoles = this._projectCoords(this.getHoles());
12779 }
12780 return this._prjHoles;
12781 };
12782
12783 Polygon.prototype._computeGeodesicLength = function _computeGeodesicLength(measurer) {
12784 var rings = this.getCoordinates();
12785 if (!isArrayHasData(rings)) {
12786 return 0;
12787 }
12788 var result = 0;
12789 for (var i = 0, len = rings.length; i < len; i++) {
12790 result += measurer.measureLength(rings[i]);
12791 }
12792 return result;
12793 };
12794
12795 Polygon.prototype._computeGeodesicArea = function _computeGeodesicArea(measurer) {
12796 var rings = this.getCoordinates();
12797 if (!isArrayHasData(rings)) {
12798 return 0;
12799 }
12800 var result = measurer.measureArea(rings[0]);
12801
12802 for (var i = 1, len = rings.length; i < len; i++) {
12803 result -= measurer.measureArea(rings[i]);
12804 }
12805 return result;
12806 };
12807
12808 Polygon.prototype._updateCache = function _updateCache() {
12809 _Path.prototype._updateCache.call(this);
12810 if (this._prjHoles) {
12811 this._holes = this._unprojectCoords(this._getPrjHoles());
12812 }
12813 };
12814
12815 Polygon.prototype._clearCache = function _clearCache() {
12816 delete this._prjShell;
12817 return _Path.prototype._clearCache.call(this);
12818 };
12819
12820 Polygon.prototype._clearProjection = function _clearProjection() {
12821 if (this._prjHoles) {
12822 this._prjHoles = null;
12823 }
12824 if (this._prjShell) {
12825 this._prjShell = null;
12826 }
12827 _Path.prototype._clearProjection.call(this);
12828 };
12829
12830 return Polygon;
12831}(Path);
12832
12833Polygon.registerJSONType(JSON_TYPE);
12834
12835var CenterMixin = function (Base) {
12836 return function (_Base) {
12837 inherits(_class, _Base);
12838
12839 function _class() {
12840 classCallCheck(this, _class);
12841 return possibleConstructorReturn(this, _Base.apply(this, arguments));
12842 }
12843
12844 _class.prototype.getCoordinates = function getCoordinates() {
12845 return this._coordinates;
12846 };
12847
12848 _class.prototype.setCoordinates = function setCoordinates(coordinates) {
12849 var center = coordinates instanceof Coordinate ? coordinates : new Coordinate(coordinates);
12850 if (center.equals(this._coordinates)) {
12851 return this;
12852 }
12853 this._coordinates = center;
12854 if (!this.getMap()) {
12855 this.onPositionChanged();
12856 return this;
12857 }
12858 var projection = this._getProjection();
12859 this._setPrjCoordinates(projection.project(this._coordinates));
12860 return this;
12861 };
12862
12863 _class.prototype._getCenter2DPoint = function _getCenter2DPoint(zoom) {
12864 var map = this.getMap();
12865 if (!map) {
12866 return null;
12867 }
12868 var z = isNil(zoom) ? map.getZoom() : map.getGLZoom();
12869 var pcenter = this._getPrjCoordinates();
12870 if (!pcenter) {
12871 return null;
12872 }
12873
12874 return map._prjToPoint(pcenter, z);
12875 };
12876
12877 _class.prototype._getPrjCoordinates = function _getPrjCoordinates() {
12878 var projection = this._getProjection();
12879 if (!projection) {
12880 return null;
12881 }
12882 this._verifyProjection();
12883 if (!this._pcenter) {
12884 if (this._coordinates) {
12885 this._pcenter = projection.project(this._coordinates);
12886 }
12887 }
12888 return this._pcenter;
12889 };
12890
12891 _class.prototype._setPrjCoordinates = function _setPrjCoordinates(pcenter) {
12892 this._pcenter = pcenter;
12893 this.onPositionChanged();
12894 };
12895
12896 _class.prototype._updateCache = function _updateCache() {
12897 this._clearCache();
12898 var projection = this._getProjection();
12899 if (this._pcenter && projection) {
12900 this._coordinates = projection.unproject(this._pcenter);
12901 }
12902 };
12903
12904 _class.prototype._clearProjection = function _clearProjection() {
12905 this._pcenter = null;
12906 _Base.prototype._clearProjection.call(this);
12907 };
12908
12909 _class.prototype._computeCenter = function _computeCenter() {
12910 return this._coordinates ? this._coordinates.copy() : null;
12911 };
12912
12913 return _class;
12914 }(Base);
12915};
12916
12917var options$7 = {
12918 'symbol': {
12919 'markerType': 'path',
12920 'markerPath': [{
12921 'path': 'M8 23l0 0 0 0 0 0 0 0 0 0c-4,-5 -8,-10 -8,-14 0,-5 4,-9 8,-9l0 0 0 0c4,0 8,4 8,9 0,4 -4,9 -8,14z M3,9 a5,5 0,1,0,0,-0.9Z',
12922 'fill': '#DE3333'
12923 }],
12924 'markerPathWidth': 16,
12925 'markerPathHeight': 23,
12926 'markerWidth': 24,
12927 'markerHeight': 34
12928 },
12929 'hitTestForEvent': false
12930};
12931
12932var Marker = function (_CenterMixin) {
12933 inherits(Marker, _CenterMixin);
12934
12935 function Marker(coordinates, opts) {
12936 classCallCheck(this, Marker);
12937
12938 var _this = possibleConstructorReturn(this, _CenterMixin.call(this, opts));
12939
12940 _this.type = 'Point';
12941 if (coordinates) {
12942 _this.setCoordinates(coordinates);
12943 }
12944 return _this;
12945 }
12946
12947 Marker.prototype.getOutline = function getOutline() {
12948 var painter = this._getPainter();
12949 if (!painter) {
12950 return null;
12951 }
12952 var coord = this.getCoordinates();
12953 var extent = painter.getContainerExtent();
12954 var anchor = this.getMap().coordToContainerPoint(coord);
12955 return new Marker(coord, {
12956 'symbol': {
12957 'markerType': 'square',
12958 'markerWidth': extent.getWidth(),
12959 'markerHeight': extent.getHeight(),
12960 'markerLineWidth': 1,
12961 'markerLineColor': '6b707b',
12962 'markerFill': 'rgba(0, 0, 0, 0)',
12963 'markerDx': extent.xmin - (anchor.x - extent.getWidth() / 2),
12964 'markerDy': extent.ymin - (anchor.y - extent.getHeight() / 2)
12965 }
12966 });
12967 };
12968
12969 Marker.prototype._isVectorMarker = function _isVectorMarker() {
12970 var symbol = this._getInternalSymbol();
12971 if (Array.isArray(symbol)) {
12972 return false;
12973 }
12974 return VectorMarkerSymbolizer.test(symbol);
12975 };
12976
12977 Marker.prototype._canEdit = function _canEdit() {
12978 var symbol = this._getInternalSymbol();
12979 if (Array.isArray(symbol)) {
12980 return false;
12981 }
12982 return VectorMarkerSymbolizer.test(symbol) || VectorPathMarkerSymbolizer.test(symbol) || ImageMarkerSymbolizer.test(symbol);
12983 };
12984
12985 Marker.prototype._containsPoint = function _containsPoint(point, t) {
12986 var extent = this.getContainerExtent();
12987 if (t) {
12988 extent = extent.expand(t);
12989 }
12990 if (extent.contains(point)) {
12991 if (this.options['hitTestForEvent']) {
12992 return _CenterMixin.prototype._containsPoint.call(this, point, t);
12993 } else {
12994 return true;
12995 }
12996 } else {
12997 return false;
12998 }
12999 };
13000
13001 Marker.prototype._computeExtent = function _computeExtent() {
13002 return computeExtent.call(this, 'getCenter');
13003 };
13004
13005 Marker.prototype._computePrjExtent = function _computePrjExtent() {
13006 return computeExtent.call(this, '_getPrjCoordinates');
13007 };
13008
13009 Marker.prototype._computeGeodesicLength = function _computeGeodesicLength() {
13010 return 0;
13011 };
13012
13013 Marker.prototype._computeGeodesicArea = function _computeGeodesicArea() {
13014 return 0;
13015 };
13016
13017 Marker.prototype._getSprite = function _getSprite(resources, canvasClass) {
13018 if (this._getPainter()) {
13019 return this._getPainter().getSprite(resources, canvasClass);
13020 }
13021 return new Painter(this).getSprite(resources, canvasClass);
13022 };
13023
13024 return Marker;
13025}(CenterMixin(Geometry));
13026
13027Marker.mergeOptions(options$7);
13028
13029Marker.registerJSONType('Marker');
13030
13031function computeExtent(fn) {
13032 var coordinates = this[fn]();
13033 if (!coordinates) {
13034 return null;
13035 }
13036 return new Extent(coordinates, coordinates, this._getProjection());
13037}
13038
13039var options$8 = {
13040 'arrowStyle': null,
13041 'arrowPlacement': 'vertex-last' };
13042
13043var LineString = function (_Path) {
13044 inherits(LineString, _Path);
13045
13046 function LineString(coordinates, options) {
13047 classCallCheck(this, LineString);
13048
13049 var _this = possibleConstructorReturn(this, _Path.call(this, options));
13050
13051 _this.type = 'LineString';
13052 if (coordinates) {
13053 _this.setCoordinates(coordinates);
13054 }
13055 return _this;
13056 }
13057
13058 LineString.prototype.setCoordinates = function setCoordinates(coordinates) {
13059 if (!coordinates) {
13060 this._coordinates = null;
13061 this._setPrjCoordinates(null);
13062 return this;
13063 }
13064 this._coordinates = Coordinate.toCoordinates(coordinates);
13065 if (this.getMap()) {
13066 this._setPrjCoordinates(this._projectCoords(this._coordinates));
13067 } else {
13068 this.onShapeChanged();
13069 }
13070 return this;
13071 };
13072
13073 LineString.prototype.getCoordinates = function getCoordinates() {
13074 return this._coordinates || [];
13075 };
13076
13077 LineString.prototype.getCenterInExtent = function getCenterInExtent(extent) {
13078 return this._getCenterInExtent(extent, this.getCoordinates(), clipLine);
13079 };
13080
13081 LineString.prototype._computeGeodesicLength = function _computeGeodesicLength(measurer) {
13082 return measurer.measureLength(this.getCoordinates());
13083 };
13084
13085 LineString.prototype._computeGeodesicArea = function _computeGeodesicArea() {
13086 return 0;
13087 };
13088
13089 return LineString;
13090}(Path);
13091
13092LineString.mergeOptions(options$8);
13093
13094LineString.registerJSONType('LineString');
13095
13096var GeometryCollection = function (_Geometry) {
13097 inherits(GeometryCollection, _Geometry);
13098
13099 function GeometryCollection(geometries, opts) {
13100 classCallCheck(this, GeometryCollection);
13101
13102 var _this = possibleConstructorReturn(this, _Geometry.call(this, opts));
13103
13104 _this.type = 'GeometryCollection';
13105 _this.setGeometries(geometries);
13106 return _this;
13107 }
13108
13109 GeometryCollection.prototype.setGeometries = function setGeometries(_geometries) {
13110 var geometries = this._checkGeometries(_geometries || []);
13111 var symbol = this._getSymbol();
13112 var options = this.config();
13113
13114 for (var i = geometries.length - 1; i >= 0; i--) {
13115 geometries[i]._initOptions(options);
13116 geometries[i]._setParent(this);
13117 geometries[i]._setEventParent(this);
13118 if (symbol) {
13119 geometries[i].setSymbol(symbol);
13120 }
13121 }
13122 this._geometries = geometries;
13123 if (this.getLayer()) {
13124 this._bindGeometriesToLayer();
13125 this.onShapeChanged();
13126 }
13127 return this;
13128 };
13129
13130 GeometryCollection.prototype.getGeometries = function getGeometries() {
13131 return this._geometries || [];
13132 };
13133
13134 GeometryCollection.prototype.forEach = function forEach(fn, context) {
13135 var geometries = this.getGeometries();
13136 for (var i = 0, l = geometries.length; i < l; i++) {
13137 if (!geometries[i]) {
13138 continue;
13139 }
13140 if (!context) {
13141 fn(geometries[i], i);
13142 } else {
13143 fn.call(context, geometries[i], i);
13144 }
13145 }
13146 return this;
13147 };
13148
13149 GeometryCollection.prototype.filter = function filter(fn, context) {
13150 if (!fn) {
13151 return new GeometryCollection();
13152 }
13153 var selected = [];
13154 var isFn = isFunction(fn);
13155 var filter = isFn ? fn : createFilter(fn);
13156
13157 this.forEach(function (geometry) {
13158 var g = isFn ? geometry : getFilterFeature(geometry);
13159 if (context ? filter.call(context, g) : filter(g)) {
13160 selected.push(geometry);
13161 }
13162 }, this);
13163
13164 return new GeometryCollection(selected);
13165 };
13166
13167 GeometryCollection.prototype.translate = function translate(offset) {
13168 if (!offset) {
13169 return this;
13170 }
13171 if (this.isEmpty()) {
13172 return this;
13173 }
13174 var args = arguments;
13175 this.forEach(function (geometry) {
13176 if (geometry && geometry.translate) {
13177 geometry.translate.apply(geometry, args);
13178 }
13179 });
13180 return this;
13181 };
13182
13183 GeometryCollection.prototype.isEmpty = function isEmpty() {
13184 return !isArrayHasData(this.getGeometries());
13185 };
13186
13187 GeometryCollection.prototype.remove = function remove() {
13188 this.forEach(function (geometry) {
13189 geometry._unbind();
13190 });
13191 return Geometry.prototype.remove.apply(this, arguments);
13192 };
13193
13194 GeometryCollection.prototype.show = function show() {
13195 this.options['visible'] = true;
13196 this.forEach(function (geometry) {
13197 geometry.show();
13198 });
13199 return this;
13200 };
13201
13202 GeometryCollection.prototype.hide = function hide() {
13203 this.options['visible'] = false;
13204 this.forEach(function (geometry) {
13205 geometry.hide();
13206 });
13207 return this;
13208 };
13209
13210 GeometryCollection.prototype.onConfig = function onConfig(config) {
13211 this.forEach(function (geometry) {
13212 geometry.config(config);
13213 });
13214 };
13215
13216 GeometryCollection.prototype.getSymbol = function getSymbol() {
13217 var s = _Geometry.prototype.getSymbol.call(this);
13218 if (!s) {
13219 var symbols = [];
13220 var is = false;
13221 this.forEach(function (g) {
13222 var symbol = g.getSymbol();
13223 if (symbol && !is) {
13224 is = true;
13225 }
13226 symbols.push(g.getSymbol());
13227 });
13228 if (is) {
13229 s = {
13230 'children': symbols
13231 };
13232 }
13233 }
13234 return s;
13235 };
13236
13237 GeometryCollection.prototype.setSymbol = function setSymbol(s) {
13238 if (s && s['children']) {
13239 this._symbol = null;
13240 this.forEach(function (g, i) {
13241 g.setSymbol(s['children'][i]);
13242 });
13243 } else {
13244 var symbol = this._prepareSymbol(s);
13245 this._symbol = symbol;
13246 this.forEach(function (g) {
13247 g.setSymbol(symbol);
13248 });
13249 }
13250 this.onSymbolChanged();
13251 return this;
13252 };
13253
13254 GeometryCollection.prototype._setExternSymbol = function _setExternSymbol(symbol) {
13255 symbol = this._prepareSymbol(symbol);
13256 this._externSymbol = symbol;
13257 this.forEach(function (geometry) {
13258 geometry._setExternSymbol(symbol);
13259 });
13260 this.onSymbolChanged();
13261 return this;
13262 };
13263
13264 GeometryCollection.prototype._bindLayer = function _bindLayer() {
13265 _Geometry.prototype._bindLayer.apply(this, arguments);
13266 this._bindGeometriesToLayer();
13267 };
13268
13269 GeometryCollection.prototype._bindGeometriesToLayer = function _bindGeometriesToLayer() {
13270 var layer = this.getLayer();
13271 this.forEach(function (geometry) {
13272 geometry._bindLayer(layer);
13273 });
13274 };
13275
13276 GeometryCollection.prototype._checkGeometries = function _checkGeometries(geometries) {
13277 var invalidGeoError = 'The geometry added to collection is invalid.';
13278 if (geometries && !Array.isArray(geometries)) {
13279 if (geometries instanceof Geometry) {
13280 return [geometries];
13281 } else {
13282 throw new Error(invalidGeoError);
13283 }
13284 } else {
13285 for (var i = 0, l = geometries.length; i < l; i++) {
13286 if (!this._checkGeo(geometries[i])) {
13287 throw new Error(invalidGeoError + ' Index: ' + i);
13288 }
13289 }
13290 return geometries;
13291 }
13292 };
13293
13294 GeometryCollection.prototype._checkGeo = function _checkGeo(geo) {
13295 return geo instanceof Geometry;
13296 };
13297
13298 GeometryCollection.prototype._updateCache = function _updateCache() {
13299 this._clearCache();
13300 if (this.isEmpty()) {
13301 return;
13302 }
13303 this.forEach(function (geometry) {
13304 if (geometry && geometry._updateCache) {
13305 geometry._updateCache();
13306 }
13307 });
13308 };
13309
13310 GeometryCollection.prototype._removePainter = function _removePainter() {
13311 if (this._painter) {
13312 this._painter.remove();
13313 }
13314 delete this._painter;
13315 this.forEach(function (geometry) {
13316 geometry._removePainter();
13317 });
13318 };
13319
13320 GeometryCollection.prototype._computeCenter = function _computeCenter(projection) {
13321 if (!projection || this.isEmpty()) {
13322 return null;
13323 }
13324 var sumX = 0,
13325 sumY = 0,
13326 counter = 0;
13327 var geometries = this.getGeometries();
13328 for (var i = 0, l = geometries.length; i < l; i++) {
13329 if (!geometries[i]) {
13330 continue;
13331 }
13332 var center = geometries[i]._computeCenter(projection);
13333 if (center) {
13334 sumX += center.x;
13335 sumY += center.y;
13336 counter++;
13337 }
13338 }
13339 if (counter === 0) {
13340 return null;
13341 }
13342 return new Coordinate(sumX / counter, sumY / counter);
13343 };
13344
13345 GeometryCollection.prototype._containsPoint = function _containsPoint(point, t) {
13346 if (this.isEmpty()) {
13347 return false;
13348 }
13349 var geometries = this.getGeometries();
13350 for (var i = 0, l = geometries.length; i < l; i++) {
13351 if (geometries[i]._containsPoint(point, t)) {
13352 return true;
13353 }
13354 }
13355 return false;
13356 };
13357
13358 GeometryCollection.prototype._computeExtent = function _computeExtent(projection) {
13359 return computeExtent$1.call(this, projection, '_computeExtent');
13360 };
13361
13362 GeometryCollection.prototype._computePrjExtent = function _computePrjExtent(projection) {
13363 return computeExtent$1.call(this, projection, '_computePrjExtent');
13364 };
13365
13366 GeometryCollection.prototype._computeGeodesicLength = function _computeGeodesicLength(projection) {
13367 if (!projection || this.isEmpty()) {
13368 return 0;
13369 }
13370 var geometries = this.getGeometries();
13371 var result = 0;
13372 for (var i = 0, l = geometries.length; i < l; i++) {
13373 if (!geometries[i]) {
13374 continue;
13375 }
13376 result += geometries[i]._computeGeodesicLength(projection);
13377 }
13378 return result;
13379 };
13380
13381 GeometryCollection.prototype._computeGeodesicArea = function _computeGeodesicArea(projection) {
13382 if (!projection || this.isEmpty()) {
13383 return 0;
13384 }
13385 var geometries = this.getGeometries();
13386 var result = 0;
13387 for (var i = 0, l = geometries.length; i < l; i++) {
13388 if (!geometries[i]) {
13389 continue;
13390 }
13391 result += geometries[i]._computeGeodesicArea(projection);
13392 }
13393 return result;
13394 };
13395
13396 GeometryCollection.prototype._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
13397 var children = [];
13398 if (!this.isEmpty()) {
13399 var geometries = this.getGeometries();
13400 for (var i = 0, l = geometries.length; i < l; i++) {
13401 if (!geometries[i]) {
13402 continue;
13403 }
13404 children.push(geometries[i]._exportGeoJSONGeometry());
13405 }
13406 }
13407 return {
13408 'type': 'GeometryCollection',
13409 'geometries': children
13410 };
13411 };
13412
13413 GeometryCollection.prototype._clearProjection = function _clearProjection() {
13414 if (this.isEmpty()) {
13415 return;
13416 }
13417 var geometries = this.getGeometries();
13418 for (var i = 0, l = geometries.length; i < l; i++) {
13419 if (!geometries[i]) {
13420 continue;
13421 }
13422 geometries[i]._clearProjection();
13423 }
13424 };
13425
13426 GeometryCollection.prototype._getConnectPoints = function _getConnectPoints() {
13427 var extent = this.getExtent();
13428 var anchors = [new Coordinate(extent.xmin, extent.ymax), new Coordinate(extent.xmax, extent.ymin), new Coordinate(extent.xmin, extent.ymin), new Coordinate(extent.xmax, extent.ymax)];
13429 return anchors;
13430 };
13431
13432 GeometryCollection.prototype._getExternalResources = function _getExternalResources() {
13433 if (this.isEmpty()) {
13434 return [];
13435 }
13436 var geometries = this.getGeometries(),
13437 resources = [];
13438 var cache = {};
13439 var symbol = void 0,
13440 res = void 0,
13441 key = void 0;
13442 for (var i = 0, l = geometries.length; i < l; i++) {
13443 if (!geometries[i]) {
13444 continue;
13445 }
13446 symbol = geometries[i]._getInternalSymbol();
13447 res = getExternalResources(symbol);
13448 for (var ii = 0, ll = res.length; ii < ll; ii++) {
13449 key = res[ii].join();
13450 if (!cache[key]) {
13451 resources.push(res[ii]);
13452 cache[key] = 1;
13453 }
13454 }
13455 }
13456 return resources;
13457 };
13458
13459 GeometryCollection.prototype.startEdit = function startEdit(opts) {
13460 var _this2 = this;
13461
13462 if (this.isEmpty()) {
13463 return this;
13464 }
13465 if (!opts) {
13466 opts = {};
13467 }
13468 if (opts['symbol']) {
13469 this._originalSymbol = this.getSymbol();
13470 this.setSymbol(opts['symbol']);
13471 }
13472 this._draggbleBeforeEdit = this.options['draggable'];
13473 this.config('draggable', false);
13474 var geometries = this.getGeometries();
13475 for (var i = 0, l = geometries.length; i < l; i++) {
13476 geometries[i].startEdit(opts);
13477 }
13478 this._editing = true;
13479 this.hide();
13480 setTimeout(function () {
13481 _this2.fire('editstart');
13482 }, 1);
13483 return this;
13484 };
13485
13486 GeometryCollection.prototype.endEdit = function endEdit() {
13487 if (this.isEmpty()) {
13488 return this;
13489 }
13490 var geometries = this.getGeometries();
13491 for (var i = 0, l = geometries.length; i < l; i++) {
13492 geometries[i].endEdit();
13493 }
13494 if (this._originalSymbol) {
13495 this.setSymbol(this._originalSymbol);
13496 delete this._originalSymbol;
13497 }
13498 this._editing = false;
13499 this.show();
13500 this.config('draggable', this._draggbleBeforeEdit);
13501 this.fire('editend');
13502 return this;
13503 };
13504
13505 GeometryCollection.prototype.isEditing = function isEditing() {
13506 if (!this._editing) {
13507 return false;
13508 }
13509 return true;
13510 };
13511
13512 return GeometryCollection;
13513}(Geometry);
13514
13515GeometryCollection.registerJSONType('GeometryCollection');
13516
13517function computeExtent$1(projection, fn) {
13518 if (this.isEmpty()) {
13519 return null;
13520 }
13521 var geometries = this.getGeometries();
13522 var result = null;
13523 for (var i = 0, l = geometries.length; i < l; i++) {
13524 var geo = geometries[i];
13525 if (!geo) {
13526 continue;
13527 }
13528 var geoExtent = geo[fn](projection);
13529 if (geoExtent) {
13530 result = geoExtent.combine(result);
13531 }
13532 }
13533 return result;
13534}
13535
13536var MultiGeometry = function (_GeometryCollection) {
13537 inherits(MultiGeometry, _GeometryCollection);
13538
13539 function MultiGeometry(geoType, type, data, options) {
13540 classCallCheck(this, MultiGeometry);
13541
13542 var _this = possibleConstructorReturn(this, _GeometryCollection.call(this, null, options));
13543
13544 _this.GeometryType = geoType;
13545 _this.type = type;
13546 _this._initData(data);
13547 return _this;
13548 }
13549
13550 MultiGeometry.prototype.getCoordinates = function getCoordinates() {
13551 var coordinates = [];
13552 var geometries = this.getGeometries();
13553 for (var i = 0, l = geometries.length; i < l; i++) {
13554 coordinates.push(geometries[i].getCoordinates());
13555 }
13556 return coordinates;
13557 };
13558
13559 MultiGeometry.prototype.setCoordinates = function setCoordinates(coordinates) {
13560 coordinates = coordinates || [];
13561 var geometries = [];
13562 for (var i = 0, l = coordinates.length; i < l; i++) {
13563 var g = new this.GeometryType(coordinates[i], this.config());
13564 geometries.push(g);
13565 }
13566 this.setGeometries(geometries);
13567 return this;
13568 };
13569
13570 MultiGeometry.prototype._initData = function _initData(data) {
13571 data = data || [];
13572 if (data.length) {
13573 if (data[0] instanceof this.GeometryType) {
13574 this.setGeometries(data);
13575 } else {
13576 this.setCoordinates(data);
13577 }
13578 }
13579 };
13580
13581 MultiGeometry.prototype._checkGeo = function _checkGeo(geo) {
13582 return geo instanceof this.GeometryType;
13583 };
13584
13585 MultiGeometry.prototype._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
13586 var points = this.getCoordinates();
13587 var coordinates = Coordinate.toNumberArrays(points);
13588 return {
13589 'type': this.getType(),
13590 'coordinates': coordinates
13591 };
13592 };
13593
13594 return MultiGeometry;
13595}(GeometryCollection);
13596
13597var MultiPoint = function (_MultiGeometry) {
13598 inherits(MultiPoint, _MultiGeometry);
13599
13600 function MultiPoint(data, opts) {
13601 classCallCheck(this, MultiPoint);
13602 return possibleConstructorReturn(this, _MultiGeometry.call(this, Marker, 'MultiPoint', data, opts));
13603 }
13604
13605 return MultiPoint;
13606}(MultiGeometry);
13607
13608MultiPoint.registerJSONType('MultiPoint');
13609
13610var MultiPath = function (_MultiGeometry) {
13611 inherits(MultiPath, _MultiGeometry);
13612
13613 function MultiPath() {
13614 classCallCheck(this, MultiPath);
13615 return possibleConstructorReturn(this, _MultiGeometry.apply(this, arguments));
13616 }
13617
13618 MultiPath.prototype.getCenterInExtent = function getCenterInExtent(extent) {
13619 var children = this.getGeometries();
13620 var sumx = 0,
13621 sumy = 0,
13622 counter = 0;
13623
13624 children.forEach(function (l) {
13625 var c = l.getCenterInExtent(extent);
13626 if (c) {
13627 sumx += c.x * c.count;
13628 sumy += c.y * c.count;
13629 counter += c.count;
13630 }
13631 });
13632 if (counter === 0) {
13633 return null;
13634 }
13635 return new Coordinate(sumx, sumy)._multi(1 / counter);
13636 };
13637
13638 return MultiPath;
13639}(MultiGeometry);
13640
13641var MultiLineString = function (_MultiPath) {
13642 inherits(MultiLineString, _MultiPath);
13643
13644 function MultiLineString(data, options) {
13645 classCallCheck(this, MultiLineString);
13646 return possibleConstructorReturn(this, _MultiPath.call(this, LineString, 'MultiLineString', data, options));
13647 }
13648
13649 return MultiLineString;
13650}(MultiPath);
13651
13652MultiLineString.registerJSONType('MultiLineString');
13653
13654var MultiPolygon = function (_MultiPath) {
13655 inherits(MultiPolygon, _MultiPath);
13656
13657 function MultiPolygon(data, opts) {
13658 classCallCheck(this, MultiPolygon);
13659 return possibleConstructorReturn(this, _MultiPath.call(this, Polygon, 'MultiPolygon', data, opts));
13660 }
13661
13662 return MultiPolygon;
13663}(MultiPath);
13664
13665MultiPolygon.registerJSONType('MultiPolygon');
13666
13667var types$1 = {
13668 'Marker': Marker,
13669 'LineString': LineString,
13670 'Polygon': Polygon,
13671 'MultiPoint': MultiPoint,
13672 'MultiLineString': MultiLineString,
13673 'MultiPolygon': MultiPolygon
13674};
13675
13676var GeoJSON = {
13677 toGeometry: function toGeometry(geoJSON) {
13678 if (isString(geoJSON)) {
13679 geoJSON = parseJSON(geoJSON);
13680 }
13681 if (Array.isArray(geoJSON)) {
13682 var resultGeos = [];
13683 for (var i = 0, len = geoJSON.length; i < len; i++) {
13684 var geo = GeoJSON._convert(geoJSON[i]);
13685 if (Array.isArray(geo)) {
13686 pushIn(resultGeos, geo);
13687 } else {
13688 resultGeos.push(geo);
13689 }
13690 }
13691 return resultGeos;
13692 } else {
13693 var resultGeo = GeoJSON._convert(geoJSON);
13694 return resultGeo;
13695 }
13696 },
13697
13698 _convert: function _convert(json) {
13699 if (!json || isNil(json['type'])) {
13700 return null;
13701 }
13702
13703 var type = json['type'];
13704 if (type === 'Feature') {
13705 var g = json['geometry'];
13706 var geometry = GeoJSON._convert(g);
13707 if (!geometry) {
13708 return null;
13709 }
13710 geometry.setId(json['id']);
13711 geometry.setProperties(json['properties']);
13712 return geometry;
13713 } else if (type === 'FeatureCollection') {
13714 var features = json['features'];
13715 if (!features) {
13716 return null;
13717 }
13718 var result = GeoJSON.toGeometry(features);
13719 return result;
13720 } else if (['Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon'].indexOf(type) >= 0) {
13721 var clazz = type === 'Point' ? 'Marker' : type;
13722 return new types$1[clazz](json['coordinates']);
13723 } else if (type === 'GeometryCollection') {
13724 var geometries = json['geometries'];
13725 if (!isArrayHasData(geometries)) {
13726 return new GeometryCollection();
13727 }
13728 var mGeos = [];
13729 var size = geometries.length;
13730 for (var i = 0; i < size; i++) {
13731 mGeos.push(GeoJSON._convert(geometries[i]));
13732 }
13733 return new GeometryCollection(mGeos);
13734 }
13735 return null;
13736 }
13737};
13738
13739var options$9 = {
13740 'numberOfShellPoints': 60
13741};
13742
13743var Circle = function (_CenterMixin) {
13744 inherits(Circle, _CenterMixin);
13745
13746 Circle.fromJSON = function fromJSON(json) {
13747 var feature = json['feature'];
13748 var circle = new Circle(json['coordinates'], json['radius'], json['options']);
13749 circle.setProperties(feature['properties']);
13750 return circle;
13751 };
13752
13753 function Circle(coordinates, radius, opts) {
13754 classCallCheck(this, Circle);
13755
13756 var _this = possibleConstructorReturn(this, _CenterMixin.call(this, null, opts));
13757
13758 if (coordinates) {
13759 _this.setCoordinates(coordinates);
13760 }
13761 _this._radius = radius;
13762 return _this;
13763 }
13764
13765 Circle.prototype.getRadius = function getRadius() {
13766 return this._radius;
13767 };
13768
13769 Circle.prototype.setRadius = function setRadius(radius) {
13770 this._radius = radius;
13771 this.onShapeChanged();
13772 return this;
13773 };
13774
13775 Circle.prototype.getShell = function getShell() {
13776 var measurer = this._getMeasurer(),
13777 center = this.getCoordinates(),
13778 numberOfPoints = this.options['numberOfShellPoints'],
13779 radius = this.getRadius();
13780 var shell = [];
13781 var rad = void 0,
13782 dx = void 0,
13783 dy = void 0;
13784 for (var i = 0, len = numberOfPoints - 1; i < len; i++) {
13785 rad = 360 * i / len * Math.PI / 180;
13786 dx = radius * Math.cos(rad);
13787 dy = radius * Math.sin(rad);
13788 var vertex = measurer.locate(center, dx, dy);
13789 shell.push(vertex);
13790 }
13791 shell.push(shell[0]);
13792 return shell;
13793 };
13794
13795 Circle.prototype.getHoles = function getHoles() {
13796 return [];
13797 };
13798
13799 Circle.prototype.animateShow = function animateShow() {
13800 return this.show();
13801 };
13802
13803 Circle.prototype._containsPoint = function _containsPoint(point, tolerance) {
13804 var map = this.getMap();
13805 if (map.getPitch()) {
13806 return _CenterMixin.prototype._containsPoint.call(this, point, tolerance);
13807 }
13808 var center = map._pointToContainerPoint(this._getCenter2DPoint()),
13809 size = this.getSize(),
13810 t = isNil(tolerance) ? this._hitTestTolerance() : tolerance,
13811 se = center.add(size.width / 2, size.height / 2);
13812 return withInEllipse(point, center, se, t);
13813 };
13814
13815 Circle.prototype._computePrjExtent = function _computePrjExtent(projection) {
13816 var minmax = this._getMinMax(projection);
13817 if (!minmax) {
13818 return null;
13819 }
13820 var pcenter = this._getPrjCoordinates();
13821 var pminmax = minmax.map(function (c) {
13822 return projection.project(c);
13823 });
13824 var dx = Math.min(Math.abs(pminmax[0].x - pcenter.x), Math.abs(pminmax[1].x - pcenter.x)),
13825 dy = Math.min(Math.abs(pminmax[2].y - pcenter.y), Math.abs(pminmax[3].y - pcenter.y));
13826 return new Extent(pcenter.sub(dx, dy), pcenter.add(dx, dy));
13827 };
13828
13829 Circle.prototype._computeExtent = function _computeExtent(measurer) {
13830 var minmax = this._getMinMax(measurer);
13831 if (!minmax) {
13832 return null;
13833 }
13834 return new Extent(minmax[0].x, minmax[2].y, minmax[1].x, minmax[3].y, this._getProjection());
13835 };
13836
13837 Circle.prototype._getMinMax = function _getMinMax(measurer) {
13838 if (!measurer || !this._coordinates || isNil(this._radius)) {
13839 return null;
13840 }
13841 var radius = this._radius;
13842 var p1 = measurer.locate(this._coordinates, -radius, 0),
13843 p2 = measurer.locate(this._coordinates, radius, 0),
13844 p3 = measurer.locate(this._coordinates, 0, radius),
13845 p4 = measurer.locate(this._coordinates, 0, -radius);
13846 return [p1, p2, p3, p4];
13847 };
13848
13849 Circle.prototype._computeGeodesicLength = function _computeGeodesicLength() {
13850 if (isNil(this._radius)) {
13851 return 0;
13852 }
13853 return Math.PI * 2 * this._radius;
13854 };
13855
13856 Circle.prototype._computeGeodesicArea = function _computeGeodesicArea() {
13857 if (isNil(this._radius)) {
13858 return 0;
13859 }
13860 return Math.PI * Math.pow(this._radius, 2);
13861 };
13862
13863 Circle.prototype._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
13864 var coordinates = Coordinate.toNumberArrays([this.getShell()]);
13865 return {
13866 'type': 'Polygon',
13867 'coordinates': coordinates
13868 };
13869 };
13870
13871 Circle.prototype._toJSON = function _toJSON(options) {
13872 var center = this.getCenter();
13873 var opts = extend({}, options);
13874 opts.geometry = false;
13875 var feature = this.toGeoJSON(opts);
13876 feature['geometry'] = {
13877 'type': 'Polygon'
13878 };
13879 return {
13880 'feature': feature,
13881 'subType': 'Circle',
13882 'coordinates': [center.x, center.y],
13883 'radius': this.getRadius()
13884 };
13885 };
13886
13887 return Circle;
13888}(CenterMixin(Polygon));
13889
13890Circle.mergeOptions(options$9);
13891
13892Circle.registerJSONType('Circle');
13893
13894var options$10 = {
13895 'numberOfShellPoints': 80
13896};
13897
13898var Ellipse = function (_CenterMixin) {
13899 inherits(Ellipse, _CenterMixin);
13900
13901 Ellipse.fromJSON = function fromJSON(json) {
13902 var feature = json['feature'];
13903 var ellipse = new Ellipse(json['coordinates'], json['width'], json['height'], json['options']);
13904 ellipse.setProperties(feature['properties']);
13905 return ellipse;
13906 };
13907
13908 function Ellipse(coordinates, width, height, opts) {
13909 classCallCheck(this, Ellipse);
13910
13911 var _this = possibleConstructorReturn(this, _CenterMixin.call(this, null, opts));
13912
13913 if (coordinates) {
13914 _this.setCoordinates(coordinates);
13915 }
13916 _this.width = width;
13917 _this.height = height;
13918 return _this;
13919 }
13920
13921 Ellipse.prototype.getWidth = function getWidth() {
13922 return this.width;
13923 };
13924
13925 Ellipse.prototype.setWidth = function setWidth(width) {
13926 this.width = width;
13927 this.onShapeChanged();
13928 return this;
13929 };
13930
13931 Ellipse.prototype.getHeight = function getHeight() {
13932 return this.height;
13933 };
13934
13935 Ellipse.prototype.setHeight = function setHeight(height) {
13936 this.height = height;
13937 this.onShapeChanged();
13938 return this;
13939 };
13940
13941 Ellipse.prototype.getShell = function getShell() {
13942 var measurer = this._getMeasurer(),
13943 center = this.getCoordinates(),
13944 numberOfPoints = this.options['numberOfShellPoints'],
13945 width = this.getWidth(),
13946 height = this.getHeight();
13947 var shell = [];
13948 var s = Math.pow(width / 2, 2) * Math.pow(height / 2, 2),
13949 sx = Math.pow(width / 2, 2),
13950 sy = Math.pow(height / 2, 2);
13951 var deg = void 0,
13952 rad = void 0,
13953 dx = void 0,
13954 dy = void 0;
13955 for (var i = 0; i < numberOfPoints; i++) {
13956 deg = 360 * i / numberOfPoints;
13957 rad = deg * Math.PI / 180;
13958 dx = Math.sqrt(s / (sx * Math.pow(Math.tan(rad), 2) + sy));
13959 dy = Math.sqrt(s / (sy * Math.pow(1 / Math.tan(rad), 2) + sx));
13960 if (deg > 90 && deg < 270) {
13961 dx *= -1;
13962 }
13963 if (deg > 180 && deg < 360) {
13964 dy *= -1;
13965 }
13966 var vertex = measurer.locate(center, dx, dy);
13967 shell.push(vertex);
13968 }
13969 return shell;
13970 };
13971
13972 Ellipse.prototype.getHoles = function getHoles() {
13973 return [];
13974 };
13975
13976 Ellipse.prototype.animateShow = function animateShow() {
13977 return this.show();
13978 };
13979
13980 Ellipse.prototype._containsPoint = function _containsPoint(point, tolerance) {
13981 var map = this.getMap();
13982 if (map.isTransforming()) {
13983 return _CenterMixin.prototype._containsPoint.call(this, point, tolerance);
13984 }
13985 var projection = map.getProjection();
13986 var t = isNil(tolerance) ? this._hitTestTolerance() : tolerance,
13987 pps = projection.projectCoords([this._coordinates, map.locate(this._coordinates, this.getWidth() / 2, this.getHeight() / 2)]),
13988 p0 = map._prjToContainerPoint(pps[0]),
13989 p1 = map._prjToContainerPoint(pps[1]);
13990 return withInEllipse(point, p0, p1, t);
13991 };
13992
13993 Ellipse.prototype._computePrjExtent = function _computePrjExtent() {
13994 return Circle.prototype._computePrjExtent.apply(this, arguments);
13995 };
13996
13997 Ellipse.prototype._computeExtent = function _computeExtent() {
13998 return Circle.prototype._computeExtent.apply(this, arguments);
13999 };
14000
14001 Ellipse.prototype._getMinMax = function _getMinMax(measurer) {
14002 if (!measurer || !this._coordinates || isNil(this.width) || isNil(this.height)) {
14003 return null;
14004 }
14005 var width = this.getWidth(),
14006 height = this.getHeight();
14007 var p1 = measurer.locate(this._coordinates, -width / 2, 0),
14008 p2 = measurer.locate(this._coordinates, width / 2, 0),
14009 p3 = measurer.locate(this._coordinates, 0, -height / 2),
14010 p4 = measurer.locate(this._coordinates, 0, height / 2);
14011 return [p1, p2, p3, p4];
14012 };
14013
14014 Ellipse.prototype._computeGeodesicLength = function _computeGeodesicLength() {
14015 if (isNil(this.width) || isNil(this.height)) {
14016 return 0;
14017 }
14018
14019 var longer = this.width > this.height ? this.width : this.height;
14020 return 2 * Math.PI * longer / 2 - 4 * Math.abs(this.width - this.height);
14021 };
14022
14023 Ellipse.prototype._computeGeodesicArea = function _computeGeodesicArea() {
14024 if (isNil(this.width) || isNil(this.height)) {
14025 return 0;
14026 }
14027 return Math.PI * this.width * this.height / 4;
14028 };
14029
14030 Ellipse.prototype._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
14031 var coordinates = Coordinate.toNumberArrays([this.getShell()]);
14032 return {
14033 'type': 'Polygon',
14034 'coordinates': coordinates
14035 };
14036 };
14037
14038 Ellipse.prototype._toJSON = function _toJSON(options) {
14039 var opts = extend({}, options);
14040 var center = this.getCenter();
14041 opts.geometry = false;
14042 var feature = this.toGeoJSON(opts);
14043 feature['geometry'] = {
14044 'type': 'Polygon'
14045 };
14046 return {
14047 'feature': feature,
14048 'subType': 'Ellipse',
14049 'coordinates': [center.x, center.y],
14050 'width': this.getWidth(),
14051 'height': this.getHeight()
14052 };
14053 };
14054
14055 return Ellipse;
14056}(CenterMixin(Polygon));
14057
14058Ellipse.mergeOptions(options$10);
14059
14060Ellipse.registerJSONType('Ellipse');
14061
14062var Rectangle = function (_Polygon) {
14063 inherits(Rectangle, _Polygon);
14064
14065 Rectangle.fromJSON = function fromJSON(json) {
14066 var feature = json['feature'];
14067 var rect = new Rectangle(json['coordinates'], json['width'], json['height'], json['options']);
14068 rect.setProperties(feature['properties']);
14069 return rect;
14070 };
14071
14072 function Rectangle(coordinates, width, height, opts) {
14073 classCallCheck(this, Rectangle);
14074
14075 var _this = possibleConstructorReturn(this, _Polygon.call(this, null, opts));
14076
14077 if (coordinates) {
14078 _this.setCoordinates(coordinates);
14079 }
14080 _this._width = width;
14081 _this._height = height;
14082 return _this;
14083 }
14084
14085 Rectangle.prototype.getCoordinates = function getCoordinates() {
14086 return this._coordinates;
14087 };
14088
14089 Rectangle.prototype.setCoordinates = function setCoordinates(nw) {
14090 this._coordinates = nw instanceof Coordinate ? nw : new Coordinate(nw);
14091 if (!this._coordinates || !this.getMap()) {
14092 this.onPositionChanged();
14093 return this;
14094 }
14095 var projection = this._getProjection();
14096 this._setPrjCoordinates(projection.project(this._coordinates));
14097 return this;
14098 };
14099
14100 Rectangle.prototype.getWidth = function getWidth() {
14101 return this._width;
14102 };
14103
14104 Rectangle.prototype.setWidth = function setWidth(width) {
14105 this._width = width;
14106 this.onShapeChanged();
14107 return this;
14108 };
14109
14110 Rectangle.prototype.getHeight = function getHeight() {
14111 return this._height;
14112 };
14113
14114 Rectangle.prototype.setHeight = function setHeight(height) {
14115 this._height = height;
14116 this.onShapeChanged();
14117 return this;
14118 };
14119
14120 Rectangle.prototype.getShell = function getShell() {
14121 var measurer = this._getMeasurer();
14122 var nw = this._coordinates;
14123 var map = this.getMap();
14124 var sx = 1,
14125 sy = -1;
14126 if (map) {
14127 var fExt = map.getFullExtent();
14128 if (fExt['left'] > fExt['right']) {
14129 sx = -1;
14130 }
14131 if (fExt['bottom'] > fExt['top']) {
14132 sy = 1;
14133 }
14134 }
14135 var points = [];
14136 points.push(nw);
14137 points.push(measurer.locate(nw, sx * this._width, 0));
14138 points.push(measurer.locate(nw, sx * this._width, sy * this._height));
14139 points.push(measurer.locate(nw, 0, sy * this._height));
14140 points.push(nw);
14141 return points;
14142 };
14143
14144 Rectangle.prototype.getHoles = function getHoles() {
14145 return [];
14146 };
14147
14148 Rectangle.prototype.animateShow = function animateShow() {
14149 return this.show();
14150 };
14151
14152 Rectangle.prototype._getPrjCoordinates = function _getPrjCoordinates() {
14153 var projection = this._getProjection();
14154 if (!projection) {
14155 return null;
14156 }
14157 this._verifyProjection();
14158 if (!this._pnw) {
14159 if (this._coordinates) {
14160 this._pnw = projection.project(this._coordinates);
14161 }
14162 }
14163 return this._pnw;
14164 };
14165
14166 Rectangle.prototype._setPrjCoordinates = function _setPrjCoordinates(pnw) {
14167 this._pnw = pnw;
14168 this.onPositionChanged();
14169 };
14170
14171 Rectangle.prototype._getPrjShell = function _getPrjShell() {
14172 var shell = _Polygon.prototype._getPrjShell.call(this);
14173 var projection = this._getProjection();
14174 if (!projection.isSphere()) {
14175 return shell;
14176 }
14177 var sphereExtent = projection.getSphereExtent(),
14178 sx = sphereExtent.sx,
14179 sy = sphereExtent.sy;
14180 var circum = this._getProjection().getCircum();
14181 var nw = shell[0];
14182 for (var i = 1, l = shell.length; i < l; i++) {
14183 var p = shell[i];
14184 var dx = 0,
14185 dy = 0;
14186 if (sx * (nw.x - p.x) > 0) {
14187 dx = circum.x * sx;
14188 }
14189 if (sy * (nw.y - p.y) < 0) {
14190 dy = circum.y * sy;
14191 }
14192 shell[i]._add(dx, dy);
14193 }
14194 return shell;
14195 };
14196
14197 Rectangle.prototype._updateCache = function _updateCache() {
14198 this._clearCache();
14199 var projection = this._getProjection();
14200 if (this._pnw && projection) {
14201 this._coordinates = projection.unproject(this._pnw);
14202 }
14203 };
14204
14205 Rectangle.prototype._clearProjection = function _clearProjection() {
14206 this._pnw = null;
14207 _Polygon.prototype._clearProjection.call(this);
14208 };
14209
14210 Rectangle.prototype._computeCenter = function _computeCenter(measurer) {
14211 return measurer.locate(this._coordinates, this._width / 2, -this._height / 2);
14212 };
14213
14214 Rectangle.prototype._containsPoint = function _containsPoint(point, tolerance) {
14215 var map = this.getMap();
14216 if (map.isTransforming()) {
14217 return _Polygon.prototype._containsPoint.call(this, point, tolerance);
14218 }
14219 var t = isNil(tolerance) ? this._hitTestTolerance() : tolerance,
14220 r = map._getResolution() * t;
14221 var extent = this._getPrjExtent().expand(r);
14222 var p = map._containerPointToPrj(point);
14223 return extent.contains(p);
14224 };
14225
14226 Rectangle.prototype._computePrjExtent = function _computePrjExtent(projection) {
14227 var se = this._getSouthEast(projection);
14228 if (!se) {
14229 return null;
14230 }
14231 var prjs = projection.projectCoords([new Coordinate(this._coordinates.x, se.y), new Coordinate(se.x, this._coordinates.y)]);
14232 return new Extent(prjs[0], prjs[1]);
14233 };
14234
14235 Rectangle.prototype._computeExtent = function _computeExtent(measurer) {
14236 var se = this._getSouthEast(measurer);
14237 if (!se) {
14238 return null;
14239 }
14240 return new Extent(this._coordinates, se, this._getProjection());
14241 };
14242
14243 Rectangle.prototype._getSouthEast = function _getSouthEast(measurer) {
14244 if (!measurer || !this._coordinates || isNil(this._width) || isNil(this._height)) {
14245 return null;
14246 }
14247 var width = this.getWidth(),
14248 height = this.getHeight();
14249 var w = width,
14250 h = -height;
14251 if (measurer.fullExtent) {
14252 var fullExtent = measurer.fullExtent,
14253 sx = fullExtent.right > fullExtent.left ? 1 : -1,
14254 sy = fullExtent.top > fullExtent.bottom ? 1 : -1;
14255 w *= sx;
14256 h *= sy;
14257 }
14258 var se = measurer.locate(this._coordinates, w, h);
14259 return se;
14260 };
14261
14262 Rectangle.prototype._computeGeodesicLength = function _computeGeodesicLength() {
14263 if (isNil(this._width) || isNil(this._height)) {
14264 return 0;
14265 }
14266 return 2 * (this._width + this._height);
14267 };
14268
14269 Rectangle.prototype._computeGeodesicArea = function _computeGeodesicArea() {
14270 if (isNil(this._width) || isNil(this._height)) {
14271 return 0;
14272 }
14273 return this._width * this._height;
14274 };
14275
14276 Rectangle.prototype._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
14277 var coordinates = Coordinate.toNumberArrays([this.getShell()]);
14278 return {
14279 'type': 'Polygon',
14280 'coordinates': coordinates
14281 };
14282 };
14283
14284 Rectangle.prototype._toJSON = function _toJSON(options) {
14285 var opts = extend({}, options);
14286 var nw = this.getCoordinates();
14287 opts.geometry = false;
14288 var feature = this.toGeoJSON(opts);
14289 feature['geometry'] = {
14290 'type': 'Polygon'
14291 };
14292 return {
14293 'feature': feature,
14294 'subType': 'Rectangle',
14295 'coordinates': [nw.x, nw.y],
14296 'width': this.getWidth(),
14297 'height': this.getHeight()
14298 };
14299 };
14300
14301 return Rectangle;
14302}(Polygon);
14303
14304Rectangle.registerJSONType('Rectangle');
14305
14306var options$11 = {
14307 'numberOfShellPoints': 60
14308};
14309
14310var Sector = function (_Circle) {
14311 inherits(Sector, _Circle);
14312
14313 Sector.fromJSON = function fromJSON(json) {
14314 var feature = json['feature'];
14315 var sector = new Sector(json['coordinates'], json['radius'], json['startAngle'], json['endAngle'], json['options']);
14316 sector.setProperties(feature['properties']);
14317 return sector;
14318 };
14319
14320 function Sector(coordinates, radius, startAngle, endAngle, opts) {
14321 classCallCheck(this, Sector);
14322
14323 var _this = possibleConstructorReturn(this, _Circle.call(this, coordinates, radius, opts));
14324
14325 _this.startAngle = startAngle;
14326 _this.endAngle = endAngle;
14327 return _this;
14328 }
14329
14330 Sector.prototype.getStartAngle = function getStartAngle() {
14331 return this.startAngle;
14332 };
14333
14334 Sector.prototype.setStartAngle = function setStartAngle(startAngle) {
14335 this.startAngle = startAngle;
14336 this.onShapeChanged();
14337 return this;
14338 };
14339
14340 Sector.prototype.getEndAngle = function getEndAngle() {
14341 return this.endAngle;
14342 };
14343
14344 Sector.prototype.setEndAngle = function setEndAngle(endAngle) {
14345 this.endAngle = endAngle;
14346 this.onShapeChanged();
14347 return this;
14348 };
14349
14350 Sector.prototype.getShell = function getShell() {
14351 var measurer = this._getMeasurer(),
14352 center = this.getCoordinates(),
14353 numberOfPoints = this.options['numberOfShellPoints'] - 2,
14354 radius = this.getRadius(),
14355 shell = [center.copy()],
14356 startAngle = this.getStartAngle(),
14357 angle = this.getEndAngle() - startAngle;
14358 var rad = void 0,
14359 dx = void 0,
14360 dy = void 0;
14361 for (var i = 0; i < numberOfPoints; i++) {
14362 rad = (angle * i / (numberOfPoints - 1) + startAngle) * Math.PI / 180;
14363 dx = radius * Math.cos(rad);
14364 dy = radius * Math.sin(rad);
14365 var vertex = measurer.locate(center, dx, dy);
14366 shell.push(vertex);
14367 }
14368 shell.push(center.copy());
14369 return shell;
14370 };
14371
14372 Sector.prototype._containsPoint = function _containsPoint(point, tolerance) {
14373 var map = this.getMap();
14374 if (map.isTransforming()) {
14375 return _Circle.prototype._containsPoint.call(this, point, tolerance);
14376 }
14377 var center = map._pointToContainerPoint(this._getCenter2DPoint()),
14378 t = isNil(tolerance) ? this._hitTestTolerance() : tolerance,
14379 size = this.getSize(),
14380 pc = center,
14381 pp = point,
14382 x = pp.x - pc.x,
14383 y = pc.y - pp.y,
14384 atan2 = Math.atan2(y, x),
14385 angle = atan2 < 0 ? (atan2 + 2 * Math.PI) * 360 / (2 * Math.PI) : atan2 * 360 / (2 * Math.PI);
14386 var sAngle = this.startAngle % 360,
14387 eAngle = this.endAngle % 360;
14388 var between = false;
14389 if (sAngle > eAngle) {
14390 between = !(angle > eAngle && angle < sAngle);
14391 } else {
14392 between = angle >= sAngle && angle <= eAngle;
14393 }
14394 return pp.distanceTo(pc) <= size.width / 2 + t && between;
14395 };
14396
14397 Sector.prototype._computeGeodesicLength = function _computeGeodesicLength() {
14398 if (isNil(this._radius)) {
14399 return 0;
14400 }
14401 return Math.PI * 2 * this._radius * Math.abs(this.startAngle - this.endAngle) / 360 + 2 * this._radius;
14402 };
14403
14404 Sector.prototype._computeGeodesicArea = function _computeGeodesicArea() {
14405 if (isNil(this._radius)) {
14406 return 0;
14407 }
14408 return Math.PI * Math.pow(this._radius, 2) * Math.abs(this.startAngle - this.endAngle) / 360;
14409 };
14410
14411 Sector.prototype._toJSON = function _toJSON(options) {
14412 var opts = extend({}, options);
14413 var center = this.getCenter();
14414 opts.geometry = false;
14415 var feature = this.toGeoJSON(opts);
14416 feature['geometry'] = {
14417 'type': 'Polygon'
14418 };
14419 return {
14420 'feature': feature,
14421 'subType': 'Sector',
14422 'coordinates': [center.x, center.y],
14423 'radius': this.getRadius(),
14424 'startAngle': this.getStartAngle(),
14425 'endAngle': this.getEndAngle()
14426 };
14427 };
14428
14429 return Sector;
14430}(Circle);
14431
14432Sector.mergeOptions(options$11);
14433
14434Sector.registerJSONType('Sector');
14435
14436var options$12 = {
14437 'enableSimplify': false,
14438 'enableClip': false
14439};
14440
14441var Curve = function (_LineString) {
14442 inherits(Curve, _LineString);
14443
14444 function Curve() {
14445 classCallCheck(this, Curve);
14446 return possibleConstructorReturn(this, _LineString.apply(this, arguments));
14447 }
14448
14449 Curve.prototype._arc = function _arc(ctx, points, lineOpacity) {
14450 var degree = this.options['arcDegree'] * Math.PI / 180;
14451 for (var i = 1, l = points.length; i < l; i++) {
14452 var c = Canvas._arcBetween(ctx, points[i - 1], points[i], degree);
14453
14454 var ctrlPoint = [points[i - 1].x + points[i].x - c[0], points[i - 1].y + points[i].y - c[1]];
14455 points[i - 1].nextCtrlPoint = ctrlPoint;
14456 points[i].prevCtrlPoint = ctrlPoint;
14457 Canvas._stroke(ctx, lineOpacity);
14458 }
14459 };
14460
14461 Curve.prototype._quadraticCurve = function _quadraticCurve(ctx, points) {
14462 if (points.length <= 2) {
14463 Canvas._path(ctx, points);
14464 return;
14465 }
14466 var i = void 0,
14467 l = void 0;
14468 for (i = 2, l = points.length; i < l; i += 2) {
14469 ctx.quadraticCurveTo(points[i - 1].x, points[i - 1].y, points[i].x, points[i].y);
14470 }
14471 i -= 1;
14472 if (i < l) {
14473 for (; i < l; i++) {
14474 ctx.lineTo(points[i].x, points[i].y);
14475 }
14476 }
14477 };
14478
14479 Curve.prototype._bezierCurve = function _bezierCurve(ctx, points) {
14480 if (points.length <= 3) {
14481 Canvas._path(ctx, points);
14482 return;
14483 }
14484 var i = void 0,
14485 l = void 0;
14486 for (i = 1, l = points.length; i + 2 < l; i += 3) {
14487 ctx.bezierCurveTo(points[i].x, points[i].y, points[i + 1].x, points[i + 1].y, points[i + 2].x, points[i + 2].y);
14488 }
14489 if (i < l) {
14490 for (; i < l; i++) {
14491 ctx.lineTo(points[i].x, points[i].y);
14492 }
14493 }
14494 };
14495
14496 Curve.prototype._getCurveArrowPoints = function _getCurveArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance, step) {
14497 var l = segments.length;
14498 var i = void 0;
14499 for (i = step; i < l; i += step) {
14500 arrows.push(this._getArrowShape(segments[i - 1], segments[i], lineWidth, arrowStyle, tolerance));
14501 }
14502 i -= step;
14503 if (i < l - 1) {
14504 for (i += 1; i < l; i++) {
14505 arrows.push(this._getArrowShape(segments[i - 1], segments[i], lineWidth, arrowStyle, tolerance));
14506 }
14507 }
14508 };
14509
14510 return Curve;
14511}(LineString);
14512
14513Curve.mergeOptions(options$12);
14514
14515var options$13 = {
14516 'arcDegree': 90
14517};
14518
14519var ArcCurve = function (_Curve) {
14520 inherits(ArcCurve, _Curve);
14521
14522 function ArcCurve() {
14523 classCallCheck(this, ArcCurve);
14524 return possibleConstructorReturn(this, _Curve.apply(this, arguments));
14525 }
14526
14527 ArcCurve.prototype._toJSON = function _toJSON(options) {
14528 return {
14529 'feature': this.toGeoJSON(options),
14530 'subType': 'ArcCurve'
14531 };
14532 };
14533
14534 ArcCurve.prototype._paintOn = function _paintOn(ctx, points, lineOpacity) {
14535 ctx.beginPath();
14536 this._arc(ctx, points, lineOpacity);
14537 Canvas._stroke(ctx, lineOpacity);
14538 this._paintArrow(ctx, points, lineOpacity);
14539 };
14540
14541 ArcCurve.fromJSON = function fromJSON(json) {
14542 var feature = json['feature'];
14543 var arc = new ArcCurve(feature['geometry']['coordinates'], json['options']);
14544 arc.setProperties(feature['properties']);
14545 return arc;
14546 };
14547
14548 return ArcCurve;
14549}(Curve);
14550
14551ArcCurve.registerJSONType('ArcCurve');
14552
14553ArcCurve.mergeOptions(options$13);
14554
14555var CubicBezierCurve = function (_Curve) {
14556 inherits(CubicBezierCurve, _Curve);
14557
14558 function CubicBezierCurve() {
14559 classCallCheck(this, CubicBezierCurve);
14560 return possibleConstructorReturn(this, _Curve.apply(this, arguments));
14561 }
14562
14563 CubicBezierCurve.fromJSON = function fromJSON(json) {
14564 var feature = json['feature'];
14565 var curve = new CubicBezierCurve(feature['geometry']['coordinates'], json['options']);
14566 curve.setProperties(feature['properties']);
14567 return curve;
14568 };
14569
14570 CubicBezierCurve.prototype._toJSON = function _toJSON(options) {
14571 return {
14572 'feature': this.toGeoJSON(options),
14573 'subType': 'CubicBezierCurve'
14574 };
14575 };
14576
14577 CubicBezierCurve.prototype._paintOn = function _paintOn(ctx, points, lineOpacity) {
14578 ctx.beginPath();
14579 ctx.moveTo(points[0].x, points[0].y);
14580 this._bezierCurve(ctx, points);
14581 Canvas._stroke(ctx, lineOpacity);
14582 this._paintArrow(ctx, points, lineOpacity);
14583 };
14584
14585 CubicBezierCurve.prototype._getArrowPoints = function _getArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance) {
14586 return this._getCurveArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance, 3);
14587 };
14588
14589 return CubicBezierCurve;
14590}(Curve);
14591
14592CubicBezierCurve.registerJSONType('CubicBezierCurve');
14593
14594var QuadBezierCurve = function (_Curve) {
14595 inherits(QuadBezierCurve, _Curve);
14596
14597 function QuadBezierCurve() {
14598 classCallCheck(this, QuadBezierCurve);
14599 return possibleConstructorReturn(this, _Curve.apply(this, arguments));
14600 }
14601
14602 QuadBezierCurve.fromJSON = function fromJSON(json) {
14603 var feature = json['feature'];
14604 var curve = new QuadBezierCurve(feature['geometry']['coordinates'], json['options']);
14605 curve.setProperties(feature['properties']);
14606 return curve;
14607 };
14608
14609 QuadBezierCurve.prototype._toJSON = function _toJSON(options) {
14610 return {
14611 'feature': this.toGeoJSON(options),
14612 'subType': 'QuadBezierCurve'
14613 };
14614 };
14615
14616 QuadBezierCurve.prototype._paintOn = function _paintOn(ctx, points, lineOpacity) {
14617 ctx.beginPath();
14618 ctx.moveTo(points[0].x, points[0].y);
14619 this._quadraticCurve(ctx, points, lineOpacity);
14620 Canvas._stroke(ctx, lineOpacity);
14621 this._paintArrow(ctx, points, lineOpacity);
14622 };
14623
14624 QuadBezierCurve.prototype._getArrowPoints = function _getArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance) {
14625 return this._getCurveArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance, 2);
14626 };
14627
14628 return QuadBezierCurve;
14629}(Curve);
14630
14631QuadBezierCurve.registerJSONType('QuadBezierCurve');
14632
14633var defaultSymbol$1 = {
14634 'textFaceName': 'monospace',
14635 'textSize': 12,
14636 'textLineSpacing': 8,
14637 'textWrapCharacter': '\n',
14638 'textHorizontalAlignment': 'middle',
14639 'textVerticalAlignment': 'middle' };
14640
14641var defaultBoxSymbol = {
14642 'markerType': 'square',
14643 'markerLineColor': '#000',
14644 'markerLineWidth': 2,
14645 'markerLineOpacity': 1,
14646 'markerFill': '#fff',
14647 'markerOpacity': 1
14648};
14649
14650var TextMarker = function (_Marker) {
14651 inherits(TextMarker, _Marker);
14652
14653 function TextMarker() {
14654 classCallCheck(this, TextMarker);
14655 return possibleConstructorReturn(this, _Marker.apply(this, arguments));
14656 }
14657
14658 TextMarker.prototype.getContent = function getContent() {
14659 return this._content;
14660 };
14661
14662 TextMarker.prototype.setContent = function setContent(content) {
14663 var old = this._content;
14664 this._content = escapeSpecialChars(content);
14665 this._refresh();
14666
14667 this._fireEvent('contentchange', {
14668 'old': old,
14669 'new': content
14670 });
14671 return this;
14672 };
14673
14674 TextMarker.prototype.onAdd = function onAdd() {
14675 this._refresh();
14676 };
14677
14678 TextMarker.prototype.toJSON = function toJSON() {
14679 var json = _Marker.prototype.toJSON.call(this);
14680 delete json['symbol'];
14681 return json;
14682 };
14683
14684 TextMarker.prototype.setSymbol = function setSymbol(symbol) {
14685 if (this._refreshing || !symbol) {
14686 return _Marker.prototype.setSymbol.call(this, symbol);
14687 }
14688 var s = this._parseSymbol(symbol);
14689 if (this.setTextStyle) {
14690 var style = this.getTextStyle() || {};
14691 style.symbol = s[0];
14692 this.setTextStyle(style);
14693 } else if (this.setTextSymbol) {
14694 this.setTextSymbol(s[0]);
14695 }
14696 if (this.setBoxStyle) {
14697 var _style = this.getBoxStyle() || {};
14698 _style.symbol = s[1];
14699 this.setBoxStyle(_style);
14700 } else if (this.setBoxSymbol) {
14701 this.setBoxSymbol(s[1]);
14702 }
14703 return this;
14704 };
14705
14706 TextMarker.prototype._parseSymbol = function _parseSymbol(symbol) {
14707 var t = {};
14708 var b = {};
14709 for (var p in symbol) {
14710 if (hasOwn(symbol, p)) {
14711 if (p.indexOf('text') === 0) {
14712 t[p] = symbol[p];
14713 } else {
14714 b[p] = symbol[p];
14715 }
14716 }
14717 }
14718 return [t, b];
14719 };
14720
14721 TextMarker.prototype._getTextSize = function _getTextSize(symbol) {
14722 return splitTextToRow(this._content, symbol)['size'];
14723 };
14724
14725 TextMarker.prototype._getInternalSymbol = function _getInternalSymbol() {
14726 return this._symbol;
14727 };
14728
14729 TextMarker.prototype._getDefaultTextSymbol = function _getDefaultTextSymbol() {
14730 return extend({}, defaultSymbol$1);
14731 };
14732
14733 TextMarker.prototype._getDefaultBoxSymbol = function _getDefaultBoxSymbol() {
14734 return extend({}, defaultBoxSymbol);
14735 };
14736
14737 TextMarker.prototype._getDefaultPadding = function _getDefaultPadding() {
14738 return [12, 8];
14739 };
14740
14741 return TextMarker;
14742}(Marker);
14743
14744var options$14 = {
14745 'textStyle': {
14746 'wrap': true,
14747 'padding': [12, 8],
14748 'verticalAlignment': 'middle',
14749 'horizontalAlignment': 'middle'
14750 },
14751 'boxSymbol': null
14752};
14753
14754var TextBox = function (_TextMarker) {
14755 inherits(TextBox, _TextMarker);
14756
14757 function TextBox(content, coordinates, width, height) {
14758 var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
14759 classCallCheck(this, TextBox);
14760
14761 var _this = possibleConstructorReturn(this, _TextMarker.call(this, coordinates, options));
14762
14763 _this._content = escapeSpecialChars(content);
14764 _this._width = isNil(width) ? 100 : width;
14765 _this._height = isNil(height) ? 40 : height;
14766 if (options.boxSymbol) {
14767 _this.setBoxSymbol(options.boxSymbol);
14768 }
14769 if (options.textStyle) {
14770 _this.setTextStyle(options.textStyle);
14771 }
14772 _this._refresh();
14773 return _this;
14774 }
14775
14776 TextBox.prototype.getWidth = function getWidth() {
14777 return this._width;
14778 };
14779
14780 TextBox.prototype.setWidth = function setWidth(width) {
14781 this._width = width;
14782 this._refresh();
14783 return this;
14784 };
14785
14786 TextBox.prototype.getHeight = function getHeight() {
14787 return this._height;
14788 };
14789
14790 TextBox.prototype.setHeight = function setHeight(height) {
14791 this._height = height;
14792 this._refresh();
14793 return this;
14794 };
14795
14796 TextBox.prototype.getBoxSymbol = function getBoxSymbol() {
14797 return extend({}, this.options.boxSymbol);
14798 };
14799
14800 TextBox.prototype.setBoxSymbol = function setBoxSymbol(symbol) {
14801 this.options.boxSymbol = symbol ? extend({}, symbol) : symbol;
14802 if (this.getSymbol()) {
14803 this._refresh();
14804 }
14805 return this;
14806 };
14807
14808 TextBox.prototype.getTextStyle = function getTextStyle() {
14809 if (!this.options.textStyle) {
14810 return null;
14811 }
14812 return extend({}, this.options.textStyle);
14813 };
14814
14815 TextBox.prototype.setTextStyle = function setTextStyle(style) {
14816 this.options.textStyle = style ? extend({}, style) : style;
14817 if (this.getSymbol()) {
14818 this._refresh();
14819 }
14820 return this;
14821 };
14822
14823 TextBox.fromJSON = function fromJSON(json) {
14824 var feature = json['feature'];
14825 var textBox = new TextBox(json['content'], feature['geometry']['coordinates'], json['width'], json['height'], json['options']);
14826 textBox.setProperties(feature['properties']);
14827 textBox.setId(feature['id']);
14828 if (json['symbol']) {
14829 textBox.setSymbol(json['symbol']);
14830 }
14831 return textBox;
14832 };
14833
14834 TextBox.prototype._toJSON = function _toJSON(options) {
14835 return {
14836 'feature': this.toGeoJSON(options),
14837 'width': this.getWidth(),
14838 'height': this.getHeight(),
14839 'subType': 'TextBox',
14840 'content': this._content
14841 };
14842 };
14843
14844 TextBox.prototype._refresh = function _refresh() {
14845 var textStyle = this.getTextStyle() || {},
14846 padding = textStyle['padding'] || [12, 8],
14847 maxWidth = this._width - 2 * padding[0],
14848 maxHeight = this._height - 2 * padding[1];
14849 var symbol = extend({}, textStyle.symbol || this._getDefaultTextSymbol(), this.options.boxSymbol || this._getDefaultBoxSymbol(), {
14850 'textName': this._content,
14851 'markerWidth': this._width,
14852 'markerHeight': this._height,
14853 'textHorizontalAlignment': 'middle',
14854 'textVerticalAlignment': 'middle',
14855 'textMaxWidth': maxWidth,
14856 'textMaxHeight': maxHeight
14857 });
14858
14859 if (textStyle['wrap'] && !symbol['textWrapWidth']) {
14860 symbol['textWrapWidth'] = maxWidth;
14861 }
14862
14863 var hAlign = textStyle['horizontalAlignment'];
14864 symbol['textDx'] = symbol['markerDx'] || 0;
14865 var offsetX = symbol['markerWidth'] / 2 - padding[0];
14866 if (hAlign === 'left') {
14867 symbol['textHorizontalAlignment'] = 'right';
14868 symbol['textDx'] = symbol['textDx'] - offsetX;
14869 } else if (hAlign === 'right') {
14870 symbol['textHorizontalAlignment'] = 'left';
14871 symbol['textDx'] = symbol['textDx'] + offsetX;
14872 }
14873
14874 var vAlign = textStyle['verticalAlignment'];
14875 symbol['textDy'] = symbol['markerDy'] || 0;
14876 var offsetY = symbol['markerHeight'] / 2 - padding[1];
14877 if (vAlign === 'top') {
14878 symbol['textVerticalAlignment'] = 'bottom';
14879 symbol['textDy'] -= offsetY;
14880 } else if (vAlign === 'bottom') {
14881 symbol['textVerticalAlignment'] = 'top';
14882 symbol['textDy'] += offsetY;
14883 }
14884 this._refreshing = true;
14885 this.updateSymbol(symbol);
14886 delete this._refreshing;
14887 };
14888
14889 return TextBox;
14890}(TextMarker);
14891
14892TextBox.mergeOptions(options$14);
14893
14894TextBox.registerJSONType('TextBox');
14895
14896var options$15 = {
14897 'boxStyle': null,
14898 textSymbol: null
14899};
14900
14901var Label = function (_TextMarker) {
14902 inherits(Label, _TextMarker);
14903
14904 function Label(content, coordinates) {
14905 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
14906 classCallCheck(this, Label);
14907
14908 var _this = possibleConstructorReturn(this, _TextMarker.call(this, coordinates, options));
14909
14910 if (options.textSymbol) {
14911 _this.setTextSymbol(options.textSymbol);
14912 }
14913 if (options.boxStyle) {
14914 _this.setBoxStyle(options.boxStyle);
14915 }
14916 _this._content = escapeSpecialChars(content);
14917 _this._refresh();
14918 return _this;
14919 }
14920
14921 Label.prototype.getBoxStyle = function getBoxStyle() {
14922 if (!this.options.boxStyle) {
14923 return null;
14924 }
14925 return extend({}, this.options.boxStyle);
14926 };
14927
14928 Label.prototype.setBoxStyle = function setBoxStyle(style) {
14929 this.options.boxStyle = style ? extend({}, style) : style;
14930 this._refresh();
14931 return this;
14932 };
14933
14934 Label.prototype.getTextSymbol = function getTextSymbol() {
14935 return extend({}, this._getDefaultTextSymbol(), this.options.textSymbol);
14936 };
14937
14938 Label.prototype.setTextSymbol = function setTextSymbol(symbol) {
14939 this.options.textSymbol = symbol ? extend({}, symbol) : symbol;
14940 this._refresh();
14941 return this;
14942 };
14943
14944 Label.fromJSON = function fromJSON(json) {
14945 var feature = json['feature'];
14946 var label = new Label(json['content'], feature['geometry']['coordinates'], json['options']);
14947 label.setProperties(feature['properties']);
14948 label.setId(feature['id']);
14949 if (json['symbol']) {
14950 label.setSymbol(json['symbol']);
14951 }
14952 return label;
14953 };
14954
14955 Label.prototype._canEdit = function _canEdit() {
14956 return false;
14957 };
14958
14959 Label.prototype._toJSON = function _toJSON(options) {
14960 return {
14961 'feature': this.toGeoJSON(options),
14962 'subType': 'Label',
14963 'content': this._content
14964 };
14965 };
14966
14967 Label.prototype._refresh = function _refresh() {
14968 var symbol = extend({}, this.getTextSymbol(), {
14969 'textName': this._content
14970 });
14971
14972 var boxStyle = this.getBoxStyle();
14973 if (boxStyle) {
14974 extend(symbol, boxStyle.symbol);
14975 var sizes = this._getBoxSize(symbol),
14976 textSize = sizes[1],
14977 padding = boxStyle['padding'] || this._getDefaultPadding();
14978 var boxSize = sizes[0];
14979
14980 symbol['markerWidth'] = boxSize['width'];
14981 symbol['markerHeight'] = boxSize['height'];
14982
14983 var dx = symbol['textDx'] || 0,
14984 dy = symbol['textDy'] || 0,
14985 textAlignPoint = getAlignPoint(textSize, symbol['textHorizontalAlignment'], symbol['textVerticalAlignment'])._add(dx, dy);
14986
14987 var hAlign = boxStyle['horizontalAlignment'] || 'middle';
14988 symbol['markerDx'] = textAlignPoint.x;
14989 if (hAlign === 'left') {
14990 symbol['markerDx'] += symbol['markerWidth'] / 2 - padding[0];
14991 } else if (hAlign === 'right') {
14992 symbol['markerDx'] -= symbol['markerWidth'] / 2 - textSize['width'] - padding[0];
14993 } else {
14994 symbol['markerDx'] += textSize['width'] / 2;
14995 }
14996
14997 var vAlign = boxStyle['verticalAlignment'] || 'middle';
14998 symbol['markerDy'] = textAlignPoint.y;
14999 if (vAlign === 'top') {
15000 symbol['markerDy'] += symbol['markerHeight'] / 2 - padding[1];
15001 } else if (vAlign === 'bottom') {
15002 symbol['markerDy'] -= symbol['markerHeight'] / 2 - textSize['height'] - padding[1];
15003 } else {
15004 symbol['markerDy'] += textSize['height'] / 2;
15005 }
15006 }
15007 this._refreshing = true;
15008 this.updateSymbol(symbol);
15009 delete this._refreshing;
15010 };
15011
15012 Label.prototype._getBoxSize = function _getBoxSize(symbol) {
15013 if (!symbol['markerType']) {
15014 symbol['markerType'] = 'square';
15015 }
15016 var boxStyle = this.getBoxStyle();
15017 var size = this._getTextSize(symbol);
15018 var width = void 0,
15019 height = void 0;
15020 var padding = boxStyle['padding'] || this._getDefaultPadding();
15021 width = size['width'] + padding[0] * 2;
15022 height = size['height'] + padding[1] * 2;
15023 if (boxStyle['minWidth']) {
15024 if (!width || width < boxStyle['minWidth']) {
15025 width = boxStyle['minWidth'];
15026 }
15027 }
15028 if (boxStyle['minHeight']) {
15029 if (!height || height < boxStyle['minHeight']) {
15030 height = boxStyle['minHeight'];
15031 }
15032 }
15033 return [new Size(width, height), size];
15034 };
15035
15036 return Label;
15037}(TextMarker);
15038
15039Label.mergeOptions(options$15);
15040
15041Label.registerJSONType('Label');
15042
15043var Connectable = function Connectable(Base) {
15044 return function (_Base) {
15045 inherits(_class, _Base);
15046
15047 function _class() {
15048 classCallCheck(this, _class);
15049 return possibleConstructorReturn(this, _Base.apply(this, arguments));
15050 }
15051
15052 _class._hasConnectors = function _hasConnectors(geometry) {
15053 return !isNil(geometry.__connectors) && geometry.__connectors.length > 0;
15054 };
15055
15056 _class._getConnectors = function _getConnectors(geometry) {
15057 return geometry.__connectors;
15058 };
15059
15060 _class.prototype.getConnectSource = function getConnectSource() {
15061 return this._connSource;
15062 };
15063
15064 _class.prototype.setConnectSource = function setConnectSource(src) {
15065 var target = this._connTarget;
15066 this.onRemove();
15067 this._connSource = src;
15068 this._connTarget = target;
15069 this.onAdd();
15070 return this;
15071 };
15072
15073 _class.prototype.getConnectTarget = function getConnectTarget() {
15074 return this._connTarget;
15075 };
15076
15077 _class.prototype.setConnectTarget = function setConnectTarget(target) {
15078 var src = this._connSource;
15079 this.onRemove();
15080 this._connSource = src;
15081 this._connTarget = target;
15082 this._updateCoordinates();
15083 this._registerEvents();
15084 return this;
15085 };
15086
15087 _class.prototype._updateCoordinates = function _updateCoordinates() {
15088 var map = this.getMap();
15089 if (!map && this._connSource) {
15090 map = this._connSource.getMap();
15091 }
15092 if (!map && this._connTarget) {
15093 map = this._connTarget.getMap();
15094 }
15095 if (!map) {
15096 return;
15097 }
15098 if (!this._connSource || !this._connTarget) {
15099 return;
15100 }
15101 var srcPoints = this._connSource._getConnectPoints();
15102 var targetPoints = this._connTarget._getConnectPoints();
15103 var minDist = 0;
15104 var oldCoordinates = this.getCoordinates();
15105 var c1 = void 0,
15106 c2 = void 0;
15107 for (var i = 0, len = srcPoints.length; i < len; i++) {
15108 var p1 = srcPoints[i];
15109 for (var j = 0, length = targetPoints.length; j < length; j++) {
15110 var p2 = targetPoints[j];
15111 var dist = map.computeLength(p1, p2);
15112 if (i === 0 && j === 0) {
15113 c1 = p1;
15114 c2 = p2;
15115 minDist = dist;
15116 } else if (dist < minDist) {
15117 c1 = p1;
15118 c2 = p2;
15119 }
15120 }
15121 }
15122 if (!isArrayHasData(oldCoordinates) || !oldCoordinates[0].equals(c1) || !oldCoordinates[1].equals(c2)) {
15123 this.setCoordinates([c1, c2]);
15124 }
15125 };
15126
15127 _class.prototype.onAdd = function onAdd() {
15128 this._registerEvents();
15129 this._updateCoordinates();
15130 };
15131
15132 _class.prototype.onRemove = function onRemove() {
15133 if (this._connSource) {
15134 if (this._connSource.__connectors) {
15135 removeFromArray(this, this._connSource.__connectors);
15136 }
15137 this._connSource.off('dragging positionchange', this._updateCoordinates, this).off('remove', this.onRemove, this);
15138 this._connSource.off('dragstart mousedown mouseover', this._showConnect, this);
15139 this._connSource.off('dragend mouseup mouseout', this.hide, this);
15140 this._connSource.off('show', this._showConnect, this).off('hide', this.hide, this);
15141 delete this._connSource;
15142 }
15143 if (this._connTarget) {
15144 removeFromArray(this, this._connTarget.__connectors);
15145 this._connTarget.off('dragging positionchange', this._updateCoordinates, this).off('remove', this.onRemove, this);
15146 this._connTarget.off('show', this._showConnect, this).off('hide', this.hide, this);
15147 delete this._connTarget;
15148 }
15149
15150 if (!(this._connSource instanceof Geometry) || !(this._connTarget instanceof Geometry)) {
15151 var map = this.getMap();
15152 if (map) {
15153 map.off('movestart moving moveend zoomstart zooming zoomend rotate pitch fovchange spatialreferencechange', this._updateCoordinates, this);
15154 }
15155 }
15156 };
15157
15158 _class.prototype._showConnect = function _showConnect() {
15159 if (!this._connSource || !this._connTarget) {
15160 return;
15161 }
15162 if (this._connSource.isVisible() && this._connTarget.isVisible()) {
15163 this._updateCoordinates();
15164 this.show();
15165 }
15166 };
15167
15168 _class.prototype._registerEvents = function _registerEvents() {
15169 if (!this._connSource || !this._connTarget) {
15170 return;
15171 }
15172 if (!this._connSource.__connectors) {
15173 this._connSource.__connectors = [];
15174 }
15175 if (!this._connTarget.__connectors) {
15176 this._connTarget.__connectors = [];
15177 }
15178 this._connSource.__connectors.push(this);
15179 this._connTarget.__connectors.push(this);
15180 this._connSource.on('dragging positionchange', this._updateCoordinates, this).on('remove', this.remove, this);
15181 this._connTarget.on('dragging positionchange', this._updateCoordinates, this).on('remove', this.remove, this);
15182 this._connSource.on('show', this._showConnect, this).on('hide', this.hide, this);
15183 this._connTarget.on('show', this._showConnect, this).on('hide', this.hide, this);
15184 var trigger = this.options['showOn'];
15185 this.hide();
15186 if (trigger === 'moving') {
15187 this._connSource.on('dragstart', this._showConnect, this).on('dragend', this.hide, this);
15188 this._connTarget.on('dragstart', this._showConnect, this).on('dragend', this.hide, this);
15189 } else if (trigger === 'click') {
15190 this._connSource.on('mousedown', this._showConnect, this).on('mouseup', this.hide, this);
15191 this._connTarget.on('mousedown', this._showConnect, this).on('mouseup', this.hide, this);
15192 } else if (trigger === 'mouseover') {
15193 this._connSource.on('mouseover', this._showConnect, this).on('mouseout', this.hide, this);
15194 this._connTarget.on('mouseover', this._showConnect, this).on('mouseout', this.hide, this);
15195 } else {
15196 this._showConnect();
15197 }
15198
15199 if (!(this._connSource instanceof Geometry) || !(this._connTarget instanceof Geometry)) {
15200 var map = this.getMap();
15201 if (map) {
15202 map.on('movestart moving moveend zoomstart zooming zoomend rotate pitch fovchange spatialreferencechange', this._updateCoordinates, this);
15203 }
15204 }
15205 };
15206
15207 return _class;
15208 }(Base);
15209};
15210
15211var options$16 = {
15212 showOn: 'always'
15213};
15214
15215var ConnectorLine = function (_Connectable) {
15216 inherits(ConnectorLine, _Connectable);
15217
15218 function ConnectorLine(src, target, options) {
15219 classCallCheck(this, ConnectorLine);
15220
15221 var _this2 = possibleConstructorReturn(this, _Connectable.call(this, null, options));
15222
15223 if (arguments.length === 1) {
15224 options = src;
15225 src = null;
15226 target = null;
15227 }
15228 _this2._connSource = src;
15229 _this2._connTarget = target;
15230 return _this2;
15231 }
15232
15233 return ConnectorLine;
15234}(Connectable(LineString));
15235
15236ConnectorLine.mergeOptions(options$16);
15237
15238ConnectorLine.registerJSONType('ConnectorLine');
15239
15240var ArcConnectorLine = function (_Connectable2) {
15241 inherits(ArcConnectorLine, _Connectable2);
15242
15243 function ArcConnectorLine(src, target, options) {
15244 classCallCheck(this, ArcConnectorLine);
15245
15246 var _this3 = possibleConstructorReturn(this, _Connectable2.call(this, null, options));
15247
15248 if (arguments.length === 1) {
15249 options = src;
15250 src = null;
15251 target = null;
15252 }
15253 _this3._connSource = src;
15254 _this3._connTarget = target;
15255 return _this3;
15256 }
15257
15258 return ArcConnectorLine;
15259}(Connectable(ArcCurve));
15260
15261ArcConnectorLine.mergeOptions(options$16);
15262
15263ArcConnectorLine.registerJSONType('ArcConnectorLine');
15264
15265var options$6 = {
15266 'drawImmediate': false
15267};
15268
15269var OverlayLayer = function (_Layer) {
15270 inherits(OverlayLayer, _Layer);
15271
15272 function OverlayLayer(id, geometries, options) {
15273 classCallCheck(this, OverlayLayer);
15274
15275 if (geometries && !(geometries instanceof Geometry) && !Array.isArray(geometries) && GEOJSON_TYPES.indexOf(geometries.type) < 0) {
15276 options = geometries;
15277 geometries = null;
15278 }
15279
15280 var _this = possibleConstructorReturn(this, _Layer.call(this, id, options));
15281
15282 _this._maxZIndex = 0;
15283 _this._minZIndex = 0;
15284 _this._initCache();
15285 if (geometries) {
15286 _this.addGeometry(geometries);
15287 }
15288 return _this;
15289 }
15290
15291 OverlayLayer.prototype.getGeometryById = function getGeometryById(id) {
15292 if (isNil(id) || id === '') {
15293 return null;
15294 }
15295 if (!this._geoMap[id]) {
15296 return null;
15297 }
15298 return this._geoMap[id];
15299 };
15300
15301 OverlayLayer.prototype.getGeometries = function getGeometries(filter, context) {
15302 if (!filter) {
15303 return this._geoList.slice(0);
15304 }
15305 var result = [];
15306 var geometry = void 0,
15307 filtered = void 0;
15308 for (var i = 0, l = this._geoList.length; i < l; i++) {
15309 geometry = this._geoList[i];
15310 if (context) {
15311 filtered = filter.call(context, geometry);
15312 } else {
15313 filtered = filter(geometry);
15314 }
15315 if (filtered) {
15316 result.push(geometry);
15317 }
15318 }
15319 return result;
15320 };
15321
15322 OverlayLayer.prototype.getFirstGeometry = function getFirstGeometry() {
15323 if (!this._geoList.length) {
15324 return null;
15325 }
15326 return this._geoList[0];
15327 };
15328
15329 OverlayLayer.prototype.getLastGeometry = function getLastGeometry() {
15330 var len = this._geoList.length;
15331 if (len === 0) {
15332 return null;
15333 }
15334 return this._geoList[len - 1];
15335 };
15336
15337 OverlayLayer.prototype.getCount = function getCount() {
15338 return this._geoList.length;
15339 };
15340
15341 OverlayLayer.prototype.getExtent = function getExtent() {
15342 if (this.getCount() === 0) {
15343 return null;
15344 }
15345 var extent = new Extent(this.getProjection());
15346 this.forEach(function (g) {
15347 extent._combine(g.getExtent());
15348 });
15349 return extent;
15350 };
15351
15352 OverlayLayer.prototype.forEach = function forEach(fn, context) {
15353 var copyOnWrite = this._geoList.slice(0);
15354 for (var i = 0, l = copyOnWrite.length; i < l; i++) {
15355 if (!context) {
15356 fn(copyOnWrite[i], i);
15357 } else {
15358 fn.call(context, copyOnWrite[i], i);
15359 }
15360 }
15361 return this;
15362 };
15363
15364 OverlayLayer.prototype.filter = function filter() {
15365 return GeometryCollection.prototype.filter.apply(this, arguments);
15366 };
15367
15368 OverlayLayer.prototype.isEmpty = function isEmpty() {
15369 return !this._geoList.length;
15370 };
15371
15372 OverlayLayer.prototype.addGeometry = function addGeometry(geometries, fitView) {
15373 if (!geometries) {
15374 return this;
15375 }
15376 if (geometries.type === 'FeatureCollection') {
15377 return this.addGeometry(GeoJSON.toGeometry(geometries), fitView);
15378 } else if (!Array.isArray(geometries)) {
15379 var count = arguments.length;
15380 var last = arguments[count - 1];
15381 geometries = Array.prototype.slice.call(arguments, 0, count - 1);
15382 fitView = last;
15383 if (isObject(last)) {
15384 geometries.push(last);
15385 fitView = false;
15386 }
15387 return this.addGeometry(geometries, fitView);
15388 } else if (geometries.length === 0) {
15389 return this;
15390 }
15391 this._initCache();
15392 var extent = void 0;
15393 if (fitView === true) {
15394 extent = new Extent();
15395 }
15396 this._toSort = this._maxZIndex > 0;
15397 var geos = [];
15398 for (var i = 0, l = geometries.length; i < l; i++) {
15399 var geo = geometries[i];
15400 if (!geo) {
15401 throw new Error('Invalid geometry to add to layer(' + this.getId() + ') at index:' + i);
15402 }
15403 if (!(geo instanceof Geometry)) {
15404 geo = Geometry.fromJSON(geo);
15405 if (Array.isArray(geo)) {
15406 for (var ii = 0, ll = geo.length; ii < ll; ii++) {
15407 this._add(geo[ii], extent, i);
15408 geos.push(geo[ii]);
15409 }
15410 }
15411 }
15412 if (!Array.isArray(geo)) {
15413 this._add(geo, extent, i);
15414 geos.push(geo);
15415 }
15416 }
15417 var map = this.getMap();
15418 if (map) {
15419 this._getRenderer().onGeometryAdd(geos);
15420 if (fitView === true && !isNil(extent.xmin)) {
15421 var z = map.getFitZoom(extent);
15422 map.setCenterAndZoom(extent.getCenter(), z);
15423 }
15424 }
15425
15426 this.fire('addgeo', {
15427 'geometries': geometries
15428 });
15429 return this;
15430 };
15431
15432 OverlayLayer.prototype.getGeoMinZIndex = function getGeoMinZIndex() {
15433 return this._minZIndex;
15434 };
15435
15436 OverlayLayer.prototype.getGeoMaxZIndex = function getGeoMaxZIndex() {
15437 return this._maxZIndex;
15438 };
15439
15440 OverlayLayer.prototype._add = function _add(geo, extent, i) {
15441 if (!this._toSort) {
15442 this._toSort = geo.getZIndex() !== 0;
15443 }
15444 this._updateZIndex(geo.getZIndex());
15445 var geoId = geo.getId();
15446 if (!isNil(geoId)) {
15447 if (!isNil(this._geoMap[geoId])) {
15448 throw new Error('Duplicate geometry id in layer(' + this.getId() + '):' + geoId + ', at index:' + i);
15449 }
15450 this._geoMap[geoId] = geo;
15451 }
15452 var internalId = UID();
15453 geo._setInternalId(internalId);
15454 this._geoList.push(geo);
15455 if (this.onAddGeometry) {
15456 this.onAddGeometry(geo);
15457 }
15458 geo._bindLayer(this);
15459 if (geo.onAdd) {
15460 geo.onAdd();
15461 }
15462 if (extent) {
15463 extent._combine(geo.getExtent());
15464 }
15465
15466 geo._fireEvent('add', {
15467 'layer': this
15468 });
15469 };
15470
15471 OverlayLayer.prototype.removeGeometry = function removeGeometry(geometries) {
15472 if (!Array.isArray(geometries)) {
15473 return this.removeGeometry([geometries]);
15474 }
15475 for (var i = geometries.length - 1; i >= 0; i--) {
15476 if (!(geometries[i] instanceof Geometry)) {
15477 geometries[i] = this.getGeometryById(geometries[i]);
15478 }
15479 if (!geometries[i] || this !== geometries[i].getLayer()) continue;
15480 geometries[i].remove();
15481 }
15482
15483 this.fire('removegeo', {
15484 'geometries': geometries
15485 });
15486 return this;
15487 };
15488
15489 OverlayLayer.prototype.clear = function clear() {
15490 this._clearing = true;
15491 this.forEach(function (geo) {
15492 geo.remove();
15493 });
15494 this._geoMap = {};
15495 var old = this._geoList;
15496 this._geoList = [];
15497 if (this._getRenderer()) {
15498 this._getRenderer().onGeometryRemove(old);
15499 }
15500 this._clearing = false;
15501
15502 this.fire('clear');
15503 return this;
15504 };
15505
15506 OverlayLayer.prototype.onRemoveGeometry = function onRemoveGeometry(geometry) {
15507 if (!geometry || this._clearing) {
15508 return;
15509 }
15510
15511 if (this !== geometry.getLayer()) {
15512 return;
15513 }
15514 var internalId = geometry._getInternalId();
15515 if (isNil(internalId)) {
15516 return;
15517 }
15518 var geoId = geometry.getId();
15519 if (!isNil(geoId)) {
15520 delete this._geoMap[geoId];
15521 }
15522 var idx = this._findInList(geometry);
15523 if (idx >= 0) {
15524 this._geoList.splice(idx, 1);
15525 }
15526 if (this._getRenderer()) {
15527 this._getRenderer().onGeometryRemove([geometry]);
15528 }
15529 };
15530
15531 OverlayLayer.prototype.hide = function hide() {
15532 for (var i = 0, l = this._geoList.length; i < l; i++) {
15533 this._geoList[i].onHide();
15534 }
15535 return Layer.prototype.hide.call(this);
15536 };
15537
15538 OverlayLayer.prototype.identify = function identify(coordinate) {
15539 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15540
15541 return this._hitGeos(this._geoList, coordinate, options);
15542 };
15543
15544 OverlayLayer.prototype._hitGeos = function _hitGeos(geometries, coordinate) {
15545 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
15546
15547 var filter = options['filter'],
15548 tolerance = options['tolerance'],
15549 hits = [];
15550 var map = this.getMap();
15551 var point = map.coordToPoint(coordinate);
15552 var cp = map._pointToContainerPoint(point);
15553 for (var i = geometries.length - 1; i >= 0; i--) {
15554 var geo = geometries[i];
15555 if (!geo || !geo.isVisible() || !geo._getPainter()) {
15556 continue;
15557 }
15558 if (!(geo instanceof LineString) || !geo._getArrowStyle() && !(geo instanceof Curve)) {
15559 var extent = geo.getContainerExtent();
15560 if (tolerance) {
15561 extent = extent.expand(tolerance);
15562 }
15563 if (!extent || !extent.contains(cp)) {
15564 continue;
15565 }
15566 }
15567 if (geo._containsPoint(cp, tolerance) && (!filter || filter(geo))) {
15568 hits.push(geo);
15569 if (options['count']) {
15570 if (hits.length >= options['count']) {
15571 break;
15572 }
15573 }
15574 }
15575 }
15576 return hits;
15577 };
15578
15579 OverlayLayer.prototype._initCache = function _initCache() {
15580 if (!this._geoList) {
15581 this._geoList = [];
15582 this._geoMap = {};
15583 }
15584 };
15585
15586 OverlayLayer.prototype._updateZIndex = function _updateZIndex() {
15587 for (var _len = arguments.length, zIndex = Array(_len), _key = 0; _key < _len; _key++) {
15588 zIndex[_key] = arguments[_key];
15589 }
15590
15591 this._maxZIndex = Math.max(this._maxZIndex, Math.max.apply(Math, zIndex));
15592 this._minZIndex = Math.min(this._minZIndex, Math.min.apply(Math, zIndex));
15593 };
15594
15595 OverlayLayer.prototype._sortGeometries = function _sortGeometries() {
15596 var _this2 = this;
15597
15598 if (!this._toSort) {
15599 return;
15600 }
15601 this._maxZIndex = 0;
15602 this._minZIndex = 0;
15603 this._geoList.sort(function (a, b) {
15604 _this2._updateZIndex(a.getZIndex(), b.getZIndex());
15605 return _this2._compare(a, b);
15606 });
15607 this._toSort = false;
15608 };
15609
15610 OverlayLayer.prototype._compare = function _compare(a, b) {
15611 if (a.getZIndex() === b.getZIndex()) {
15612 return a._getInternalId() - b._getInternalId();
15613 }
15614 return a.getZIndex() - b.getZIndex();
15615 };
15616
15617 OverlayLayer.prototype._findInList = function _findInList(geo) {
15618 var len = this._geoList.length;
15619 if (len === 0) {
15620 return -1;
15621 }
15622 var low = 0,
15623 high = len - 1,
15624 middle = void 0;
15625 while (low <= high) {
15626 middle = Math.floor((low + high) / 2);
15627 if (this._geoList[middle] === geo) {
15628 return middle;
15629 } else if (this._compare(this._geoList[middle], geo) > 0) {
15630 high = middle - 1;
15631 } else {
15632 low = middle + 1;
15633 }
15634 }
15635 return -1;
15636 };
15637
15638 OverlayLayer.prototype._onGeometryEvent = function _onGeometryEvent(param) {
15639 if (!param || !param['target']) {
15640 return;
15641 }
15642 var type = param['type'];
15643 if (type === 'idchange') {
15644 this._onGeometryIdChange(param);
15645 } else if (type === 'zindexchange') {
15646 this._onGeometryZIndexChange(param);
15647 } else if (type === 'positionchange') {
15648 this._onGeometryPositionChange(param);
15649 } else if (type === 'shapechange') {
15650 this._onGeometryShapeChange(param);
15651 } else if (type === 'symbolchange') {
15652 this._onGeometrySymbolChange(param);
15653 } else if (type === 'show') {
15654 this._onGeometryShow(param);
15655 } else if (type === 'hide') {
15656 this._onGeometryHide(param);
15657 } else if (type === 'propertieschange') {
15658 this._onGeometryPropertiesChange(param);
15659 }
15660 };
15661
15662 OverlayLayer.prototype._onGeometryIdChange = function _onGeometryIdChange(param) {
15663 if (param['new'] === param['old']) {
15664 if (this._geoMap[param['old']] && this._geoMap[param['old']] === param['target']) {
15665 return;
15666 }
15667 }
15668 if (!isNil(param['new'])) {
15669 if (this._geoMap[param['new']]) {
15670 throw new Error('Duplicate geometry id in layer(' + this.getId() + '):' + param['new']);
15671 }
15672 this._geoMap[param['new']] = param['target'];
15673 }
15674 if (!isNil(param['old']) && param['new'] !== param['old']) {
15675 delete this._geoMap[param['old']];
15676 }
15677 };
15678
15679 OverlayLayer.prototype._onGeometryZIndexChange = function _onGeometryZIndexChange(param) {
15680 if (param['old'] !== param['new']) {
15681 this._updateZIndex(param['new']);
15682 this._toSort = true;
15683 if (this._getRenderer()) {
15684 this._getRenderer().onGeometryZIndexChange(param);
15685 }
15686 }
15687 };
15688
15689 OverlayLayer.prototype._onGeometryPositionChange = function _onGeometryPositionChange(param) {
15690 if (this._getRenderer()) {
15691 this._getRenderer().onGeometryPositionChange(param);
15692 }
15693 };
15694
15695 OverlayLayer.prototype._onGeometryShapeChange = function _onGeometryShapeChange(param) {
15696 if (this._getRenderer()) {
15697 this._getRenderer().onGeometryShapeChange(param);
15698 }
15699 };
15700
15701 OverlayLayer.prototype._onGeometrySymbolChange = function _onGeometrySymbolChange(param) {
15702 if (this._getRenderer()) {
15703 this._getRenderer().onGeometrySymbolChange(param);
15704 }
15705 };
15706
15707 OverlayLayer.prototype._onGeometryShow = function _onGeometryShow(param) {
15708 if (this._getRenderer()) {
15709 this._getRenderer().onGeometryShow(param);
15710 }
15711 };
15712
15713 OverlayLayer.prototype._onGeometryHide = function _onGeometryHide(param) {
15714 if (this._getRenderer()) {
15715 this._getRenderer().onGeometryHide(param);
15716 }
15717 };
15718
15719 OverlayLayer.prototype._onGeometryPropertiesChange = function _onGeometryPropertiesChange(param) {
15720 if (this._getRenderer()) {
15721 this._getRenderer().onGeometryPropertiesChange(param);
15722 }
15723 };
15724
15725 return OverlayLayer;
15726}(Layer);
15727
15728OverlayLayer.mergeOptions(options$6);
15729
15730var options$5 = {
15731 'debug': false,
15732 'enableSimplify': true,
15733 'geometryEvents': true,
15734 'defaultIconSize': [20, 20],
15735 'cacheVectorOnCanvas': true,
15736 'cacheSvgOnCanvas': Browser$1.gecko,
15737 'enableAltitude': false,
15738 'altitudeProperty': 'altitude',
15739 'drawAltitude': false
15740};
15741
15742var VectorLayer = function (_OverlayLayer) {
15743 inherits(VectorLayer, _OverlayLayer);
15744
15745 function VectorLayer(id, geometries, options) {
15746 classCallCheck(this, VectorLayer);
15747
15748 var _this = possibleConstructorReturn(this, _OverlayLayer.call(this, id, geometries, options));
15749
15750 var style = _this.options['style'];
15751 delete _this.options['style'];
15752 if (style) {
15753 _this.setStyle(style);
15754 }
15755 return _this;
15756 }
15757
15758 VectorLayer.prototype.getStyle = function getStyle() {
15759 if (!this._style) {
15760 return null;
15761 }
15762 return this._style;
15763 };
15764
15765 VectorLayer.prototype.setStyle = function setStyle(style) {
15766 this._style = style;
15767 this._cookedStyles = compileStyle(style);
15768 this.forEach(function (geometry) {
15769 this._styleGeometry(geometry);
15770 }, this);
15771
15772 this.fire('setstyle', {
15773 'style': style
15774 });
15775 return this;
15776 };
15777
15778 VectorLayer.prototype.removeStyle = function removeStyle() {
15779 if (!this._style) {
15780 return this;
15781 }
15782 delete this._style;
15783 delete this._cookedStyles;
15784 this.forEach(function (geometry) {
15785 geometry._setExternSymbol(null);
15786 }, this);
15787
15788 this.fire('removestyle');
15789 return this;
15790 };
15791
15792 VectorLayer.prototype.onAddGeometry = function onAddGeometry(geo) {
15793 var style = this.getStyle();
15794 if (style) {
15795 this._styleGeometry(geo);
15796 }
15797 };
15798
15799 VectorLayer.prototype.onConfig = function onConfig(conf) {
15800 _OverlayLayer.prototype.onConfig.call(this, conf);
15801 if (conf['enableAltitude'] || conf['drawAltitude'] || conf['altitudeProperty']) {
15802 var renderer = this.getRenderer();
15803 if (renderer && renderer.setToRedraw) {
15804 renderer.setToRedraw();
15805 }
15806 }
15807 };
15808
15809 VectorLayer.prototype._styleGeometry = function _styleGeometry(geometry) {
15810 if (!this._cookedStyles) {
15811 return false;
15812 }
15813 var g = getFilterFeature(geometry);
15814 for (var i = 0, len = this._cookedStyles.length; i < len; i++) {
15815 if (this._cookedStyles[i]['filter'](g) === true) {
15816 geometry._setExternSymbol(this._cookedStyles[i]['symbol']);
15817 return true;
15818 }
15819 }
15820 return false;
15821 };
15822
15823 VectorLayer.prototype.identify = function identify(coordinate) {
15824 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15825
15826 var renderer = this.getRenderer();
15827
15828 if (options['onlyVisible'] && renderer && renderer.identify) {
15829 return renderer.identify(coordinate, options);
15830 }
15831 return _OverlayLayer.prototype.identify.call(this, coordinate, options);
15832 };
15833
15834 VectorLayer.prototype.toJSON = function toJSON(options) {
15835 if (!options) {
15836 options = {};
15837 }
15838 var profile = {
15839 'type': this.getJSONType(),
15840 'id': this.getId(),
15841 'options': this.config()
15842 };
15843 if ((isNil(options['style']) || options['style']) && this.getStyle()) {
15844 profile['style'] = this.getStyle();
15845 }
15846 if (isNil(options['geometries']) || options['geometries']) {
15847 var clipExtent = void 0;
15848 if (options['clipExtent']) {
15849 var map = this.getMap();
15850 var projection = map ? map.getProjection() : null;
15851 clipExtent = new Extent(options['clipExtent'], projection);
15852 }
15853 var geoJSONs = [];
15854 var geometries = this.getGeometries();
15855 for (var i = 0, len = geometries.length; i < len; i++) {
15856 var geo = geometries[i];
15857 var geoExt = geo.getExtent();
15858 if (!geoExt || clipExtent && !clipExtent.intersects(geoExt)) {
15859 continue;
15860 }
15861 var json = geo.toJSON(options['geometries']);
15862 geoJSONs.push(json);
15863 }
15864 profile['geometries'] = geoJSONs;
15865 }
15866 return profile;
15867 };
15868
15869 VectorLayer.fromJSON = function fromJSON(json) {
15870 if (!json || json['type'] !== 'VectorLayer') {
15871 return null;
15872 }
15873 var layer = new VectorLayer(json['id'], json['options']);
15874 var geoJSONs = json['geometries'];
15875 var geometries = [];
15876 for (var i = 0; i < geoJSONs.length; i++) {
15877 var geo = Geometry.fromJSON(geoJSONs[i]);
15878 if (geo) {
15879 geometries.push(geo);
15880 }
15881 }
15882 layer.addGeometry(geometries);
15883 if (json['style']) {
15884 layer.setStyle(json['style']);
15885 }
15886 return layer;
15887 };
15888
15889 return VectorLayer;
15890}(OverlayLayer);
15891
15892VectorLayer.mergeOptions(options$5);
15893
15894VectorLayer.registerJSONType('VectorLayer');
15895
15896var key = '_map_tool';
15897
15898var MapTool = function (_Eventable) {
15899 inherits(MapTool, _Eventable);
15900
15901 function MapTool() {
15902 classCallCheck(this, MapTool);
15903 return possibleConstructorReturn(this, _Eventable.apply(this, arguments));
15904 }
15905
15906 MapTool.prototype.addTo = function addTo(map) {
15907 if (!map) {
15908 return this;
15909 }
15910 this._map = map;
15911
15912 if (map[key]) {
15913 map[key].disable();
15914 }
15915 if (this.onAdd) {
15916 this.onAdd();
15917 }
15918 this.enable();
15919 map[key] = this;
15920
15921 this._fireEvent('add');
15922 return this;
15923 };
15924
15925 MapTool.prototype.getMap = function getMap() {
15926 return this._map;
15927 };
15928
15929 MapTool.prototype.enable = function enable() {
15930 var map = this._map;
15931 if (!map || this._enabled) {
15932 return this;
15933 }
15934 this._enabled = true;
15935 this._switchEvents('off');
15936
15937 this._registerEvents();
15938 if (this.onEnable) {
15939 this.onEnable();
15940 }
15941
15942 this._fireEvent('enable');
15943 return this;
15944 };
15945
15946 MapTool.prototype.disable = function disable() {
15947 if (!this._enabled || !this._map) {
15948 return this;
15949 }
15950 this._enabled = false;
15951 this._switchEvents('off');
15952 if (this.onDisable) {
15953 this.onDisable();
15954 }
15955
15956 this._fireEvent('disable');
15957 return this;
15958 };
15959
15960 MapTool.prototype.isEnabled = function isEnabled() {
15961 if (!this._enabled) {
15962 return false;
15963 }
15964 return true;
15965 };
15966
15967 MapTool.prototype.remove = function remove() {
15968 if (!this._map) {
15969 return this;
15970 }
15971 this.disable();
15972 if (this._map) {
15973 delete this._map[key];
15974 delete this._map;
15975 }
15976
15977 this._fireEvent('remove');
15978 return this;
15979 };
15980
15981 MapTool.prototype._registerEvents = function _registerEvents() {
15982 this._switchEvents('on');
15983 };
15984
15985 MapTool.prototype._switchEvents = function _switchEvents(to) {
15986 var events = this.getEvents();
15987 if (events) {
15988 this._map[to](events, this);
15989 }
15990 };
15991
15992 MapTool.prototype._fireEvent = function _fireEvent(eventName, param) {
15993 if (!param) {
15994 param = {};
15995 }
15996 this.fire(eventName, param);
15997 };
15998
15999 return MapTool;
16000}(Eventable(Class));
16001
16002var options$3 = {
16003 'symbol': {
16004 'lineColor': '#000',
16005 'lineWidth': 2,
16006 'lineOpacity': 1,
16007 'polygonFill': '#fff',
16008 'polygonOpacity': 0.3
16009 },
16010 'doubleClickZoom': false,
16011 'mode': null,
16012 'once': false,
16013 'ignoreMouseleave': true
16014};
16015
16016var registeredMode = {};
16017
16018var DrawTool = function (_MapTool) {
16019 inherits(DrawTool, _MapTool);
16020
16021 DrawTool.registerMode = function registerMode(name, modeAction) {
16022 registeredMode[name.toLowerCase()] = modeAction;
16023 };
16024
16025 DrawTool.getRegisterMode = function getRegisterMode(name) {
16026 return registeredMode[name.toLowerCase()];
16027 };
16028
16029 function DrawTool(options) {
16030 classCallCheck(this, DrawTool);
16031
16032 var _this = possibleConstructorReturn(this, _MapTool.call(this, options));
16033
16034 _this._checkMode();
16035
16036 _this._events = {
16037 'click': _this._firstClickHandler,
16038 'mousemove': _this._mouseMoveHandler,
16039 'dblclick': _this._doubleClickHandler,
16040 'mousedown': _this._mouseDownHandler,
16041 'mouseup': _this._mouseUpHandler
16042 };
16043 return _this;
16044 }
16045
16046 DrawTool.prototype.getMode = function getMode() {
16047 if (this.options['mode']) {
16048 return this.options['mode'].toLowerCase();
16049 }
16050 return null;
16051 };
16052
16053 DrawTool.prototype.setMode = function setMode(mode) {
16054 if (this._geometry) {
16055 this._geometry.remove();
16056 delete this._geometry;
16057 }
16058 this._clearStage();
16059 this._switchEvents('off');
16060 this.options['mode'] = mode;
16061 this._checkMode();
16062 if (this.isEnabled()) {
16063 this._switchEvents('on');
16064 this._restoreMapCfg();
16065 this._saveMapCfg();
16066 }
16067 return this;
16068 };
16069
16070 DrawTool.prototype.getSymbol = function getSymbol() {
16071 var symbol = this.options['symbol'];
16072 if (symbol) {
16073 return extendSymbol(symbol);
16074 } else {
16075 return extendSymbol(this.options['symbol']);
16076 }
16077 };
16078
16079 DrawTool.prototype.setSymbol = function setSymbol(symbol) {
16080 if (!symbol) {
16081 return this;
16082 }
16083 this.options['symbol'] = symbol;
16084 if (this._geometry) {
16085 this._geometry.setSymbol(symbol);
16086 }
16087 return this;
16088 };
16089
16090 DrawTool.prototype.getCurrentGeometry = function getCurrentGeometry() {
16091 return this._geometry;
16092 };
16093
16094 DrawTool.prototype.onAdd = function onAdd() {
16095 this._checkMode();
16096 };
16097
16098 DrawTool.prototype.onEnable = function onEnable() {
16099 this._saveMapCfg();
16100 this._drawToolLayer = this._getDrawLayer();
16101 this._clearStage();
16102 this._loadResources();
16103 return this;
16104 };
16105
16106 DrawTool.prototype.onDisable = function onDisable() {
16107 var map = this.getMap();
16108 this._restoreMapCfg();
16109 this.endDraw();
16110 if (this._map) {
16111 map.removeLayer(this._getDrawLayer());
16112 }
16113 return this;
16114 };
16115
16116 DrawTool.prototype.undo = function undo() {
16117 var registerMode = this._getRegisterMode();
16118 var action = registerMode.action;
16119 if (!this._shouldRecordHistory(action) || !this._historyPointer) {
16120 return this;
16121 }
16122 var coords = this._clickCoords.slice(0, --this._historyPointer);
16123 registerMode.update(coords, this._geometry);
16124 return this;
16125 };
16126
16127 DrawTool.prototype.redo = function redo() {
16128 var registerMode = this._getRegisterMode();
16129 var action = registerMode.action;
16130 if (!this._shouldRecordHistory(action) || isNil(this._historyPointer) || this._historyPointer === this._clickCoords.length) {
16131 return this;
16132 }
16133 var coords = this._clickCoords.slice(0, ++this._historyPointer);
16134 registerMode.update(coords, this._geometry);
16135 return this;
16136 };
16137
16138 DrawTool.prototype._shouldRecordHistory = function _shouldRecordHistory(actions) {
16139 return Array.isArray(actions) && actions[0] === 'click' && actions[1] === 'mousemove' && actions[2] === 'dblclick';
16140 };
16141
16142 DrawTool.prototype._checkMode = function _checkMode() {
16143 this._getRegisterMode();
16144 };
16145
16146 DrawTool.prototype._saveMapCfg = function _saveMapCfg() {
16147 var map = this.getMap();
16148 this._mapDoubleClickZoom = map.options['doubleClickZoom'];
16149 map.config({
16150 'doubleClickZoom': this.options['doubleClickZoom']
16151 });
16152 var actions = this._getRegisterMode()['action'];
16153 if (actions.indexOf('mousedown') > -1) {
16154 var _map = this.getMap();
16155 this._mapDraggable = _map.options['draggable'];
16156 _map.config({
16157 'draggable': false
16158 });
16159 }
16160 };
16161
16162 DrawTool.prototype._restoreMapCfg = function _restoreMapCfg() {
16163 var map = this.getMap();
16164 map.config({
16165 'doubleClickZoom': this._mapDoubleClickZoom
16166 });
16167 if (!isNil(this._mapDraggable)) {
16168 map.config('draggable', this._mapDraggable);
16169 }
16170 delete this._mapDraggable;
16171 delete this._mapDoubleClickZoom;
16172 };
16173
16174 DrawTool.prototype._loadResources = function _loadResources() {
16175 var symbol = this.getSymbol();
16176 var resources = getExternalResources(symbol);
16177 if (resources.length > 0) {
16178 this._drawToolLayer._getRenderer().loadResources(resources);
16179 }
16180 };
16181
16182 DrawTool.prototype._getProjection = function _getProjection() {
16183 return this._map.getProjection();
16184 };
16185
16186 DrawTool.prototype._getRegisterMode = function _getRegisterMode() {
16187 var mode = this.getMode();
16188 var registerMode = DrawTool.getRegisterMode(mode);
16189 if (!registerMode) {
16190 throw new Error(mode + ' is not a valid mode of DrawTool.');
16191 }
16192 return registerMode;
16193 };
16194
16195 DrawTool.prototype.getEvents = function getEvents() {
16196 var action = this._getRegisterMode()['action'];
16197 var _events = {};
16198 if (Array.isArray(action)) {
16199 for (var i = 0; i < action.length; i++) {
16200 _events[action[i]] = this._events[action[i]];
16201 }
16202 return _events;
16203 }
16204 return null;
16205 };
16206
16207 DrawTool.prototype._mouseDownHandler = function _mouseDownHandler(event) {
16208 this._createGeometry(event);
16209 };
16210
16211 DrawTool.prototype._mouseUpHandler = function _mouseUpHandler(event) {
16212 this.endDraw(event);
16213 };
16214
16215 DrawTool.prototype._firstClickHandler = function _firstClickHandler(event) {
16216 var registerMode = this._getRegisterMode();
16217 var coordinate = event['coordinate'];
16218 if (!this._geometry) {
16219 this._createGeometry(event);
16220 } else {
16221 if (!isNil(this._historyPointer)) {
16222 this._clickCoords = this._clickCoords.slice(0, this._historyPointer);
16223 }
16224 this._clickCoords.push(coordinate);
16225 this._historyPointer = this._clickCoords.length;
16226 if (registerMode['clickLimit'] && registerMode['clickLimit'] === this._historyPointer) {
16227 registerMode['update']([coordinate], this._geometry, event);
16228 this.endDraw(event);
16229 } else {
16230 registerMode['update'](this._clickCoords, this._geometry, event);
16231 }
16232
16233 this._fireEvent('drawvertex', event);
16234 }
16235 };
16236
16237 DrawTool.prototype._createGeometry = function _createGeometry(event) {
16238 var mode = this.getMode();
16239 var registerMode = this._getRegisterMode();
16240 var coordinate = event['coordinate'];
16241 var symbol = this.getSymbol();
16242 if (!this._geometry) {
16243 this._clickCoords = [coordinate];
16244 this._geometry = registerMode['create'](this._clickCoords, event);
16245 if (symbol && mode !== 'point') {
16246 this._geometry.setSymbol(symbol);
16247 } else if (this.options.hasOwnProperty('symbol')) {
16248 this._geometry.setSymbol(this.options['symbol']);
16249 }
16250 this._addGeometryToStage(this._geometry);
16251
16252 this._fireEvent('drawstart', event);
16253 }
16254 if (mode === 'point') {
16255 this.endDraw(event);
16256 }
16257 };
16258
16259 DrawTool.prototype._mouseMoveHandler = function _mouseMoveHandler(event) {
16260 var map = this.getMap();
16261 var coordinate = event['coordinate'];
16262 if (!this._geometry || !map || map.isInteracting()) {
16263 return;
16264 }
16265 var containerPoint = this._getMouseContainerPoint(event);
16266 if (!this._isValidContainerPoint(containerPoint)) {
16267 return;
16268 }
16269 var registerMode = this._getRegisterMode();
16270 if (this._shouldRecordHistory(registerMode.action)) {
16271 var path = this._clickCoords.slice(0, this._historyPointer);
16272 if (path && path.length > 0 && coordinate.equals(path[path.length - 1])) {
16273 return;
16274 }
16275 if (!(this._historyPointer === null)) {
16276 this._clickCoords = this._clickCoords.slice(0, this._historyPointer);
16277 }
16278 this._historyPointer = this._clickCoords.length;
16279 registerMode['update'](path.concat([coordinate]), this._geometry, event);
16280 } else {
16281 registerMode['update']([coordinate], this._geometry, event);
16282 }
16283
16284 this._fireEvent('mousemove', event);
16285 };
16286
16287 DrawTool.prototype._doubleClickHandler = function _doubleClickHandler(event) {
16288 if (!this._geometry) {
16289 return;
16290 }
16291 var containerPoint = this._getMouseContainerPoint(event);
16292 if (!this._isValidContainerPoint(containerPoint)) {
16293 return;
16294 }
16295 var registerMode = this._getRegisterMode();
16296 var clickCoords = this._clickCoords;
16297 if (clickCoords.length < 2) {
16298 return;
16299 }
16300
16301 var path = [clickCoords[0]];
16302 for (var i = 1, len = clickCoords.length; i < len; i++) {
16303 if (clickCoords[i].x !== clickCoords[i - 1].x || clickCoords[i].y !== clickCoords[i - 1].y) {
16304 path.push(clickCoords[i]);
16305 }
16306 }
16307 if (path.length < 2 || this._geometry && this._geometry instanceof Polygon && path.length < 3) {
16308 return;
16309 }
16310 registerMode['update'](path, this._geometry, event);
16311 this.endDraw(event);
16312 };
16313
16314 DrawTool.prototype._addGeometryToStage = function _addGeometryToStage(geometry) {
16315 var drawLayer = this._getDrawLayer();
16316 drawLayer.addGeometry(geometry);
16317 };
16318
16319 DrawTool.prototype.endDraw = function endDraw(param) {
16320 if (!this._geometry || this._ending) {
16321 return this;
16322 }
16323 this._ending = true;
16324 var geometry = this._geometry;
16325 this._clearStage();
16326 param = param || {};
16327 this._geometry = geometry;
16328
16329 this._fireEvent('drawend', param);
16330 delete this._geometry;
16331 if (this.options['once']) {
16332 this.disable();
16333 }
16334 delete this._ending;
16335 return this;
16336 };
16337
16338 DrawTool.prototype._clearStage = function _clearStage() {
16339 this._getDrawLayer().clear();
16340 delete this._geometry;
16341 delete this._clickCoords;
16342 };
16343
16344 DrawTool.prototype._getMouseContainerPoint = function _getMouseContainerPoint(event) {
16345 var action = this._getRegisterMode()['action'];
16346 if (action === 'mousedown') {
16347 stopPropagation(event['domEvent']);
16348 }
16349 return event['containerPoint'];
16350 };
16351
16352 DrawTool.prototype._isValidContainerPoint = function _isValidContainerPoint(containerPoint) {
16353 var mapSize = this._map.getSize();
16354 var w = mapSize['width'],
16355 h = mapSize['height'];
16356 if (containerPoint.x < 0 || containerPoint.y < 0) {
16357 return false;
16358 } else if (containerPoint.x > w || containerPoint.y > h) {
16359 return false;
16360 }
16361 return true;
16362 };
16363
16364 DrawTool.prototype._getDrawLayer = function _getDrawLayer() {
16365 var drawLayerId = INTERNAL_LAYER_PREFIX + 'drawtool';
16366 var drawToolLayer = this._map.getLayer(drawLayerId);
16367 if (!drawToolLayer) {
16368 drawToolLayer = new VectorLayer(drawLayerId, {
16369 'enableSimplify': false
16370 });
16371 this._map.addLayer(drawToolLayer);
16372 }
16373 return drawToolLayer;
16374 };
16375
16376 DrawTool.prototype._fireEvent = function _fireEvent(eventName, param) {
16377 if (!param) {
16378 param = {};
16379 }
16380 if (this._geometry) {
16381 param['geometry'] = this._getRegisterMode()['generate'](this._geometry).copy();
16382 }
16383 MapTool.prototype._fireEvent.call(this, eventName, param);
16384 };
16385
16386 return DrawTool;
16387}(MapTool);
16388
16389DrawTool.mergeOptions(options$3);
16390
16391var MapBoxZoomHander = function (_Handler) {
16392 inherits(MapBoxZoomHander, _Handler);
16393
16394 function MapBoxZoomHander(target) {
16395 classCallCheck(this, MapBoxZoomHander);
16396
16397 var _this = possibleConstructorReturn(this, _Handler.call(this, target));
16398
16399 _this.drawTool = new DrawTool({
16400 'mode': 'boxZoom',
16401 'ignoreMouseleave': false
16402 });
16403 return _this;
16404 }
16405
16406 MapBoxZoomHander.prototype.addHooks = function addHooks() {
16407 this.target.on('_mousedown', this._onMouseDown, this);
16408 };
16409
16410 MapBoxZoomHander.prototype.removeHooks = function removeHooks() {
16411 this.target.off('_mousedown', this._onMouseDown, this);
16412 if (this.drawTool.isEnabled()) {
16413 this.drawTool.remove();
16414 }
16415 };
16416
16417 MapBoxZoomHander.prototype._onMouseDown = function _onMouseDown(param) {
16418 if (!this.target.options['boxZoom']) {
16419 return;
16420 }
16421 if (param.domEvent.shiftKey) {
16422 this.drawTool.setSymbol(this.target.options['boxZoomSymbol']).on('drawend', this._boxZoom, this).addTo(this.target);
16423 }
16424 };
16425
16426 MapBoxZoomHander.prototype._boxZoom = function _boxZoom(param) {
16427 var map = this.target;
16428 this.drawTool.remove();
16429 var geometry = param.geometry,
16430 center = geometry.getCenter(),
16431 symbol = geometry.getSymbol(),
16432 w = symbol.markerWidth,
16433 h = symbol.markerHeight;
16434
16435 var extent = new Extent(center, map.locateByPoint(center, w, h), map.getProjection());
16436 var zoom = map.getFitZoom(extent);
16437 map.animateTo({
16438 center: extent.getCenter(),
16439 zoom: zoom
16440 });
16441 };
16442
16443 return MapBoxZoomHander;
16444}(Handler$1);
16445
16446Map.mergeOptions({
16447 'boxZoom': true,
16448 'boxZoomSymbol': {
16449 'markerType': 'rectangle',
16450 'markerLineWidth': 3,
16451 'markerLineColor': '#1bbc9b',
16452 'markerLineDasharray': [10, 5],
16453 'markerFillOpacity': 0.1,
16454 'markerFill': '#1bbc9b',
16455 'markerWidth': 1,
16456 'markerHeight': 1
16457 }
16458});
16459
16460Map.addOnLoadHook('addHandler', 'boxZoom', MapBoxZoomHander);
16461
16462function equalView(view1, view2) {
16463 for (var p in view1) {
16464 if (hasOwn(view1, p)) {
16465 if (p === 'center') {
16466 if (view1[p][0] !== view2[p][0] || view1[p][1] !== view2[p][1]) {
16467 return false;
16468 }
16469 } else if (view1[p] !== view2[p]) {
16470 return false;
16471 }
16472 }
16473 }
16474 return true;
16475}
16476
16477Map.include({
16478 animateTo: function animateTo(view) {
16479 var _this = this;
16480
16481 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16482 var step = arguments[2];
16483
16484 this._stopAnim(this._animPlayer);
16485 if (isFunction(options)) {
16486 step = options;
16487 options = {};
16488 }
16489 var projection = this.getProjection(),
16490 currView = this.getView(),
16491 props = {};
16492 var empty = true;
16493 for (var p in view) {
16494 if (hasOwn(view, p) && !isNil(currView[p])) {
16495 empty = false;
16496 if (p === 'center') {
16497 var from = new Coordinate(currView[p]).toFixed(7),
16498 to = new Coordinate(view[p]).toFixed(7);
16499 if (!from.equals(to)) {
16500 props['center'] = [from, to];
16501 }
16502 } else if (currView[p] !== view[p] && p !== 'around') {
16503 props[p] = [currView[p], view[p]];
16504 }
16505 }
16506 }
16507 if (empty) {
16508 return null;
16509 }
16510 var zoomOrigin = view['around'] || new Point(this.width / 2, this.height / 2);
16511 var preView = this.getView();
16512 var renderer = this._getRenderer(),
16513 framer = function framer(fn) {
16514 renderer.callInNextFrame(fn);
16515 };
16516
16517 var player = this._animPlayer = Animation.animate(props, {
16518 'easing': options['easing'] || 'out',
16519 'duration': options['duration'] || this.options['zoomAnimationDuration'],
16520 'framer': framer
16521 }, function (frame) {
16522 if (_this.isRemoved()) {
16523 player.finish();
16524 return;
16525 }
16526 if (player.playState === 'running') {
16527 var _view = _this.getView();
16528 if (!options['continueOnViewChanged'] && !equalView(_view, preView)) {
16529 _this._stopAnim(player);
16530 return;
16531 }
16532 if (frame.styles['center']) {
16533 var center = frame.styles['center'];
16534 _this._setPrjCenter(projection.project(center));
16535 _this.onMoving(_this._parseEventFromCoord(_this.getCenter()));
16536 }
16537 if (!isNil(frame.styles['zoom'])) {
16538 _this.onZooming(frame.styles['zoom'], zoomOrigin);
16539 }
16540 if (!isNil(frame.styles['pitch'])) {
16541 _this.setPitch(frame.styles['pitch']);
16542 }
16543 if (!isNil(frame.styles['bearing'])) {
16544 _this.setBearing(frame.styles['bearing']);
16545 }
16546 preView = _this.getView();
16547 _this._fireEvent('animating');
16548 } else if (player.playState === 'finished') {
16549 if (!player._interupted) {
16550 if (props['center']) {
16551 _this._setPrjCenter(projection.project(props['center'][1]));
16552 }
16553 if (!isNil(props['pitch'])) {
16554 _this.setPitch(props['pitch'][1]);
16555 }
16556 if (!isNil(props['bearing'])) {
16557 _this.setBearing(props['bearing'][1]);
16558 }
16559 }
16560 _this._endAnim(player, props, zoomOrigin, options);
16561 preView = _this.getView();
16562 }
16563 if (step) {
16564 step(frame);
16565 }
16566 });
16567
16568 this._startAnim(props, zoomOrigin);
16569
16570 return player;
16571 },
16572 isAnimating: function isAnimating() {
16573 return !!this._animPlayer;
16574 },
16575 isRotating: function isRotating() {
16576 return this.isDragRotating() || !!this._animRotating;
16577 },
16578 _endAnim: function _endAnim(player, props, zoomOrigin, options) {
16579 delete this._animRotating;
16580 var evtType = player._interupted ? 'animateinterupted' : 'animateend';
16581 if (player === this._animPlayer) {
16582 delete this._animPlayer;
16583 }
16584 if (props['center']) {
16585 var endCoord = void 0;
16586 if (player._interupted) {
16587 endCoord = this.getCenter();
16588 } else {
16589 endCoord = props['center'][1];
16590 }
16591 this.onMoveEnd(this._parseEventFromCoord(endCoord));
16592 }
16593 if (!isNil(props['zoom'])) {
16594 if (player._interupted) {
16595 this.onZoomEnd(this.getZoom(), zoomOrigin);
16596 } else if (!options['wheelZoom']) {
16597 this.onZoomEnd(props['zoom'][1], zoomOrigin);
16598 } else {
16599 this.onZooming(props['zoom'][1], zoomOrigin);
16600 }
16601 }
16602 if (evtType) {
16603 this._fireEvent(evtType);
16604 }
16605 },
16606 _startAnim: function _startAnim(props, zoomOrigin) {
16607 if (!this._animPlayer) {
16608 return;
16609 }
16610 if (props['center']) {
16611 this.onMoveStart();
16612 }
16613 if (props['zoom'] && !this.isZooming()) {
16614 this.onZoomStart(props['zoom'][1], zoomOrigin);
16615 }
16616 if (props['pitch'] || props['bearing']) {
16617 this._animRotating = true;
16618 }
16619 this._fireEvent('animatestart');
16620 this._animPlayer.play();
16621 },
16622 _stopAnim: function _stopAnim(player) {
16623 if (player && player.playState !== 'finished') {
16624 player._interupted = true;
16625 player.finish();
16626 }
16627 }
16628});
16629
16630var events = 'mousedown ' + 'mouseup ' + 'mouseover ' + 'mouseout ' + 'mouseenter ' + 'mouseleave ' + 'mousemove ' + 'click ' + 'dblclick ' + 'contextmenu ' + 'keypress ' + 'touchstart ' + 'touchmove ' + 'touchend ';
16631
16632Map.include({
16633 _registerDomEvents: function _registerDomEvents() {
16634 var dom = this._panels.mapWrapper || this._containerDOM;
16635 addDomEvent(dom, events, this._handleDOMEvent, this);
16636 },
16637 _removeDomEvents: function _removeDomEvents() {
16638 var dom = this._panels.mapWrapper || this._containerDOM;
16639 removeDomEvent(dom, events, this._handleDOMEvent, this);
16640 },
16641 _handleDOMEvent: function _handleDOMEvent(e) {
16642 var type = e.type;
16643
16644 if (type === 'contextmenu') {
16645 preventDefault(e);
16646 }
16647 if (this._ignoreEvent(e)) {
16648 return;
16649 }
16650 var mimicClick = false;
16651
16652 if (type === 'mousedown' || type === 'touchstart' && e.touches.length === 1) {
16653 this._mouseDownTime = now();
16654 } else if (type === 'click' || type === 'touchend' || type === 'contextmenu') {
16655 if (!this._mouseDownTime) {
16656 return;
16657 } else {
16658 var downTime = this._mouseDownTime;
16659 delete this._mouseDownTime;
16660 var time = now();
16661 if (time - downTime > 300) {
16662 if (type === 'click' || type === 'contextmenu') {
16663 return;
16664 }
16665 } else if (type === 'touchend') {
16666 mimicClick = true;
16667 }
16668 }
16669 }
16670 this._fireDOMEvent(this, e, type);
16671 if (mimicClick) {
16672 if (this._clickTime && now() - this._clickTime <= 300) {
16673 delete this._clickTime;
16674 this._fireDOMEvent(this, e, 'dblclick');
16675 } else {
16676 this._clickTime = now();
16677 this._fireDOMEvent(this, e, 'click');
16678 }
16679 }
16680 },
16681 _ignoreEvent: function _ignoreEvent(domEvent) {
16682 if (!domEvent || !this._panels.control) {
16683 return false;
16684 }
16685 if (this._isEventOutMap(domEvent)) {
16686 return true;
16687 }
16688 var target = domEvent.srcElement || domEvent.target;
16689 var preTarget = void 0;
16690 if (target) {
16691 while (target && target !== this._containerDOM) {
16692 if (target.className && target.className.indexOf && (target.className.indexOf('maptalks-control') >= 0 || target.className.indexOf('maptalks-ui') >= 0 && !preTarget['eventsPropagation'])) {
16693 return true;
16694 }
16695 preTarget = target;
16696 target = target.parentNode;
16697 }
16698 }
16699 return false;
16700 },
16701 _isEventOutMap: function _isEventOutMap(domEvent) {
16702 if (this.getPitch() > this.options['maxVisualPitch']) {
16703 var actualEvent = this._getActualEvent(domEvent);
16704 var eventPos = getEventContainerPoint(actualEvent, this._containerDOM);
16705 if (!this.getContainerExtent().contains(eventPos)) {
16706 return true;
16707 }
16708 }
16709 return false;
16710 },
16711 _parseEvent: function _parseEvent(e, type) {
16712 if (!e) {
16713 return null;
16714 }
16715 var eventParam = {
16716 'domEvent': e
16717 };
16718 if (type !== 'keypress') {
16719 var actual = this._getActualEvent(e);
16720 if (actual) {
16721 var containerPoint = getEventContainerPoint(actual, this._containerDOM);
16722 eventParam = extend(eventParam, {
16723 'coordinate': this.containerPointToCoord(containerPoint),
16724 'containerPoint': containerPoint,
16725 'viewPoint': this.containerPointToViewPoint(containerPoint),
16726 'point2d': this._containerPointToPoint(containerPoint)
16727 });
16728 }
16729 }
16730 return eventParam;
16731 },
16732 _parseEventFromCoord: function _parseEventFromCoord(coord) {
16733 var containerPoint = this.coordToContainerPoint(coord),
16734 viewPoint = this.containerPointToViewPoint(containerPoint);
16735 var e = {
16736 'coordinate': coord,
16737 'containerPoint': containerPoint,
16738 'viewPoint': viewPoint,
16739 'point2d': this.coordToPoint(coord)
16740 };
16741 return e;
16742 },
16743 _getActualEvent: function _getActualEvent(e) {
16744 return e.touches && e.touches.length > 0 ? e.touches[0] : e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches[0] : e;
16745 },
16746 _fireDOMEvent: function _fireDOMEvent(target, e, type) {
16747 if (this.isRemoved()) {
16748 return;
16749 }
16750 var eventParam = this._parseEvent(e, type);
16751 this._fireEvent(type, eventParam);
16752 }
16753});
16754
16755Map.addOnLoadHook('_registerDomEvents');
16756
16757Map.include({
16758 isFullScreen: function isFullScreen() {
16759 return !!(document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement);
16760 },
16761 requestFullScreen: function requestFullScreen(dom) {
16762 this._fireEvent('fullscreenstart');
16763 this._requestFullScreen(dom || this._containerDOM);
16764
16765 this._fireEvent('fullscreenend');
16766 return this;
16767 },
16768 cancelFullScreen: function cancelFullScreen() {
16769 this._cancelFullScreen();
16770
16771 this._fireEvent('cancelfullscreen');
16772 return this;
16773 },
16774 _requestFullScreen: function _requestFullScreen(dom) {
16775 if (dom.requestFullScreen) {
16776 dom.requestFullScreen();
16777 } else if (dom.mozRequestFullScreen) {
16778 dom.mozRequestFullScreen();
16779 } else if (dom.webkitRequestFullScreen) {
16780 dom.webkitRequestFullScreen();
16781 } else if (dom.msRequestFullScreen) {
16782 dom.msRequestFullScreen();
16783 } else {
16784 var features = 'fullscreen=1,status=no,resizable=yes,top=0,left=0,scrollbars=no,' + 'titlebar=no,menubar=no,location=no,toolbar=no,z-look=yes,' + 'width=' + (screen.availWidth - 8) + ',height=' + (screen.availHeight - 45);
16785 var newWin = window.open(location.href, '_blank', features);
16786 if (newWin !== null) {
16787 window.opener = null;
16788
16789 window.close();
16790 }
16791 }
16792 },
16793 _cancelFullScreen: function _cancelFullScreen() {
16794 if (document.cancelFullScreen) {
16795 document.cancelFullScreen();
16796 } else if (document.mozCancelFullScreen) {
16797 document.mozCancelFullScreen();
16798 } else if (document.webkitCancelFullScreen) {
16799 document.webkitCancelFullScreen();
16800 } else {
16801 var features = 'fullscreen=no,status=yes,resizable=yes,scrollbars=no,' + 'titlebar=no,menubar=yes,location=yes,toolbar=yes,z-look=yes';
16802 var newWin = window.open(location.href, '_blank', features);
16803 if (newWin !== null) {
16804 window.opener = null;
16805
16806 window.close();
16807 }
16808 }
16809 }
16810});
16811
16812Map.include({
16813 panTo: function panTo(coordinate) {
16814 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16815 var step = arguments[2];
16816
16817 if (!coordinate) {
16818 return this;
16819 }
16820 if (isFunction(options)) {
16821 step = options;
16822 options = {};
16823 }
16824 coordinate = new Coordinate(coordinate);
16825 if (typeof options['animation'] === 'undefined' || options['animation']) {
16826 return this._panAnimation(coordinate, options['duration'], step);
16827 } else {
16828 this.setCenter(coordinate);
16829 return this;
16830 }
16831 },
16832
16833 panBy: function panBy(offset) {
16834 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16835 var step = arguments[2];
16836
16837 if (!offset) {
16838 return this;
16839 }
16840 if (isFunction(options)) {
16841 step = options;
16842 options = {};
16843 }
16844 offset = new Point(offset).multi(-1);
16845 this.onMoveStart();
16846 if (typeof options['animation'] === 'undefined' || options['animation']) {
16847 var target = this.locateByPoint(this.getCenter(), offset.x, offset.y);
16848 this._panAnimation(target, options['duration'], step);
16849 } else {
16850 this._offsetCenterByPixel(offset);
16851 this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));
16852 }
16853 return this;
16854 },
16855
16856 _panAnimation: function _panAnimation(target, t, cb) {
16857 return this.animateTo({
16858 'center': target
16859 }, {
16860 'duration': t || this.options['panAnimationDuration']
16861 }, cb);
16862 }
16863});
16864
16865Geometry.fromJSON = function (json) {
16866 if (Array.isArray(json)) {
16867 var result = [];
16868 for (var i = 0, len = json.length; i < len; i++) {
16869 var c = Geometry.fromJSON(json[i]);
16870 if (Array.isArray(json)) {
16871 result = result.concat(c);
16872 } else {
16873 result.push(c);
16874 }
16875 }
16876 return result;
16877 }
16878
16879 if (json && !json['feature']) {
16880 return GeoJSON.toGeometry(json);
16881 }
16882 var geometry = void 0;
16883 if (json['subType']) {
16884 geometry = Geometry.getJSONClass(json['subType']).fromJSON(json);
16885 if (!isNil(json['feature']['id'])) {
16886 geometry.setId(json['feature']['id']);
16887 }
16888 } else {
16889 geometry = GeoJSON.toGeometry(json['feature']);
16890 if (json['options']) {
16891 geometry.config(json['options']);
16892 }
16893 }
16894 if (json['symbol']) {
16895 geometry.setSymbol(json['symbol']);
16896 }
16897 if (json['infoWindow']) {
16898 geometry.setInfoWindow(json['infoWindow']);
16899 }
16900 return geometry;
16901};
16902
16903Layer.fromJSON = function (layerJSON) {
16904 if (!layerJSON) {
16905 return null;
16906 }
16907 var layerType = layerJSON['type'];
16908 var clazz = Layer.getJSONClass(layerType);
16909 if (!clazz || !clazz.fromJSON) {
16910 throw new Error('unsupported layer type:' + layerType);
16911 }
16912 return clazz.fromJSON(layerJSON);
16913};
16914
16915Map.include({
16916 'JSON_VERSION': '1.0',
16917
16918 toJSON: function toJSON(options) {
16919 if (!options) {
16920 options = {};
16921 }
16922 var json = {
16923 'version': this['JSON_VERSION'],
16924 'extent': this.getExtent().toJSON()
16925 };
16926 json['options'] = this.config();
16927 json['options']['center'] = this.getCenter();
16928 json['options']['zoom'] = this.getZoom();
16929
16930 var baseLayer = this.getBaseLayer();
16931 if ((isNil(options['baseLayer']) || options['baseLayer']) && baseLayer) {
16932 json['baseLayer'] = baseLayer.toJSON(options['baseLayer']);
16933 }
16934 var extraLayerOptions = {};
16935 if (options['clipExtent']) {
16936 if (options['clipExtent'] === true) {
16937 extraLayerOptions['clipExtent'] = this.getExtent();
16938 } else {
16939 extraLayerOptions['clipExtent'] = options['clipExtent'];
16940 }
16941 }
16942 var layersJSON = [];
16943 if (isNil(options['layers']) || options['layers'] && !Array.isArray(options['layers'])) {
16944 var layers = this.getLayers();
16945 for (var i = 0, len = layers.length; i < len; i++) {
16946 if (!layers[i].toJSON) {
16947 continue;
16948 }
16949 var opts = extend({}, isObject(options['layers']) ? options['layers'] : {}, extraLayerOptions);
16950 layersJSON.push(layers[i].toJSON(opts));
16951 }
16952 json['layers'] = layersJSON;
16953 } else if (isArrayHasData(options['layers'])) {
16954 var _layers = options['layers'];
16955 for (var _i = 0; _i < _layers.length; _i++) {
16956 var exportOption = _layers[_i];
16957 var layer = this.getLayer(exportOption['id']);
16958 if (!layer.toJSON) {
16959 continue;
16960 }
16961 var _opts = extend({}, exportOption['options'], extraLayerOptions);
16962 layersJSON.push(layer.toJSON(_opts));
16963 }
16964 json['layers'] = layersJSON;
16965 } else {
16966 json['layers'] = [];
16967 }
16968 return json;
16969 }
16970});
16971
16972Map.fromJSON = function (container, profile, options) {
16973 if (!container || !profile) {
16974 return null;
16975 }
16976 if (!options) {
16977 options = {};
16978 }
16979 var map = new Map(container, profile['options']);
16980 if (isNil(options['baseLayer']) || options['baseLayer']) {
16981 var baseLayer = Layer.fromJSON(profile['baseLayer']);
16982 if (baseLayer) {
16983 map.setBaseLayer(baseLayer);
16984 }
16985 }
16986 if (isNil(options['layers']) || options['layers']) {
16987 var layers = [];
16988 var layerJSONs = profile['layers'];
16989 for (var i = 0; i < layerJSONs.length; i++) {
16990 var layer = Layer.fromJSON(layerJSONs[i]);
16991 layers.push(layer);
16992 }
16993 map.addLayer(layers);
16994 }
16995
16996 return map;
16997};
16998
16999Map.include({
17000 computeLength: function computeLength(coord1, coord2) {
17001 if (!this.getProjection()) {
17002 return null;
17003 }
17004 var p1 = new Coordinate(coord1),
17005 p2 = new Coordinate(coord2);
17006 if (p1.equals(p2)) {
17007 return 0;
17008 }
17009 return this.getProjection().measureLength(p1, p2);
17010 },
17011
17012 computeGeometryLength: function computeGeometryLength(geometry) {
17013 return geometry._computeGeodesicLength(this.getProjection());
17014 },
17015
17016 computeGeometryArea: function computeGeometryArea(geometry) {
17017 return geometry._computeGeodesicArea(this.getProjection());
17018 },
17019
17020 identify: function identify(opts, callback) {
17021 if (!opts) {
17022 return this;
17023 }
17024 var reqLayers = opts['layers'];
17025 if (!isArrayHasData(reqLayers)) {
17026 return this;
17027 }
17028 var layers = [];
17029 for (var i = 0, len = reqLayers.length; i < len; i++) {
17030 if (isString(reqLayers[i])) {
17031 layers.push(this.getLayer(reqLayers[i]));
17032 } else {
17033 layers.push(reqLayers[i]);
17034 }
17035 }
17036 var coordinate = new Coordinate(opts['coordinate']);
17037 var options = extend({}, opts);
17038 var hits = [];
17039 for (var _i = layers.length - 1; _i >= 0; _i--) {
17040 if (opts['count'] && hits.length >= opts['count']) {
17041 break;
17042 }
17043 var layer = layers[_i];
17044 if (!layer || !layer.getMap() || !opts['includeInvisible'] && !layer.isVisible() || !opts['includeInternals'] && layer.getId().indexOf(INTERNAL_LAYER_PREFIX) >= 0) {
17045 continue;
17046 }
17047 var layerHits = layer.identify(coordinate, options);
17048 if (layerHits) {
17049 if (Array.isArray(layerHits)) {
17050 pushIn(hits, layerHits);
17051 } else {
17052 hits.push(layerHits);
17053 }
17054 }
17055 }
17056 callback.call(this, hits);
17057 return this;
17058 }
17059
17060});
17061
17062Map.include({
17063 _zoom: function _zoom(nextZoom, origin) {
17064 if (!this.options['zoomable'] || this.isZooming()) {
17065 return;
17066 }
17067 origin = this._checkZoomOrigin(origin);
17068 nextZoom = this._checkZoom(nextZoom);
17069 this.onZoomStart(nextZoom, origin);
17070 this._frameZoom = this.getZoom();
17071 this.onZoomEnd(nextZoom, origin);
17072 },
17073 _zoomAnimation: function _zoomAnimation(nextZoom, origin, startScale) {
17074 if (!this.options['zoomable'] || this.isZooming()) {
17075 return;
17076 }
17077
17078 nextZoom = this._checkZoom(nextZoom);
17079 if (this.getZoom() === nextZoom) {
17080 return;
17081 }
17082 origin = this._checkZoomOrigin(origin);
17083 this._startZoomAnim(nextZoom, origin, startScale);
17084 },
17085 _checkZoomOrigin: function _checkZoomOrigin(origin) {
17086 if (!origin || this.options['zoomInCenter']) {
17087 origin = new Point(this.width / 2, this.height / 2);
17088 }
17089 return origin;
17090 },
17091 _startZoomAnim: function _startZoomAnim(nextZoom, origin, startScale) {
17092 if (isNil(startScale)) {
17093 startScale = 1;
17094 }
17095 var endScale = this._getResolution(this._startZoomVal) / this._getResolution(nextZoom);
17096 var duration = this.options['zoomAnimationDuration'] * Math.abs(endScale - startScale) / Math.abs(endScale - 1);
17097 this._frameZoom = this._startZoomVal;
17098 this.animateTo({
17099 'zoom': nextZoom,
17100 'around': origin
17101 }, {
17102 'continueOnViewChanged': true,
17103 'duration': duration
17104 });
17105 },
17106 onZoomStart: function onZoomStart(nextZoom, origin) {
17107 if (!this.options['zoomable'] || this.isZooming()) {
17108 return;
17109 }
17110 this._zooming = true;
17111 this._startZoomVal = this.getZoom();
17112 this._startZoomCoord = this._containerPointToPrj(origin);
17113
17114 this._fireEvent('zoomstart', { 'from': this._startZoomVal, 'to': nextZoom });
17115 },
17116 onZooming: function onZooming(nextZoom, origin, startScale) {
17117 if (!this.options['zoomable']) {
17118 return;
17119 }
17120 var frameZoom = this._frameZoom;
17121 if (frameZoom === nextZoom) {
17122 return;
17123 }
17124 if (isNil(startScale)) {
17125 startScale = 1;
17126 }
17127 this._zoomTo(nextZoom, origin);
17128 var res = this.getResolution(nextZoom),
17129 fromRes = this.getResolution(this._startZoomVal),
17130 scale = fromRes / res / startScale,
17131 startPoint = this._prjToContainerPoint(this._startZoomCoord, this._startZoomVal);
17132 var offset = this.getViewPoint();
17133 if (!this.isRotating() && !startPoint.equals(origin) && scale !== 1) {
17134 var pitch = this.getPitch();
17135
17136 var originOffset = startPoint._sub(origin)._multi(1 / (1 - scale));
17137 if (pitch) {
17138 originOffset.y /= Math.cos(pitch * Math.PI / 180);
17139 }
17140 origin = origin.add(originOffset);
17141 }
17142 var matrix = {
17143 'view': [scale, 0, 0, scale, (origin.x - offset.x) * (1 - scale), (origin.y - offset.y) * (1 - scale)]
17144 };
17145 if (Browser$1.retina) {
17146 origin = origin.multi(2);
17147 }
17148 matrix['container'] = [scale, 0, 0, scale, origin.x * (1 - scale), origin.y * (1 - scale)];
17149
17150 this._fireEvent('zooming', { 'from': this._startZoomVal, 'to': nextZoom, 'origin': origin, 'matrix': matrix });
17151 this._frameZoom = nextZoom;
17152 },
17153 onZoomEnd: function onZoomEnd(nextZoom, origin) {
17154 if (!this.options['zoomable']) {
17155 return;
17156 }
17157 var startZoomVal = this._startZoomVal;
17158 this._zoomTo(nextZoom, origin);
17159 this._zooming = false;
17160 this._getRenderer().onZoomEnd();
17161
17162 this._fireEvent('zoomend', { 'from': startZoomVal, 'to': nextZoom });
17163 if (!this._verifyExtent(this.getCenter())) {
17164 this.panTo(this.getMaxExtent().getCenter());
17165 }
17166 },
17167 _zoomTo: function _zoomTo(nextZoom, origin) {
17168 this._zoomLevel = nextZoom;
17169 this._calcMatrices();
17170 if (origin) {
17171 this._setPrjCoordAtContainerPoint(this._startZoomCoord, origin);
17172 }
17173 },
17174 _checkZoom: function _checkZoom(nextZoom) {
17175 var maxZoom = this.getMaxZoom(),
17176 minZoom = this.getMinZoom();
17177 if (nextZoom < minZoom) {
17178 nextZoom = minZoom;
17179 }
17180 if (nextZoom > maxZoom) {
17181 nextZoom = maxZoom;
17182 }
17183 return nextZoom;
17184 }
17185});
17186
17187function perspective(out, fovy, aspect, near, far) {
17188 var f = 1.0 / Math.tan(fovy / 2),
17189 nf = 1 / (near - far);
17190 out[0] = f / aspect;
17191 out[1] = 0;
17192 out[2] = 0;
17193 out[3] = 0;
17194 out[4] = 0;
17195 out[5] = f;
17196 out[6] = 0;
17197 out[7] = 0;
17198 out[8] = 0;
17199 out[9] = 0;
17200 out[10] = (far + near) * nf;
17201 out[11] = -1;
17202 out[12] = 0;
17203 out[13] = 0;
17204 out[14] = 2 * far * near * nf;
17205 out[15] = 0;
17206 return out;
17207}
17208
17209function translate(out, a, v) {
17210 var x = v[0],
17211 y = v[1],
17212 z = v[2],
17213 a00,
17214 a01,
17215 a02,
17216 a03,
17217 a10,
17218 a11,
17219 a12,
17220 a13,
17221 a20,
17222 a21,
17223 a22,
17224 a23;
17225
17226 if (a === out) {
17227 out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
17228 out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
17229 out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
17230 out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
17231 } else {
17232 a00 = a[0];a01 = a[1];a02 = a[2];a03 = a[3];
17233 a10 = a[4];a11 = a[5];a12 = a[6];a13 = a[7];
17234 a20 = a[8];a21 = a[9];a22 = a[10];a23 = a[11];
17235
17236 out[0] = a00;out[1] = a01;out[2] = a02;out[3] = a03;
17237 out[4] = a10;out[5] = a11;out[6] = a12;out[7] = a13;
17238 out[8] = a20;out[9] = a21;out[10] = a22;out[11] = a23;
17239
17240 out[12] = a00 * x + a10 * y + a20 * z + a[12];
17241 out[13] = a01 * x + a11 * y + a21 * z + a[13];
17242 out[14] = a02 * x + a12 * y + a22 * z + a[14];
17243 out[15] = a03 * x + a13 * y + a23 * z + a[15];
17244 }
17245
17246 return out;
17247}
17248
17249function scale(out, a, v) {
17250 var x = v[0],
17251 y = v[1],
17252 z = v[2];
17253
17254 out[0] = a[0] * x;
17255 out[1] = a[1] * x;
17256 out[2] = a[2] * x;
17257 out[3] = a[3] * x;
17258 out[4] = a[4] * y;
17259 out[5] = a[5] * y;
17260 out[6] = a[6] * y;
17261 out[7] = a[7] * y;
17262 out[8] = a[8] * z;
17263 out[9] = a[9] * z;
17264 out[10] = a[10] * z;
17265 out[11] = a[11] * z;
17266 out[12] = a[12];
17267 out[13] = a[13];
17268 out[14] = a[14];
17269 out[15] = a[15];
17270 return out;
17271}
17272
17273function rotateX(out, a, rad) {
17274 var s = Math.sin(rad),
17275 c = Math.cos(rad),
17276 a10 = a[4],
17277 a11 = a[5],
17278 a12 = a[6],
17279 a13 = a[7],
17280 a20 = a[8],
17281 a21 = a[9],
17282 a22 = a[10],
17283 a23 = a[11];
17284
17285 if (a !== out) {
17286 out[0] = a[0];
17287 out[1] = a[1];
17288 out[2] = a[2];
17289 out[3] = a[3];
17290 out[12] = a[12];
17291 out[13] = a[13];
17292 out[14] = a[14];
17293 out[15] = a[15];
17294 }
17295
17296 out[4] = a10 * c + a20 * s;
17297 out[5] = a11 * c + a21 * s;
17298 out[6] = a12 * c + a22 * s;
17299 out[7] = a13 * c + a23 * s;
17300 out[8] = a20 * c - a10 * s;
17301 out[9] = a21 * c - a11 * s;
17302 out[10] = a22 * c - a12 * s;
17303 out[11] = a23 * c - a13 * s;
17304 return out;
17305}
17306
17307function rotateZ(out, a, rad) {
17308 var s = Math.sin(rad),
17309 c = Math.cos(rad),
17310 a00 = a[0],
17311 a01 = a[1],
17312 a02 = a[2],
17313 a03 = a[3],
17314 a10 = a[4],
17315 a11 = a[5],
17316 a12 = a[6],
17317 a13 = a[7];
17318
17319 if (a !== out) {
17320 out[8] = a[8];
17321 out[9] = a[9];
17322 out[10] = a[10];
17323 out[11] = a[11];
17324 out[12] = a[12];
17325 out[13] = a[13];
17326 out[14] = a[14];
17327 out[15] = a[15];
17328 }
17329
17330 out[0] = a00 * c + a10 * s;
17331 out[1] = a01 * c + a11 * s;
17332 out[2] = a02 * c + a12 * s;
17333 out[3] = a03 * c + a13 * s;
17334 out[4] = a10 * c - a00 * s;
17335 out[5] = a11 * c - a01 * s;
17336 out[6] = a12 * c - a02 * s;
17337 out[7] = a13 * c - a03 * s;
17338 return out;
17339}
17340
17341function multiply(out, a, b) {
17342 var a00 = a[0],
17343 a01 = a[1],
17344 a02 = a[2],
17345 a03 = a[3],
17346 a10 = a[4],
17347 a11 = a[5],
17348 a12 = a[6],
17349 a13 = a[7],
17350 a20 = a[8],
17351 a21 = a[9],
17352 a22 = a[10],
17353 a23 = a[11],
17354 a30 = a[12],
17355 a31 = a[13],
17356 a32 = a[14],
17357 a33 = a[15];
17358
17359 var b0 = b[0],
17360 b1 = b[1],
17361 b2 = b[2],
17362 b3 = b[3];
17363 out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
17364 out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
17365 out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
17366 out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
17367
17368 b0 = b[4];b1 = b[5];b2 = b[6];b3 = b[7];
17369 out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
17370 out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
17371 out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
17372 out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
17373
17374 b0 = b[8];b1 = b[9];b2 = b[10];b3 = b[11];
17375 out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
17376 out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
17377 out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
17378 out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
17379
17380 b0 = b[12];b1 = b[13];b2 = b[14];b3 = b[15];
17381 out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
17382 out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
17383 out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
17384 out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
17385 return out;
17386}
17387
17388function invert(out, a) {
17389 var a00 = a[0],
17390 a01 = a[1],
17391 a02 = a[2],
17392 a03 = a[3],
17393 a10 = a[4],
17394 a11 = a[5],
17395 a12 = a[6],
17396 a13 = a[7],
17397 a20 = a[8],
17398 a21 = a[9],
17399 a22 = a[10],
17400 a23 = a[11],
17401 a30 = a[12],
17402 a31 = a[13],
17403 a32 = a[14],
17404 a33 = a[15],
17405 b00 = a00 * a11 - a01 * a10,
17406 b01 = a00 * a12 - a02 * a10,
17407 b02 = a00 * a13 - a03 * a10,
17408 b03 = a01 * a12 - a02 * a11,
17409 b04 = a01 * a13 - a03 * a11,
17410 b05 = a02 * a13 - a03 * a12,
17411 b06 = a20 * a31 - a21 * a30,
17412 b07 = a20 * a32 - a22 * a30,
17413 b08 = a20 * a33 - a23 * a30,
17414 b09 = a21 * a32 - a22 * a31,
17415 b10 = a21 * a33 - a23 * a31,
17416 b11 = a22 * a33 - a23 * a32,
17417 det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
17418
17419 if (!det) {
17420 return null;
17421 }
17422 det = 1.0 / det;
17423
17424 out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
17425 out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
17426 out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
17427 out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
17428 out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
17429 out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
17430 out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
17431 out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
17432 out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
17433 out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
17434 out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
17435 out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
17436 out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
17437 out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
17438 out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
17439 out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
17440
17441 return out;
17442}
17443
17444function identity(out) {
17445 out[0] = 1;
17446 out[1] = 0;
17447 out[2] = 0;
17448 out[3] = 0;
17449 out[4] = 0;
17450 out[5] = 1;
17451 out[6] = 0;
17452 out[7] = 0;
17453 out[8] = 0;
17454 out[9] = 0;
17455 out[10] = 1;
17456 out[11] = 0;
17457 out[12] = 0;
17458 out[13] = 0;
17459 out[14] = 0;
17460 out[15] = 1;
17461 return out;
17462}
17463
17464function set$2(out, x, y, z) {
17465 out[0] = x;
17466 out[1] = y;
17467 out[2] = z;
17468 return out;
17469}
17470
17471function add(out, a, b) {
17472 out[0] = a[0] + b[0];
17473 out[1] = a[1] + b[1];
17474 out[2] = a[2] + b[2];
17475 return out;
17476}
17477
17478function subtract(out, a, b) {
17479 out[0] = a[0] - b[0];
17480 out[1] = a[1] - b[1];
17481 out[2] = a[2] - b[2];
17482 return out;
17483}
17484
17485function length(a) {
17486 var x = a[0],
17487 y = a[1],
17488 z = a[2];
17489 return Math.sqrt(x * x + y * y + z * z);
17490}
17491
17492function normalize(out, a) {
17493 var x = a[0],
17494 y = a[1],
17495 z = a[2];
17496 var len = x * x + y * y + z * z;
17497 if (len > 0) {
17498 len = 1 / Math.sqrt(len);
17499 out[0] = a[0] * len;
17500 out[1] = a[1] * len;
17501 out[2] = a[2] * len;
17502 }
17503 return out;
17504}
17505
17506function dot(a, b) {
17507 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
17508}
17509
17510function scale$1(out, a, b) {
17511 out[0] = a[0] * b;
17512 out[1] = a[1] * b;
17513 out[2] = a[2] * b;
17514 return out;
17515}
17516
17517function cross(out, a, b) {
17518 var ax = a[0],
17519 ay = a[1],
17520 az = a[2],
17521 bx = b[0],
17522 by = b[1],
17523 bz = b[2];
17524
17525 out[0] = ay * bz - az * by;
17526 out[1] = az * bx - ax * bz;
17527 out[2] = ax * by - ay * bx;
17528 return out;
17529}
17530
17531function applyMatrix(out, v, e) {
17532 var x = v[0],
17533 y = v[1],
17534 z = v[2];
17535
17536
17537 var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
17538
17539 out[0] = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
17540 out[1] = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
17541 out[2] = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
17542
17543 return out;
17544}
17545
17546
17547
17548function matrixToQuaternion(out, te) {
17549
17550 var m11 = te[0],
17551 m12 = te[4],
17552 m13 = te[8],
17553 m21 = te[1],
17554 m22 = te[5],
17555 m23 = te[9],
17556 m31 = te[2],
17557 m32 = te[6],
17558 m33 = te[10],
17559 trace = m11 + m22 + m33;
17560 var s = void 0;
17561
17562 if (trace > 0) {
17563
17564 s = 0.5 / Math.sqrt(trace + 1.0);
17565
17566 out.w = 0.25 / s;
17567 out.x = (m32 - m23) * s;
17568 out.y = (m13 - m31) * s;
17569 out.z = (m21 - m12) * s;
17570 } else if (m11 > m22 && m11 > m33) {
17571
17572 s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
17573
17574 out.w = (m32 - m23) / s;
17575 out.x = 0.25 * s;
17576 out.y = (m12 + m21) / s;
17577 out.z = (m13 + m31) / s;
17578 } else if (m22 > m33) {
17579
17580 s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
17581
17582 out.w = (m13 - m31) / s;
17583 out.x = (m12 + m21) / s;
17584 out.y = 0.25 * s;
17585 out.z = (m23 + m32) / s;
17586 } else {
17587
17588 s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
17589
17590 out.w = (m21 - m12) / s;
17591 out.x = (m13 + m31) / s;
17592 out.y = (m23 + m32) / s;
17593 out.z = 0.25 * s;
17594 }
17595
17596 return this;
17597}
17598
17599function quaternionToMatrix(out, q) {
17600 var te = out;
17601
17602 var x = q.x,
17603 y = q.y,
17604 z = q.z,
17605 w = q.w;
17606 var x2 = x + x,
17607 y2 = y + y,
17608 z2 = z + z;
17609 var xx = x * x2,
17610 xy = x * y2,
17611 xz = x * z2;
17612 var yy = y * y2,
17613 yz = y * z2,
17614 zz = z * z2;
17615 var wx = w * x2,
17616 wy = w * y2,
17617 wz = w * z2;
17618
17619 te[0] = 1 - (yy + zz);
17620 te[4] = xy - wz;
17621 te[8] = xz + wy;
17622
17623 te[1] = xy + wz;
17624 te[5] = 1 - (xx + zz);
17625 te[9] = yz - wx;
17626
17627 te[2] = xz - wy;
17628 te[6] = yz + wx;
17629 te[10] = 1 - (xx + yy);
17630
17631 te[3] = 0;
17632 te[7] = 0;
17633 te[11] = 0;
17634
17635 te[12] = 0;
17636 te[13] = 0;
17637 te[14] = 0;
17638 te[15] = 1;
17639
17640 return te;
17641}
17642
17643function setPosition(out, v) {
17644 var te = out;
17645
17646 te[12] = v[0];
17647 te[13] = v[1];
17648 te[14] = v[2];
17649
17650 return out;
17651}
17652
17653function lookAt(te, eye, target, up) {
17654 var x = [0, 0, 0];
17655 var y = [0, 0, 0];
17656 var z = [0, 0, 0];
17657 subtract(z, eye, target);
17658
17659 if (length(z) === 0) {
17660
17661 z[2] = 1;
17662 }
17663
17664 normalize(z, z);
17665 cross(x, up, z);
17666
17667 if (length(z) === 0) {
17668
17669 if (Math.abs(up[2]) === 1) {
17670
17671 z[0] += 0.0001;
17672 } else {
17673
17674 z[2] += 0.0001;
17675 }
17676
17677 normalize(z, z);
17678 cross(x, up, z);
17679 }
17680
17681 normalize(x, x);
17682 cross(y, z, x);
17683
17684 te[0] = x[0];te[4] = y[0];te[8] = z[0];
17685 te[1] = x[1];te[5] = y[1];te[9] = z[1];
17686 te[2] = x[2];te[6] = y[2];te[10] = z[2];
17687
17688 return te;
17689}
17690
17691var RADIAN = Math.PI / 180;
17692var DEFAULT_FOV = 0.6435011087932844;
17693
17694Map.include({
17695 getFov: function getFov() {
17696 if (!this._fov) {
17697 this._fov = DEFAULT_FOV;
17698 }
17699 return this._fov / RADIAN;
17700 },
17701 setFov: function setFov(fov) {
17702 if (this.isZooming()) {
17703 return this;
17704 }
17705 fov = Math.max(0.01, Math.min(60, fov));
17706 if (this._fov === fov) return this;
17707 var from = this.getFov();
17708 this._fov = fov * RADIAN;
17709 this._calcMatrices();
17710 this._renderLayers();
17711
17712 this._fireEvent('fovchange', { 'from': from, 'to': this.getFov() });
17713 return this;
17714 },
17715 getBearing: function getBearing() {
17716 if (!this._angle) {
17717 return 0;
17718 }
17719 return -this._angle / RADIAN;
17720 },
17721 setBearing: function setBearing(bearing) {
17722 if (Browser$1.ie9) {
17723 throw new Error('map can\'t rotate in IE9.');
17724 }
17725 var b = -wrap(bearing, -180, 180) * RADIAN;
17726 if (this._angle === b) return this;
17727 var from = this.getBearing();
17728
17729 this._fireEvent('rotatestart', { 'from': from, 'to': b });
17730 this._angle = b;
17731 this._calcMatrices();
17732 this._renderLayers();
17733
17734 this._fireEvent('rotate', { 'from': from, 'to': b });
17735
17736 this._fireEvent('rotateend', { 'from': from, 'to': b });
17737 return this;
17738 },
17739 getPitch: function getPitch() {
17740 if (!this._pitch) {
17741 return 0;
17742 }
17743 return this._pitch / Math.PI * 180;
17744 },
17745 setPitch: function setPitch(pitch) {
17746 if (Browser$1.ie9) {
17747 throw new Error('map can\'t tilt in IE9.');
17748 }
17749 var p = clamp(pitch, 0, this.options['maxPitch']) * RADIAN;
17750 if (this._pitch === p) return this;
17751 var from = this.getPitch();
17752
17753 this._fireEvent('pitchstart', { 'from': from, 'to': p });
17754 this._pitch = p;
17755 this._calcMatrices();
17756 this._renderLayers();
17757
17758 this._fireEvent('pitch', { 'from': from, 'to': p });
17759
17760 this._fireEvent('pitchend', { 'from': from, 'to': p });
17761 return this;
17762 },
17763 isTransforming: function isTransforming() {
17764 return !!(this._pitch || this._angle);
17765 },
17766 getFrustumAltitude: function getFrustumAltitude() {
17767 var pitch = 90 - this.getPitch();
17768 var fov = this.getFov() / 2;
17769 var cameraAlt = this.cameraPosition ? this.cameraPosition[2] : 0;
17770 if (fov <= pitch) {
17771 return cameraAlt;
17772 }
17773 fov = Math.PI * fov / 180;
17774 var d1 = new Point(this.cameraPosition).distanceTo(new Point(this.cameraLookAt)),
17775 d2 = cameraAlt * Math.tan(fov * 2);
17776 var d = Math.tan(fov) * (d1 + d2);
17777 return cameraAlt + d;
17778 },
17779
17780 _pointToContainerPoint: function () {
17781 var a = [0, 0, 0];
17782 return function (point, zoom) {
17783 var altitude = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
17784
17785 point = this._pointToPoint(point, zoom);
17786 if (this.isTransforming() || altitude) {
17787 altitude *= this.getResolution(zoom) / this.getResolution();
17788 var _scale = this._glScale;
17789 set$2(a, point.x * _scale, point.y * _scale, altitude * _scale);
17790
17791
17792 var t = this._projIfBehindCamera(a, this.cameraPosition, this.cameraForward);
17793
17794 applyMatrix(t, t, this.projViewMatrix);
17795
17796 var w2 = this.width / 2,
17797 h2 = this.height / 2;
17798 t[0] = t[0] * w2 + w2;
17799 t[1] = -(t[1] * h2) + h2;
17800 return new Point(t[0], t[1]);
17801 } else {
17802 var centerPoint = this._prjToPoint(this._getPrjCenter());
17803 return point._sub(centerPoint)._add(this.width / 2, this.height / 2);
17804 }
17805 };
17806 }(),
17807
17808 _projIfBehindCamera: function () {
17809 var vectorFromCam = new Array(3);
17810 var nVectorFromCam = new Array(3);
17811 var proj = new Array(3);
17812 var sub = new Array(3);
17813 return function (position, cameraPos, camForward) {
17814 subtract(vectorFromCam, position, cameraPos);
17815 var cameraDot = dot(camForward, normalize(nVectorFromCam, vectorFromCam));
17816
17817 if (cameraDot <= 0) {
17818 var camDot = dot(camForward, vectorFromCam);
17819 scale$1(proj, camForward, camDot * 1.01);
17820 add(position, cameraPos, subtract(sub, vectorFromCam, proj));
17821 }
17822
17823 return position;
17824 };
17825 }(),
17826
17827 _containerPointToPoint: function () {
17828 var cp = [0, 0, 0],
17829 coord0 = [0, 0, 0, 1],
17830 coord1 = [0, 0, 0, 1];
17831 return function (p, zoom) {
17832 if (this.isTransforming()) {
17833 var w2 = this.width / 2 || 1,
17834 h2 = this.height / 2 || 1;
17835 set$2(cp, (p.x - w2) / w2, (h2 - p.y) / h2, 0);
17836
17837 set$2(coord0, cp[0], cp[1], 0);
17838 set$2(coord1, cp[0], cp[1], 1);
17839 coord0[3] = coord1[3] = 1;
17840
17841 applyMatrix(coord0, coord0, this.projViewMatrixInverse);
17842 applyMatrix(coord1, coord1, this.projViewMatrixInverse);
17843 var x0 = coord0[0];
17844 var x1 = coord1[0];
17845 var y0 = coord0[1];
17846 var y1 = coord1[1];
17847 var z0 = coord0[2];
17848 var z1 = coord1[2];
17849
17850 var t = z0 === z1 ? 0 : (0 - z0) / (z1 - z0);
17851
17852 var point = new Point(interpolate(x0, x1, t), interpolate(y0, y1, t))._multi(1 / this._glScale);
17853 return zoom === undefined || this.getZoom() === zoom ? point : this._pointToPointAtZoom(point, zoom);
17854 }
17855 var centerPoint = this._prjToPoint(this._getPrjCenter(), zoom),
17856 scale$$1 = zoom !== undefined ? this._getResolution() / this._getResolution(zoom) : 1;
17857 var x = scale$$1 * (p.x - this.width / 2),
17858 y = scale$$1 * (p.y - this.height / 2);
17859 return centerPoint._add(x, y);
17860 };
17861 }(),
17862
17863 _calcMatrices: function () {
17864 var m0 = Browser$1.ie9 ? null : createMat4(),
17865 m1 = Browser$1.ie9 ? null : createMat4();
17866 return function () {
17867 if (Browser$1.ie9) {
17868 return;
17869 }
17870 var size = this.getSize();
17871 var w = size.width || 1,
17872 h = size.height || 1;
17873
17874 this._glScale = this.getGLScale();
17875
17876 var fov = this.getFov() * Math.PI / 180;
17877 var maxScale = this.getScale(this.getMinZoom()) / this.getScale(this.getMaxNativeZoom());
17878 var farZ = maxScale * h / 2 / this._getFovRatio() * 1.4;
17879
17880 var projMatrix = this.projMatrix || createMat4();
17881 perspective(projMatrix, fov, w / h, 0.1, farZ);
17882 this.projMatrix = projMatrix;
17883
17884 var worldMatrix = this._getCameraWorldMatrix();
17885
17886 this.viewMatrix = invert(m0, worldMatrix);
17887
17888 this.projViewMatrix = multiply(this.projViewMatrix || createMat4(), projMatrix, this.viewMatrix);
17889
17890 this.projViewMatrixInverse = multiply(this.projViewMatrixInverse || createMat4(), worldMatrix, invert(m1, projMatrix));
17891 this.domCssMatrix = this._calcDomMatrix();
17892 };
17893 }(),
17894
17895 _calcDomMatrix: function () {
17896 var m = Browser$1.ie9 ? null : createMat4(),
17897 minusY = [1, -1, 1],
17898 arr = [0, 0, 0];
17899 return function () {
17900 var cameraToCenterDistance = 0.5 / Math.tan(this._fov / 2) * this.height;
17901 scale(m, this.projMatrix, minusY);
17902 translate(m, m, set$2(arr, 0, 0, -cameraToCenterDistance));
17903 if (this._pitch) {
17904 rotateX(m, m, this._pitch);
17905 }
17906 if (this._angle) {
17907 rotateZ(m, m, this._angle);
17908 }
17909 var m1 = createMat4();
17910 scale(m1, m1, set$2(arr, this.width / 2, -this.height / 2, 1));
17911 return multiply(this.domCssMatrix || createMat4(), m1, m);
17912 };
17913 }(),
17914
17915 _getCameraWorldMatrix: function () {
17916 var q = {},
17917 minusY = [1, -1, 1];
17918 return function () {
17919 var targetZ = this.getGLZoom();
17920
17921 var size = this.getSize(),
17922 scale$$1 = this.getGLScale();
17923 var center2D = this._prjToPoint(this._prjCenter, targetZ);
17924 this.cameraLookAt = set$2(this.cameraLookAt || [0, 0, 0], center2D.x, center2D.y, 0);
17925
17926 var pitch = this.getPitch() * RADIAN;
17927 var bearing = -this.getBearing() * RADIAN;
17928
17929 var ratio = this._getFovRatio();
17930 var z = scale$$1 * (size.height || 1) / 2 / ratio;
17931 var cz = z * Math.cos(pitch);
17932
17933 var dist = Math.sin(pitch) * z;
17934
17935 var cx = center2D.x + dist * Math.sin(bearing);
17936 var cy = center2D.y + dist * Math.cos(bearing);
17937 this.cameraPosition = set$2(this.cameraPosition || [0, 0, 0], cx, cy, cz);
17938
17939 var d = dist || 1;
17940 var up = this.cameraUp = set$2(this.cameraUp || [0, 0, 0], Math.sin(bearing) * d, Math.cos(bearing) * d, 0);
17941 var m = this.cameraWorldMatrix = this.cameraWorldMatrix || createMat4();
17942 lookAt(m, this.cameraPosition, this.cameraLookAt, up);
17943
17944 var cameraForward = this.cameraForward || [0, 0, 0];
17945 subtract(cameraForward, this.cameraLookAt, this.cameraPosition);
17946
17947 this.cameraForward = normalize(cameraForward, cameraForward);
17948
17949 matrixToQuaternion(q, m);
17950 quaternionToMatrix(m, q);
17951 setPosition(m, this.cameraPosition);
17952 scale(m, m, minusY);
17953 return m;
17954 };
17955 }(),
17956
17957 _getFovRatio: function _getFovRatio() {
17958 var fov = this.getFov();
17959 return Math.tan(fov / 2 * RADIAN);
17960 },
17961 _renderLayers: function _renderLayers() {
17962 if (this.isInteracting()) {
17963 return;
17964 }
17965 var layers = this._getLayers();
17966
17967 layers.forEach(function (layer) {
17968 if (!layer) {
17969 return;
17970 }
17971 var renderer = layer._getRenderer();
17972 if (renderer && renderer.setToRedraw) {
17973 renderer.setToRedraw();
17974 }
17975 });
17976 }
17977});
17978
17979function createMat4() {
17980 return identity(new Array(16));
17981}
17982
17983Map.include({
17984 _onViewChange: function _onViewChange(view) {
17985 if (!this._viewHistory) {
17986 this._viewHistory = [];
17987 this._viewHistoryPointer = 0;
17988 }
17989 var old = this._getCurrentView();
17990 for (var i = this._viewHistory.length - 1; i >= 0; i--) {
17991 if (equalMapView(view, this._viewHistory[i])) {
17992 this._viewHistoryPointer = i;
17993 this._fireViewChange(old, view);
17994 return;
17995 }
17996 }
17997
17998 if (this._viewHistoryPointer < this._viewHistory.length - 1) {
17999 this._viewHistory.splice(this._viewHistoryPointer + 1);
18000 }
18001 this._viewHistory.push(view);
18002 var count = this.options['viewHistoryCount'];
18003 if (count > 0 && this._viewHistory.length > count) {
18004 this._viewHistory.splice(0, this._viewHistory.length - count);
18005 }
18006 this._viewHistoryPointer = this._viewHistory.length - 1;
18007
18008 this._fireViewChange(old, view);
18009 },
18010 zoomToPreviousView: function zoomToPreviousView() {
18011 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18012
18013 if (!this.hasPreviousView()) {
18014 return null;
18015 }
18016 var view = this._viewHistory[--this._viewHistoryPointer];
18017 this._zoomToView(view, options);
18018 return view;
18019 },
18020 hasPreviousView: function hasPreviousView() {
18021 if (!this._viewHistory || this._viewHistoryPointer === 0) {
18022 return false;
18023 }
18024 return true;
18025 },
18026 zoomToNextView: function zoomToNextView() {
18027 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18028
18029 if (!this.hasNextView()) {
18030 return null;
18031 }
18032 var view = this._viewHistory[++this._viewHistoryPointer];
18033 this._zoomToView(view, options);
18034 return view;
18035 },
18036 hasNextView: function hasNextView() {
18037 if (!this._viewHistory || this._viewHistoryPointer === this._viewHistory.length - 1) {
18038 return false;
18039 }
18040 return true;
18041 },
18042 _zoomToView: function _zoomToView(view, options) {
18043 var _this = this;
18044
18045 var old = this.getView();
18046 if (options['animation']) {
18047 this.animateTo(view, {
18048 'duration': options['duration']
18049 }, function (frame) {
18050 if (frame.state.playState === 'finished') {
18051 _this._fireViewChange(old, view);
18052 }
18053 });
18054 } else {
18055 this.setView(view);
18056 this._fireViewChange(old, view);
18057 }
18058 },
18059 getViewHistory: function getViewHistory() {
18060 return this._viewHistory;
18061 },
18062 _fireViewChange: function _fireViewChange(old, view) {
18063 this._fireEvent('viewchange', {
18064 'old': old,
18065 'new': view
18066 });
18067 },
18068 _getCurrentView: function _getCurrentView() {
18069 if (!this._viewHistory) {
18070 return null;
18071 }
18072 return this._viewHistory[this._viewHistoryPointer];
18073 }
18074});
18075
18076Map.mergeOptions({
18077 'viewHistory': true,
18078 'viewHistoryCount': 10
18079});
18080
18081var options$17 = {
18082 'mode': 'LineString',
18083 'language': 'zh-CN',
18084 'metric': true,
18085 'imperial': false,
18086 'symbol': {
18087 'lineColor': '#000',
18088 'lineWidth': 3,
18089 'lineOpacity': 1
18090 },
18091 'vertexSymbol': {
18092 'markerType': 'ellipse',
18093 'markerFill': '#fff',
18094 'markerLineColor': '#000',
18095 'markerLineWidth': 3,
18096 'markerWidth': 11,
18097 'markerHeight': 11
18098 },
18099 'labelOptions': {
18100 'textSymbol': {
18101 'textFaceName': 'monospace',
18102 'textLineSpacing': 1,
18103 'textHorizontalAlignment': 'right',
18104 'textDx': 15
18105 },
18106 'boxStyle': {
18107 'padding': [6, 2],
18108 'symbol': {
18109 'markerType': 'square',
18110 'markerFill': '#fff',
18111 'markerFillOpacity': 0.9,
18112 'markerLineColor': '#b4b3b3'
18113 }
18114 }
18115 },
18116 'clearButtonSymbol': [{
18117 'markerType': 'square',
18118 'markerFill': '#fff',
18119 'markerLineColor': '#b4b3b3',
18120 'markerLineWidth': 2,
18121 'markerWidth': 15,
18122 'markerHeight': 15,
18123 'markerDx': 20
18124 }, {
18125 'markerType': 'x',
18126 'markerWidth': 10,
18127 'markerHeight': 10,
18128 'markerDx': 20
18129 }]
18130};
18131
18132var DistanceTool = function (_DrawTool) {
18133 inherits(DistanceTool, _DrawTool);
18134
18135 function DistanceTool(options) {
18136 classCallCheck(this, DistanceTool);
18137
18138 var _this = possibleConstructorReturn(this, _DrawTool.call(this, options));
18139
18140 _this.on('enable', _this._afterEnable, _this).on('disable', _this._afterDisable, _this);
18141 _this._measureLayers = [];
18142 return _this;
18143 }
18144
18145 DistanceTool.prototype.clear = function clear() {
18146 if (isArrayHasData(this._measureLayers)) {
18147 for (var i = 0; i < this._measureLayers.length; i++) {
18148 this._measureLayers[i].remove();
18149 }
18150 }
18151 delete this._lastMeasure;
18152 delete this._lastVertex;
18153 this._measureLayers = [];
18154 return this;
18155 };
18156
18157 DistanceTool.prototype.getMeasureLayers = function getMeasureLayers() {
18158 return this._measureLayers;
18159 };
18160
18161 DistanceTool.prototype.getLastMeasure = function getLastMeasure() {
18162 if (!this._lastMeasure) {
18163 return 0;
18164 }
18165 return this._lastMeasure;
18166 };
18167
18168 DistanceTool.prototype._measure = function _measure(toMeasure) {
18169 var map = this.getMap();
18170 var length = void 0;
18171 if (toMeasure instanceof Geometry) {
18172 length = map.computeGeometryLength(toMeasure);
18173 } else if (Array.isArray(toMeasure)) {
18174 length = map.getProjection().measureLength(toMeasure);
18175 }
18176 this._lastMeasure = length;
18177 var units = void 0;
18178 if (this.options['language'] === 'zh-CN') {
18179 units = [' 米', ' 公里', ' 英尺', ' 英里'];
18180 } else {
18181 units = [' m', ' km', ' feet', ' mile'];
18182 }
18183 var content = '';
18184 if (this.options['metric']) {
18185 content += length < 1000 ? length.toFixed(0) + units[0] : (length / 1000).toFixed(2) + units[1];
18186 }
18187 if (this.options['imperial']) {
18188 length *= 3.2808399;
18189 if (content.length > 0) {
18190 content += '\n';
18191 }
18192 content += length < 5280 ? length.toFixed(0) + units[2] : (length / 5280).toFixed(2) + units[3];
18193 }
18194 return content;
18195 };
18196
18197 DistanceTool.prototype._registerMeasureEvents = function _registerMeasureEvents() {
18198 this.on('drawstart', this._msOnDrawStart, this).on('drawvertex', this._msOnDrawVertex, this).on('mousemove', this._msOnMouseMove, this).on('drawend', this._msOnDrawEnd, this);
18199 };
18200
18201 DistanceTool.prototype._afterEnable = function _afterEnable() {
18202 this._registerMeasureEvents();
18203 };
18204
18205 DistanceTool.prototype._afterDisable = function _afterDisable() {
18206 this.off('drawstart', this._msOnDrawStart, this).off('drawvertex', this._msOnDrawVertex, this).off('mousemove', this._msOnMouseMove, this).off('drawend', this._msOnDrawEnd, this);
18207 };
18208
18209 DistanceTool.prototype._msOnDrawStart = function _msOnDrawStart(param) {
18210 var map = this.getMap();
18211 var uid = UID();
18212 var layerId = 'distancetool_' + uid;
18213 var markerLayerId = 'distancetool_markers_' + uid;
18214 if (!map.getLayer(layerId)) {
18215 this._measureLineLayer = new VectorLayer(layerId).addTo(map);
18216 this._measureMarkerLayer = new VectorLayer(markerLayerId).addTo(map);
18217 } else {
18218 this._measureLineLayer = map.getLayer(layerId);
18219 this._measureMarkerLayer = map.getLayer(markerLayerId);
18220 }
18221 this._measureLayers.push(this._measureLineLayer);
18222 this._measureLayers.push(this._measureMarkerLayer);
18223
18224 new Marker(param['coordinate'], {
18225 'symbol': this.options['vertexSymbol']
18226 }).addTo(this._measureMarkerLayer);
18227 var content = this.options['language'] === 'zh-CN' ? '起点' : 'start';
18228 var startLabel = new Label(content, param['coordinate'], this.options['labelOptions']);
18229 this._measureMarkerLayer.addGeometry(startLabel);
18230 };
18231
18232 DistanceTool.prototype._msOnMouseMove = function _msOnMouseMove(param) {
18233 var ms = this._measure(this._msGetCoordsToMeasure(param));
18234 if (!this._tailMarker) {
18235 var symbol = extendSymbol(this.options['vertexSymbol']);
18236 symbol['markerWidth'] /= 2;
18237 symbol['markerHeight'] /= 2;
18238 this._tailMarker = new Marker(param['coordinate'], {
18239 'symbol': symbol
18240 }).addTo(this._measureMarkerLayer);
18241 this._tailLabel = new Label(ms, param['coordinate'], this.options['labelOptions']).addTo(this._measureMarkerLayer);
18242 }
18243 this._tailMarker.setCoordinates(param['coordinate']);
18244 this._tailLabel.setContent(ms);
18245 this._tailLabel.setCoordinates(param['coordinate']);
18246 };
18247
18248 DistanceTool.prototype._msGetCoordsToMeasure = function _msGetCoordsToMeasure(param) {
18249 return param['geometry'].getCoordinates().concat([param['coordinate']]);
18250 };
18251
18252 DistanceTool.prototype._msOnDrawVertex = function _msOnDrawVertex(param) {
18253 var geometry = param['geometry'];
18254
18255 new Marker(param['coordinate'], {
18256 'symbol': this.options['vertexSymbol']
18257 }).addTo(this._measureMarkerLayer);
18258 var length = this._measure(geometry);
18259 var vertexLabel = new Label(length, param['coordinate'], this.options['labelOptions']);
18260 this._measureMarkerLayer.addGeometry(vertexLabel);
18261 this._lastVertex = vertexLabel;
18262 };
18263
18264 DistanceTool.prototype._msOnDrawEnd = function _msOnDrawEnd(param) {
18265 this._clearTailMarker();
18266 var size = this._lastVertex.getSize();
18267 if (!size) {
18268 size = new Size(10, 10);
18269 }
18270 this._addClearMarker(this._lastVertex.getCoordinates(), size['width']);
18271 var geo = param['geometry'].copy();
18272 geo.addTo(this._measureLineLayer);
18273 this._lastMeasure = geo.getLength();
18274 };
18275
18276 DistanceTool.prototype._addClearMarker = function _addClearMarker(coordinates, dx) {
18277 var symbol = this.options['clearButtonSymbol'];
18278 var dxSymbol = {
18279 'markerDx': (symbol['markerDx'] || 0) + dx,
18280 'textDx': (symbol['textDx'] || 0) + dx
18281 };
18282 if (Array.isArray(symbol)) {
18283 dxSymbol = symbol.map(function (s) {
18284 if (s) {
18285 return {
18286 'markerDx': (s['markerDx'] || 0) + dx,
18287 'textDx': (s['textDx'] || 0) + dx
18288 };
18289 }
18290 return null;
18291 });
18292 }
18293 symbol = extendSymbol(symbol, dxSymbol);
18294 var endMarker = new Marker(coordinates, {
18295 'symbol': symbol
18296 });
18297 var measureLineLayer = this._measureLineLayer,
18298 measureMarkerLayer = this._measureMarkerLayer;
18299 endMarker.on('click', function () {
18300 measureLineLayer.remove();
18301 measureMarkerLayer.remove();
18302
18303 return false;
18304 }, this);
18305 endMarker.addTo(this._measureMarkerLayer);
18306 };
18307
18308 DistanceTool.prototype._clearTailMarker = function _clearTailMarker() {
18309 if (this._tailMarker) {
18310 this._tailMarker.remove();
18311 delete this._tailMarker;
18312 }
18313 if (this._tailLabel) {
18314 this._tailLabel.remove();
18315 delete this._tailLabel;
18316 }
18317 };
18318
18319 return DistanceTool;
18320}(DrawTool);
18321
18322DistanceTool.mergeOptions(options$17);
18323
18324var options$18 = {
18325 'mode': 'Polygon',
18326 'symbol': {
18327 'lineColor': '#000000',
18328 'lineWidth': 2,
18329 'lineOpacity': 1,
18330 'lineDasharray': '',
18331 'polygonFill': '#ffffff',
18332 'polygonOpacity': 0.5
18333 }
18334};
18335
18336var AreaTool = function (_DistanceTool) {
18337 inherits(AreaTool, _DistanceTool);
18338
18339 function AreaTool(options) {
18340 classCallCheck(this, AreaTool);
18341
18342 var _this = possibleConstructorReturn(this, _DistanceTool.call(this, options));
18343
18344 _this.on('enable', _this._afterEnable, _this).on('disable', _this._afterDisable, _this);
18345 _this._measureLayers = [];
18346 return _this;
18347 }
18348
18349 AreaTool.prototype._measure = function _measure(toMeasure) {
18350 var map = this.getMap();
18351 var area = void 0;
18352 if (toMeasure instanceof Geometry) {
18353 area = map.computeGeometryArea(toMeasure);
18354 } else if (Array.isArray(toMeasure)) {
18355 area = map.getProjection().measureArea(toMeasure);
18356 }
18357 this._lastMeasure = area;
18358 var units = void 0;
18359 if (this.options['language'] === 'zh-CN') {
18360 units = [' 平方米', ' 平方公里', ' 平方英尺', ' 平方英里'];
18361 } else {
18362 units = [' sq.m', ' sq.km', ' sq.ft', ' sq.mi'];
18363 }
18364 var content = '';
18365 if (this.options['metric']) {
18366 content += area < 1E6 ? area.toFixed(0) + units[0] : (area / 1E6).toFixed(2) + units[1];
18367 }
18368 if (this.options['imperial']) {
18369 area *= 3.2808399;
18370 if (content.length > 0) {
18371 content += '\n';
18372 }
18373 var sqmi = 5280 * 5280;
18374 content += area < sqmi ? area.toFixed(0) + units[2] : (area / sqmi).toFixed(2) + units[3];
18375 }
18376 return content;
18377 };
18378
18379 AreaTool.prototype._msGetCoordsToMeasure = function _msGetCoordsToMeasure(param) {
18380 return param['geometry'].getShell().concat([param['coordinate']]);
18381 };
18382
18383 AreaTool.prototype._msOnDrawVertex = function _msOnDrawVertex(param) {
18384 var vertexMarker = new Marker(param['coordinate'], {
18385 'symbol': this.options['vertexSymbol']
18386 }).addTo(this._measureMarkerLayer);
18387 this._measure(param['geometry']);
18388 this._lastVertex = vertexMarker;
18389 };
18390
18391 AreaTool.prototype._msOnDrawEnd = function _msOnDrawEnd(param) {
18392 this._clearTailMarker();
18393
18394 var ms = this._measure(param['geometry']);
18395 var endLabel = new Label(ms, param['coordinate'], this.options['labelOptions']).addTo(this._measureMarkerLayer);
18396 var size = endLabel.getSize();
18397 if (!size) {
18398 size = new Size(10, 10);
18399 }
18400 this._addClearMarker(param['coordinate'], size['width']);
18401 var geo = param['geometry'].copy();
18402 geo.addTo(this._measureLineLayer);
18403 this._lastMeasure = geo.getArea();
18404 };
18405
18406 return AreaTool;
18407}(DistanceTool);
18408
18409AreaTool.mergeOptions(options$18);
18410
18411DrawTool.registerMode('circle', {
18412 'clickLimit': 2,
18413 'action': ['click', 'mousemove', 'click'],
18414 'create': function create(coordinate) {
18415 return new Circle(coordinate[0], 0);
18416 },
18417 'update': function update(path, geometry) {
18418 var map = geometry.getMap();
18419 var radius = map.computeLength(geometry.getCenter(), path[path.length - 1]);
18420 geometry.setRadius(radius);
18421 },
18422 'generate': function generate(geometry) {
18423 return geometry;
18424 }
18425});
18426
18427DrawTool.registerMode('freeHandCircle', {
18428 'action': ['mousedown', 'mousemove', 'mouseup'],
18429 'create': function create(coordinate) {
18430 return new Circle(coordinate[0], 0);
18431 },
18432 'update': function update(path, geometry) {
18433 var map = geometry.getMap();
18434 var radius = map.computeLength(geometry.getCenter(), path[path.length - 1]);
18435 geometry.setRadius(radius);
18436 },
18437 'generate': function generate(geometry) {
18438 return geometry;
18439 }
18440});
18441
18442DrawTool.registerMode('ellipse', {
18443 'clickLimit': 2,
18444 'action': ['click', 'mousemove', 'click'],
18445 'create': function create(coordinates) {
18446 return new Ellipse(coordinates[0], 0, 0);
18447 },
18448 'update': function update(path, geometry) {
18449 var map = geometry.getMap();
18450 var center = geometry.getCenter();
18451 var rx = map.computeLength(center, new Coordinate({
18452 x: path[path.length - 1].x,
18453 y: center.y
18454 }));
18455 var ry = map.computeLength(center, new Coordinate({
18456 x: center.x,
18457 y: path[path.length - 1].y
18458 }));
18459 geometry.setWidth(rx * 2);
18460 geometry.setHeight(ry * 2);
18461 },
18462 'generate': function generate(geometry) {
18463 return geometry;
18464 }
18465});
18466
18467DrawTool.registerMode('freeHandEllipse', {
18468 'action': ['mousedown', 'mousemove', 'mouseup'],
18469 'create': function create(coordinates) {
18470 return new Ellipse(coordinates[0], 0, 0);
18471 },
18472 'update': function update(path, geometry) {
18473 var map = geometry.getMap();
18474 var center = geometry.getCenter();
18475 var rx = map.computeLength(center, new Coordinate({
18476 x: path[path.length - 1].x,
18477 y: center.y
18478 }));
18479 var ry = map.computeLength(center, new Coordinate({
18480 x: center.x,
18481 y: path[path.length - 1].y
18482 }));
18483 geometry.setWidth(rx * 2);
18484 geometry.setHeight(ry * 2);
18485 },
18486 'generate': function generate(geometry) {
18487 return geometry;
18488 }
18489});
18490
18491DrawTool.registerMode('rectangle', {
18492 'clickLimit': 2,
18493 'action': ['click', 'mousemove', 'click'],
18494 'create': function create(coordinates) {
18495 var rect = new Polygon([]);
18496 rect._firstClick = coordinates[0];
18497 return rect;
18498 },
18499 'update': function update(coordinates, geometry, param) {
18500 var map = geometry.getMap();
18501 var containerPoint = param['containerPoint'];
18502 var firstClick = map.coordToContainerPoint(geometry._firstClick);
18503 var ring = [[firstClick.x, firstClick.y], [containerPoint.x, firstClick.y], [containerPoint.x, containerPoint.y], [firstClick.x, containerPoint.y]];
18504 geometry.setCoordinates(ring.map(function (c) {
18505 return map.containerPointToCoord(new Point(c));
18506 }));
18507 },
18508 'generate': function generate(geometry) {
18509 return geometry;
18510 }
18511});
18512
18513DrawTool.registerMode('freeHandRectangle', {
18514 'action': ['mousedown', 'mousemove', 'mouseup'],
18515 'create': function create(coordinates) {
18516 var rect = new Polygon([]);
18517 rect._firstClick = coordinates[0];
18518 return rect;
18519 },
18520 'update': function update(coordinates, geometry) {
18521 var firstClick = geometry._firstClick;
18522 var ring = [[firstClick.x, firstClick.y], [coordinates[0].x, firstClick.y], [coordinates[0].x, coordinates[0].y], [firstClick.x, coordinates[0].y]];
18523 geometry.setCoordinates(ring);
18524 },
18525 'generate': function generate(geometry) {
18526 return geometry;
18527 }
18528});
18529
18530DrawTool.registerMode('point', {
18531 'clickLimit': 1,
18532 'action': ['click'],
18533 'create': function create(coordinate) {
18534 return new Marker(coordinate[0]);
18535 },
18536 'generate': function generate(geometry) {
18537 return geometry;
18538 }
18539});
18540
18541DrawTool.registerMode('polygon', {
18542 'action': ['click', 'mousemove', 'dblclick'],
18543 'create': function create(path) {
18544 return new LineString(path);
18545 },
18546 'update': function update(path, geometry) {
18547 var symbol = geometry.getSymbol();
18548 geometry.setCoordinates(path);
18549
18550 var layer = geometry.getLayer();
18551 if (layer) {
18552 var polygon = layer.getGeometryById('polygon');
18553 if (!polygon && path.length >= 3) {
18554 polygon = new Polygon([path], {
18555 'id': 'polygon'
18556 });
18557 if (symbol) {
18558 var pSymbol = extendSymbol(symbol, {
18559 'lineOpacity': 0
18560 });
18561 polygon.setSymbol(pSymbol);
18562 }
18563 polygon.addTo(layer);
18564 }
18565 if (polygon) {
18566 polygon.setCoordinates(path);
18567 }
18568 }
18569 },
18570 'generate': function generate(geometry) {
18571 return new Polygon(geometry.getCoordinates(), {
18572 'symbol': geometry.getSymbol()
18573 });
18574 }
18575});
18576
18577DrawTool.registerMode('freeHandPolygon', {
18578 'action': ['mousedown', 'mousemove', 'mouseup'],
18579 'create': function create(path) {
18580 return new LineString(path);
18581 },
18582 'update': function update(path, geometry) {
18583 var coordinates = geometry.getCoordinates();
18584 var symbol = geometry.getSymbol();
18585 geometry.setCoordinates(coordinates.concat(path));
18586
18587 var layer = geometry.getLayer();
18588 if (layer) {
18589 var polygon = layer.getGeometryById('polygon');
18590 if (!polygon && path.length >= 3) {
18591 polygon = new Polygon([path], {
18592 'id': 'polygon'
18593 });
18594 if (symbol) {
18595 var pSymbol = extendSymbol(symbol, {
18596 'lineOpacity': 0
18597 });
18598 polygon.setSymbol(pSymbol);
18599 }
18600 polygon.addTo(layer);
18601 }
18602 if (polygon) {
18603 polygon.setCoordinates(path);
18604 }
18605 }
18606 },
18607 'generate': function generate(geometry) {
18608 return new Polygon(geometry.getCoordinates(), {
18609 'symbol': geometry.getSymbol()
18610 });
18611 }
18612});
18613
18614DrawTool.registerMode('linestring', {
18615 'action': ['click', 'mousemove', 'dblclick'],
18616 'create': function create(path) {
18617 return new LineString(path);
18618 },
18619 'update': function update(path, geometry) {
18620 geometry.setCoordinates(path);
18621 },
18622 'generate': function generate(geometry) {
18623 return geometry;
18624 }
18625});
18626
18627DrawTool.registerMode('freeHandLinestring', {
18628 'action': ['mousedown', 'mousemove', 'mouseup'],
18629 'create': function create(path) {
18630 return new LineString(path);
18631 },
18632 'update': function update(path, geometry) {
18633 var coordinates = geometry.getCoordinates();
18634 geometry.setCoordinates(coordinates.concat(path));
18635 },
18636 'generate': function generate(geometry) {
18637 return geometry;
18638 }
18639});
18640
18641DrawTool.registerMode('arccurve', {
18642 'action': ['click', 'mousemove', 'dblclick'],
18643 'create': function create(path) {
18644 return new ArcCurve(path);
18645 },
18646 'update': function update(path, geometry) {
18647 geometry.setCoordinates(path);
18648 },
18649 'generate': function generate(geometry) {
18650 return geometry;
18651 }
18652});
18653
18654DrawTool.registerMode('quadbeziercurve', {
18655 'action': ['click', 'mousemove', 'dblclick'],
18656 'create': function create(path) {
18657 return new QuadBezierCurve(path);
18658 },
18659 'update': function update(path, geometry) {
18660 geometry.setCoordinates(path);
18661 },
18662 'generate': function generate(geometry) {
18663 return geometry;
18664 }
18665});
18666
18667DrawTool.registerMode('cubicbeziercurve', {
18668 'action': ['click', 'mousemove', 'dblclick'],
18669 'create': function create(path) {
18670 return new CubicBezierCurve(path);
18671 },
18672 'update': function update(path, geometry) {
18673 geometry.setCoordinates(path);
18674 },
18675 'generate': function generate(geometry) {
18676 return geometry;
18677 }
18678});
18679
18680DrawTool.registerMode('boxZoom', {
18681 'action': ['mousedown', 'mousemove', 'mouseup'],
18682 'create': function create(coordinates) {
18683 var marker = new Marker(coordinates[0]);
18684 marker._firstClick = coordinates[0];
18685 return marker;
18686 },
18687 'update': function update(path, geometry, param) {
18688 var map = geometry.getMap();
18689 var p1 = map.coordToContainerPoint(geometry._firstClick),
18690 p2 = param['containerPoint'];
18691 var coords = map.containerPointToCoordinate(new Coordinate(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y)));
18692 geometry.setCoordinates(coords).updateSymbol({
18693 markerWidth: Math.abs(p1.x - p2.x),
18694 markerHeight: Math.abs(p1.y - p2.y)
18695 });
18696 },
18697 'generate': function generate(geometry) {
18698 return geometry;
18699 }
18700});
18701
18702function parse(arcConf) {
18703 var tileInfo = arcConf['tileInfo'],
18704 tileSize = [tileInfo['cols'], tileInfo['rows']],
18705 resolutions = [],
18706 lods = tileInfo['lods'];
18707 for (var i = 0, len = lods.length; i < len; i++) {
18708 resolutions.push(lods[i]['resolution']);
18709 }
18710 var fullExtent = arcConf['fullExtent'],
18711 origin = tileInfo['origin'],
18712 tileSystem = [1, -1, origin['x'], origin['y']];
18713 delete fullExtent['spatialReference'];
18714 return {
18715 'spatialReference': {
18716 'resolutions': resolutions,
18717 'fullExtent': fullExtent
18718 },
18719 'tileSystem': tileSystem,
18720 'tileSize': tileSize
18721 };
18722}
18723
18724SpatialReference.loadArcgis = function (url, cb) {
18725 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { 'jsonp': true };
18726
18727 if (isString(url) && url.substring(0, 1) !== '{') {
18728 Ajax.getJSON(url, function (err, json) {
18729 if (err) {
18730 cb(err);
18731 return;
18732 }
18733 var spatialRef = parse(json);
18734 cb(null, spatialRef);
18735 }, options);
18736 } else {
18737 if (isString(url)) {
18738 url = parseJSON(url);
18739 }
18740 var spatialRef = parse(url);
18741 cb(null, spatialRef);
18742 }
18743 return this;
18744};
18745
18746var options$19 = {
18747 'eventsPropagation': false,
18748 'eventsToStop': null,
18749 'dx': 0,
18750 'dy': 0,
18751 'autoPan': false,
18752 'autoPanDuration': 600,
18753 'single': true,
18754 'animation': 'scale',
18755 'animationOnHide': true,
18756 'animationDuration': 500
18757};
18758
18759var UIComponent = function (_Eventable) {
18760 inherits(UIComponent, _Eventable);
18761
18762 function UIComponent(options) {
18763 classCallCheck(this, UIComponent);
18764 return possibleConstructorReturn(this, _Eventable.call(this, options));
18765 }
18766
18767 UIComponent.prototype.addTo = function addTo(owner) {
18768 this._owner = owner;
18769
18770 this._switchEvents('on');
18771 if (this.onAdd) {
18772 this.onAdd();
18773 }
18774
18775 this.fire('add');
18776 return this;
18777 };
18778
18779 UIComponent.prototype.getMap = function getMap() {
18780 if (!this._owner) {
18781 return null;
18782 }
18783
18784 if (this._owner.getBaseLayer) {
18785 return this._owner;
18786 }
18787 return this._owner.getMap();
18788 };
18789
18790 UIComponent.prototype.show = function show(coordinate) {
18791 var map = this.getMap();
18792 if (!map) {
18793 return this;
18794 }
18795
18796 if (!this._mapEventsOn) {
18797 this._switchMapEvents('on');
18798 }
18799
18800 coordinate = coordinate || this._coordinate || this._owner.getCenter();
18801
18802 var visible = this.isVisible();
18803
18804 this.fire('showstart');
18805 var container = this._getUIContainer();
18806 this._coordinate = coordinate;
18807 this._removePrevDOM();
18808 var dom = this.__uiDOM = this.buildOn(map);
18809 dom['eventsPropagation'] = this.options['eventsPropagation'];
18810
18811 if (!dom) {
18812 this.fire('showend');
18813 return this;
18814 }
18815
18816 this._measureSize(dom);
18817
18818 if (this._singleton()) {
18819 map[this._uiDomKey()] = dom;
18820 }
18821
18822 this._setPosition();
18823
18824 dom.style[TRANSITION] = null;
18825
18826 container.appendChild(dom);
18827
18828 var anim = this._getAnimation();
18829
18830 if (visible) {
18831 anim.ok = false;
18832 }
18833
18834 if (anim.ok) {
18835 if (anim.fade) {
18836 dom.style.opacity = 0;
18837 }
18838 if (anim.scale) {
18839 if (this.getTransformOrigin) {
18840 var origin = this.getTransformOrigin();
18841 dom.style[TRANSFORMORIGIN] = origin;
18842 }
18843 dom.style[TRANSFORM] = toCSSTranslate(this._pos) + ' scale(0)';
18844 }
18845 }
18846
18847 dom.style.display = '';
18848
18849 if (this.options['eventsToStop']) {
18850 on(dom, this.options['eventsToStop'], stopPropagation);
18851 }
18852
18853 if (this.options['autoPan']) {
18854 this._autoPan();
18855 }
18856
18857 var transition = anim.transition;
18858 if (anim.ok && transition) {
18859 dom.offsetHeight;
18860
18861 if (transition) {
18862 dom.style[TRANSITION] = transition;
18863 }
18864 if (anim.fade) {
18865 dom.style.opacity = 1;
18866 }
18867 if (anim.scale) {
18868 dom.style[TRANSFORM] = toCSSTranslate(this._pos) + ' scale(1)';
18869 }
18870 }
18871
18872 this.fire('showend');
18873 return this;
18874 };
18875
18876 UIComponent.prototype.hide = function hide() {
18877 if (!this.getDOM() || !this.getMap()) {
18878 return this;
18879 }
18880
18881 var anim = this._getAnimation(),
18882 dom = this.getDOM();
18883 if (!this.options['animationOnHide']) {
18884 anim.ok = false;
18885 }
18886 if (!anim.ok) {
18887 dom.style.display = 'none';
18888 } else {
18889 dom.offsetHeight;
18890
18891 dom.style[TRANSITION] = anim.transition;
18892 setTimeout(function () {
18893 dom.style.display = 'none';
18894 }, this.options['animationDuration']);
18895 }
18896 if (anim.fade) {
18897 dom.style.opacity = 0;
18898 }
18899 if (anim.scale) {
18900 dom.style[TRANSFORM] = toCSSTranslate(this._pos) + ' scale(0)';
18901 }
18902
18903 this.fire('hide');
18904 return this;
18905 };
18906
18907 UIComponent.prototype.isVisible = function isVisible() {
18908 var dom = this.getDOM();
18909 return this.getMap() && dom && dom.parentNode && dom.style.display !== 'none';
18910 };
18911
18912 UIComponent.prototype.remove = function remove() {
18913 delete this._mapEventsOn;
18914 if (!this._owner) {
18915 return this;
18916 }
18917 this.hide();
18918 this._switchEvents('off');
18919 if (this.onRemove) {
18920 this.onRemove();
18921 }
18922 if (!this._singleton() && this.__uiDOM) {
18923 this._removePrevDOM();
18924 }
18925 delete this._owner;
18926
18927 this.fire('remove');
18928 return this;
18929 };
18930
18931 UIComponent.prototype.getSize = function getSize() {
18932 if (this._size) {
18933 return this._size.copy();
18934 } else {
18935 return null;
18936 }
18937 };
18938
18939 UIComponent.prototype.getOwner = function getOwner() {
18940 return this._owner;
18941 };
18942
18943 UIComponent.prototype.getDOM = function getDOM() {
18944 return this.__uiDOM;
18945 };
18946
18947 UIComponent.prototype.getPosition = function getPosition() {
18948 if (!this.getMap()) {
18949 return null;
18950 }
18951 var p = this._getViewPoint()._round();
18952 if (this.getOffset) {
18953 var o = this.getOffset()._round();
18954 if (o) {
18955 p._add(o);
18956 }
18957 }
18958 return p;
18959 };
18960
18961 UIComponent.prototype._getAnimation = function _getAnimation() {
18962 var anim = {
18963 'fade': false,
18964 'scale': false
18965 };
18966 var animations = this.options['animation'] ? this.options['animation'].split(',') : [];
18967 for (var i = 0; i < animations.length; i++) {
18968 var trimed = trim(animations[i]);
18969 if (trimed === 'fade') {
18970 anim.fade = true;
18971 } else if (trimed === 'scale') {
18972 anim.scale = true;
18973 }
18974 }
18975 var transition = null;
18976 if (anim.fade) {
18977 transition = 'opacity ' + this.options['animationDuration'] + 'ms';
18978 }
18979 if (anim.scale) {
18980 transition = transition ? transition + ',' : '';
18981 transition += TRANSFORM + ' ' + this.options['animationDuration'] + 'ms';
18982 }
18983 anim.transition = transition;
18984 anim.ok = transition !== null;
18985 return anim;
18986 };
18987
18988 UIComponent.prototype._getViewPoint = function _getViewPoint() {
18989 return this.getMap().coordToViewPoint(this._coordinate)._add(this.options['dx'], this.options['dy']);
18990 };
18991
18992 UIComponent.prototype._autoPan = function _autoPan() {
18993 var map = this.getMap(),
18994 dom = this.getDOM();
18995 if (map.isMoving()) {
18996 return;
18997 }
18998 var point = this._pos;
18999 var mapSize = map.getSize(),
19000 mapWidth = mapSize['width'],
19001 mapHeight = mapSize['height'];
19002
19003 var containerPoint = map.viewPointToContainerPoint(point);
19004 var clientWidth = parseInt(dom.clientWidth),
19005 clientHeight = parseInt(dom.clientHeight);
19006 var left = 0,
19007 top = 0;
19008 if (containerPoint.x < 0) {
19009 left = -(containerPoint.x - clientWidth / 2);
19010 } else if (containerPoint.x + clientWidth - 35 > mapWidth) {
19011 left = mapWidth - (containerPoint.x + clientWidth * 3 / 2);
19012 }
19013 if (containerPoint.y < 0) {
19014 top = -containerPoint.y + 50;
19015 } else if (containerPoint.y > mapHeight) {
19016 top = mapHeight - containerPoint.y - clientHeight - 30;
19017 }
19018 if (top !== 0 || left !== 0) {
19019 map.panBy(new Point(left, top), { 'duration': this.options['autoPanDuration'] });
19020 }
19021 };
19022
19023 UIComponent.prototype._measureSize = function _measureSize(dom) {
19024 var container = this._getUIContainer();
19025 dom.style.position = 'absolute';
19026 dom.style.left = -99999 + 'px';
19027 var anchor = dom.style.bottom ? 'bottom' : 'top';
19028 dom.style[anchor] = -99999 + 'px';
19029 dom.style.display = '';
19030 container.appendChild(dom);
19031 this._size = new Size(dom.clientWidth, dom.clientHeight);
19032 dom.style.display = 'none';
19033 dom.style.left = '0px';
19034 dom.style[anchor] = '0px';
19035 return this._size;
19036 };
19037
19038 UIComponent.prototype._removePrevDOM = function _removePrevDOM() {
19039 if (this.onDomRemove) {
19040 this.onDomRemove();
19041 }
19042 var eventsToStop = this.options['eventsToStop'];
19043 if (this._singleton()) {
19044 var map = this.getMap(),
19045 key = this._uiDomKey();
19046 if (map[key]) {
19047 if (eventsToStop) {
19048 off(map[key], eventsToStop, stopPropagation);
19049 }
19050 removeDomNode(map[key]);
19051 delete map[key];
19052 }
19053 delete this.__uiDOM;
19054 } else if (this.__uiDOM) {
19055 if (eventsToStop) {
19056 off(this.__uiDOM, eventsToStop, stopPropagation);
19057 }
19058 removeDomNode(this.__uiDOM);
19059 delete this.__uiDOM;
19060 }
19061 };
19062
19063 UIComponent.prototype._uiDomKey = function _uiDomKey() {
19064 return '__ui_' + this._getClassName();
19065 };
19066
19067 UIComponent.prototype._singleton = function _singleton() {
19068 return this.options['single'];
19069 };
19070
19071 UIComponent.prototype._getUIContainer = function _getUIContainer() {
19072 return this.getMap()._panels['ui'];
19073 };
19074
19075 UIComponent.prototype._getClassName = function _getClassName() {
19076 return 'UIComponent';
19077 };
19078
19079 UIComponent.prototype._switchMapEvents = function _switchMapEvents(to) {
19080 var map = this.getMap();
19081 if (!map) {
19082 return;
19083 }
19084 this._mapEventsOn = to === 'on';
19085 var events = this._getDefaultEvents();
19086 if (this.getEvents) {
19087 extend(events, this.getEvents());
19088 }
19089 if (events) {
19090 for (var p in events) {
19091 if (events.hasOwnProperty(p)) {
19092 map[to](p, events[p], this);
19093 }
19094 }
19095 }
19096 };
19097
19098 UIComponent.prototype._switchEvents = function _switchEvents(to) {
19099 this._switchMapEvents(to);
19100 var ownerEvents = this._getOwnerEvents();
19101 if (this._owner) {
19102 for (var p in ownerEvents) {
19103 if (ownerEvents.hasOwnProperty(p)) {
19104 this._owner[to](p, ownerEvents[p], this);
19105 }
19106 }
19107 }
19108 };
19109
19110 UIComponent.prototype._getDefaultEvents = function _getDefaultEvents() {
19111 return {
19112 'zooming rotate pitch': this.onEvent,
19113 'zoomend': this.onZoomEnd,
19114 'moving': this.onMoving
19115 };
19116 };
19117
19118 UIComponent.prototype._getOwnerEvents = function _getOwnerEvents() {
19119 var events = {};
19120 if (this._owner && this._owner instanceof Geometry) {
19121 events.positionchange = this.onGeometryPositionChange;
19122 }
19123 if (this.getOwnerEvents) {
19124 extend(events, this.getOwnerEvents());
19125 }
19126 return events;
19127 };
19128
19129 UIComponent.prototype.onGeometryPositionChange = function onGeometryPositionChange(param) {
19130 if (this._owner && this.isVisible()) {
19131 this.show(param['target'].getCenter());
19132 }
19133 };
19134
19135 UIComponent.prototype.onMoving = function onMoving() {
19136 if (this.isVisible() && this.getMap().isTransforming()) {
19137 this._updatePosition();
19138 }
19139 };
19140
19141 UIComponent.prototype.onEvent = function onEvent() {
19142 if (this.isVisible()) {
19143 this._updatePosition();
19144 }
19145 };
19146
19147 UIComponent.prototype.onZoomEnd = function onZoomEnd() {
19148 if (this.isVisible()) {
19149 this._setPosition();
19150 }
19151 };
19152
19153 UIComponent.prototype._updatePosition = function _updatePosition() {
19154 var renderer = this.getMap()._getRenderer();
19155 renderer.callInNextFrame(this._setPosition.bind(this));
19156 };
19157
19158 UIComponent.prototype._setPosition = function _setPosition() {
19159 var dom = this.getDOM(),
19160 p = this.getPosition();
19161 this._pos = p;
19162 dom.style[TRANSITION] = null;
19163 dom.style[TRANSFORM] = toCSSTranslate(p) + ' scale(1)';
19164 };
19165
19166 return UIComponent;
19167}(Eventable(Class));
19168
19169UIComponent.mergeOptions(options$19);
19170
19171function toCSSTranslate(p) {
19172 if (!p) {
19173 return '';
19174 }
19175 if (Browser$1.any3d) {
19176 return 'translate3d(' + p.x + 'px,' + p.y + 'px, 0px)';
19177 } else {
19178 return 'translate(' + p.x + 'px,' + p.y + 'px)';
19179 }
19180}
19181
19182var options$20 = {
19183 'eventsPropagation': true,
19184 'draggable': false,
19185 'single': false,
19186 'content': null
19187};
19188
19189var domEvents = 'mousedown ' + 'mouseup ' + 'mouseenter ' + 'mouseover ' + 'mouseout ' + 'mousemove ' + 'click ' + 'dblclick ' + 'contextmenu ' + 'keypress ' + 'touchstart ' + 'touchmove ' + 'touchend';
19190
19191var UIMarker = function (_Handlerable) {
19192 inherits(UIMarker, _Handlerable);
19193
19194 function UIMarker(coordinate, options) {
19195 classCallCheck(this, UIMarker);
19196
19197 var _this = possibleConstructorReturn(this, _Handlerable.call(this, options));
19198
19199 _this._markerCoord = new Coordinate(coordinate);
19200 return _this;
19201 }
19202
19203 UIMarker.prototype._getClassName = function _getClassName() {
19204 return 'UIMarker';
19205 };
19206
19207 UIMarker.prototype.setCoordinates = function setCoordinates(coordinates) {
19208 this._markerCoord = coordinates;
19209
19210 this.fire('positionchange');
19211 if (this.isVisible()) {
19212 this._coordinate = this._markerCoord;
19213 this._setPosition();
19214 }
19215 return this;
19216 };
19217
19218 UIMarker.prototype.getCoordinates = function getCoordinates() {
19219 return this._markerCoord;
19220 };
19221
19222 UIMarker.prototype.setContent = function setContent(content) {
19223 var old = this.options['content'];
19224 this.options['content'] = content;
19225
19226 this.fire('contentchange', {
19227 'old': old,
19228 'new': content
19229 });
19230 if (this.isVisible()) {
19231 this.show();
19232 }
19233 return this;
19234 };
19235
19236 UIMarker.prototype.getContent = function getContent() {
19237 return this.options['content'];
19238 };
19239
19240 UIMarker.prototype.onAdd = function onAdd() {
19241 this.show();
19242 };
19243
19244 UIMarker.prototype.show = function show() {
19245 return _Handlerable.prototype.show.call(this, this._markerCoord);
19246 };
19247
19248 UIMarker.prototype.flash = function flash$$1(interval, count, cb, context) {
19249 return flash.call(this, interval, count, cb, context);
19250 };
19251
19252 UIMarker.prototype.buildOn = function buildOn() {
19253 var dom = void 0;
19254 if (isString(this.options['content'])) {
19255 dom = createEl('div');
19256 dom.innerHTML = this.options['content'];
19257 } else {
19258 dom = this.options['content'];
19259 }
19260 this._registerDOMEvents(dom);
19261 return dom;
19262 };
19263
19264 UIMarker.prototype.getOffset = function getOffset() {
19265 var size = this.getSize();
19266 return new Point(-size.width / 2, -size.height / 2);
19267 };
19268
19269 UIMarker.prototype.getTransformOrigin = function getTransformOrigin() {
19270 return 'center center';
19271 };
19272
19273 UIMarker.prototype.onDomRemove = function onDomRemove() {
19274 var dom = this.getDOM();
19275 this._removeDOMEvents(dom);
19276 };
19277
19278 UIMarker.prototype.isDragging = function isDragging() {
19279 if (this['draggable']) {
19280 return this['draggable'].isDragging();
19281 }
19282 return false;
19283 };
19284
19285 UIMarker.prototype._registerDOMEvents = function _registerDOMEvents(dom) {
19286 on(dom, domEvents, this._onDomEvents, this);
19287 };
19288
19289 UIMarker.prototype._onDomEvents = function _onDomEvents(e) {
19290 var event = this.getMap()._parseEvent(e, e.type);
19291 this.fire(e.type, event);
19292 };
19293
19294 UIMarker.prototype._removeDOMEvents = function _removeDOMEvents(dom) {
19295 off(dom, domEvents, this._onDomEvents, this);
19296 };
19297
19298 UIMarker.prototype._getConnectPoints = function _getConnectPoints() {
19299 var map = this.getMap();
19300 var containerPoint = map.coordToContainerPoint(this.getCoordinates());
19301 var size = this.getSize(),
19302 width = size.width,
19303 height = size.height;
19304 var anchors = [map.containerPointToCoordinate(containerPoint.add(-width / 2, 0)), map.containerPointToCoordinate(containerPoint.add(width / 2, 0)), map.containerPointToCoordinate(containerPoint.add(0, height / 2)), map.containerPointToCoordinate(containerPoint.add(0, -height / 2))];
19305 return anchors;
19306 };
19307
19308 return UIMarker;
19309}(Handlerable(UIComponent));
19310
19311UIMarker.mergeOptions(options$20);
19312
19313var EVENTS$1 = Browser$1.touch ? 'touchstart mousedown' : 'mousedown';
19314
19315var UIMarkerDragHandler = function (_Handler) {
19316 inherits(UIMarkerDragHandler, _Handler);
19317
19318 function UIMarkerDragHandler(target) {
19319 classCallCheck(this, UIMarkerDragHandler);
19320 return possibleConstructorReturn(this, _Handler.call(this, target));
19321 }
19322
19323 UIMarkerDragHandler.prototype.addHooks = function addHooks() {
19324 this.target.on(EVENTS$1, this._startDrag, this);
19325 };
19326
19327 UIMarkerDragHandler.prototype.removeHooks = function removeHooks() {
19328 this.target.off(EVENTS$1, this._startDrag, this);
19329 };
19330
19331 UIMarkerDragHandler.prototype._startDrag = function _startDrag(param) {
19332 var domEvent = param['domEvent'];
19333 if (domEvent.touches && domEvent.touches.length > 1 || domEvent.button === 2) {
19334 return;
19335 }
19336 if (this.isDragging()) {
19337 return;
19338 }
19339 this.target.on('click', this._endDrag, this);
19340 this._lastCoord = param['coordinate'];
19341 this._lastPoint = param['containerPoint'];
19342
19343 this._prepareDragHandler();
19344 this._dragHandler.onMouseDown(param['domEvent']);
19345
19346 this.target.fire('dragstart', param);
19347 };
19348
19349 UIMarkerDragHandler.prototype._prepareDragHandler = function _prepareDragHandler() {
19350 this._dragHandler = new DragHandler(this.target.getDOM(), {
19351 'cancelOn': this._cancelOn.bind(this),
19352 'ignoreMouseleave': true
19353 });
19354 this._dragHandler.on('mousedown', this._onMouseDown, this);
19355 this._dragHandler.on('dragging', this._dragging, this);
19356 this._dragHandler.on('mouseup', this._endDrag, this);
19357 this._dragHandler.enable();
19358 };
19359
19360 UIMarkerDragHandler.prototype._cancelOn = function _cancelOn(domEvent) {
19361 var target = domEvent.srcElement || domEvent.target,
19362 tagName = target.tagName.toLowerCase();
19363 if (tagName === 'button' || tagName === 'input' || tagName === 'select' || tagName === 'option' || tagName === 'textarea') {
19364 return true;
19365 }
19366 return false;
19367 };
19368
19369 UIMarkerDragHandler.prototype._onMouseDown = function _onMouseDown(param) {
19370 stopPropagation(param['domEvent']);
19371 };
19372
19373 UIMarkerDragHandler.prototype._dragging = function _dragging(param) {
19374 var target = this.target,
19375 map = target.getMap(),
19376 eventParam = map._parseEvent(param['domEvent']),
19377 domEvent = eventParam['domEvent'];
19378 if (domEvent.touches && domEvent.touches.length > 1) {
19379 return;
19380 }
19381 if (!this._isDragging) {
19382 this._isDragging = true;
19383 return;
19384 }
19385
19386 var coord = eventParam['coordinate'],
19387 point = eventParam['containerPoint'];
19388 if (!this._lastCoord) {
19389 this._lastCoord = coord;
19390 }
19391 if (!this._lastPoint) {
19392 this._lastPoint = point;
19393 }
19394 var coordOffset = coord.sub(this._lastCoord),
19395 pointOffset = point.sub(this._lastPoint);
19396 this._lastCoord = coord;
19397 this._lastPoint = point;
19398 this.target.setCoordinates(this.target.getCoordinates().add(coordOffset));
19399 eventParam['coordOffset'] = coordOffset;
19400 eventParam['pointOffset'] = pointOffset;
19401
19402 target.fire('dragging', eventParam);
19403 };
19404
19405 UIMarkerDragHandler.prototype._endDrag = function _endDrag(param) {
19406 var target = this.target,
19407 map = target.getMap();
19408 if (this._dragHandler) {
19409 target.off('click', this._endDrag, this);
19410 this._dragHandler.disable();
19411 delete this._dragHandler;
19412 }
19413 delete this._lastCoord;
19414 delete this._lastPoint;
19415 this._isDragging = false;
19416 if (!map) {
19417 return;
19418 }
19419 var eventParam = map._parseEvent(param['domEvent']);
19420
19421 target.fire('dragend', eventParam);
19422 };
19423
19424 UIMarkerDragHandler.prototype.isDragging = function isDragging() {
19425 if (!this._isDragging) {
19426 return false;
19427 }
19428 return true;
19429 };
19430
19431 return UIMarkerDragHandler;
19432}(Handler$1);
19433
19434UIMarker.addInitHook('addHandler', 'draggable', UIMarkerDragHandler);
19435
19436var options$21 = {
19437 'autoPan': true,
19438 'autoCloseOn': null,
19439 'autoOpenOn': 'click',
19440 'width': 300,
19441 'minHeight': 120,
19442 'custom': false,
19443 'title': null,
19444 'content': null
19445};
19446
19447var InfoWindow = function (_UIComponent) {
19448 inherits(InfoWindow, _UIComponent);
19449
19450 function InfoWindow() {
19451 classCallCheck(this, InfoWindow);
19452 return possibleConstructorReturn(this, _UIComponent.apply(this, arguments));
19453 }
19454
19455 InfoWindow.prototype._getClassName = function _getClassName() {
19456 return 'InfoWindow';
19457 };
19458
19459 InfoWindow.prototype.addTo = function addTo(owner) {
19460 if (owner instanceof Geometry) {
19461 if (owner.getInfoWindow() && owner.getInfoWindow() !== this) {
19462 owner.removeInfoWindow();
19463 }
19464 owner._infoWindow = this;
19465 }
19466 return _UIComponent.prototype.addTo.call(this, owner);
19467 };
19468
19469 InfoWindow.prototype.setContent = function setContent(content) {
19470 var old = this.options['content'];
19471 this.options['content'] = content;
19472
19473 this.fire('contentchange', {
19474 'old': old,
19475 'new': content
19476 });
19477 if (this.isVisible()) {
19478 this.show(this._coordinate);
19479 }
19480 return this;
19481 };
19482
19483 InfoWindow.prototype.getContent = function getContent() {
19484 return this.options['content'];
19485 };
19486
19487 InfoWindow.prototype.setTitle = function setTitle(title) {
19488 var old = title;
19489 this.options['title'] = title;
19490
19491 this.fire('contentchange', {
19492 'old': old,
19493 'new': title
19494 });
19495 if (this.isVisible()) {
19496 this.show(this._coordinate);
19497 }
19498 return this;
19499 };
19500
19501 InfoWindow.prototype.getTitle = function getTitle() {
19502 return this.options['title'];
19503 };
19504
19505 InfoWindow.prototype.buildOn = function buildOn() {
19506 if (this.options['custom']) {
19507 if (isString(this.options['content'])) {
19508 var _dom = createEl('div');
19509 _dom.innerHTML = this.options['content'];
19510 return _dom;
19511 } else {
19512 return this.options['content'];
19513 }
19514 }
19515 var dom = createEl('div');
19516 dom.className = 'maptalks-msgBox';
19517 dom.style.width = this._getWindowWidth() + 'px';
19518 dom.style.bottom = '0px';
19519 var content = '<em class="maptalks-ico"></em>';
19520 if (this.options['title']) {
19521 content += '<h2>' + this.options['title'] + '</h2>';
19522 }
19523 var onClose = '"this.parentNode.style.display=\'none\';return false;"';
19524 content += '<a href="javascript:void(0);" onclick=' + onClose + ' ontouchend=' + onClose + ' class="maptalks-close"></a><div class="maptalks-msgContent">' + this.options['content'] + '</div>';
19525 dom.innerHTML = content;
19526 return dom;
19527 };
19528
19529 InfoWindow.prototype.getTransformOrigin = function getTransformOrigin() {
19530 var size = this.getSize();
19531 return size.width / 2 + 'px bottom';
19532 };
19533
19534 InfoWindow.prototype.getOffset = function getOffset() {
19535 var size = this.getSize();
19536 var o = new Point(-size['width'] / 2, 0);
19537 if (!this.options['custom']) {
19538 o._sub(4, 12);
19539 }
19540 var owner = this.getOwner();
19541 if (owner instanceof Marker) {
19542 var painter = owner._getPainter();
19543 if (painter) {
19544 var markerSize = owner.getSize();
19545 var fixExtent = painter.getFixedExtent();
19546 o._add(fixExtent.xmax - markerSize.width / 2, fixExtent.ymin);
19547 }
19548 }
19549 return o;
19550 };
19551
19552 InfoWindow.prototype.show = function show(coordinate) {
19553 if (!this.getMap()) {
19554 return this;
19555 }
19556 if (!this.getMap().options['enableInfoWindow']) {
19557 return this;
19558 }
19559 return _UIComponent.prototype.show.call(this, coordinate);
19560 };
19561
19562 InfoWindow.prototype.getEvents = function getEvents() {
19563 if (!this.options['autoCloseOn']) {
19564 return null;
19565 }
19566 var events = {};
19567 events[this.options['autoCloseOn']] = this.hide;
19568 return events;
19569 };
19570
19571 InfoWindow.prototype.getOwnerEvents = function getOwnerEvents() {
19572 var owner = this.getOwner();
19573 if (!this.options['autoOpenOn'] || !owner) {
19574 return null;
19575 }
19576 var events = {};
19577 events[this.options['autoOpenOn']] = this._onAutoOpen;
19578 return events;
19579 };
19580
19581 InfoWindow.prototype._onAutoOpen = function _onAutoOpen(e) {
19582 var _this2 = this;
19583
19584 var owner = this.getOwner();
19585 setTimeout(function () {
19586 if (owner instanceof Marker) {
19587 _this2.show(owner.getCoordinates());
19588 } else {
19589 _this2.show(e.coordinate);
19590 }
19591 }, 1);
19592 };
19593
19594 InfoWindow.prototype._getWindowWidth = function _getWindowWidth() {
19595 var defaultWidth = 300;
19596 var width = this.options['width'];
19597 if (!width) {
19598 width = defaultWidth;
19599 }
19600 return width;
19601 };
19602
19603 return InfoWindow;
19604}(UIComponent);
19605
19606InfoWindow.mergeOptions(options$21);
19607
19608var options$22 = {
19609 'width': 0,
19610 'height': 0,
19611 'animation': 'fade',
19612 'cssName': 'maptalks-tooltip',
19613 'showTimeout': 400
19614};
19615
19616var ToolTip = function (_UIComponent) {
19617 inherits(ToolTip, _UIComponent);
19618
19619 ToolTip.prototype._getClassName = function _getClassName() {
19620 return 'ToolTip';
19621 };
19622
19623 function ToolTip(content) {
19624 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19625 classCallCheck(this, ToolTip);
19626
19627 var _this = possibleConstructorReturn(this, _UIComponent.call(this, options));
19628
19629 _this._content = content;
19630 return _this;
19631 }
19632
19633 ToolTip.prototype.addTo = function addTo(owner) {
19634 if (owner instanceof Geometry) {
19635 owner.on('mousemove', this.onMouseMove, this);
19636 owner.on('mouseout', this.onMouseOut, this);
19637 return _UIComponent.prototype.addTo.call(this, owner);
19638 } else {
19639 throw new Error('Invalid geometry the tooltip is added to.');
19640 }
19641 };
19642
19643 ToolTip.prototype.setStyle = function setStyle$$1(cssName) {
19644 this.options.cssName = cssName;
19645 return this;
19646 };
19647
19648 ToolTip.prototype.getStyle = function getStyle() {
19649 return this.options.cssName;
19650 };
19651
19652 ToolTip.prototype.getContent = function getContent() {
19653 return this._content;
19654 };
19655
19656 ToolTip.prototype.buildOn = function buildOn() {
19657 var dom = createEl('div');
19658 if (options$22.height) {
19659 dom.style.height = options$22.height + 'px';
19660 }
19661 if (options$22.width) {
19662 dom.style.width = options$22.width + 'px';
19663 }
19664 var cssName = this.options.cssName;
19665 if (!cssName && options$22.height) {
19666 dom.style.lineHeight = options$22.height + 'px';
19667 }
19668 dom.innerHTML = '<div class="' + cssName + '">' + this._content + '</div>';
19669 return dom;
19670 };
19671
19672 ToolTip.prototype.onMouseOut = function onMouseOut() {
19673 clearTimeout(this._timeout);
19674 if (this.isVisible()) {
19675 this._removePrevDOM();
19676 }
19677 };
19678
19679 ToolTip.prototype.onMouseMove = function onMouseMove(e) {
19680 var _this2 = this;
19681
19682 clearTimeout(this._timeout);
19683 var map = this.getMap();
19684 if (!map) {
19685 return;
19686 }
19687 var coord = map.locateByPoint(e.coordinate, -5, 25);
19688 if (this.options['showTimeout'] === 0) {
19689 this.show(coord);
19690 } else {
19691 this._timeout = setTimeout(function () {
19692 if (map) {
19693 _this2.show(coord);
19694 }
19695 }, this.options['showTimeout']);
19696 }
19697 };
19698
19699 ToolTip.prototype.onRemove = function onRemove() {
19700 clearTimeout(this._timeout);
19701 if (this._owner) {
19702 this._owner.off('mouseover', this.onMouseOver, this);
19703 this._owner.off('mouseout', this.onMouseOut, this);
19704 }
19705 };
19706
19707 return ToolTip;
19708}(UIComponent);
19709
19710ToolTip.mergeOptions(options$22);
19711
19712var defaultOptions = {
19713 'animation': null,
19714 'animationDelay': 10,
19715 'animationOnHide': false,
19716 'autoPan': false,
19717 'width': 160,
19718 'maxHeight': 0,
19719 'custom': false,
19720 'items': []
19721};
19722
19723var Menu = function (_UIComponent) {
19724 inherits(Menu, _UIComponent);
19725
19726 function Menu(options) {
19727 classCallCheck(this, Menu);
19728 return possibleConstructorReturn(this, _UIComponent.call(this, options));
19729 }
19730
19731 Menu.prototype._getClassName = function _getClassName() {
19732 return 'Menu';
19733 };
19734
19735 Menu.prototype.addTo = function addTo(owner) {
19736 if (owner._menu && owner._menu !== this) {
19737 owner.removeMenu();
19738 }
19739 owner._menu = this;
19740 return UIComponent.prototype.addTo.apply(this, arguments);
19741 };
19742
19743 Menu.prototype.setItems = function setItems(items) {
19744 this.options['items'] = items;
19745 return this;
19746 };
19747
19748 Menu.prototype.getItems = function getItems() {
19749 return this.options['items'] || [];
19750 };
19751
19752 Menu.prototype.buildOn = function buildOn() {
19753 if (this.options['custom']) {
19754 if (isString(this.options['items'])) {
19755 var container = createEl('div');
19756 container.innerHTML = this.options['items'];
19757 return container;
19758 } else {
19759 return this.options['items'];
19760 }
19761 } else {
19762 var dom = createEl('div');
19763 addClass(dom, 'maptalks-menu');
19764 dom.style.width = this._getMenuWidth() + 'px';
19765
19766 var menuItems = this._createMenuItemDom();
19767
19768 dom.appendChild(menuItems);
19769 on(dom, 'contextmenu', preventDefault);
19770 return dom;
19771 }
19772 };
19773
19774 Menu.prototype.getOffset = function getOffset() {
19775 if (!this.getMap()) {
19776 return null;
19777 }
19778 var mapSize = this.getMap().getSize(),
19779 p = this.getMap().viewPointToContainerPoint(this._getViewPoint()),
19780 size = this.getSize();
19781 var dx = 0,
19782 dy = 0;
19783 if (p.x + size['width'] > mapSize['width']) {
19784 dx = -size['width'];
19785 }
19786 if (p.y + size['height'] > mapSize['height']) {
19787 dy = -size['height'];
19788 }
19789 return new Point(dx, dy);
19790 };
19791
19792 Menu.prototype.getTransformOrigin = function getTransformOrigin() {
19793 var p = this.getOffset()._multi(-1);
19794 return p.x + 'px ' + p.y + 'px';
19795 };
19796
19797 Menu.prototype.getEvents = function getEvents() {
19798 return {
19799 '_zoomstart _zoomend _movestart _dblclick _click': this._removePrevDOM
19800 };
19801 };
19802
19803 Menu.prototype._createMenuItemDom = function _createMenuItemDom() {
19804 var me = this;
19805 var map = this.getMap();
19806 var ul = createEl('ul');
19807 addClass(ul, 'maptalks-menu-items');
19808 var items = this.getItems();
19809
19810 function onMenuClick(index) {
19811 return function (e) {
19812 var param = map._parseEvent(e, 'click');
19813 param['target'] = me;
19814 param['owner'] = me._owner;
19815 param['index'] = index;
19816 var result = this._callback(param);
19817 if (result === false) {
19818 return;
19819 }
19820 me.hide();
19821 };
19822 }
19823 var item = void 0,
19824 itemDOM = void 0;
19825 for (var i = 0, len = items.length; i < len; i++) {
19826 item = items[i];
19827 if (item === '-' || item === '_') {
19828 itemDOM = createEl('li');
19829 addClass(itemDOM, 'maptalks-menu-splitter');
19830 } else {
19831 itemDOM = createEl('li');
19832 var itemTitle = item['item'];
19833 if (isFunction(itemTitle)) {
19834 itemTitle = itemTitle({
19835 'owner': this._owner,
19836 'index': i
19837 });
19838 }
19839 itemDOM.innerHTML = itemTitle;
19840 itemDOM._callback = item['click'];
19841 on(itemDOM, 'click', onMenuClick(i));
19842 }
19843 ul.appendChild(itemDOM);
19844 }
19845 var maxHeight = this.options['maxHeight'] || 0;
19846 if (maxHeight > 0) {
19847 setStyle(ul, 'max-height: ' + maxHeight + 'px; overflow-y: auto;');
19848 }
19849 return ul;
19850 };
19851
19852 Menu.prototype._getMenuWidth = function _getMenuWidth() {
19853 var defaultWidth = 160;
19854 var width = this.options['width'] || defaultWidth;
19855 return width;
19856 };
19857
19858 return Menu;
19859}(UIComponent);
19860
19861Menu.mergeOptions(defaultOptions);
19862
19863var Menuable = {
19864 setMenu: function setMenu(options) {
19865 this._menuOptions = options;
19866
19867 if (this._menu) {
19868 this._menu.setOptions(options);
19869 } else {
19870 this.on('contextmenu', this._defaultOpenMenu, this);
19871 }
19872 return this;
19873 },
19874 openMenu: function openMenu(coordinate) {
19875 var map = this instanceof Map ? this : this.getMap();
19876 if (!coordinate) {
19877 coordinate = this.getCenter();
19878 }
19879 if (!this._menu) {
19880 if (this._menuOptions && map) {
19881 this._bindMenu(this._menuOptions);
19882 this._menu.show(coordinate);
19883 }
19884 } else {
19885 this._menu.show(coordinate);
19886 }
19887 return this;
19888 },
19889 setMenuItems: function setMenuItems(items) {
19890 if (!this._menuOptions) {
19891 this._menuOptions = {};
19892 }
19893 if (Array.isArray(items)) {
19894 this._menuOptions['custom'] = false;
19895 }
19896 this._menuOptions['items'] = items;
19897 this.setMenu(this._menuOptions);
19898 return this;
19899 },
19900 getMenuItems: function getMenuItems() {
19901 if (this._menu) {
19902 return this._menu.getItems();
19903 } else if (this._menuOptions) {
19904 return this._menuOptions['items'] || [];
19905 }
19906 return [];
19907 },
19908 closeMenu: function closeMenu() {
19909 if (this._menu) {
19910 this._menu.hide();
19911 }
19912 return this;
19913 },
19914 removeMenu: function removeMenu() {
19915 this.off('contextmenu', this._defaultOpenMenu, this);
19916 this._unbindMenu();
19917 delete this._menuOptions;
19918 return this;
19919 },
19920 _bindMenu: function _bindMenu(options) {
19921 this._menu = new Menu(options);
19922 this._menu.addTo(this);
19923
19924 return this;
19925 },
19926 _unbindMenu: function _unbindMenu() {
19927 if (this._menu) {
19928 this.closeMenu();
19929 this._menu.remove();
19930 delete this._menu;
19931 }
19932 return this;
19933 },
19934 _defaultOpenMenu: function _defaultOpenMenu(param) {
19935 if (this.listens('contextmenu') > 1) {
19936 return true;
19937 } else {
19938 this.openMenu(param['coordinate']);
19939 return false;
19940 }
19941 }
19942};
19943
19944Map.include(Menuable);
19945Geometry.include(Menuable);
19946
19947
19948
19949var index$4 = Object.freeze({
19950 UIComponent: UIComponent,
19951 UIMarker: UIMarker,
19952 InfoWindow: InfoWindow,
19953 ToolTip: ToolTip,
19954 Menuable: Menuable,
19955 Menu: Menu
19956});
19957
19958var Control = function (_Eventable) {
19959 inherits(Control, _Eventable);
19960
19961 function Control(options) {
19962 classCallCheck(this, Control);
19963
19964 if (options && options['position'] && !isString(options['position'])) {
19965 options['position'] = extend({}, options['position']);
19966 }
19967 return possibleConstructorReturn(this, _Eventable.call(this, options));
19968 }
19969
19970 Control.prototype.addTo = function addTo(map) {
19971 this.remove();
19972 if (!map.options['control']) {
19973 return this;
19974 }
19975 this._map = map;
19976 var controlContainer = map._panels.control;
19977 this.__ctrlContainer = createEl('div');
19978 setStyle(this.__ctrlContainer, 'position:absolute;overflow:visible;');
19979
19980 this.update();
19981 controlContainer.appendChild(this.__ctrlContainer);
19982 if (this.onAdd) {
19983 this.onAdd();
19984 }
19985
19986 this.fire('add', {
19987 'dom': controlContainer
19988 });
19989 return this;
19990 };
19991
19992 Control.prototype.update = function update() {
19993 this.__ctrlContainer.innerHTML = '';
19994 this._controlDom = this.buildOn(this.getMap());
19995 if (this._controlDom) {
19996 this._updatePosition();
19997 this.__ctrlContainer.appendChild(this._controlDom);
19998 }
19999 return this;
20000 };
20001
20002 Control.prototype.getMap = function getMap() {
20003 return this._map;
20004 };
20005
20006 Control.prototype.getPosition = function getPosition() {
20007 return extend({}, this._parse(this.options['position']));
20008 };
20009
20010 Control.prototype.setPosition = function setPosition(position) {
20011 if (isString(position)) {
20012 this.options['position'] = position;
20013 } else {
20014 this.options['position'] = extend({}, position);
20015 }
20016 this._updatePosition();
20017 return this;
20018 };
20019
20020 Control.prototype.getContainerPoint = function getContainerPoint() {
20021 var position = this.getPosition();
20022
20023 var size = this.getMap().getSize();
20024 var x = void 0,
20025 y = void 0;
20026 if (!isNil(position['left'])) {
20027 x = parseInt(position['left']);
20028 } else if (!isNil(position['right'])) {
20029 x = size['width'] - parseInt(position['right']);
20030 }
20031 if (!isNil(position['top'])) {
20032 y = parseInt(position['top']);
20033 } else if (!isNil(position['bottom'])) {
20034 y = size['height'] - parseInt(position['bottom']);
20035 }
20036 return new Point(x, y);
20037 };
20038
20039 Control.prototype.getContainer = function getContainer() {
20040 return this.__ctrlContainer;
20041 };
20042
20043 Control.prototype.getDOM = function getDOM() {
20044 return this._controlDom;
20045 };
20046
20047 Control.prototype.show = function show() {
20048 this.__ctrlContainer.style.display = '';
20049 return this;
20050 };
20051
20052 Control.prototype.hide = function hide() {
20053 this.__ctrlContainer.style.display = 'none';
20054 return this;
20055 };
20056
20057 Control.prototype.isVisible = function isVisible() {
20058 return this.__ctrlContainer && this.__ctrlContainer.style.display === '';
20059 };
20060
20061 Control.prototype.remove = function remove() {
20062 if (!this._map) {
20063 return this;
20064 }
20065 removeDomNode(this.__ctrlContainer);
20066 if (this.onRemove) {
20067 this.onRemove();
20068 }
20069 delete this._map;
20070 delete this.__ctrlContainer;
20071 delete this._controlDom;
20072
20073 this.fire('remove');
20074 return this;
20075 };
20076
20077 Control.prototype._parse = function _parse(position) {
20078 var p = position;
20079 if (isString(position)) {
20080 p = Control['positions'][p];
20081 }
20082 return p;
20083 };
20084
20085 Control.prototype._updatePosition = function _updatePosition() {
20086 var position = this.getPosition();
20087 if (!position) {
20088 position = {
20089 'top': 20,
20090 'left': 20
20091 };
20092 }
20093 for (var p in position) {
20094 if (position.hasOwnProperty(p)) {
20095 position[p] = parseInt(position[p]);
20096 this.__ctrlContainer.style[p] = position[p] + 'px';
20097 }
20098 }
20099
20100 this.fire('positionchange', {
20101 'position': extend({}, position)
20102 });
20103 };
20104
20105 return Control;
20106}(Eventable(Class));
20107
20108Control.positions = {
20109 'top-left': {
20110 'top': 20,
20111 'left': 20
20112 },
20113 'top-right': {
20114 'top': 20,
20115 'right': 20
20116 },
20117 'bottom-left': {
20118 'bottom': 20,
20119 'left': 20
20120 },
20121 'bottom-right': {
20122 'bottom': 20,
20123 'right': 20
20124 }
20125};
20126
20127Map.mergeOptions({
20128 'control': true
20129});
20130
20131Map.include({
20132 addControl: function addControl(control) {
20133 if (this._containerDOM.getContext) {
20134 return this;
20135 }
20136 control.addTo(this);
20137 return this;
20138 },
20139
20140 removeControl: function removeControl(control) {
20141 if (!control || control.getMap() !== this) {
20142 return this;
20143 }
20144 control.remove();
20145 return this;
20146 }
20147
20148});
20149
20150var options$23 = {
20151 'position': {
20152 'bottom': 0,
20153 'left': 0
20154 },
20155 'content': '<a href="http://maptalks.org" target="_blank">maptalks</a>'
20156};
20157
20158var layerEvents = 'addlayer removelayer setbaselayer baselayerremove';
20159
20160var Attribution = function (_Control) {
20161 inherits(Attribution, _Control);
20162
20163 function Attribution() {
20164 classCallCheck(this, Attribution);
20165 return possibleConstructorReturn(this, _Control.apply(this, arguments));
20166 }
20167
20168 Attribution.prototype.buildOn = function buildOn() {
20169 this._attributionContainer = createEl('div');
20170 this._attributionContainer.className = 'maptalks-attribution';
20171 this._update();
20172 return this._attributionContainer;
20173 };
20174
20175 Attribution.prototype.onAdd = function onAdd() {
20176 this.getMap().on(layerEvents, this._update, this);
20177 };
20178
20179 Attribution.prototype.onRemove = function onRemove() {
20180 this.getMap().off(layerEvents, this._update, this);
20181 };
20182
20183 Attribution.prototype._update = function _update() {
20184 var map = this.getMap();
20185 if (!map) {
20186 return;
20187 }
20188
20189 var attributions = map._getLayers(function (layer) {
20190 return layer.options['attribution'];
20191 }).reverse().map(function (layer) {
20192 return layer.options['attribution'];
20193 });
20194 var content = this.options['content'] + (attributions.length > 0 ? ' - ' + attributions.join(', ') : '');
20195 this._attributionContainer.innerHTML = '<span style="padding:0px 4px">' + content + '</span>';
20196 };
20197
20198 return Attribution;
20199}(Control);
20200
20201Attribution.mergeOptions(options$23);
20202
20203Map.mergeOptions({
20204 'attribution': true
20205});
20206
20207Map.addOnLoadHook(function () {
20208 var a = this.options['attribution'] || this.options['attributionControl'];
20209 if (a) {
20210 this.attributionControl = new Attribution(a);
20211 this.addControl(this.attributionControl);
20212 }
20213});
20214
20215var options$24 = {
20216 'position': 'top-right',
20217 'baseTitle': 'Base Layers',
20218 'overlayTitle': 'Layers',
20219 'excludeLayers': [],
20220 'containerClass': 'maptalks-layer-switcher'
20221};
20222
20223var LayerSwitcher = function (_Control) {
20224 inherits(LayerSwitcher, _Control);
20225
20226 function LayerSwitcher() {
20227 classCallCheck(this, LayerSwitcher);
20228 return possibleConstructorReturn(this, _Control.apply(this, arguments));
20229 }
20230
20231 LayerSwitcher.prototype.buildOn = function buildOn() {
20232 var container = this.container = createEl('div', this.options['containerClass']),
20233 panel = this.panel = createEl('div', 'panel'),
20234 button = this.button = createEl('button');
20235 container.appendChild(button);
20236 container.appendChild(panel);
20237 return container;
20238 };
20239
20240 LayerSwitcher.prototype.onAdd = function onAdd() {
20241 on(this.button, 'mouseover', this._show, this);
20242 on(this.panel, 'mouseleave', this._hide, this);
20243 on(this.getMap(), 'click', this._hide, this);
20244 };
20245
20246 LayerSwitcher.prototype.onRemove = function onRemove() {
20247 if (this.panel) {
20248 off(this.button, 'mouseover', this._show, this);
20249 off(this.panel, 'mouseleave', this._hide, this);
20250 off(this.getMap(), 'click', this._hide, this);
20251 removeDomNode(this.panel);
20252 removeDomNode(this.button);
20253 delete this.panel;
20254 delete this.button;
20255 delete this.container;
20256 }
20257 };
20258
20259 LayerSwitcher.prototype._show = function _show() {
20260 if (!hasClass(this.container, 'shown')) {
20261 addClass(this.container, 'shown');
20262 this._createPanel();
20263 }
20264 };
20265
20266 LayerSwitcher.prototype._hide = function _hide(e) {
20267 if (!this.panel.contains(e.toElement || e.relatedTarget)) {
20268 setClass(this.container, this.options['containerClass']);
20269 }
20270 };
20271
20272 LayerSwitcher.prototype._createPanel = function _createPanel() {
20273 this.panel.innerHTML = '';
20274 var ul = createEl('ul');
20275 this.panel.appendChild(ul);
20276 this._renderLayers(this.getMap(), ul);
20277 };
20278
20279 LayerSwitcher.prototype._renderLayers = function _renderLayers(map, elm) {
20280 var base = map.getBaseLayer(),
20281 layers = map.getLayers(),
20282 len = layers.length;
20283 if (base) {
20284 var baseLayers = base.layers || [base],
20285 li = createEl('li', 'group'),
20286 ul = createEl('ul'),
20287 label = createEl('label');
20288 label.innerHTML = this.options['baseTitle'];
20289 li.appendChild(label);
20290 for (var i = 0, _len = baseLayers.length; i < _len; i++) {
20291 var layer = baseLayers[i];
20292 if (this._isExcluded(layer)) {
20293 ul.appendChild(this._renderLayer(baseLayers[i], true));
20294 li.appendChild(ul);
20295 elm.appendChild(li);
20296 }
20297 }
20298 }
20299
20300 if (len) {
20301 var _li = createEl('li', 'group'),
20302 _ul = createEl('ul'),
20303 _label = createEl('label');
20304 _label.innerHTML = this.options['overlayTitle'];
20305 _li.appendChild(_label);
20306 for (var _i = 0; _i < len; _i++) {
20307 var _layer = layers[_i];
20308 if (this._isExcluded(_layer)) {
20309 _ul.appendChild(this._renderLayer(_layer));
20310 }
20311 }
20312 _li.appendChild(_ul);
20313 elm.appendChild(_li);
20314 }
20315 };
20316
20317 LayerSwitcher.prototype._isExcluded = function _isExcluded(layer) {
20318 var id = layer.getId(),
20319 excludeLayers = this.options['excludeLayers'];
20320 return !(excludeLayers.length && excludeLayers.indexOf(id) >= 0);
20321 };
20322
20323 LayerSwitcher.prototype._renderLayer = function _renderLayer(layer, isBase) {
20324 var _this2 = this;
20325
20326 var li = createEl('li', 'layer'),
20327 label = createEl('label'),
20328 input = createEl('input'),
20329 map = this.getMap();
20330 var visible = layer.options['visible'];
20331 layer.options['visible'] = true;
20332 var enabled = layer.isVisible();
20333 layer.options['visible'] = visible;
20334 li.className = 'layer';
20335 if (isBase) {
20336 input.type = 'radio';
20337 input.name = 'base';
20338 } else {
20339 input.type = 'checkbox';
20340 }
20341
20342 input.checked = visible && enabled;
20343 if (!enabled) {
20344 input.setAttribute('disabled', 'disabled');
20345 }
20346
20347 input.onchange = function (e) {
20348 if (e.target.type === 'radio') {
20349 var baseLayer = map.getBaseLayer(),
20350 baseLayers = baseLayer.layers;
20351 if (baseLayers) {
20352 for (var i = 0, len = baseLayers.length; i < len; i++) {
20353 var _baseLayer = baseLayers[i];
20354 _baseLayer[_baseLayer === layer ? 'show' : 'hide']();
20355 }
20356 } else if (!baseLayer.isVisible()) {
20357 baseLayer.show();
20358 }
20359 map._fireEvent('setbaselayer');
20360 } else {
20361 layer[e.target.checked ? 'show' : 'hide']();
20362 }
20363 _this2.fire('layerchange', { target: layer });
20364 };
20365 li.appendChild(input);
20366 label.innerHTML = layer.getId();
20367 li.appendChild(label);
20368 return li;
20369 };
20370
20371 return LayerSwitcher;
20372}(Control);
20373
20374LayerSwitcher.mergeOptions(options$24);
20375
20376Map.mergeOptions({
20377 'layerSwitcherControl': false
20378});
20379
20380Map.addOnLoadHook(function () {
20381 if (this.options['layerSwitcherControl']) {
20382 this.layerSwitcherControl = new LayerSwitcher(this.options['layerSwitcherControl']);
20383 this.addControl(this.layerSwitcherControl);
20384 }
20385});
20386
20387var options$25 = {
20388 'level': 4,
20389 'position': {
20390 'right': 1,
20391 'bottom': 1
20392 },
20393 'size': [300, 200],
20394 'maximize': true,
20395 'symbol': {
20396 'lineWidth': 3,
20397 'lineColor': '#1bbc9b',
20398 'polygonFill': '#1bbc9b',
20399 'polygonOpacity': 0.4
20400 },
20401 'containerClass': 'maptalks-overview',
20402 'buttonClass': 'maptalks-overview-button'
20403};
20404
20405var Overview = function (_Control) {
20406 inherits(Overview, _Control);
20407
20408 function Overview() {
20409 classCallCheck(this, Overview);
20410 return possibleConstructorReturn(this, _Control.apply(this, arguments));
20411 }
20412
20413 Overview.prototype.buildOn = function buildOn() {
20414 var size = this.options['size'];
20415 if (!this.options['maximize']) {
20416 size = [0, 0];
20417 }
20418 var container = createEl('div');
20419
20420 var mapContainer = this.mapContainer = createEl('div');
20421 mapContainer.style.width = size[0] + 'px';
20422 mapContainer.style.height = size[1] + 'px';
20423 mapContainer.className = this.options['containerClass'];
20424 var button = this.button = createEl('div');
20425 button.className = this.options['buttonClass'];
20426 container.appendChild(mapContainer);
20427 container.appendChild(button);
20428 return container;
20429 };
20430
20431 Overview.prototype.onAdd = function onAdd() {
20432 if (this.options['maximize']) {
20433 this._createOverview();
20434 }
20435 this.getMap().on('resize moving zooming rotate dragrotating viewchange', this._update, this).on('setbaselayer', this._updateBaseLayer, this).on('spatialreferencechange', this._updateSpatialReference, this);
20436 on(this.button, 'click', this._onButtonClick, this);
20437 this._updateButtonText();
20438 };
20439
20440 Overview.prototype.onRemove = function onRemove() {
20441 this.getMap().off('resize moving zooming rotate dragrotating viewchange', this._update, this).off('setbaselayer', this._updateBaseLayer, this).off('spatialreferencechange', this._updateSpatialReference, this);
20442 if (this._overview) {
20443 this._overview.remove();
20444 delete this._overview;
20445 delete this._perspective;
20446 }
20447 off(this.button, 'click', this._onButtonClick, this);
20448 };
20449
20450 Overview.prototype.maxmize = function maxmize() {
20451 var size = this.options['size'];
20452 var dom = this.mapContainer;
20453 dom.style.width = size[0] + 'px';
20454 dom.style.height = size[1] + 'px';
20455 this._createOverview();
20456 };
20457
20458 Overview.prototype.minimize = function minimize() {
20459 if (this._overview) {
20460 this._overview.remove();
20461 }
20462 delete this._overview;
20463 delete this._perspective;
20464 var dom = this.mapContainer;
20465 dom.style.width = 0 + 'px';
20466 dom.style.height = 0 + 'px';
20467 };
20468
20469 Overview.prototype._onButtonClick = function _onButtonClick() {
20470 if (!this._overview) {
20471 this.maxmize();
20472 } else {
20473 this.minimize();
20474 }
20475 this._updateButtonText();
20476 };
20477
20478 Overview.prototype._updateButtonText = function _updateButtonText() {
20479 if (this._overview) {
20480 this.button.innerHTML = '-';
20481 } else {
20482 this.button.innerHTML = '+';
20483 }
20484 };
20485
20486 Overview.prototype._createOverview = function _createOverview() {
20487 var map = this.getMap(),
20488 dom = this.mapContainer;
20489 var options = map.config();
20490 extend(options, {
20491 'center': map.getCenter(),
20492 'zoom': this._getOverviewZoom(),
20493 'zoomAnimationDuration': 150,
20494 'pitch': 0,
20495 'bearing': 0,
20496 'scrollWheelZoom': false,
20497 'checkSize': false,
20498 'doubleClickZoom': false,
20499 'touchZoom': false,
20500 'control': false,
20501 'draggable': false,
20502 'maxExtent': null
20503 });
20504 this._overview = new Map(dom, options);
20505 this._updateBaseLayer();
20506 this._perspective = new Polygon(this._getPerspectiveCoords(), {
20507 'draggable': true,
20508 'cursor': 'move',
20509 'symbol': this.options['symbol']
20510 }).on('dragend', this._onDragEnd, this);
20511 new VectorLayer('perspective_layer', this._perspective).addTo(this._overview);
20512 this.fire('load');
20513 };
20514
20515 Overview.prototype._getOverviewZoom = function _getOverviewZoom() {
20516 var map = this.getMap(),
20517 zoom = map.getZoom(),
20518 minZoom = map.getMinZoom(),
20519 level = this.options['level'];
20520 if (level > 0) {
20521 for (var i = level; i > 0; i--) {
20522 if (zoom - i >= minZoom) {
20523 return zoom - i;
20524 }
20525 }
20526 } else {
20527 for (var _i = level; _i < 0; _i++) {
20528 if (zoom - _i >= minZoom) {
20529 return zoom - _i;
20530 }
20531 }
20532 }
20533
20534 return zoom;
20535 };
20536
20537 Overview.prototype._onDragEnd = function _onDragEnd() {
20538 var center = this._perspective.getCenter();
20539 this._overview.setCenter(center);
20540 this.getMap().panTo(center);
20541 };
20542
20543 Overview.prototype._getPerspectiveCoords = function _getPerspectiveCoords() {
20544 var map = this.getMap();
20545 return map.getContainerExtent().toArray().map(function (c) {
20546 return map.containerPointToCoordinate(c);
20547 });
20548 };
20549
20550 Overview.prototype._update = function _update() {
20551 if (!this._overview) {
20552 return;
20553 }
20554 var coords = this._getPerspectiveCoords();
20555 this._perspective.setCoordinates(coords);
20556 this._overview.setCenterAndZoom(this.getMap().getCenter(), this._getOverviewZoom());
20557 };
20558
20559 Overview.prototype._updateSpatialReference = function _updateSpatialReference() {
20560 if (!this._overview) {
20561 return;
20562 }
20563 var map = this.getMap();
20564 var spatialRef = map.options['spatialReference'];
20565 this._overview.setSpatialReference(spatialRef);
20566 };
20567
20568 Overview.prototype._updateBaseLayer = function _updateBaseLayer() {
20569 if (!this._overview) {
20570 return;
20571 }
20572 var map = this.getMap(),
20573 baseLayer = map.getBaseLayer();
20574 if (!baseLayer) {
20575 this._overview.setBaseLayer(null);
20576 return;
20577 }
20578 var layers = baseLayer.layers;
20579 var showIndex = 0;
20580 if (layers) {
20581 for (var i = 0, l = layers.length; i < l; i++) {
20582 var _layer = layers[i];
20583 if (_layer.isVisible()) {
20584 showIndex = i;
20585 break;
20586 }
20587 }
20588 }
20589
20590 var json = baseLayer.toJSON();
20591 var options = null;
20592 if (layers) {
20593 options = json.layers[showIndex].options;
20594 options.visible = true;
20595 } else {
20596 options = json.options;
20597 }
20598 this._overview.setMinZoom(options.minZoom || null).setMaxZoom(options.maxZoom || null);
20599 delete options.minZoom;
20600 delete options.maxZoom;
20601 delete json.options.canvas;
20602 json.options.visible = true;
20603 json.options.renderer = 'canvas';
20604 var layer = Layer.fromJSON(json);
20605 for (var p in baseLayer) {
20606 if (isFunction(baseLayer[p]) && baseLayer.hasOwnProperty(p) && baseLayer[p] !== baseLayer.constructor.prototype[p]) {
20607 layer[p] = baseLayer[p];
20608 }
20609 }
20610 this._overview.setBaseLayer(layer);
20611 };
20612
20613 return Overview;
20614}(Control);
20615
20616Overview.mergeOptions(options$25);
20617
20618Map.mergeOptions({
20619 'overviewControl': false
20620});
20621
20622Map.addOnLoadHook(function () {
20623 if (this.options['overviewControl']) {
20624 this.overviewControl = new Overview(this.options['overviewControl']);
20625 this.addControl(this.overviewControl);
20626 }
20627});
20628
20629var options$26 = {
20630 'position': 'top-right',
20631 'draggable': true,
20632 'custom': false,
20633 'content': '',
20634 'closeButton': true
20635};
20636
20637var Panel = function (_Control) {
20638 inherits(Panel, _Control);
20639
20640 function Panel() {
20641 classCallCheck(this, Panel);
20642 return possibleConstructorReturn(this, _Control.apply(this, arguments));
20643 }
20644
20645 Panel.prototype.buildOn = function buildOn() {
20646 var dom = void 0;
20647 if (this.options['custom']) {
20648 if (isString(this.options['content'])) {
20649 dom = createEl('div');
20650 dom.innerHTML = this.options['content'];
20651 } else {
20652 dom = this.options['content'];
20653 }
20654 } else {
20655 dom = createEl('div', 'maptalks-panel');
20656 if (this.options['closeButton']) {
20657 var closeButton = createEl('a', 'maptalks-close');
20658 closeButton.href = 'javascript:;';
20659 closeButton.onclick = function () {
20660 dom.style.display = 'none';
20661 };
20662 dom.appendChild(closeButton);
20663 }
20664
20665 var panelContent = createEl('div', 'maptalks-panel-content');
20666 panelContent.innerHTML = this.options['content'];
20667 dom.appendChild(panelContent);
20668 }
20669
20670 this.draggable = new DragHandler(dom, {
20671 'cancelOn': this._cancelOn.bind(this),
20672 'ignoreMouseleave': true
20673 });
20674
20675 this.draggable.on('dragstart', this._onDragStart, this).on('dragging', this._onDragging, this).on('dragend', this._onDragEnd, this);
20676
20677 if (this.options['draggable']) {
20678 this.draggable.enable();
20679 }
20680
20681 return dom;
20682 };
20683
20684 Panel.prototype.update = function update() {
20685 if (this.draggable) {
20686 this.draggable.disable();
20687 delete this.draggable;
20688 }
20689 return Control.prototype.update.call(this);
20690 };
20691
20692 Panel.prototype.setContent = function setContent(content) {
20693 var old = this.options['content'];
20694 this.options['content'] = content;
20695
20696 this.fire('contentchange', {
20697 'old': old,
20698 'new': content
20699 });
20700 if (this.isVisible()) {
20701 this.update();
20702 }
20703 return this;
20704 };
20705
20706 Panel.prototype.getContent = function getContent() {
20707 return this.options['content'];
20708 };
20709
20710 Panel.prototype._cancelOn = function _cancelOn(domEvent) {
20711 var target = domEvent.srcElement || domEvent.target,
20712 tagName = target.tagName.toLowerCase();
20713 if (tagName === 'button' || tagName === 'input' || tagName === 'select' || tagName === 'option' || tagName === 'textarea') {
20714 return true;
20715 }
20716 return false;
20717 };
20718
20719 Panel.prototype._onDragStart = function _onDragStart(param) {
20720 this._startPos = param['mousePos'];
20721 this._startPosition = extend({}, this.getPosition());
20722
20723 this.fire('dragstart', param);
20724 };
20725
20726 Panel.prototype._onDragging = function _onDragging(param) {
20727 var pos = param['mousePos'];
20728 var offset = pos.sub(this._startPos);
20729
20730 var startPosition = this._startPosition;
20731 var position = this.getPosition();
20732 if (!isNil(position['top'])) {
20733 position['top'] = parseInt(startPosition['top']) + offset.y;
20734 }
20735 if (!isNil(position['bottom'])) {
20736 position['bottom'] = parseInt(startPosition['bottom']) - offset.y;
20737 }
20738 if (!isNil(position['left'])) {
20739 position['left'] = parseInt(startPosition['left']) + offset.x;
20740 }
20741 if (!isNil(position['right'])) {
20742 position['right'] = parseInt(startPosition['right']) - offset.x;
20743 }
20744 this.setPosition(position);
20745
20746 this.fire('dragging', param);
20747 };
20748
20749 Panel.prototype._onDragEnd = function _onDragEnd(param) {
20750 delete this._startPos;
20751 delete this._startPosition;
20752
20753 this.fire('dragend', param);
20754 };
20755
20756 Panel.prototype._getConnectPoints = function _getConnectPoints() {
20757 var map = this.getMap();
20758 var containerPoint = this.getContainerPoint();
20759 var dom = this.getDOM(),
20760 width = parseInt(dom.clientWidth),
20761 height = parseInt(dom.clientHeight);
20762 var anchors = [map.containerPointToCoordinate(containerPoint.add(width / 2, 0)), map.containerPointToCoordinate(containerPoint.add(width, height / 2)), map.containerPointToCoordinate(containerPoint.add(width / 2, height)), map.containerPointToCoordinate(containerPoint.add(0, height / 2))];
20763 return anchors;
20764 };
20765
20766 return Panel;
20767}(Control);
20768
20769Panel.mergeOptions(options$26);
20770
20771var options$27 = {
20772 'position': 'bottom-left',
20773 'maxWidth': 100,
20774 'metric': true,
20775 'imperial': false
20776};
20777
20778var Scale = function (_Control) {
20779 inherits(Scale, _Control);
20780
20781 function Scale() {
20782 classCallCheck(this, Scale);
20783 return possibleConstructorReturn(this, _Control.apply(this, arguments));
20784 }
20785
20786 Scale.prototype.buildOn = function buildOn(map) {
20787 this._map = map;
20788 this._scaleContainer = createEl('div');
20789 this._addScales();
20790 map.on('zoomend', this._update, this);
20791 if (this._map._loaded) {
20792 this._update();
20793 }
20794 return this._scaleContainer;
20795 };
20796
20797 Scale.prototype.onRemove = function onRemove() {
20798 this.getMap().off('zoomend', this._update, this);
20799 };
20800
20801 Scale.prototype._addScales = function _addScales() {
20802 var css = 'border: 2px solid #000000;border-top: none;line-height: 1.1;padding: 2px 5px 1px;' + 'color: #000000;font-size: 11px;text-align:center;white-space: nowrap;overflow: hidden' + ';-moz-box-sizing: content-box;box-sizing: content-box;background: #fff; background: rgba(255, 255, 255, 0);';
20803 if (this.options['metric']) {
20804 this._mScale = createElOn('div', css, this._scaleContainer);
20805 }
20806 if (this.options['imperial']) {
20807 this._iScale = createElOn('div', css, this._scaleContainer);
20808 }
20809 };
20810
20811 Scale.prototype._update = function _update() {
20812 var map = this._map;
20813 var maxMeters = map.pixelToDistance(this.options['maxWidth'], 0);
20814 this._updateScales(maxMeters);
20815 };
20816
20817 Scale.prototype._updateScales = function _updateScales(maxMeters) {
20818 if (this.options['metric'] && maxMeters) {
20819 this._updateMetric(maxMeters);
20820 }
20821 if (this.options['imperial'] && maxMeters) {
20822 this._updateImperial(maxMeters);
20823 }
20824 };
20825
20826 Scale.prototype._updateMetric = function _updateMetric(maxMeters) {
20827 var meters = this._getRoundNum(maxMeters),
20828 label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
20829
20830 this._updateScale(this._mScale, label, meters / maxMeters);
20831 };
20832
20833 Scale.prototype._updateImperial = function _updateImperial(maxMeters) {
20834 var maxFeet = maxMeters * 3.2808399;
20835 var maxMiles = void 0,
20836 miles = void 0,
20837 feet = void 0;
20838
20839 if (maxFeet > 5280) {
20840 maxMiles = maxFeet / 5280;
20841 miles = this._getRoundNum(maxMiles);
20842 this._updateScale(this._iScale, miles + ' mile', miles / maxMiles);
20843 } else {
20844 feet = this._getRoundNum(maxFeet);
20845 this._updateScale(this._iScale, feet + ' feet', feet / maxFeet);
20846 }
20847 };
20848
20849 Scale.prototype._updateScale = function _updateScale(scale, text, ratio) {
20850 scale['style']['width'] = Math.round(this.options['maxWidth'] * ratio) + 'px';
20851 scale['innerHTML'] = text;
20852 };
20853
20854 Scale.prototype._getRoundNum = function _getRoundNum(num) {
20855 var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
20856 var d = num / pow10;
20857
20858 d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
20859
20860 return pow10 * d;
20861 };
20862
20863 return Scale;
20864}(Control);
20865
20866Scale.mergeOptions(options$27);
20867
20868Map.mergeOptions({
20869 'scaleControl': false
20870});
20871
20872Map.addOnLoadHook(function () {
20873 if (this.options['scaleControl']) {
20874 this.scaleControl = new Scale(this.options['scaleControl']);
20875 this.addControl(this.scaleControl);
20876 }
20877});
20878
20879var options$28 = {
20880 'height': 28,
20881 'vertical': false,
20882 'position': 'top-right',
20883 'reverseMenu': false,
20884 'items': {}
20885};
20886
20887var Toolbar = function (_Control) {
20888 inherits(Toolbar, _Control);
20889
20890 function Toolbar() {
20891 classCallCheck(this, Toolbar);
20892 return possibleConstructorReturn(this, _Control.apply(this, arguments));
20893 }
20894
20895 Toolbar.prototype.buildOn = function buildOn(map) {
20896 this._map = map;
20897 var dom = createEl('div');
20898 var ul = createEl('ul', 'maptalks-toolbar-hx');
20899 dom.appendChild(ul);
20900
20901 if (this.options['vertical']) {
20902 addClass(dom, 'maptalks-toolbar-vertical');
20903 } else {
20904 addClass(dom, 'maptalks-toolbar-horizonal');
20905 }
20906 var me = this;
20907
20908 function onButtonClick(fn, index, childIndex, targetDom) {
20909 var item = me._getItems()[index];
20910 return function (e) {
20911 stopPropagation(e);
20912 return fn({
20913 'target': item,
20914 'index': index,
20915 'childIndex': childIndex,
20916 'dom': targetDom
20917 });
20918 };
20919 }
20920
20921 var items = this.options['items'];
20922 if (isArrayHasData(items)) {
20923 for (var i = 0, len = items.length; i < len; i++) {
20924 var item = items[i];
20925 var li = createEl('li');
20926 if (this.options['height'] !== 28) {
20927 li.style.lineHeight = this.options['height'] + 'px';
20928 }
20929 li.style.height = this.options['height'] + 'px';
20930 li.style.cursor = 'pointer';
20931 if (isHTML(item['item'])) {
20932 li.style.textAlign = 'center';
20933 var itemSize = measureDom('div', item['item']);
20934
20935 li.innerHTML = '<div style="margin-top:' + (this.options['height'] - itemSize['height']) / 2 + 'px;">' + item['item'] + '</div>';
20936 } else {
20937 li.innerHTML = item['item'];
20938 }
20939 if (item['click']) {
20940 on(li, 'click', onButtonClick(item['click'], i, null, li));
20941 }
20942 if (isArrayHasData(item['children'])) {
20943 var dropMenu = this._createDropMenu(i);
20944 li.appendChild(dropMenu);
20945 li._menu = dropMenu;
20946 on(li, 'mouseover', function () {
20947 this._menu.style.display = '';
20948 });
20949 on(li, 'mouseout', function () {
20950 this._menu.style.display = 'none';
20951 });
20952 }
20953 ul.appendChild(li);
20954 }
20955 }
20956 return dom;
20957 };
20958
20959 Toolbar.prototype._createDropMenu = function _createDropMenu(index) {
20960 var me = this;
20961
20962 function onButtonClick(fn, index, childIndex) {
20963 var item = me._getItems()[index]['children'][childIndex];
20964 return function (e) {
20965 stopPropagation(e);
20966 return fn({
20967 'target': item,
20968 'index': index,
20969 'childIndex': childIndex
20970 });
20971 };
20972 }
20973 var menuDom = createEl('div', 'maptalks-dropMenu'),
20974 items = this._getItems(),
20975 len = items.length,
20976 menuUL = createEl('ul'),
20977 children = items[index]['children'];
20978 if (index === len - 1 && children) {
20979 menuDom.style.cssText = 'right: 0px;';
20980 menuUL.style.cssText = 'right: 0px;position: absolute;';
20981 if (this.options['reverseMenu']) {
20982 menuUL.style.bottom = 0;
20983 }
20984 }
20985 menuDom.appendChild(createEl('em', 'maptalks-ico'));
20986
20987 var liWidth = 0;
20988 for (var i = 0, l = children.length; i < l; i++) {
20989 var size = stringLength(children[i]['item'], '12px');
20990 if (size.width > liWidth) {
20991 liWidth = size.width;
20992 }
20993 }
20994 for (var _i = 0, _l = children.length; _i < _l; _i++) {
20995 var child = children[_i];
20996 var li = createEl('li');
20997 li.innerHTML = '<a href="javascript:;">' + child['item'] + '</a>';
20998 li.style.cursor = 'pointer';
20999 li.style.width = liWidth + 24 + 'px';
21000 on(li.childNodes[0], 'click', onButtonClick(child['click'], index, _i));
21001 menuUL.appendChild(li);
21002 }
21003 if (this.options['vertical']) {
21004 var width = liWidth < 95 ? 95 : liWidth;
21005 if (this.options['reverseMenu']) {
21006 menuDom.style.right = -(width + 10 * 2) + 'px';
21007 } else {
21008 menuDom.style.left = -(width + 10 * 2) + 'px';
21009 }
21010 } else if (this.options['reverseMenu']) {
21011 menuDom.style.bottom = '28px';
21012 } else {
21013 menuDom.style.top = '28px';
21014 }
21015 menuDom.appendChild(menuUL);
21016 menuDom.style.display = 'none';
21017 return menuDom;
21018 };
21019
21020 Toolbar.prototype._getItems = function _getItems() {
21021 return this.options['items'] || [];
21022 };
21023
21024 return Toolbar;
21025}(Control);
21026
21027Toolbar.mergeOptions(options$28);
21028
21029var options$29 = {
21030 'position': 'top-left',
21031 'slider': true,
21032 'zoomLevel': true,
21033 'seamless': false
21034};
21035
21036var UNIT = 10;
21037
21038var Zoom = function (_Control) {
21039 inherits(Zoom, _Control);
21040
21041 function Zoom() {
21042 classCallCheck(this, Zoom);
21043 return possibleConstructorReturn(this, _Control.apply(this, arguments));
21044 }
21045
21046 Zoom.prototype.buildOn = function buildOn(map) {
21047 var options = this.options;
21048
21049 var dom = createEl('div', 'maptalks-zoom');
21050
21051 if (options['zoomLevel']) {
21052 var levelDOM = createEl('span', 'maptalks-zoom-zoomlevel');
21053 dom.appendChild(levelDOM);
21054 this._levelDOM = levelDOM;
21055 }
21056
21057 var zoomDOM = createEl('div', 'maptalks-zoom-slider');
21058
21059 var zoomInButton = createEl('a', 'maptalks-zoom-zoomin');
21060 zoomInButton.href = 'javascript:;';
21061 zoomInButton.innerHTML = '+';
21062 zoomDOM.appendChild(zoomInButton);
21063 this._zoomInButton = zoomInButton;
21064
21065 if (options['slider']) {
21066 var box = createEl('div', 'maptalks-zoom-slider-box');
21067 var ruler = createEl('div', 'maptalks-zoom-slider-ruler');
21068 var reading = createEl('span', 'maptalks-zoom-slider-reading');
21069 var dot = createEl('span', 'maptalks-zoom-slider-dot');
21070 ruler.appendChild(reading);
21071 box.appendChild(ruler);
21072 box.appendChild(dot);
21073 zoomDOM.appendChild(box);
21074 this._sliderBox = box;
21075 this._sliderRuler = ruler;
21076 this._sliderReading = reading;
21077 this._sliderDot = dot;
21078 }
21079
21080 var zoomOutButton = createEl('a', 'maptalks-zoom-zoomout');
21081 zoomOutButton.href = 'javascript:;';
21082 zoomOutButton.innerHTML = '-';
21083 zoomDOM.appendChild(zoomOutButton);
21084 this._zoomOutButton = zoomOutButton;
21085
21086 dom.appendChild(zoomDOM);
21087
21088 map.on('_zoomend _zoomstart _spatialreferencechange', this._update, this);
21089
21090 this._update();
21091 this._registerDomEvents();
21092
21093 return dom;
21094 };
21095
21096 Zoom.prototype.onRemove = function onRemove() {
21097 this.getMap().off('_zoomend _zoomstart _spatialreferencechange', this._update, this);
21098 if (this._zoomInButton) {
21099 off(this._zoomInButton, 'click', this._onZoomInClick, this);
21100 }
21101 if (this._zoomOutButton) {
21102 off(this._zoomOutButton, 'click', this._onZoomOutClick, this);
21103 }
21104 if (this._sliderRuler) {
21105 off(this._sliderRuler, 'click', this._onClickRuler, this);
21106 this.dotDragger.disable();
21107 delete this.dotDragger;
21108 }
21109 };
21110
21111 Zoom.prototype._update = function _update() {
21112 var map = this.getMap();
21113 if (this._sliderBox) {
21114 var totalRange = (map.getMaxZoom() - map.getMinZoom()) * UNIT;
21115 this._sliderBox.style.height = totalRange + 16 + 'px';
21116 this._sliderRuler.style.height = totalRange + 8 + 'px';
21117 this._sliderRuler.style.cursor = 'pointer';
21118 var zoomRange = (map.getMaxZoom() - map.getZoom()) * UNIT;
21119
21120 this._sliderReading.style.height = (map.getZoom() - map.getMinZoom() + 1) * UNIT + 'px';
21121 this._sliderDot.style.top = zoomRange + 'px';
21122 }
21123 this._updateText();
21124 };
21125
21126 Zoom.prototype._updateText = function _updateText() {
21127 if (this._levelDOM) {
21128 var map = this.getMap();
21129 var zoom = map.getZoom();
21130 if (!isInteger(zoom)) {
21131 zoom = zoom.toFixed(1);
21132 }
21133 this._levelDOM.innerHTML = zoom;
21134 }
21135 };
21136
21137 Zoom.prototype._registerDomEvents = function _registerDomEvents() {
21138 if (this._zoomInButton) {
21139 on(this._zoomInButton, 'click', this._onZoomInClick, this);
21140 }
21141 if (this._zoomOutButton) {
21142 on(this._zoomOutButton, 'click', this._onZoomOutClick, this);
21143 }
21144 if (this._sliderRuler) {
21145 on(this._sliderRuler, 'click', this._onClickRuler, this);
21146 this.dotDragger = new DragHandler(this._sliderDot, {
21147 'ignoreMouseleave': true
21148 });
21149 this.dotDragger.on('dragstart', this._onDotDragstart, this).on('dragging dragend', this._onDotDrag, this).enable();
21150 }
21151 };
21152
21153 Zoom.prototype._onZoomInClick = function _onZoomInClick(e) {
21154 preventDefault(e);
21155 this.getMap().zoomIn();
21156 };
21157
21158 Zoom.prototype._onZoomOutClick = function _onZoomOutClick(e) {
21159 preventDefault(e);
21160 this.getMap().zoomOut();
21161 };
21162
21163 Zoom.prototype._onClickRuler = function _onClickRuler(e) {
21164 preventDefault(e);
21165 var map = this.getMap(),
21166 point = getEventContainerPoint(e, this._sliderRuler),
21167 h = point.y;
21168 var maxZoom = map.getMaxZoom(),
21169 zoom = Math.floor(maxZoom - h / UNIT);
21170 map.setZoom(zoom);
21171 };
21172
21173 Zoom.prototype._onDotDragstart = function _onDotDragstart(e) {
21174 preventDefault(e.domEvent);
21175 var map = this.getMap(),
21176 origin = map.getSize().toPoint()._multi(1 / 2);
21177 map.onZoomStart(map.getZoom(), origin);
21178 };
21179
21180 Zoom.prototype._onDotDrag = function _onDotDrag(e) {
21181 preventDefault(e.domEvent);
21182 var map = this.getMap(),
21183 origin = map.getSize().toPoint()._multi(1 / 2),
21184 point = getEventContainerPoint(e.domEvent, this._sliderRuler),
21185 maxZoom = map.getMaxZoom(),
21186 minZoom = map.getMinZoom();
21187 var top = point.y,
21188 z = maxZoom - top / UNIT;
21189
21190 if (maxZoom < z) {
21191 z = maxZoom;
21192 top = 0;
21193 } else if (minZoom > z) {
21194 z = minZoom;
21195 top = (maxZoom - minZoom) * UNIT;
21196 }
21197
21198 if (e.type === 'dragging') {
21199 map.onZooming(z, origin, 1);
21200 } else if (e.type === 'dragend') {
21201 if (this.options['seamless']) {
21202 map.onZoomEnd(z, origin);
21203 } else {
21204 map.onZoomEnd(Math.round(z), origin);
21205 }
21206 }
21207 this._sliderDot.style.top = top + 'px';
21208
21209 this._sliderReading.style.height = (map.getZoom() - minZoom + 1) * UNIT + 'px';
21210 this._updateText();
21211 };
21212
21213 return Zoom;
21214}(Control);
21215
21216Zoom.mergeOptions(options$29);
21217
21218Map.mergeOptions({
21219 'zoomControl': false
21220});
21221
21222Map.addOnLoadHook(function () {
21223 if (this.options['zoomControl']) {
21224 this.zoomControl = new Zoom(this.options['zoomControl']);
21225 this.addControl(this.zoomControl);
21226 }
21227});
21228
21229
21230
21231var index$5 = Object.freeze({
21232 Control: Control,
21233 Attribution: Attribution,
21234 LayerSwitcher: LayerSwitcher,
21235 Overview: Overview,
21236 Panel: Panel,
21237 Scale: Scale,
21238 Toolbar: Toolbar,
21239 Zoom: Zoom
21240});
21241
21242var TileSystem = function () {
21243 function TileSystem(sx, sy, ox, oy) {
21244 classCallCheck(this, TileSystem);
21245
21246 if (Array.isArray(sx)) {
21247 this.scale = {
21248 x: sx[0],
21249 y: sx[1]
21250 };
21251 this.origin = {
21252 x: sx[2],
21253 y: sx[3]
21254 };
21255 } else {
21256 this.scale = {
21257 x: sx,
21258 y: sy
21259 };
21260 this.origin = {
21261 x: ox,
21262 y: oy
21263 };
21264 }
21265 }
21266
21267 TileSystem.getDefault = function getDefault(projection) {
21268 if (projection['code'].toLowerCase() === 'baidu') {
21269 return 'baidu';
21270 } else if (projection['code'].toLowerCase() === 'EPSG:4326'.toLowerCase()) {
21271 return 'tms-global-geodetic';
21272 } else if (projection['code'].toLowerCase() === 'identity') {
21273 return [1, -1, 0, 0];
21274 } else {
21275 return 'web-mercator';
21276 }
21277 };
21278
21279 return TileSystem;
21280}();
21281
21282var semiCircum = 6378137 * Math.PI;
21283
21284extend(TileSystem, {
21285 'web-mercator': new TileSystem([1, -1, -semiCircum, semiCircum]),
21286
21287 'tms-global-mercator': new TileSystem([1, 1, -semiCircum, -semiCircum]),
21288
21289 'tms-global-geodetic': new TileSystem([1, 1, -180, -90]),
21290
21291 'baidu': new TileSystem([1, 1, 0, 0])
21292});
21293
21294var TileConfig = function () {
21295 function TileConfig(tileSystem, fullExtent, tileSize) {
21296 classCallCheck(this, TileConfig);
21297
21298 this.tileSize = tileSize;
21299 this.fullExtent = fullExtent;
21300 this.prepareTileInfo(tileSystem, fullExtent);
21301 }
21302
21303 TileConfig.prototype.prepareTileInfo = function prepareTileInfo(tileSystem, fullExtent) {
21304 if (isString(tileSystem)) {
21305 tileSystem = TileSystem[tileSystem.toLowerCase()];
21306 } else if (Array.isArray(tileSystem)) {
21307 tileSystem = new TileSystem(tileSystem);
21308 }
21309
21310 if (!tileSystem) {
21311 throw new Error('Invalid TileSystem');
21312 }
21313 this.tileSystem = tileSystem;
21314
21315 var a = fullExtent['right'] > fullExtent['left'] ? 1 : -1,
21316 b = fullExtent['top'] > fullExtent['bottom'] ? -1 : 1,
21317 c = tileSystem['origin']['x'],
21318 d = tileSystem['origin']['y'];
21319 this.transformation = new Transformation([a, b, c, d]);
21320 };
21321
21322 TileConfig.prototype._getTileNum = function _getTileNum(point, res) {
21323 var tileSystem = this.tileSystem,
21324 tileSize = this['tileSize'],
21325 delta = 1E-7;
21326 var tileX = Math.floor(delta + point.x / (tileSize['width'] * res));
21327 var tileY = -Math.floor(delta + point.y / (tileSize['height'] * res));
21328
21329 return {
21330 'x': tileSystem['scale']['x'] * tileX,
21331 'y': tileSystem['scale']['y'] * tileY
21332 };
21333 };
21334
21335 TileConfig.prototype.getTileIndex = function getTileIndex(pCoord, res) {
21336 var tileSystem = this.tileSystem;
21337
21338 var point = this.transformation.transform(pCoord, 1);
21339 var tileIndex = this._getTileNum(point, res);
21340
21341 if (tileSystem['scale']['x'] < 0) {
21342 tileIndex['x'] -= 1;
21343 }
21344
21345 if (tileSystem['scale']['y'] > 0) {
21346 tileIndex['y'] -= 1;
21347 }
21348
21349 return this.getNeighorTileIndex(tileIndex['x'], tileIndex['y'], 0, 0, true);
21350 };
21351
21352 TileConfig.prototype.getNeighorTileIndex = function getNeighorTileIndex(tileX, tileY, offsetX, offsetY, res, isRepeatWorld) {
21353 var tileSystem = this.tileSystem;
21354 var x = tileX + tileSystem['scale']['x'] * offsetX;
21355 var y = tileY - tileSystem['scale']['y'] * offsetY;
21356 var idx = x;
21357 var idy = y;
21358 if (isRepeatWorld) {
21359 var ext = this._getTileFullIndex(res);
21360 if (x < ext['xmin']) {
21361 x = ext['xmax'] - (ext['xmin'] - x) % (ext['xmax'] - ext['xmin']);
21362 if (x === ext['xmax']) {
21363 x = ext['xmin'];
21364 }
21365 } else if (x >= ext['xmax']) {
21366 x = ext['xmin'] + (x - ext['xmin']) % (ext['xmax'] - ext['xmin']);
21367 }
21368
21369 if (y >= ext['ymax']) {
21370 y = ext['ymin'] + (y - ext['ymin']) % (ext['ymax'] - ext['ymin']);
21371 } else if (y < ext['ymin']) {
21372 y = ext['ymax'] - (ext['ymin'] - y) % (ext['ymax'] - ext['ymin']);
21373 if (y === ext['ymax']) {
21374 y = ext['ymin'];
21375 }
21376 }
21377 }
21378 return {
21379 'x': x,
21380 'y': y,
21381
21382 'idx': idx,
21383 'idy': idy
21384 };
21385 };
21386
21387 TileConfig.prototype._getTileFullIndex = function _getTileFullIndex(res) {
21388 var ext = this.fullExtent;
21389 var transformation = this.transformation;
21390 var nwIndex = this._getTileNum(transformation.transform(new Coordinate(ext['left'], ext['top']), 1), res);
21391 var seIndex = this._getTileNum(transformation.transform(new Coordinate(ext['right'], ext['bottom']), 1), res);
21392 return new Extent(nwIndex, seIndex);
21393 };
21394
21395 TileConfig.prototype.getTilePrjNW = function getTilePrjNW(tileX, tileY, res) {
21396 var tileSystem = this.tileSystem;
21397 var tileSize = this['tileSize'];
21398 var y = tileSystem['origin']['y'] + tileSystem['scale']['y'] * (tileY + (tileSystem['scale']['y'] === 1 ? 1 : 0)) * (res * tileSize['height']);
21399 var x = tileSystem['scale']['x'] * (tileX + (tileSystem['scale']['x'] === 1 ? 0 : 1)) * res * tileSize['width'] + tileSystem['origin']['x'];
21400 return new Coordinate(x, y);
21401 };
21402
21403 TileConfig.prototype.getTilePrjSE = function getTilePrjSE(tileX, tileY, res) {
21404 var tileSystem = this.tileSystem;
21405 var tileSize = this['tileSize'];
21406 var y = tileSystem['origin']['y'] + tileSystem['scale']['y'] * (tileY + (tileSystem['scale']['y'] === 1 ? 0 : 1)) * (res * tileSize['height']);
21407 var x = tileSystem['scale']['x'] * (tileX + (tileSystem['scale']['x'] === 1 ? 1 : 0)) * res * tileSize['width'] + tileSystem['origin']['x'];
21408 return new Coordinate(x, y);
21409 };
21410
21411 TileConfig.prototype.getTilePrjExtent = function getTilePrjExtent(tileX, tileY, res) {
21412 var nw = this.getTilePrjNW(tileX, tileY, res),
21413 se = this.getTilePrjSE(tileX, tileY, res);
21414 return new Extent(nw, se);
21415 };
21416
21417 return TileConfig;
21418}();
21419
21420var options$30 = {
21421
21422 'urlTemplate': null,
21423 'subdomains': null,
21424
21425 'repeatWorld': true,
21426
21427 'background': true,
21428 'backgroundZoomDiff': 6,
21429
21430 'loadingLimitOnInteracting': 3,
21431
21432 'placeholder': false,
21433
21434 'crossOrigin': null,
21435
21436 'tileSize': [256, 256],
21437
21438 'offset': [0, 0],
21439
21440 'tileSystem': null,
21441
21442 'fadeAnimation': !IS_NODE,
21443
21444 'debug': false,
21445
21446 'spatialReference': null,
21447
21448 'maxCacheSize': 256,
21449
21450 'renderer': function () {
21451 return Browser$1.webgl ? 'gl' : 'canvas';
21452 }(),
21453
21454 'clipByPitch': true,
21455
21456 'maxAvailableZoom': null,
21457
21458 'cascadeTiles': true,
21459 'minPitchToCascade': 35
21460};
21461
21462var urlPattern = /\{ *([\w_]+) *\}/g;
21463
21464var MAX_VISIBLE_SIZE = 5;
21465
21466var TileLayer = function (_Layer) {
21467 inherits(TileLayer, _Layer);
21468
21469 function TileLayer() {
21470 classCallCheck(this, TileLayer);
21471 return possibleConstructorReturn(this, _Layer.apply(this, arguments));
21472 }
21473
21474 TileLayer.fromJSON = function fromJSON(layerJSON) {
21475 if (!layerJSON || layerJSON['type'] !== 'TileLayer') {
21476 return null;
21477 }
21478 return new TileLayer(layerJSON['id'], layerJSON['options']);
21479 };
21480
21481 TileLayer.prototype.getTileSize = function getTileSize() {
21482 return new Size(this.options['tileSize']);
21483 };
21484
21485 TileLayer.prototype.getTiles = function getTiles(z) {
21486 var map = this.getMap();
21487 var mapExtent = map.getContainerExtent();
21488 var tileGrids = [];
21489 var count = 0;
21490 var minZoom = this.getMinZoom();
21491 var minPitchToCascade = this.options['minPitchToCascade'];
21492 var tileZoom = isNil(z) ? this._getTileZoom(map.getZoom()) : z;
21493 if (!isNil(z) || !this.options['cascadeTiles'] || map.getPitch() <= minPitchToCascade || !isNil(minZoom) && tileZoom <= minZoom) {
21494 var _currentTiles = this._getTiles(tileZoom, mapExtent);
21495 if (_currentTiles) {
21496 count += _currentTiles.tiles.length;
21497 tileGrids.push(_currentTiles);
21498 }
21499 return {
21500 tileGrids: tileGrids, count: count
21501 };
21502 }
21503
21504 var visualHeight = Math.floor(map._getVisualHeight(minPitchToCascade));
21505 var extent0 = new PointExtent(0, map.height - visualHeight, map.width, map.height);
21506 var currentTiles = this._getTiles(tileZoom, extent0, 0);
21507 count += currentTiles ? currentTiles.tiles.length : 0;
21508
21509 var extent1 = new PointExtent(0, mapExtent.ymin, map.width, extent0.ymin);
21510 var d = map.getSpatialReference().getZoomDirection();
21511 var parentTiles = this._getTiles(tileZoom - d, extent1, 1);
21512 count += parentTiles ? parentTiles.tiles.length : 0;
21513
21514 tileGrids.push(currentTiles, parentTiles);
21515 return {
21516 tileGrids: tileGrids, count: count
21517 };
21518 };
21519
21520 TileLayer.prototype.getTileUrl = function getTileUrl(x, y, z) {
21521 var urlTemplate = this.options['urlTemplate'];
21522 var domain = '';
21523 if (this.options['subdomains']) {
21524 var subdomains = this.options['subdomains'];
21525 if (isArrayHasData(subdomains)) {
21526 var length = subdomains.length;
21527 var s = (x + y) % length;
21528 if (s < 0) {
21529 s = 0;
21530 }
21531 domain = subdomains[s];
21532 }
21533 }
21534 if (isFunction(urlTemplate)) {
21535 return urlTemplate(x, y, z, domain);
21536 }
21537 var data = {
21538 'x': x,
21539 'y': y,
21540 'z': z,
21541 's': domain
21542 };
21543 return urlTemplate.replace(urlPattern, function (str, key) {
21544 var value = data[key];
21545
21546 if (value === undefined) {
21547 throw new Error('No value provided for variable ' + str);
21548 } else if (typeof value === 'function') {
21549 value = value(data);
21550 }
21551 return value;
21552 });
21553 };
21554
21555 TileLayer.prototype.clear = function clear() {
21556 if (this._renderer) {
21557 this._renderer.clear();
21558 }
21559
21560 this.fire('clear');
21561 return this;
21562 };
21563
21564 TileLayer.prototype.toJSON = function toJSON() {
21565 var profile = {
21566 'type': this.getJSONType(),
21567 'id': this.getId(),
21568 'options': this.config()
21569 };
21570 return profile;
21571 };
21572
21573 TileLayer.prototype.getSpatialReference = function getSpatialReference() {
21574 var map = this.getMap();
21575 if (map && (!this.options['spatialReference'] || SpatialReference.equals(this.options['spatialReference'], map.options['spatialReference']))) {
21576 return map.getSpatialReference();
21577 }
21578 this._sr = this._sr || new SpatialReference(this.options['spatialReference']);
21579 return this._sr;
21580 };
21581
21582 TileLayer.prototype._getTileZoom = function _getTileZoom(zoom) {
21583 var map = this.getMap();
21584 if (!isInteger(zoom)) {
21585 if (map.isZooming()) {
21586 zoom = zoom > map._frameZoom ? Math.floor(zoom) : Math.ceil(zoom);
21587 } else {
21588 zoom = Math.round(zoom);
21589 }
21590 }
21591 var maxZoom = this.options['maxAvailableZoom'];
21592 if (!isNil(maxZoom) && zoom > maxZoom) {
21593 zoom = maxZoom;
21594 }
21595 return zoom;
21596 };
21597
21598 TileLayer.prototype._getTiles = function _getTiles(z, containerExtent, maskID) {
21599 var map = this.getMap();
21600 if (!map || !this.isVisible() || !map.width || !map.height) {
21601 return null;
21602 }
21603 var minZoom = this.getMinZoom(),
21604 maxZoom = this.getMaxZoom();
21605 if (!isNil(minZoom) && z < minZoom || !isNil(maxZoom) && z > maxZoom) {
21606 return null;
21607 }
21608 var tileConfig = this._getTileConfig();
21609 if (!tileConfig) {
21610 return null;
21611 }
21612
21613 var zoom = z,
21614 sr = this.getSpatialReference(),
21615 mapSR = map.getSpatialReference(),
21616 res = sr.getResolution(zoom);
21617 var emptyGrid = {
21618 'zoom': zoom,
21619 'extent': null,
21620 'tiles': []
21621 };
21622
21623 var offset = this._getTileOffset(zoom),
21624 hasOffset = offset[0] || offset[1];
21625
21626 var extent2d = containerExtent.convertTo(function (c) {
21627 return map._containerPointToPoint(c);
21628 })._add(offset),
21629 innerExtent2D = this._getInnerExtent(zoom, containerExtent, extent2d);
21630
21631 var maskExtent = this._getMask2DExtent();
21632 if (maskExtent) {
21633 var intersection = maskExtent.intersection(extent2d);
21634 if (!intersection) {
21635 return emptyGrid;
21636 }
21637 containerExtent = intersection.convertTo(function (c) {
21638 return map._pointToContainerPoint(c);
21639 });
21640 }
21641
21642 var prjCenter = map._containerPointToPrj(containerExtent.getCenter());
21643 var c = void 0;
21644 if (hasOffset) {
21645 c = this._project(map._pointToPrj(map._prjToPoint(prjCenter)._add(offset)));
21646 } else {
21647 c = this._project(prjCenter);
21648 }
21649 var pmin = this._project(map._pointToPrj(extent2d.getMin())),
21650 pmax = this._project(map._pointToPrj(extent2d.getMax()));
21651
21652 var centerTile = tileConfig.getTileIndex(c, res),
21653 ltTile = tileConfig.getTileIndex(pmin, res),
21654 rbTile = tileConfig.getTileIndex(pmax, res);
21655
21656 var top = Math.ceil(Math.abs(centerTile.y - ltTile.y)),
21657 left = Math.ceil(Math.abs(centerTile.x - ltTile.x)),
21658 bottom = Math.ceil(Math.abs(centerTile.y - rbTile.y)),
21659 right = Math.ceil(Math.abs(centerTile.x - rbTile.x));
21660 var layerId = this.getId(),
21661 renderer = this.getRenderer(),
21662 tileSize = this.getTileSize(),
21663 scale = this._getTileConfig().tileSystem.scale;
21664 var tiles = [],
21665 extent = new PointExtent();
21666 for (var i = -left; i <= right; i++) {
21667 for (var j = -top; j <= bottom; j++) {
21668 var idx = tileConfig.getNeighorTileIndex(centerTile['x'], centerTile['y'], i, j, res, this.options['repeatWorld']),
21669 pnw = tileConfig.getTilePrjNW(idx.x, idx.y, res),
21670 p = map._prjToPoint(this._unproject(pnw), zoom);
21671 var width = void 0,
21672 height = void 0;
21673 if (sr === mapSR) {
21674 width = tileSize.width;
21675 height = tileSize.height;
21676 } else {
21677 var pse = tileConfig.getTilePrjSE(idx.x, idx.y, res),
21678 pp = map._prjToPoint(this._unproject(pse), zoom);
21679 width = Math.abs(Math.round(pp.x - p.x));
21680 height = Math.abs(Math.round(pp.y - p.y));
21681 }
21682 var dx = scale.x * (idx.idx - idx.x) * width,
21683 dy = -scale.y * (idx.idy - idx.y) * height;
21684 if (dx || dy) {
21685 p._add(dx, dy);
21686 }
21687 if (sr !== mapSR) {
21688 width++;
21689 height++;
21690 }
21691 if (hasOffset) {
21692 p._sub(offset);
21693 }
21694 var tileExtent = new PointExtent(p, p.add(width, height)),
21695 tileInfo = {
21696 'point': p,
21697 'z': zoom,
21698 'x': idx.x,
21699 'y': idx.y,
21700 'extent2d': tileExtent,
21701 'mask': maskID
21702 };
21703 if (innerExtent2D.intersects(tileExtent) || !innerExtent2D.equals(extent2d) && this._isTileInExtent(tileInfo, containerExtent)) {
21704 if (hasOffset) {
21705 tileInfo.point._add(offset);
21706 tileInfo.extent2d._add(offset);
21707 }
21708 tileInfo['size'] = [width, height];
21709 tileInfo['dupKey'] = p.round().toArray().join() + ',' + width + ',' + height + ',' + layerId;
21710 tileInfo['id'] = this._getTileId(idx, zoom);
21711 tileInfo['layer'] = layerId;
21712 if (!renderer || !renderer.isTileCachedOrLoading(tileInfo.id)) {
21713 tileInfo['url'] = this.getTileUrl(idx.x, idx.y, zoom);
21714 }
21715 tiles.push(tileInfo);
21716 extent._combine(tileExtent);
21717 }
21718 }
21719 }
21720
21721 var center = map._containerPointToPoint(containerExtent.getCenter(), zoom)._add(offset);
21722 tiles.sort(function (a, b) {
21723 return a.point.distanceTo(center) - b.point.distanceTo(center);
21724 });
21725
21726 return {
21727 'offset': offset,
21728 'zoom': zoom,
21729 'extent': extent,
21730 'tiles': tiles
21731 };
21732 };
21733
21734 TileLayer.prototype._getInnerExtent = function _getInnerExtent(zoom, containerExtent, extent2d) {
21735 var map = this.getMap(),
21736 res = map.getResolution(zoom),
21737 scale = map.getResolution() / res,
21738 center = extent2d.getCenter()._multi(scale),
21739 bearing = map.getBearing() * Math.PI / 180,
21740 ch = containerExtent.getHeight() / 2 * scale,
21741 cw = containerExtent.getWidth() / 2 * scale,
21742 h = Math.abs(Math.cos(bearing) * ch) || ch,
21743 w = Math.abs(Math.sin(bearing) * ch) || cw;
21744 return new PointExtent(center.sub(w, h), center.add(w, h));
21745 };
21746
21747 TileLayer.prototype._getTileOffset = function _getTileOffset(z) {
21748 var map = this.getMap();
21749 var scale = map._getResolution() / map._getResolution(z);
21750 var offset = this.options['offset'];
21751 if (isFunction(offset)) {
21752 offset = offset(this);
21753 }
21754 offset[0] *= scale;
21755 offset[1] *= scale;
21756 return offset;
21757 };
21758
21759 TileLayer.prototype._getTileId = function _getTileId(idx, zoom, id) {
21760 return [id || this.getId(), idx.idy, idx.idx, zoom].join('__');
21761 };
21762
21763 TileLayer.prototype._project = function _project(pcoord) {
21764 var map = this.getMap();
21765 var sr = this.getSpatialReference();
21766 if (sr !== map.getSpatialReference()) {
21767 return sr.getProjection().project(map.getProjection().unproject(pcoord));
21768 } else {
21769 return pcoord;
21770 }
21771 };
21772
21773 TileLayer.prototype._unproject = function _unproject(pcoord) {
21774 var map = this.getMap();
21775 var sr = this.getSpatialReference();
21776 if (sr !== map.getSpatialReference()) {
21777 return map.getProjection().project(sr.getProjection().unproject(pcoord));
21778 } else {
21779 return pcoord;
21780 }
21781 };
21782
21783 TileLayer.prototype._initTileConfig = function _initTileConfig() {
21784 var map = this.getMap(),
21785 tileSize = this.getTileSize();
21786 var sr = this.getSpatialReference();
21787 var projection = sr.getProjection(),
21788 fullExtent = sr.getFullExtent();
21789 this._defaultTileConfig = new TileConfig(TileSystem.getDefault(projection), fullExtent, tileSize);
21790 if (this.options['tileSystem']) {
21791 this._tileConfig = new TileConfig(this.options['tileSystem'], fullExtent, tileSize);
21792 }
21793
21794 if (map && !this._tileConfig && map.getSpatialReference() === sr && map.getBaseLayer() && map.getBaseLayer() !== this && map.getBaseLayer()._getTileConfig) {
21795 var base = map.getBaseLayer()._getTileConfig();
21796 this._tileConfig = new TileConfig(base.tileSystem, base.fullExtent, tileSize);
21797 }
21798 };
21799
21800 TileLayer.prototype._getTileConfig = function _getTileConfig() {
21801 if (!this._defaultTileConfig) {
21802 this._initTileConfig();
21803 }
21804 return this._tileConfig || this._defaultTileConfig;
21805 };
21806
21807 TileLayer.prototype._bindMap = function _bindMap(map) {
21808 var baseLayer = map.getBaseLayer();
21809 if (baseLayer === this) {
21810 if (!baseLayer.options.hasOwnProperty('forceRenderOnMoving')) {
21811 this.config({
21812 'forceRenderOnMoving': true
21813 });
21814 }
21815 }
21816 return _Layer.prototype._bindMap.apply(this, arguments);
21817 };
21818
21819 TileLayer.prototype._isTileInExtent = function _isTileInExtent(tileInfo, extent) {
21820 var map = this.getMap();
21821 if (!map) {
21822 return false;
21823 }
21824 var tileZoom = tileInfo.z;
21825 var tileExtent = tileInfo.extent2d.convertTo(function (c) {
21826 return map._pointToContainerPoint(c, tileZoom);
21827 });
21828 if (tileExtent.getWidth() < MAX_VISIBLE_SIZE || tileExtent.getHeight() < MAX_VISIBLE_SIZE) {
21829 return false;
21830 }
21831 return extent.intersects(tileExtent);
21832 };
21833
21834 TileLayer.prototype.getEvents = function getEvents() {
21835 return {
21836 'spatialreferencechange': this._onSpatialReferenceChange
21837 };
21838 };
21839
21840 TileLayer.prototype._onSpatialReferenceChange = function _onSpatialReferenceChange() {
21841 delete this._tileConfig;
21842 delete this._defaultTileConfig;
21843 delete this._sr;
21844 };
21845
21846 return TileLayer;
21847}(Layer);
21848
21849TileLayer.registerJSONType('TileLayer');
21850
21851TileLayer.mergeOptions(options$30);
21852
21853var GroupTileLayer = function (_TileLayer) {
21854 inherits(GroupTileLayer, _TileLayer);
21855
21856 GroupTileLayer.fromJSON = function fromJSON(layerJSON) {
21857 if (!layerJSON || layerJSON['type'] !== 'GroupTileLayer') {
21858 return null;
21859 }
21860 var layers = layerJSON['layers'].map(function (json) {
21861 return Layer.fromJSON(json);
21862 });
21863 return new GroupTileLayer(layerJSON['id'], layers, layerJSON['options']);
21864 };
21865
21866 function GroupTileLayer(id, layers, options) {
21867 classCallCheck(this, GroupTileLayer);
21868
21869 var _this = possibleConstructorReturn(this, _TileLayer.call(this, id, options));
21870
21871 _this.layers = layers || [];
21872 _this._checkChildren();
21873 _this.layerMap = {};
21874 _this._groupChildren = [];
21875 return _this;
21876 }
21877
21878 GroupTileLayer.prototype.getLayers = function getLayers() {
21879 return this.layers;
21880 };
21881
21882 GroupTileLayer.prototype.toJSON = function toJSON() {
21883 var profile = {
21884 'type': this.getJSONType(),
21885 'id': this.getId(),
21886 'layers': this.layers.map(function (layer) {
21887 return layer.toJSON();
21888 }),
21889 'options': this.config()
21890 };
21891 return profile;
21892 };
21893
21894 GroupTileLayer.prototype.getTiles = function getTiles(z) {
21895 var layers = this.layers;
21896 var tiles = [];
21897 var count = 0;
21898 for (var i = 0, l = layers.length; i < l; i++) {
21899 var layer = layers[i];
21900 if (!layer.options['visible']) {
21901 continue;
21902 }
21903 var childGrid = layer.getTiles(z);
21904 if (!childGrid || childGrid.count === 0) {
21905 continue;
21906 }
21907 count += childGrid.count;
21908 pushIn(tiles, childGrid.tileGrids);
21909 }
21910
21911 return {
21912 count: count,
21913 tileGrids: tiles
21914 };
21915 };
21916
21917 GroupTileLayer.prototype.onAdd = function onAdd() {
21918 var _this2 = this;
21919
21920 var map = this.getMap();
21921 this.layers.forEach(function (layer) {
21922 _this2.layerMap[layer.getId()] = layer;
21923 if (layer.getChildLayer) {
21924 _this2._groupChildren.push(layer);
21925 }
21926 layer._bindMap(map);
21927 layer.on('show hide', _this2._onLayerShowHide, _this2);
21928 });
21929 _TileLayer.prototype.onAdd.call(this);
21930 };
21931
21932 GroupTileLayer.prototype.onRemove = function onRemove() {
21933 var _this3 = this;
21934
21935 this.layers.forEach(function (layer) {
21936 layer._doRemove();
21937 layer.off('show hide', _this3._onLayerShowHide, _this3);
21938 });
21939 delete this.layerMap;
21940 delete this._groupChildren;
21941 _TileLayer.prototype.onRemove.call(this);
21942 };
21943
21944 GroupTileLayer.prototype.getChildLayer = function getChildLayer(id) {
21945 var layer = this.layerMap[id];
21946 if (layer) {
21947 return layer;
21948 }
21949 for (var i = 0; i < this._groupChildren.length; i++) {
21950 var child = this._groupChildren[i].getChildLayer(id);
21951 if (child) {
21952 return child;
21953 }
21954 }
21955 return null;
21956 };
21957
21958 GroupTileLayer.prototype._onLayerShowHide = function _onLayerShowHide() {
21959 var renderer = this.getRenderer();
21960 if (renderer) {
21961 renderer.setToRedraw();
21962 }
21963 };
21964
21965 GroupTileLayer.prototype.isVisible = function isVisible() {
21966 if (!_TileLayer.prototype.isVisible.call(this)) {
21967 return false;
21968 }
21969 var children = this.layers;
21970 for (var i = 0, l = children.length; i < l; i++) {
21971 if (children[i].isVisible()) {
21972 return true;
21973 }
21974 }
21975 return false;
21976 };
21977
21978 GroupTileLayer.prototype._checkChildren = function _checkChildren() {
21979 var _this4 = this;
21980
21981 var ids = {};
21982 this.layers.forEach(function (layer) {
21983 var layerId = layer.getId();
21984 if (ids[layerId]) {
21985 throw new Error('Duplicate child layer id (' + layerId + ') in the GroupTileLayer (' + _this4.getId() + ')');
21986 } else {
21987 ids[layerId] = 1;
21988 }
21989 });
21990 };
21991
21992 return GroupTileLayer;
21993}(TileLayer);
21994
21995GroupTileLayer.registerJSONType('GroupTileLayer');
21996
21997var options$31 = {
21998 crs: null,
21999 uppercase: false,
22000 detectRetina: false
22001};
22002
22003var defaultWmsParams = {
22004 service: 'WMS',
22005 request: 'GetMap',
22006 layers: '',
22007 styles: '',
22008 format: 'image/jpeg',
22009 transparent: false,
22010 version: '1.1.1'
22011};
22012
22013var WMSTileLayer = function (_TileLayer) {
22014 inherits(WMSTileLayer, _TileLayer);
22015
22016 function WMSTileLayer(id, options) {
22017 classCallCheck(this, WMSTileLayer);
22018
22019 var _this = possibleConstructorReturn(this, _TileLayer.call(this, id));
22020
22021 var wmsParams = extend({}, defaultWmsParams);
22022 for (var p in options) {
22023 if (!(p in _this.options)) {
22024 wmsParams[p] = options[p];
22025 }
22026 }
22027 _this.setOptions(options);
22028 var r = options.detectRetina && Browser$1.retina ? 2 : 1,
22029 tileSize = _this.getTileSize();
22030 wmsParams.width = tileSize.width * r;
22031 wmsParams.height = tileSize.height * r;
22032 _this.wmsParams = wmsParams;
22033 _this._wmsVersion = parseFloat(wmsParams.version);
22034 return _this;
22035 }
22036
22037 WMSTileLayer.prototype.onAdd = function onAdd() {
22038 var crs = this.options.crs || this.getMap().getProjection().code;
22039 var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';
22040 this.wmsParams[projectionKey] = crs;
22041 _TileLayer.prototype.onAdd.call(this);
22042 };
22043
22044 WMSTileLayer.prototype.getTileUrl = function getTileUrl(x, y, z) {
22045 var map = this.getMap(),
22046 res = map._getResolution(z),
22047 tileConfig = this._getTileConfig(),
22048 tileExtent = tileConfig.getTilePrjExtent(x, y, res);
22049 var max = tileExtent.getMax(),
22050 min = tileExtent.getMin();
22051
22052 var bbox = (this._wmsVersion >= 1.3 && this.wmsParams.crs === 'EPSG:4326' ? [min.y, min.x, max.y, max.x] : [min.x, min.y, max.x, max.y]).join(',');
22053
22054 var url = _TileLayer.prototype.getTileUrl.call(this, x, y, z);
22055
22056 return url + getParamString(this.wmsParams, url, this.options.uppercase) + (this.options.uppercase ? '&BBOX=' : '&bbox=') + bbox;
22057 };
22058
22059 WMSTileLayer.prototype.toJSON = function toJSON() {
22060 return {
22061 'type': 'WMSTileLayer',
22062 'id': this.getId(),
22063 'options': this.config()
22064 };
22065 };
22066
22067 WMSTileLayer.fromJSON = function fromJSON(layerJSON) {
22068 if (!layerJSON || layerJSON['type'] !== 'WMSTileLayer') {
22069 return null;
22070 }
22071 return new WMSTileLayer(layerJSON['id'], layerJSON['options']);
22072 };
22073
22074 return WMSTileLayer;
22075}(TileLayer);
22076
22077WMSTileLayer.registerJSONType('WMSTileLayer');
22078
22079WMSTileLayer.mergeOptions(options$31);
22080
22081function getParamString(obj, existingUrl, uppercase) {
22082 var params = [];
22083 for (var i in obj) {
22084 params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));
22085 }
22086 return (!existingUrl || existingUrl.indexOf('?') === -1 ? '?' : '&') + params.join('&');
22087}
22088
22089var CanvasTileLayer = function (_TileLayer) {
22090 inherits(CanvasTileLayer, _TileLayer);
22091
22092 function CanvasTileLayer(id, options) {
22093 classCallCheck(this, CanvasTileLayer);
22094
22095 var _this = possibleConstructorReturn(this, _TileLayer.call(this, id, options));
22096
22097 if (!_this.options.hasOwnProperty('forceRenderOnMoving')) {
22098 _this.options['forceRenderOnMoving'] = false;
22099 }
22100 return _this;
22101 }
22102
22103 CanvasTileLayer.prototype.drawTile = function drawTile() {};
22104
22105 CanvasTileLayer.prototype.toJSON = function toJSON() {
22106 return {
22107 'type': 'CanvasTileLayer',
22108 'id': this.getId(),
22109 'options': this.config()
22110 };
22111 };
22112
22113 CanvasTileLayer.fromJSON = function fromJSON(layerJSON) {
22114 if (!layerJSON || layerJSON['type'] !== 'CanvasTileLayer') {
22115 return null;
22116 }
22117 return new CanvasTileLayer(layerJSON['id'], layerJSON['options']);
22118 };
22119
22120 return CanvasTileLayer;
22121}(TileLayer);
22122
22123CanvasTileLayer.registerJSONType('CanvasTileLayer');
22124
22125function createGLContext(canvas, options) {
22126 var attributes = {
22127 'alpha': true,
22128 'stencil': true,
22129 'preserveDrawingBuffer': true,
22130 'antialias': false
22131 };
22132 var names = ['webgl', 'experimental-webgl'];
22133 var context = null;
22134
22135 for (var i = 0; i < names.length; ++i) {
22136 try {
22137 context = canvas.getContext(names[i], options || attributes);
22138 } catch (e) {}
22139 if (context) {
22140 break;
22141 }
22142 }
22143 return context;
22144}
22145
22146function compileShader(gl, type, source) {
22147 var shader = gl.createShader(type);
22148
22149 gl.shaderSource(shader, source);
22150 gl.compileShader(shader);
22151
22152 var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
22153 if (!compiled) {
22154 var error = gl.getShaderInfoLog(shader);
22155 gl.deleteShader(shader);
22156 throw new Error('Failed to compile shader: ' + error);
22157 }
22158 return shader;
22159}
22160
22161function createProgram(gl, vert, frag) {
22162 var vertexShader = compileShader(gl, gl.VERTEX_SHADER, vert);
22163 var fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, frag);
22164 if (!vertexShader || !fragmentShader) {
22165 return null;
22166 }
22167
22168 var program = gl.createProgram();
22169 if (!program) {
22170 return null;
22171 }
22172
22173 gl.attachShader(program, vertexShader);
22174 gl.attachShader(program, fragmentShader);
22175
22176 gl.linkProgram(program);
22177 return { program: program, vertexShader: vertexShader, fragmentShader: fragmentShader };
22178}
22179
22180function enableVertexAttrib(gl, program, attributes) {
22181 if (Array.isArray(attributes[0])) {
22182 var FSIZE = Float32Array.BYTES_PER_ELEMENT;
22183 var STRIDE = 0;
22184 for (var i = 0; i < attributes.length; i++) {
22185 STRIDE += attributes[i][1] || 0;
22186 }
22187 var offset = 0;
22188 for (var _i = 0; _i < attributes.length; _i++) {
22189 var attr = gl.getAttribLocation(program, attributes[_i][0]);
22190 if (attr < 0) {
22191 throw new Error('Failed to get the storage location of ' + attributes[_i][0]);
22192 }
22193 gl.vertexAttribPointer(attr, attributes[_i][1], gl[attributes[_i][2] || 'FLOAT'], false, FSIZE * STRIDE, FSIZE * offset);
22194 offset += attributes[_i][1] || 0;
22195 gl.enableVertexAttribArray(attr);
22196 }
22197 } else {
22198 var _attr = gl.getAttribLocation(program, attributes[0]);
22199 gl.vertexAttribPointer(_attr, attributes[1], gl[attributes[2] || 'FLOAT'], false, 0, 0);
22200 gl.enableVertexAttribArray(_attr);
22201 }
22202}
22203
22204var shaders = {
22205 'vertexShader': '\n attribute vec3 a_position;\n\n attribute vec2 a_texCoord;\n\n uniform mat4 u_matrix;\n\n varying vec2 v_texCoord;\n\n void main() {\n gl_Position = u_matrix * vec4(a_position, 1.0);\n\n v_texCoord = a_texCoord;\n }\n ',
22206
22207 'fragmentShader': '\n precision mediump float;\n\n uniform sampler2D u_image;\n\n uniform float u_opacity;\n\n varying vec2 v_texCoord;\n\n void main() {\n\n gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;\n\n }\n '
22208};
22209
22210var v2 = [0, 0];
22211var v3 = [0, 0, 0];
22212var arr16 = new Array(16);
22213
22214var ImageGLRenderable = function ImageGLRenderable(Base) {
22215 var renderable = function (_Base) {
22216 inherits(renderable, _Base);
22217
22218 function renderable() {
22219 classCallCheck(this, renderable);
22220 return possibleConstructorReturn(this, _Base.apply(this, arguments));
22221 }
22222
22223 renderable.prototype.drawGLImage = function drawGLImage(image, x, y, w, h, opacity) {
22224 var gl = this.gl;
22225 this.loadTexture(image);
22226
22227 v3[0] = x || 0;
22228 v3[1] = y || 0;
22229 var uMatrix = identity(arr16);
22230 translate(uMatrix, uMatrix, v3);
22231 multiply(uMatrix, this.getMap().projViewMatrix, uMatrix);
22232 gl.uniformMatrix4fv(this.program['u_matrix'], false, uMatrix);
22233 gl.uniform1f(this.program['u_opacity'], opacity);
22234 if (!image.glBuffer) {
22235 image.glBuffer = this.bufferTileData(0, 0, w, h);
22236 } else {
22237 gl.bindBuffer(gl.ARRAY_BUFFER, image.glBuffer);
22238 }
22239
22240 v2[0] = 'a_position';
22241 v2[1] = 3;
22242 this.enableVertexAttrib(v2);
22243 gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
22244 };
22245
22246 renderable.prototype.bufferTileData = function bufferTileData(x, y, w, h, buffer) {
22247 var x1 = x;
22248 var x2 = x + w;
22249 var y1 = y;
22250 var y2 = y + h;
22251 return this.loadImageBuffer(this.set12(x1, y1, 0, x1, y2, 0, x2, y1, 0, x2, y2, 0), buffer);
22252 };
22253
22254 renderable.prototype.drawTinImage = function drawTinImage(image, vertices, texCoords, indices, opacity) {
22255 var gl = this.gl;
22256 this.loadTexture(image);
22257 gl.uniformMatrix4fv(this.program['u_matrix'], false, this.getMap().projViewMatrix);
22258 gl.uniform1f(this.program['u_opacity'], opacity);
22259
22260 gl.bindBuffer(gl.ARRAY_BUFFER, this.posBuffer);
22261 this.enableVertexAttrib(['a_position', 3]);
22262
22263 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.DYNAMIC_DRAW);
22264
22265 gl.bindBuffer(gl.ARRAY_BUFFER, this.texBuffer);
22266 this.enableVertexAttrib(['a_texCoord', 2]);
22267 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(texCoords), gl.DYNAMIC_DRAW);
22268
22269 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.DYNAMIC_DRAW);
22270
22271 gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0);
22272 };
22273
22274 renderable.prototype.createCanvas2 = function createCanvas2() {
22275 this.canvas2 = Canvas.createCanvas(this.canvas.width, this.canvas.height);
22276 };
22277
22278 renderable.prototype.createGLContext = function createGLContext$$1() {
22279 var gl = this.gl = createGLContext(this.canvas2 || this.canvas, this.layer.options['glOptions']);
22280 gl.clearColor(0.0, 0.0, 0.0, 0.0);
22281
22282 gl.disable(gl.DEPTH_TEST);
22283 gl.enable(gl.STENCIL_TEST);
22284
22285 gl.enable(gl.BLEND);
22286 gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
22287
22288 this.program = this.createProgram(shaders['vertexShader'], this.layer.options['fragmentShader'] || shaders['fragmentShader'], ['u_matrix', 'u_image', 'u_opacity']);
22289 this.useProgram(this.program);
22290
22291 this.texBuffer = this.createBuffer();
22292 gl.bindBuffer(gl.ARRAY_BUFFER, this.texBuffer);
22293 this.enableVertexAttrib(['a_texCoord', 2]);
22294 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0]), gl.STATIC_DRAW);
22295
22296 this.enableSampler('u_image');
22297
22298 gl.activeTexture(gl['TEXTURE0']);
22299
22300 gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
22301
22302 this.posBuffer = this.createBuffer();
22303 gl.bindBuffer(gl.ARRAY_BUFFER, this.posBuffer);
22304 this.enableVertexAttrib(['a_position', 3]);
22305
22306 this.indicesBuffer = this.createBuffer();
22307 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
22308 };
22309
22310 renderable.prototype.resizeGLCanvas = function resizeGLCanvas() {
22311 if (this.gl) {
22312 this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
22313 }
22314 if (!this.canvas2) {
22315 return;
22316 }
22317 if (this.canvas2.width !== this.canvas.width || this.canvas2.height !== this.canvas.height) {
22318 this.canvas2.width = this.canvas.width;
22319 this.canvas2.height = this.canvas.height;
22320 }
22321 };
22322
22323 renderable.prototype.clearGLCanvas = function clearGLCanvas() {
22324 if (this.gl) {
22325 this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.STENCIL_BUFFER_BIT);
22326 }
22327 };
22328
22329 renderable.prototype.disposeImage = function disposeImage(image) {
22330 if (!image) {
22331 return;
22332 }
22333 if (image.texture) {
22334 this.saveTexture(image.texture);
22335 }
22336 if (image.glBuffer) {
22337 this.saveImageBuffer(image.glBuffer);
22338 }
22339 delete image.texture;
22340 delete image.glBuffer;
22341 };
22342
22343 renderable.prototype._createTexture = function _createTexture(image) {
22344 var gl = this.gl;
22345 var texture = this.getTexture() || gl.createTexture();
22346 gl.bindTexture(gl.TEXTURE_2D, texture);
22347
22348 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
22349 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
22350 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
22351 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
22352
22353 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
22354
22355 if (isInteger(log2(image.width)) && isInteger(log2(image.width))) {
22356 gl.generateMipmap(gl.TEXTURE_2D);
22357 }
22358
22359 return texture;
22360 };
22361
22362 renderable.prototype.getTexture = function getTexture() {
22363 if (!this._textures) {
22364 this._textures = [];
22365 }
22366 var textures = this._textures;
22367 return textures && textures.length > 0 ? textures.pop() : null;
22368 };
22369
22370 renderable.prototype.saveTexture = function saveTexture(texture) {
22371 this._textures.push(texture);
22372 };
22373
22374 renderable.prototype.loadTexture = function loadTexture(image) {
22375 var gl = this.gl;
22376 var texture = image.texture;
22377 if (!texture) {
22378 texture = this._createTexture(image);
22379 image.texture = texture;
22380 }
22381 gl.bindTexture(gl.TEXTURE_2D, texture);
22382 return texture;
22383 };
22384
22385 renderable.prototype.getImageBuffer = function getImageBuffer() {
22386 if (!this._imageBuffers) {
22387 this._imageBuffers = [];
22388 }
22389 var imageBuffers = this._imageBuffers;
22390 return imageBuffers && imageBuffers.length > 0 ? imageBuffers.pop() : null;
22391 };
22392
22393 renderable.prototype.saveImageBuffer = function saveImageBuffer(buffer) {
22394 this._imageBuffers.push(buffer);
22395 };
22396
22397 renderable.prototype.loadImageBuffer = function loadImageBuffer(data, glBuffer) {
22398 var gl = this.gl;
22399
22400 var buffer = glBuffer || this.createImageBuffer();
22401 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
22402 gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
22403 return buffer;
22404 };
22405
22406 renderable.prototype.createImageBuffer = function createImageBuffer() {
22407 return this.getImageBuffer() || this.createBuffer();
22408 };
22409
22410 renderable.prototype.removeGLCanvas = function removeGLCanvas() {
22411 var gl = this.gl;
22412 if (!gl) {
22413 return;
22414 }
22415 if (this._buffers) {
22416 this._buffers.forEach(function (b) {
22417 gl.deleteBuffer(b);
22418 });
22419 delete this._buffers;
22420 }
22421 if (this._textures) {
22422 this._textures.forEach(function (t) {
22423 return gl.deleteTexture(t);
22424 });
22425 delete this._textures;
22426 }
22427 delete this.posBuffer;
22428 var program = gl.program;
22429 gl.deleteShader(program.fragmentShader);
22430 gl.deleteShader(program.vertexShader);
22431 gl.deleteProgram(program);
22432 delete this.gl;
22433 delete this.canvas2;
22434 };
22435
22436 renderable.prototype.createBuffer = function createBuffer() {
22437 var gl = this.gl;
22438
22439 var buffer = gl.createBuffer();
22440 if (!buffer) {
22441 throw new Error('Failed to create the buffer object');
22442 }
22443 if (!this._buffers) {
22444 this._buffers = [];
22445 }
22446 this._buffers.push(buffer);
22447 return buffer;
22448 };
22449
22450 renderable.prototype.enableVertexAttrib = function enableVertexAttrib$$1(attributes) {
22451 enableVertexAttrib(this.gl, this.gl.program, attributes);
22452 };
22453
22454 renderable.prototype.createProgram = function createProgram$$1(vert, frag, uniforms) {
22455 var gl = this.gl;
22456
22457 var _createProgram2 = createProgram(gl, vert, frag),
22458 program = _createProgram2.program,
22459 vertexShader = _createProgram2.vertexShader,
22460 fragmentShader = _createProgram2.fragmentShader;
22461
22462 program.vertexShader = vertexShader;
22463 program.fragmentShader = fragmentShader;
22464
22465 this._initUniforms(program, uniforms);
22466 return program;
22467 };
22468
22469 renderable.prototype.useProgram = function useProgram(program) {
22470 var gl = this.gl;
22471 gl.useProgram(program);
22472 gl.program = program;
22473 return this;
22474 };
22475
22476 renderable.prototype.enableSampler = function enableSampler(sampler, texIdx) {
22477 var gl = this.gl;
22478 var uSampler = this._getUniform(gl.program, sampler);
22479 if (!texIdx) {
22480 texIdx = 0;
22481 }
22482
22483 gl.uniform1i(uSampler, texIdx);
22484 return uSampler;
22485 };
22486
22487 renderable.prototype._initUniforms = function _initUniforms(program, uniforms) {
22488 for (var i = 0; i < uniforms.length; i++) {
22489 var name = uniforms[i];
22490 var uniform = uniforms[i];
22491 var b = name.indexOf('[');
22492 if (b >= 0) {
22493 name = name.substring(0, b);
22494 if (!IS_NODE) {
22495 uniform = uniform.substring(0, b);
22496 }
22497 }
22498 program[name] = this._getUniform(program, uniform);
22499 }
22500 };
22501
22502 renderable.prototype._getUniform = function _getUniform(program, uniformName) {
22503 var gl = this.gl;
22504 var uniform = gl.getUniformLocation(program, uniformName);
22505 if (!uniform) {
22506 throw new Error('Failed to get the storage location of ' + uniformName);
22507 }
22508 return uniform;
22509 };
22510
22511 return renderable;
22512 }(Base);
22513
22514 extend(renderable.prototype, {
22515 set12: function () {
22516 var out = Browser$1.ie9 ? null : new Float32Array(12);
22517 return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) {
22518 out[0] = a0;
22519 out[1] = a1;
22520 out[2] = a2;
22521 out[3] = a3;
22522 out[4] = a4;
22523 out[5] = a5;
22524 out[6] = a6;
22525 out[7] = a7;
22526 out[8] = a8;
22527 out[9] = a9;
22528 out[10] = a10;
22529 out[11] = a11;
22530 return out;
22531 };
22532 }()
22533 });
22534
22535 return renderable;
22536};
22537
22538var options$32 = {
22539 renderer: Browser$1.webgl ? 'gl' : 'canvas',
22540 crossOrigin: null
22541};
22542
22543var ImageLayer = function (_Layer) {
22544 inherits(ImageLayer, _Layer);
22545
22546 function ImageLayer(id, images, options) {
22547 classCallCheck(this, ImageLayer);
22548
22549 if (!Array.isArray(images) && !images.url) {
22550 options = images;
22551 images = null;
22552 }
22553
22554 var _this = possibleConstructorReturn(this, _Layer.call(this, id, options));
22555
22556 _this._prepareImages(images);
22557 return _this;
22558 }
22559
22560 ImageLayer.prototype.setImages = function setImages(images) {
22561 this._images = images;
22562 this._prepareImages(images);
22563 return this;
22564 };
22565
22566 ImageLayer.prototype.getImages = function getImages() {
22567 return this._images;
22568 };
22569
22570 ImageLayer.prototype._prepareImages = function _prepareImages(images) {
22571 images = images || [];
22572 if (!Array.isArray(images)) {
22573 images = [images];
22574 }
22575 this._imageData = images.map(function (img) {
22576 return extend({}, img, {
22577 extent: new Extent(img.extent)
22578 });
22579 });
22580 this._images = images;
22581 var renderer = this.getRenderer();
22582 if (renderer) {
22583 renderer.refreshImages();
22584 }
22585 };
22586
22587 return ImageLayer;
22588}(Layer);
22589
22590ImageLayer.mergeOptions(options$32);
22591
22592var EMPTY_ARRAY = [];
22593
22594var ImageLayerCanvasRenderer = function (_CanvasRenderer) {
22595 inherits(ImageLayerCanvasRenderer, _CanvasRenderer);
22596
22597 function ImageLayerCanvasRenderer() {
22598 classCallCheck(this, ImageLayerCanvasRenderer);
22599 return possibleConstructorReturn(this, _CanvasRenderer.apply(this, arguments));
22600 }
22601
22602 ImageLayerCanvasRenderer.prototype.isDrawable = function isDrawable() {
22603 if (this.getMap().getPitch()) {
22604 if (console) {
22605 console.warn('ImageLayer with canvas renderer can\'t be pitched, use gl renderer (\'renderer\' : \'gl\') instead.');
22606 }
22607 return false;
22608 }
22609 return true;
22610 };
22611
22612 ImageLayerCanvasRenderer.prototype.checkResources = function checkResources() {
22613 var _this3 = this;
22614
22615 if (this._imageLoaded) {
22616 return EMPTY_ARRAY;
22617 }
22618 var layer = this.layer;
22619 var urls = layer._imageData.map(function (img) {
22620 return [img.url, null, null];
22621 });
22622 if (this.resources) {
22623 var unloaded = [];
22624 var resources = new ResourceCache();
22625 urls.forEach(function (url) {
22626 if (_this3.resources.isResourceLoaded(url)) {
22627 var img = _this3.resources.getImage(url);
22628 resources.addResource(url, img);
22629 } else {
22630 unloaded.push(url);
22631 }
22632 });
22633 this.resources.forEach(function (url, res) {
22634 if (!resources.isResourceLoaded(url)) {
22635 _this3.retireImage(res.image);
22636 }
22637 });
22638 this.resources = resources;
22639 urls = unloaded;
22640 }
22641 this._imageLoaded = true;
22642 return urls;
22643 };
22644
22645 ImageLayerCanvasRenderer.prototype.retireImage = function retireImage() {};
22646
22647 ImageLayerCanvasRenderer.prototype.refreshImages = function refreshImages() {
22648 this._imageLoaded = false;
22649 this.setToRedraw();
22650 };
22651
22652 ImageLayerCanvasRenderer.prototype.needToRedraw = function needToRedraw() {
22653 var map = this.getMap();
22654
22655 if (map.isZooming() && !map.getPitch()) {
22656 return false;
22657 }
22658 return _CanvasRenderer.prototype.needToRedraw.call(this);
22659 };
22660
22661 ImageLayerCanvasRenderer.prototype.draw = function draw() {
22662 if (!this.isDrawable()) {
22663 return;
22664 }
22665 this.prepareCanvas();
22666 this._painted = false;
22667 this._drawImages();
22668 this.completeRender();
22669 };
22670
22671 ImageLayerCanvasRenderer.prototype._drawImages = function _drawImages() {
22672 var imgData = this.layer._imageData;
22673 var map = this.getMap();
22674 var mapExtent = map.getExtent();
22675 if (imgData && imgData.length) {
22676 for (var i = 0; i < imgData.length; i++) {
22677 var extent = imgData[i].extent;
22678 var image = this.resources && this.resources.getImage(imgData[i].url);
22679 if (image && mapExtent.intersects(extent)) {
22680 this._painted = true;
22681 this._drawImage(image, extent, imgData[i].opacity || 1);
22682 }
22683 }
22684 }
22685 };
22686
22687 ImageLayerCanvasRenderer.prototype._drawImage = function _drawImage(image, extent, opacity) {
22688 var globalAlpha = 0;
22689 var ctx = this.context;
22690 if (opacity < 1) {
22691 globalAlpha = ctx.globalAlpha;
22692 ctx.globalAlpha = opacity;
22693 }
22694 var map = this.getMap();
22695 var min = map.coordToPoint(extent.getMin()),
22696 max = map.coordToPoint(extent.getMax());
22697 var point = map._pointToContainerPoint(min);
22698 var x = point.x,
22699 y = point.y;
22700 var bearing = map.getBearing();
22701 if (bearing) {
22702 ctx.save();
22703 ctx.translate(x, y);
22704 if (bearing) {
22705 ctx.rotate(-bearing * Math.PI / 180);
22706 }
22707 x = y = 0;
22708 }
22709 ctx.drawImage(image, x, y, max.x - min.x, max.y - min.y);
22710 if (bearing) {
22711 ctx.restore();
22712 }
22713 if (globalAlpha) {
22714 ctx.globalAlpha = globalAlpha;
22715 }
22716 };
22717
22718 ImageLayerCanvasRenderer.prototype.drawOnInteracting = function drawOnInteracting() {
22719 this.draw();
22720 };
22721
22722 return ImageLayerCanvasRenderer;
22723}(CanvasRenderer);
22724
22725var ImageLayerGLRenderer = function (_ImageGLRenderable) {
22726 inherits(ImageLayerGLRenderer, _ImageGLRenderable);
22727
22728 function ImageLayerGLRenderer() {
22729 classCallCheck(this, ImageLayerGLRenderer);
22730 return possibleConstructorReturn(this, _ImageGLRenderable.apply(this, arguments));
22731 }
22732
22733 ImageLayerGLRenderer.prototype.isDrawable = function isDrawable() {
22734 return true;
22735 };
22736
22737 ImageLayerGLRenderer.prototype._drawImage = function _drawImage(image, extent, opacity) {
22738 var map = this.getMap();
22739 var extent2d = extent.__imagelayerposition;
22740 if (!extent2d) {
22741 extent2d = extent.__imagelayerposition = extent.convertTo(function (c) {
22742 return map.coordToPoint(c, map.getGLZoom());
22743 });
22744 }
22745 this.drawGLImage(image, extent2d.xmin, extent2d.ymin, extent2d.getWidth(), extent2d.getHeight(), opacity);
22746 };
22747
22748 ImageLayerGLRenderer.prototype.createContext = function createContext() {
22749 this.createGLContext();
22750 };
22751
22752 ImageLayerGLRenderer.prototype.resizeCanvas = function resizeCanvas(canvasSize) {
22753 if (!this.canvas) {
22754 return;
22755 }
22756 _ImageGLRenderable.prototype.resizeCanvas.call(this, canvasSize);
22757 this.resizeGLCanvas();
22758 };
22759
22760 ImageLayerGLRenderer.prototype.clearCanvas = function clearCanvas() {
22761 if (!this.canvas) {
22762 return;
22763 }
22764 _ImageGLRenderable.prototype.clearCanvas.call(this);
22765 this.clearGLCanvas();
22766 };
22767
22768 ImageLayerGLRenderer.prototype.retireImage = function retireImage(image) {
22769 this.disposeImage(image);
22770 };
22771
22772 ImageLayerGLRenderer.prototype.onRemove = function onRemove() {
22773 this.removeGLCanvas();
22774 _ImageGLRenderable.prototype.onRemove.call(this);
22775 };
22776
22777 return ImageLayerGLRenderer;
22778}(ImageGLRenderable(ImageLayerCanvasRenderer));
22779
22780ImageLayer.registerRenderer('canvas', ImageLayerCanvasRenderer);
22781ImageLayer.registerRenderer('gl', ImageLayerGLRenderer);
22782
22783var CanvasLayerRenderer = function (_CanvasRenderer) {
22784 inherits(CanvasLayerRenderer, _CanvasRenderer);
22785
22786 function CanvasLayerRenderer() {
22787 classCallCheck(this, CanvasLayerRenderer);
22788 return possibleConstructorReturn(this, _CanvasRenderer.apply(this, arguments));
22789 }
22790
22791 CanvasLayerRenderer.prototype.getPrepareParams = function getPrepareParams() {
22792 return [];
22793 };
22794
22795 CanvasLayerRenderer.prototype.getDrawParams = function getDrawParams() {
22796 return [];
22797 };
22798
22799 CanvasLayerRenderer.prototype.onCanvasCreate = function onCanvasCreate() {
22800 if (this.canvas && this.layer.options['doubleBuffer']) {
22801 this.buffer = Canvas.createCanvas(this.canvas.width, this.canvas.height, this.getMap().CanvasClass);
22802 }
22803 };
22804
22805 CanvasLayerRenderer.prototype.needToRedraw = function needToRedraw() {
22806 if (this.layer.options['animation']) {
22807 return true;
22808 }
22809 var map = this.getMap();
22810 if (map.isInteracting() && !this.layer.drawOnInteracting) {
22811 return false;
22812 }
22813 return _CanvasRenderer.prototype.needToRedraw.call(this);
22814 };
22815
22816 CanvasLayerRenderer.prototype.draw = function draw() {
22817 this.prepareCanvas();
22818 this.prepareDrawContext();
22819 this._drawLayer();
22820 };
22821
22822 CanvasLayerRenderer.prototype.drawOnInteracting = function drawOnInteracting() {
22823 this._drawLayerOnInteracting();
22824 };
22825
22826 CanvasLayerRenderer.prototype.getCanvasImage = function getCanvasImage() {
22827 var canvasImg = _CanvasRenderer.prototype.getCanvasImage.call(this);
22828 if (canvasImg && canvasImg.image && this.layer.options['doubleBuffer']) {
22829 var canvas = canvasImg.image;
22830 if (this.buffer.width !== canvas.width || this.buffer.height !== canvas.height) {
22831 this.buffer.width = canvas.width;
22832 this.buffer.height = canvas.height;
22833 }
22834 var bufferContext = this.buffer.getContext('2d');
22835 var prevent = this.layer.doubleBuffer(bufferContext, this.context);
22836 if (prevent === undefined || prevent) {
22837 Canvas.image(bufferContext, canvas, 0, 0);
22838 canvasImg.image = this.buffer;
22839 }
22840 }
22841 return canvasImg;
22842 };
22843
22844 CanvasLayerRenderer.prototype.remove = function remove() {
22845 delete this._drawContext;
22846 return _CanvasRenderer.prototype.remove.call(this);
22847 };
22848
22849 CanvasLayerRenderer.prototype.onZoomStart = function onZoomStart(param) {
22850 this.layer.onZoomStart(param);
22851 _CanvasRenderer.prototype.onZoomStart.call(this, param);
22852 };
22853
22854 CanvasLayerRenderer.prototype.onZooming = function onZooming(param) {
22855 this.layer.onZooming(param);
22856 _CanvasRenderer.prototype.onZooming.call(this, param);
22857 };
22858
22859 CanvasLayerRenderer.prototype.onZoomEnd = function onZoomEnd(param) {
22860 this.layer.onZoomEnd(param);
22861 _CanvasRenderer.prototype.onZoomEnd.call(this, param);
22862 };
22863
22864 CanvasLayerRenderer.prototype.onMoveStart = function onMoveStart(param) {
22865 this.layer.onMoveStart(param);
22866 _CanvasRenderer.prototype.onMoveStart.call(this, param);
22867 };
22868
22869 CanvasLayerRenderer.prototype.onMoving = function onMoving(param) {
22870 this.layer.onMoving(param);
22871 _CanvasRenderer.prototype.onMoving.call(this, param);
22872 };
22873
22874 CanvasLayerRenderer.prototype.onMoveEnd = function onMoveEnd(param) {
22875 this.layer.onMoveEnd(param);
22876 _CanvasRenderer.prototype.onMoveEnd.call(this, param);
22877 };
22878
22879 CanvasLayerRenderer.prototype.onResize = function onResize(param) {
22880 this.layer.onResize(param);
22881 _CanvasRenderer.prototype.onResize.call(this, param);
22882 };
22883
22884 CanvasLayerRenderer.prototype.prepareDrawContext = function prepareDrawContext() {
22885 if (!this._predrawed) {
22886 var params = ensureParams(this.getPrepareParams());
22887 this._drawContext = this.layer.prepareToDraw.apply(this.layer, [this.context].concat(params));
22888 if (!this._drawContext) {
22889 this._drawContext = [];
22890 }
22891 if (!Array.isArray(this._drawContext)) {
22892 this._drawContext = [this._drawContext];
22893 }
22894 this._predrawed = true;
22895 }
22896 };
22897
22898 CanvasLayerRenderer.prototype._prepareDrawParams = function _prepareDrawParams() {
22899 if (!this.getMap()) {
22900 return null;
22901 }
22902 var view = this.getViewExtent();
22903 if (view['maskExtent'] && !view['extent'].intersects(view['maskExtent'])) {
22904 this.completeRender();
22905 return null;
22906 }
22907 var args = [this.context, view];
22908 var params = ensureParams(this.getDrawParams());
22909 args.push.apply(args, params);
22910 args.push.apply(args, this._drawContext);
22911 return args;
22912 };
22913
22914 CanvasLayerRenderer.prototype._drawLayer = function _drawLayer() {
22915 var args = this._prepareDrawParams();
22916 if (!args) {
22917 return;
22918 }
22919 this.layer.draw.apply(this.layer, args);
22920 this.completeRender();
22921 };
22922
22923 CanvasLayerRenderer.prototype._drawLayerOnInteracting = function _drawLayerOnInteracting() {
22924 if (!this.layer.drawOnInteracting) {
22925 return;
22926 }
22927 var args = this._prepareDrawParams();
22928 if (!args) {
22929 return;
22930 }
22931 this.layer.drawOnInteracting.apply(this.layer, args);
22932 this.completeRender();
22933 };
22934
22935 return CanvasLayerRenderer;
22936}(CanvasRenderer);
22937
22938function ensureParams(params) {
22939 if (!params) {
22940 params = [];
22941 }
22942 if (!Array.isArray(params)) {
22943 params = [params];
22944 }
22945 return params;
22946}
22947
22948var options$33 = {
22949 'doubleBuffer': false,
22950 'animation': false
22951};
22952
22953var CanvasLayer = function (_Layer) {
22954 inherits(CanvasLayer, _Layer);
22955
22956 function CanvasLayer() {
22957 classCallCheck(this, CanvasLayer);
22958 return possibleConstructorReturn(this, _Layer.apply(this, arguments));
22959 }
22960
22961 CanvasLayer.prototype.isCanvasRender = function isCanvasRender() {
22962 return true;
22963 };
22964
22965 CanvasLayer.prototype.prepareToDraw = function prepareToDraw() {};
22966
22967 CanvasLayer.prototype.draw = function draw() {};
22968
22969 CanvasLayer.prototype.redraw = function redraw() {
22970 if (this._getRenderer()) {
22971 this._getRenderer().setToRedraw();
22972 }
22973 return this;
22974 };
22975
22976 CanvasLayer.prototype.play = function play() {
22977 this.config('animation', true);
22978 return this;
22979 };
22980
22981 CanvasLayer.prototype.pause = function pause() {
22982 this.config('animation', false);
22983 return this;
22984 };
22985
22986 CanvasLayer.prototype.isPlaying = function isPlaying() {
22987 return this.options['animation'];
22988 };
22989
22990 CanvasLayer.prototype.clearCanvas = function clearCanvas() {
22991 if (this._getRenderer()) {
22992 this._getRenderer().clearCanvas();
22993 }
22994 return this;
22995 };
22996
22997 CanvasLayer.prototype.requestMapToRender = function requestMapToRender() {
22998 if (this._getRenderer()) {
22999 this._getRenderer().requestMapToRender();
23000 }
23001 return this;
23002 };
23003
23004 CanvasLayer.prototype.completeRender = function completeRender() {
23005 if (this._getRenderer()) {
23006 this._getRenderer().completeRender();
23007 }
23008 return this;
23009 };
23010
23011 CanvasLayer.prototype.onCanvasCreate = function onCanvasCreate() {
23012 return this;
23013 };
23014
23015 CanvasLayer.prototype.onZoomStart = function onZoomStart() {};
23016
23017 CanvasLayer.prototype.onZooming = function onZooming() {};
23018
23019 CanvasLayer.prototype.onZoomEnd = function onZoomEnd() {};
23020
23021 CanvasLayer.prototype.onMoveStart = function onMoveStart() {};
23022
23023 CanvasLayer.prototype.onMoving = function onMoving() {};
23024
23025 CanvasLayer.prototype.onMoveEnd = function onMoveEnd() {};
23026
23027 CanvasLayer.prototype.onResize = function onResize() {};
23028
23029 CanvasLayer.prototype.doubleBuffer = function doubleBuffer(bufferContext) {
23030 bufferContext.clearRect(0, 0, bufferContext.canvas.width, bufferContext.canvas.height);
23031 return this;
23032 };
23033
23034 return CanvasLayer;
23035}(Layer);
23036
23037CanvasLayer.mergeOptions(options$33);
23038
23039CanvasLayer.registerRenderer('canvas', CanvasLayerRenderer);
23040
23041var options$34 = {
23042 'animation': true
23043};
23044
23045var ParticleLayer = function (_CanvasLayer) {
23046 inherits(ParticleLayer, _CanvasLayer);
23047
23048 function ParticleLayer() {
23049 classCallCheck(this, ParticleLayer);
23050 return possibleConstructorReturn(this, _CanvasLayer.apply(this, arguments));
23051 }
23052
23053 ParticleLayer.prototype.getParticles = function getParticles() {};
23054
23055 ParticleLayer.prototype.draw = function draw(context, view) {
23056 var points = this.getParticles(now());
23057 if (!points || points.length === 0) {
23058 var renderer = this._getRenderer();
23059 if (renderer) {
23060 this._getRenderer()._shouldClear = true;
23061 }
23062 return;
23063 }
23064 var map = this.getMap();
23065 var extent = view.extent;
23066 if (view.maskExtent) {
23067 extent = view.extent.intersection(view.maskExtent);
23068 }
23069 extent = extent.convertTo(function (c) {
23070 return map._pointToContainerPoint(c);
23071 });
23072 var e = 2 * Math.PI;
23073 for (var i = 0, l = points.length; i < l; i++) {
23074 var pos = points[i].point;
23075 if (extent.contains(pos)) {
23076 var color = points[i].color || this.options['lineColor'] || '#fff',
23077 r = points[i].r;
23078 if (context.fillStyle !== color) {
23079 context.fillStyle = color;
23080 }
23081 if (r <= 2) {
23082 context.fillRect(pos.x - r / 2, pos.y - r / 2, r, r);
23083 } else {
23084 context.beginPath();
23085 context.arc(pos.x, pos.y, r / 2, 0, e);
23086 context.fill();
23087 }
23088 }
23089 }
23090 this._fillCanvas(context);
23091 };
23092
23093 ParticleLayer.prototype._fillCanvas = function _fillCanvas(context) {
23094 var g = context.globalCompositeOperation;
23095 context.globalCompositeOperation = 'destination-out';
23096 var trail = this.options['trail'] || 30;
23097 context.fillStyle = 'rgba(0, 0, 0, ' + 1 / trail + ')';
23098 context.fillRect(0, 0, context.canvas.width, context.canvas.height);
23099 context.globalCompositeOperation = g;
23100 };
23101
23102 return ParticleLayer;
23103}(CanvasLayer);
23104
23105ParticleLayer.mergeOptions(options$34);
23106
23107ParticleLayer.registerRenderer('canvas', function (_CanvasLayerRenderer) {
23108 inherits(_class, _CanvasLayerRenderer);
23109
23110 function _class() {
23111 classCallCheck(this, _class);
23112 return possibleConstructorReturn(this, _CanvasLayerRenderer.apply(this, arguments));
23113 }
23114
23115 _class.prototype.draw = function draw() {
23116 if (!this.canvas || !this.layer.options['animation'] || this._shouldClear) {
23117 this.prepareCanvas();
23118 this._shouldClear = false;
23119 }
23120 this.prepareDrawContext();
23121 this._drawLayer();
23122 };
23123
23124 _class.prototype.drawOnInteracting = function drawOnInteracting() {
23125 this.draw();
23126 this._shouldClear = false;
23127 };
23128
23129 _class.prototype.onSkipDrawOnInteracting = function onSkipDrawOnInteracting() {
23130 this._shouldClear = true;
23131 };
23132
23133 return _class;
23134}(CanvasLayerRenderer));
23135
23136var EDIT_STAGE_LAYER_PREFIX = INTERNAL_LAYER_PREFIX + '_edit_stage_';
23137
23138function createHandleSymbol(markerType, opacity) {
23139 return {
23140 'markerType': markerType,
23141 'markerFill': '#fff',
23142 'markerLineColor': '#000',
23143 'markerLineWidth': 2,
23144 'markerWidth': 10,
23145 'markerHeight': 10,
23146 'opacity': opacity
23147 };
23148}
23149
23150var options$35 = {
23151 'fixAspectRatio': false,
23152
23153 'symbol': null,
23154 'removeVertexOn': 'contextmenu',
23155
23156 'centerHandleSymbol': createHandleSymbol('ellipse', 1),
23157 'vertexHandleSymbol': createHandleSymbol('square', 1),
23158 'newVertexHandleSymbol': createHandleSymbol('square', 0.4)
23159};
23160
23161var GeometryEditor = function (_Eventable) {
23162 inherits(GeometryEditor, _Eventable);
23163
23164 function GeometryEditor(geometry, opts) {
23165 classCallCheck(this, GeometryEditor);
23166
23167 var _this = possibleConstructorReturn(this, _Eventable.call(this, opts));
23168
23169 _this._geometry = geometry;
23170 if (!_this._geometry) {
23171 return possibleConstructorReturn(_this);
23172 }
23173 return _this;
23174 }
23175
23176 GeometryEditor.prototype.getMap = function getMap() {
23177 return this._geometry.getMap();
23178 };
23179
23180 GeometryEditor.prototype.prepare = function prepare() {
23181 var map = this.getMap();
23182 if (!map) {
23183 return;
23184 }
23185
23186 if (this.options['symbol']) {
23187 this._originalSymbol = this._geometry.getSymbol();
23188 this._geometry.setSymbol(this.options['symbol']);
23189 }
23190
23191 this._prepareEditStageLayer();
23192 };
23193
23194 GeometryEditor.prototype._prepareEditStageLayer = function _prepareEditStageLayer() {
23195 var map = this.getMap();
23196 var uid = UID();
23197 var stageId = EDIT_STAGE_LAYER_PREFIX + uid,
23198 shadowId = EDIT_STAGE_LAYER_PREFIX + uid + '_shadow';
23199 this._editStageLayer = map.getLayer(stageId);
23200 this._shadowLayer = map.getLayer(shadowId);
23201 if (!this._editStageLayer) {
23202 this._editStageLayer = new VectorLayer(stageId);
23203 map.addLayer(this._editStageLayer);
23204 }
23205 if (!this._shadowLayer) {
23206 this._shadowLayer = new VectorLayer(shadowId);
23207 map.addLayer(this._shadowLayer);
23208 }
23209 };
23210
23211 GeometryEditor.prototype.start = function start() {
23212 var _this2 = this;
23213
23214 if (!this._geometry || !this._geometry.getMap() || this._geometry.editing) {
23215 return;
23216 }
23217 var map = this.getMap();
23218 this.editing = true;
23219 var geometry = this._geometry;
23220 this._geometryDraggble = geometry.options['draggable'];
23221 geometry.config('draggable', false);
23222 this.prepare();
23223
23224 var shadow = geometry.copy();
23225 shadow.setSymbol(geometry._getInternalSymbol());
23226
23227 shadow.copyEventListeners(geometry);
23228 if (geometry._getParent()) {
23229 shadow.copyEventListeners(geometry._getParent());
23230 }
23231
23232 shadow.setId(null).config({
23233 'draggable': false
23234 });
23235
23236 this._shadow = shadow;
23237
23238 this._switchGeometryEvents('on');
23239
23240 geometry.hide();
23241 if (geometry instanceof Marker || geometry instanceof Circle || geometry instanceof Rectangle || geometry instanceof Ellipse) {
23242 this._createOrRefreshOutline();
23243 }
23244 this._shadowLayer.bringToFront().addGeometry(shadow);
23245 this._editStageLayer.bringToFront();
23246 this._addListener([map, 'zoomstart', function () {
23247 _this2._editStageLayer.hide();
23248 }]);
23249 this._addListener([map, 'zoomend', function () {
23250 _this2._editStageLayer.show();
23251 }]);
23252 if (!(geometry instanceof Marker)) {
23253 this._createCenterHandle();
23254 } else {
23255 shadow.config('draggable', true);
23256 shadow.on('dragend', this._onMarkerDragEnd, this);
23257 }
23258 if (geometry instanceof Marker) {
23259 this.createMarkerEditor();
23260 } else if (geometry instanceof Circle) {
23261 this.createCircleEditor();
23262 } else if (geometry instanceof Rectangle) {
23263 this.createEllipseOrRectEditor();
23264 } else if (geometry instanceof Ellipse) {
23265 this.createEllipseOrRectEditor();
23266 } else if (geometry instanceof Sector) {} else if (geometry instanceof Polygon || geometry instanceof LineString) {
23267 this.createPolygonEditor();
23268 }
23269 };
23270
23271 GeometryEditor.prototype.stop = function stop() {
23272 delete this._history;
23273 delete this._historyPointer;
23274 delete this._editOutline;
23275 this._switchGeometryEvents('off');
23276 var map = this.getMap();
23277 if (!map) {
23278 return;
23279 }
23280 delete this._shadow;
23281 this._geometry.config('draggable', this._geometryDraggble);
23282 delete this._geometryDraggble;
23283 this._geometry.show();
23284
23285 this._editStageLayer.remove();
23286 this._shadowLayer.remove();
23287 this._clearAllListeners();
23288 this._refreshHooks = [];
23289 if (this.options['symbol']) {
23290 this._geometry.setSymbol(this._originalSymbol);
23291 delete this._originalSymbol;
23292 }
23293 this.editing = false;
23294 };
23295
23296 GeometryEditor.prototype.isEditing = function isEditing() {
23297 if (isNil(this.editing)) {
23298 return false;
23299 }
23300 return this.editing;
23301 };
23302
23303 GeometryEditor.prototype._getGeometryEvents = function _getGeometryEvents() {
23304 return {
23305 'symbolchange': this._onGeoSymbolChange,
23306 'positionchange shapechange': this._exeAndReset
23307 };
23308 };
23309
23310 GeometryEditor.prototype._switchGeometryEvents = function _switchGeometryEvents(oper) {
23311 if (this._geometry) {
23312 var events = this._getGeometryEvents();
23313 for (var p in events) {
23314 this._geometry[oper](p, events[p], this);
23315 }
23316 }
23317 };
23318
23319 GeometryEditor.prototype._onGeoSymbolChange = function _onGeoSymbolChange(param) {
23320 if (this._shadow) {
23321 this._shadow.setSymbol(param.target._getInternalSymbol());
23322 }
23323 };
23324
23325 GeometryEditor.prototype._onMarkerDragEnd = function _onMarkerDragEnd() {
23326 this._update('setCoordinates', this._shadow.getCoordinates().toArray());
23327 this._refresh();
23328 };
23329
23330 GeometryEditor.prototype._createOrRefreshOutline = function _createOrRefreshOutline() {
23331 var geometry = this._geometry;
23332 var outline = this._editOutline;
23333 if (!outline) {
23334 outline = geometry.getOutline();
23335 this._editStageLayer.addGeometry(outline);
23336 this._editOutline = outline;
23337 this._addRefreshHook(this._createOrRefreshOutline);
23338 } else {
23339 outline.remove();
23340 this._editOutline = outline = geometry.getOutline();
23341 this._editStageLayer.addGeometry(outline);
23342 }
23343
23344 return outline;
23345 };
23346
23347 GeometryEditor.prototype._createCenterHandle = function _createCenterHandle() {
23348 var _this3 = this;
23349
23350 var center = this._shadow.getCenter();
23351 var symbol = this.options['centerHandleSymbol'];
23352 var shadow = void 0;
23353 var handle = this.createHandle(center, {
23354 'symbol': symbol,
23355 'cursor': 'move',
23356 onDown: function onDown() {
23357 shadow = _this3._shadow.copy();
23358 var symbol = lowerSymbolOpacity(shadow._getInternalSymbol(), 0.5);
23359 shadow.setSymbol(symbol).addTo(_this3._editStageLayer);
23360 },
23361 onMove: function onMove(v, param) {
23362 var offset = param['coordOffset'];
23363 shadow.translate(offset);
23364 },
23365 onUp: function onUp() {
23366 _this3._update('setCoordinates', Coordinate.toNumberArrays(shadow.getCoordinates()));
23367 shadow.remove();
23368 _this3._refresh();
23369 }
23370 });
23371 this._addRefreshHook(function () {
23372 var center = _this3._shadow.getCenter();
23373 handle.setCoordinates(center);
23374 });
23375 };
23376
23377 GeometryEditor.prototype._createHandleInstance = function _createHandleInstance(coordinate, opts) {
23378 var symbol = opts['symbol'];
23379 var handle = new Marker(coordinate, {
23380 'draggable': true,
23381 'dragShadow': false,
23382 'dragOnAxis': opts['axis'],
23383 'cursor': opts['cursor'],
23384 'symbol': symbol
23385 });
23386 return handle;
23387 };
23388
23389 GeometryEditor.prototype.createHandle = function createHandle(coordinate, opts) {
23390 if (!opts) {
23391 opts = {};
23392 }
23393 var map = this.getMap();
23394 var handle = this._createHandleInstance(coordinate, opts);
23395 var me = this;
23396
23397 function onHandleDragstart(param) {
23398 if (opts.onDown) {
23399 opts.onDown.call(me, param['viewPoint'], param);
23400 }
23401 return false;
23402 }
23403
23404 function onHandleDragging(param) {
23405 me._hideContext();
23406 var viewPoint = map._prjToViewPoint(handle._getPrjCoordinates());
23407 if (opts.onMove) {
23408 opts.onMove.call(me, viewPoint, param);
23409 }
23410 return false;
23411 }
23412
23413 function onHandleDragEnd(ev) {
23414 if (opts.onUp) {
23415 opts.onUp.call(me, ev);
23416 }
23417 return false;
23418 }
23419
23420 function onHandleRemove() {
23421 handle.config('draggable', false);
23422 handle.off('dragstart', onHandleDragstart, me);
23423 handle.off('dragging', onHandleDragging, me);
23424 handle.off('dragend', onHandleDragEnd, me);
23425 handle.off('removestart', onHandleRemove, me);
23426 delete handle['maptalks--editor-refresh-fn'];
23427 }
23428
23429 handle.on('dragstart', onHandleDragstart, this);
23430 handle.on('dragging', onHandleDragging, this);
23431 handle.on('dragend', onHandleDragEnd, this);
23432 handle.on('removestart', onHandleRemove, this);
23433
23434 if (opts.onRefresh) {
23435 handle['maptalks--editor-refresh-fn'] = opts.onRefresh;
23436 }
23437 this._editStageLayer.addGeometry(handle);
23438 return handle;
23439 };
23440
23441 GeometryEditor.prototype._createResizeHandles = function _createResizeHandles(blackList, onHandleMove, onHandleUp) {
23442 var _this4 = this;
23443
23444 var cursors = ['nw-resize', 'n-resize', 'ne-resize', 'w-resize', 'e-resize', 'sw-resize', 's-resize', 'se-resize'];
23445
23446 var axis = [null, 'y', null, 'x', 'x', null, 'y', null];
23447 var geometry = this._geometry;
23448
23449 function getResizeAnchors(ext) {
23450 return [ext.getMin(), new Point((ext['xmax'] + ext['xmin']) / 2, ext['ymin']), new Point(ext['xmax'], ext['ymin']), new Point(ext['xmin'], (ext['ymax'] + ext['ymin']) / 2), new Point(ext['xmax'], (ext['ymax'] + ext['ymin']) / 2), new Point(ext['xmin'], ext['ymax']), new Point((ext['xmax'] + ext['xmin']) / 2, ext['ymax']), ext.getMax()];
23451 }
23452 if (!blackList) {
23453 blackList = [];
23454 }
23455 var me = this;
23456 var resizeHandles = [],
23457 anchorIndexes = {},
23458 map = this.getMap(),
23459 handleSymbol = this.options['vertexHandleSymbol'];
23460 var fnLocateHandles = function fnLocateHandles() {
23461 var pExt = geometry._getPainter().get2DExtent(),
23462 anchors = getResizeAnchors(pExt);
23463
23464 var _loop = function _loop(i) {
23465 if (Array.isArray(blackList)) {
23466 var isBlack = blackList.some(function (ele) {
23467 return ele === i;
23468 });
23469 if (isBlack) {
23470 return 'continue';
23471 }
23472 }
23473 var anchor = anchors[i],
23474 coordinate = map.pointToCoordinate(anchor);
23475 if (resizeHandles.length < anchors.length - blackList.length) {
23476 var handle = _this4.createHandle(coordinate, {
23477 'symbol': handleSymbol,
23478 'cursor': cursors[i],
23479 'axis': axis[i],
23480 onMove: function (_index) {
23481 return function (handleViewPoint) {
23482 me._updating = true;
23483 onHandleMove(handleViewPoint, _index);
23484 geometry.fire('resizing');
23485 };
23486 }(i),
23487 onUp: function onUp() {
23488 me._updating = false;
23489 onHandleUp();
23490 _this4._refresh();
23491 }
23492 });
23493 handle.setId(i);
23494 anchorIndexes[i] = resizeHandles.length;
23495 resizeHandles.push(handle);
23496 } else {
23497 resizeHandles[anchorIndexes[i]].setCoordinates(coordinate);
23498 }
23499 };
23500
23501 for (var i = 0; i < anchors.length; i++) {
23502 var _ret = _loop(i);
23503
23504 if (_ret === 'continue') continue;
23505 }
23506 };
23507
23508 fnLocateHandles();
23509
23510 this._addRefreshHook(fnLocateHandles);
23511 return resizeHandles;
23512 };
23513
23514 GeometryEditor.prototype.createMarkerEditor = function createMarkerEditor() {
23515 var _this5 = this;
23516
23517 var geometryToEdit = this._geometry,
23518 shadow = this._shadow,
23519 map = this.getMap();
23520 if (!shadow._canEdit()) {
23521 if (console) {
23522 console.warn('A marker can\'t be resized with symbol:', shadow.getSymbol());
23523 }
23524 return;
23525 }
23526
23527 if (!this._history) {
23528 this._recordHistory(getUpdates());
23529 }
23530
23531
23532 var symbol = shadow._getInternalSymbol();
23533 var dxdy = new Point(0, 0);
23534 if (isNumber(symbol['markerDx'])) {
23535 dxdy.x = symbol['markerDx'];
23536 }
23537 if (isNumber(symbol['markerDy'])) {
23538 dxdy.y = symbol['markerDy'];
23539 }
23540
23541 var blackList = null;
23542
23543 if (VectorMarkerSymbolizer.test(symbol)) {
23544 if (symbol['markerType'] === 'pin' || symbol['markerType'] === 'pie' || symbol['markerType'] === 'bar') {
23545 blackList = [5, 6, 7];
23546 }
23547 } else if (ImageMarkerSymbolizer.test(symbol) || VectorPathMarkerSymbolizer.test(symbol)) {
23548 blackList = [5, 6, 7];
23549 }
23550
23551 var resizeAbilities = [2, 1, 2, 0, 0, 2, 1, 2];
23552
23553 var aspectRatio = void 0;
23554 if (this.options['fixAspectRatio']) {
23555 var size = shadow.getSize();
23556 aspectRatio = size.width / size.height;
23557 }
23558
23559 var resizeHandles = this._createResizeHandles(null, function (handleViewPoint, i) {
23560 if (blackList && blackList.indexOf(i) >= 0) {
23561 var newCoordinates = map.viewPointToCoordinate(handleViewPoint.sub(dxdy));
23562 var coordinates = shadow.getCoordinates();
23563 newCoordinates.x = coordinates.x;
23564 shadow.setCoordinates(newCoordinates);
23565 _this5._updateCoordFromShadow(true);
23566
23567 var mirrorHandle = resizeHandles[resizeHandles.length - 1 - i];
23568 var mirrorViewPoint = map.coordToViewPoint(mirrorHandle.getCoordinates());
23569 handleViewPoint = mirrorViewPoint;
23570 }
23571
23572 var viewCenter = map._pointToViewPoint(shadow._getCenter2DPoint()).add(dxdy),
23573 symbol = shadow._getInternalSymbol();
23574 var wh = handleViewPoint.sub(viewCenter);
23575 if (blackList && handleViewPoint.y > viewCenter.y) {
23576 wh.y = 0;
23577 }
23578
23579 var r = blackList ? 1 : 2;
23580 var width = Math.abs(wh.x) * 2,
23581 height = Math.abs(wh.y) * r;
23582 if (aspectRatio) {
23583 width = Math.max(width, height * aspectRatio);
23584 height = width / aspectRatio;
23585 }
23586 var ability = resizeAbilities[i];
23587 if (!(shadow instanceof TextBox)) {
23588 if (aspectRatio || ability === 0 || ability === 2) {
23589 symbol['markerWidth'] = width;
23590 }
23591 if (aspectRatio || ability === 1 || ability === 2) {
23592 symbol['markerHeight'] = height;
23593 }
23594 shadow.setSymbol(symbol);
23595 geometryToEdit.setSymbol(symbol);
23596 } else {
23597 if (aspectRatio || ability === 0 || ability === 2) {
23598 shadow.setWidth(width);
23599 geometryToEdit.setWidth(width);
23600 }
23601 if (aspectRatio || ability === 1 || ability === 2) {
23602 shadow.setHeight(height);
23603 geometryToEdit.setHeight(height);
23604 }
23605 }
23606 }, function () {
23607 _this5._update(getUpdates());
23608 });
23609
23610 function getUpdates() {
23611 var updates = [['setCoordinates', shadow.getCoordinates().toArray()]];
23612 if (shadow instanceof TextBox) {
23613 updates.push(['setWidth', shadow.getWidth()]);
23614 updates.push(['setHeight', shadow.getHeight()]);
23615 } else {
23616 updates.push(['setSymbol', shadow.getSymbol()]);
23617 }
23618 return updates;
23619 }
23620
23621 function onZoomEnd() {
23622 this._refresh();
23623 }
23624
23625 this._addListener([map, 'zoomend', onZoomEnd]);
23626 };
23627
23628 GeometryEditor.prototype.createCircleEditor = function createCircleEditor() {
23629 var _this6 = this;
23630
23631 var circle = this._geometry,
23632 shadow = this._shadow;
23633 var map = this.getMap();
23634
23635 if (!this._history) {
23636 this._recordHistory([['setCoordinates', shadow.getCoordinates().toArray()], ['setRadius', shadow.getRadius()]]);
23637 }
23638
23639 this._createResizeHandles(null, function (handleViewPoint) {
23640 var viewCenter = map._pointToViewPoint(shadow._getCenter2DPoint());
23641 var wh = handleViewPoint.sub(viewCenter);
23642 var w = Math.abs(wh.x),
23643 h = Math.abs(wh.y);
23644 var r = void 0;
23645 if (w > h) {
23646 r = map.pixelToDistance(w, 0);
23647 } else {
23648 r = map.pixelToDistance(0, h);
23649 }
23650 shadow.setRadius(r);
23651 circle.setRadius(r);
23652 }, function () {
23653 _this6._update('setRadius', shadow.getRadius());
23654 });
23655 };
23656
23657 GeometryEditor.prototype.createEllipseOrRectEditor = function createEllipseOrRectEditor() {
23658 var _this7 = this;
23659
23660 var resizeAbilities = [2, 1, 2, 0, 0, 2, 1, 2];
23661 var geometryToEdit = this._geometry,
23662 shadow = this._shadow;
23663
23664 if (!this._history) {
23665 this._recordHistory(getUpdates());
23666 }
23667
23668 var map = this.getMap();
23669 var isRect = this._geometry instanceof Rectangle;
23670 var aspectRatio = void 0;
23671 if (this.options['fixAspectRatio']) {
23672 aspectRatio = geometryToEdit.getWidth() / geometryToEdit.getHeight();
23673 }
23674 var resizeHandles = this._createResizeHandles(null, function (mouseViewPoint, i) {
23675 var r = isRect ? 1 : 2;
23676 var pointSub = void 0,
23677 w = void 0,
23678 h = void 0;
23679 var targetPoint = mouseViewPoint;
23680 var ability = resizeAbilities[i];
23681 if (isRect) {
23682 var mirror = resizeHandles[7 - i];
23683 var mirrorViewPoint = map.coordToViewPoint(mirror.getCoordinates());
23684 pointSub = targetPoint.sub(mirrorViewPoint);
23685 var absSub = pointSub.abs();
23686 w = map.pixelToDistance(absSub.x, 0);
23687 h = map.pixelToDistance(0, absSub.y);
23688 var size = geometryToEdit.getSize();
23689 if (ability === 0) {
23690 if (aspectRatio) {
23691 absSub.y = absSub.x / aspectRatio;
23692 size.height = Math.abs(absSub.y);
23693 h = w / aspectRatio;
23694 }
23695 targetPoint.y = mirrorViewPoint.y - size.height / 2;
23696 } else if (ability === 1) {
23697 if (aspectRatio) {
23698 absSub.x = absSub.y * aspectRatio;
23699 size.width = Math.abs(absSub.x);
23700 w = h * aspectRatio;
23701 }
23702 targetPoint.x = mirrorViewPoint.x - size.width / 2;
23703 } else if (aspectRatio) {
23704 if (w > h * aspectRatio) {
23705 h = w / aspectRatio;
23706 targetPoint.y = mirrorViewPoint.y + absSub.x * sign(pointSub.y) / aspectRatio;
23707 } else {
23708 w = h * aspectRatio;
23709 targetPoint.x = mirrorViewPoint.x + absSub.y * sign(pointSub.x) * aspectRatio;
23710 }
23711 }
23712
23713 var newCoordinates = map.viewPointToCoordinate(new Point(Math.min(targetPoint.x, mirrorViewPoint.x), Math.min(targetPoint.y, mirrorViewPoint.y)));
23714 shadow.setCoordinates(newCoordinates);
23715 _this7._updateCoordFromShadow(true);
23716 } else {
23717 var viewCenter = map.coordToViewPoint(geometryToEdit.getCenter());
23718 pointSub = viewCenter.sub(targetPoint)._abs();
23719 w = map.pixelToDistance(pointSub.x, 0);
23720 h = map.pixelToDistance(0, pointSub.y);
23721 if (aspectRatio) {
23722 w = Math.max(w, h * aspectRatio);
23723 h = w / aspectRatio;
23724 }
23725 }
23726
23727 if (aspectRatio || ability === 0 || ability === 2) {
23728 shadow.setWidth(w * r);
23729 geometryToEdit.setWidth(w * r);
23730 }
23731 if (aspectRatio || ability === 1 || ability === 2) {
23732 shadow.setHeight(h * r);
23733 geometryToEdit.setHeight(h * r);
23734 }
23735 }, function () {
23736 _this7._update(getUpdates());
23737 });
23738
23739 function getUpdates() {
23740 return [['setCoordinates', shadow.getCoordinates().toArray()], ['setWidth', shadow.getWidth()], ['setHeight', shadow.getHeight()]];
23741 }
23742 };
23743
23744 GeometryEditor.prototype.createPolygonEditor = function createPolygonEditor() {
23745
23746 var map = this.getMap(),
23747 shadow = this._shadow,
23748 me = this,
23749 projection = map.getProjection();
23750 if (!this._history) {
23751 this._recordHistory('setCoordinates', Coordinate.toNumberArrays(shadow.getCoordinates()));
23752 }
23753
23754 var verticeLimit = shadow instanceof Polygon ? 3 : 2;
23755 var propertyOfVertexRefreshFn = 'maptalks--editor-refresh-fn',
23756 propertyOfVertexIndex = 'maptalks--editor-vertex-index';
23757 var vertexHandles = [],
23758 newVertexHandles = [];
23759
23760 function getVertexCoordinates() {
23761 if (shadow instanceof Polygon) {
23762 var coordinates = shadow.getCoordinates()[0];
23763 return coordinates.slice(0, coordinates.length - 1);
23764 } else {
23765 return shadow.getCoordinates();
23766 }
23767 }
23768
23769 function getVertexPrjCoordinates() {
23770 return shadow._getPrjCoordinates();
23771 }
23772
23773 function onVertexAddOrRemove() {
23774 for (var i = vertexHandles.length - 1; i >= 0; i--) {
23775 vertexHandles[i][propertyOfVertexIndex] = i;
23776 }
23777 for (var _i = newVertexHandles.length - 1; _i >= 0; _i--) {
23778 newVertexHandles[_i][propertyOfVertexIndex] = _i;
23779 }
23780 me._updateCoordFromShadow();
23781 }
23782
23783 function removeVertex(param) {
23784 var handle = param['target'],
23785 index = handle[propertyOfVertexIndex];
23786 var prjCoordinates = getVertexPrjCoordinates();
23787 if (prjCoordinates.length <= verticeLimit) {
23788 return;
23789 }
23790 prjCoordinates.splice(index, 1);
23791 shadow._setPrjCoordinates(prjCoordinates);
23792 shadow._updateCache();
23793
23794 vertexHandles.splice(index, 1)[0].remove();
23795
23796 if (index < newVertexHandles.length) {
23797 newVertexHandles.splice(index, 1)[0].remove();
23798 }
23799 var nextIndex = void 0;
23800 if (index === 0) {
23801 nextIndex = newVertexHandles.length - 1;
23802 } else {
23803 nextIndex = index - 1;
23804 }
23805 newVertexHandles.splice(nextIndex, 1)[0].remove();
23806
23807 newVertexHandles.splice(nextIndex, 0, createNewVertexHandle.call(me, nextIndex));
23808 onVertexAddOrRemove();
23809 me._refresh();
23810 }
23811
23812 function moveVertexHandle(handleViewPoint, index) {
23813 var vertice = getVertexPrjCoordinates();
23814 var nVertex = map._viewPointToPrj(handleViewPoint);
23815 var pVertex = vertice[index];
23816 pVertex.x = nVertex.x;
23817 pVertex.y = nVertex.y;
23818 shadow._updateCache();
23819 shadow.onShapeChanged();
23820 me._updateCoordFromShadow(true);
23821 var nextIndex = void 0;
23822 if (index === 0) {
23823 nextIndex = newVertexHandles.length - 1;
23824 } else {
23825 nextIndex = index - 1;
23826 }
23827
23828 if (newVertexHandles[index]) {
23829 newVertexHandles[index][propertyOfVertexRefreshFn]();
23830 }
23831 if (newVertexHandles[nextIndex]) {
23832 newVertexHandles[nextIndex][propertyOfVertexRefreshFn]();
23833 }
23834 }
23835
23836 function createVertexHandle(index) {
23837 var vertex = getVertexCoordinates()[index];
23838 var handle = me.createHandle(vertex, {
23839 'symbol': me.options['vertexHandleSymbol'],
23840 'cursor': 'pointer',
23841 'axis': null,
23842 onMove: function onMove(handleViewPoint) {
23843 moveVertexHandle(handleViewPoint, handle[propertyOfVertexIndex]);
23844 },
23845 onRefresh: function onRefresh() {
23846 vertex = getVertexCoordinates()[handle[propertyOfVertexIndex]];
23847 handle.setCoordinates(vertex);
23848 },
23849 onUp: function onUp() {
23850 me._refresh();
23851 me._updateCoordFromShadow();
23852 }
23853 });
23854 handle[propertyOfVertexIndex] = index;
23855 handle.on(me.options['removeVertexOn'], removeVertex);
23856 return handle;
23857 }
23858
23859 function createNewVertexHandle(index) {
23860 var vertexCoordinates = getVertexCoordinates();
23861 var nextVertex = void 0;
23862 if (index + 1 >= vertexCoordinates.length) {
23863 nextVertex = vertexCoordinates[0];
23864 } else {
23865 nextVertex = vertexCoordinates[index + 1];
23866 }
23867 var vertex = vertexCoordinates[index].add(nextVertex).multi(1 / 2);
23868 var handle = me.createHandle(vertex, {
23869 'symbol': me.options['newVertexHandleSymbol'],
23870 'cursor': 'pointer',
23871 'axis': null,
23872 onDown: function onDown(param, e) {
23873 if (e && e.domEvent && e.domEvent.button === 2) {
23874 return;
23875 }
23876 var prjCoordinates = getVertexPrjCoordinates();
23877 var vertexIndex = handle[propertyOfVertexIndex];
23878
23879 var pVertex = projection.project(handle.getCoordinates());
23880
23881 prjCoordinates.splice(vertexIndex + 1, 0, pVertex);
23882 shadow._setPrjCoordinates(prjCoordinates);
23883 shadow._updateCache();
23884
23885 var symbol = handle.getSymbol();
23886 delete symbol['opacity'];
23887 handle.setSymbol(symbol);
23888
23889 newVertexHandles.splice(vertexIndex, 0, createNewVertexHandle.call(me, vertexIndex), createNewVertexHandle.call(me, vertexIndex + 1));
23890 },
23891 onMove: function onMove(handleViewPoint) {
23892 moveVertexHandle(handleViewPoint, handle[propertyOfVertexIndex] + 1);
23893 },
23894 onUp: function onUp(e) {
23895 if (e && e.domEvent && e.domEvent.button === 2) {
23896 return;
23897 }
23898 var vertexIndex = handle[propertyOfVertexIndex];
23899
23900 removeFromArray(handle, newVertexHandles);
23901 handle.remove();
23902
23903 vertexHandles.splice(vertexIndex + 1, 0, createVertexHandle.call(me, vertexIndex + 1));
23904 onVertexAddOrRemove();
23905 me._updateCoordFromShadow();
23906 me._refresh();
23907 },
23908 onRefresh: function onRefresh() {
23909 vertexCoordinates = getVertexCoordinates();
23910 var vertexIndex = handle[propertyOfVertexIndex];
23911 var nextIndex = void 0;
23912 if (vertexIndex === vertexCoordinates.length - 1) {
23913 nextIndex = 0;
23914 } else {
23915 nextIndex = vertexIndex + 1;
23916 }
23917 var refreshVertex = vertexCoordinates[vertexIndex].add(vertexCoordinates[nextIndex]).multi(1 / 2);
23918 handle.setCoordinates(refreshVertex);
23919 }
23920 });
23921 handle[propertyOfVertexIndex] = index;
23922 return handle;
23923 }
23924 var vertexCoordinates = getVertexCoordinates();
23925 for (var i = 0, len = vertexCoordinates.length; i < len; i++) {
23926 vertexHandles.push(createVertexHandle.call(this, i));
23927 if (i < len - 1) {
23928 newVertexHandles.push(createNewVertexHandle.call(this, i));
23929 }
23930 }
23931 if (shadow instanceof Polygon) {
23932 newVertexHandles.push(createNewVertexHandle.call(this, vertexCoordinates.length - 1));
23933 }
23934 this._addRefreshHook(function () {
23935 for (var _i2 = newVertexHandles.length - 1; _i2 >= 0; _i2--) {
23936 newVertexHandles[_i2][propertyOfVertexRefreshFn]();
23937 }
23938 for (var _i3 = vertexHandles.length - 1; _i3 >= 0; _i3--) {
23939 vertexHandles[_i3][propertyOfVertexRefreshFn]();
23940 }
23941 });
23942 };
23943
23944 GeometryEditor.prototype._refresh = function _refresh() {
23945 if (this._refreshHooks) {
23946 for (var i = this._refreshHooks.length - 1; i >= 0; i--) {
23947 this._refreshHooks[i].call(this);
23948 }
23949 }
23950 };
23951
23952 GeometryEditor.prototype._hideContext = function _hideContext() {
23953 if (this._geometry) {
23954 this._geometry.closeMenu();
23955 this._geometry.closeInfoWindow();
23956 }
23957 };
23958
23959 GeometryEditor.prototype._addListener = function _addListener(listener) {
23960 if (!this._eventListeners) {
23961 this._eventListeners = [];
23962 }
23963 this._eventListeners.push(listener);
23964 listener[0].on(listener[1], listener[2], this);
23965 };
23966
23967 GeometryEditor.prototype._clearAllListeners = function _clearAllListeners() {
23968 if (this._eventListeners && this._eventListeners.length > 0) {
23969 for (var i = this._eventListeners.length - 1; i >= 0; i--) {
23970 var listener = this._eventListeners[i];
23971 listener[0].off(listener[1], listener[2], this);
23972 }
23973 this._eventListeners = [];
23974 }
23975 };
23976
23977 GeometryEditor.prototype._addRefreshHook = function _addRefreshHook(fn) {
23978 if (!fn) {
23979 return;
23980 }
23981 if (!this._refreshHooks) {
23982 this._refreshHooks = [];
23983 }
23984 this._refreshHooks.push(fn);
23985 };
23986
23987 GeometryEditor.prototype._update = function _update(method) {
23988 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
23989 args[_key - 1] = arguments[_key];
23990 }
23991
23992 this._exeHistory([method, args]);
23993 this._recordHistory.apply(this, [method].concat(args));
23994 };
23995
23996 GeometryEditor.prototype._updateCoordFromShadow = function _updateCoordFromShadow(ignoreRecord) {
23997 if (!this._shadow) {
23998 return;
23999 }
24000
24001 var coords = this._shadow.getCoordinates();
24002 var geo = this._geometry;
24003 var updating = this._updating;
24004 this._updating = true;
24005 geo.setCoordinates(coords);
24006 if (!ignoreRecord) {
24007 this._recordHistory('setCoordinates', Coordinate.toNumberArrays(geo.getCoordinates()));
24008 }
24009 this._updating = updating;
24010 };
24011
24012 GeometryEditor.prototype._recordHistory = function _recordHistory(method) {
24013 if (!this._history) {
24014 this._history = [];
24015 this._historyPointer = 0;
24016 }
24017
24018 if (this._historyPointer < this._history.length - 1) {
24019 this._history.splice(this._historyPointer + 1);
24020 }
24021
24022 for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
24023 args[_key2 - 1] = arguments[_key2];
24024 }
24025
24026 this._history.push([method, args]);
24027 this._historyPointer = this._history.length - 1;
24028
24029 this._geometry.fire('editrecord');
24030 };
24031
24032 GeometryEditor.prototype.undo = function undo() {
24033 if (!this._history || this._historyPointer === 0) {
24034 return this;
24035 }
24036 var record = this._history[--this._historyPointer];
24037 this._exeAndReset(record);
24038 return this;
24039 };
24040
24041 GeometryEditor.prototype.redo = function redo() {
24042 if (!this._history || this._historyPointer === this._history.length - 1) {
24043 return null;
24044 }
24045 var record = this._history[++this._historyPointer];
24046 this._exeAndReset(record);
24047 return this;
24048 };
24049
24050 GeometryEditor.prototype._exeAndReset = function _exeAndReset(record) {
24051 if (this._updating) {
24052 return;
24053 }
24054 this._exeHistory(record);
24055 var history = this._history,
24056 pointer = this._historyPointer;
24057 this.stop();
24058 this._history = history;
24059 this._historyPointer = pointer;
24060 this.start();
24061 };
24062
24063 GeometryEditor.prototype._exeHistory = function _exeHistory(record) {
24064 var _this8 = this;
24065
24066 if (!Array.isArray(record)) {
24067 return;
24068 }
24069 var updating = this._updating;
24070 this._updating = true;
24071 var geo = this._geometry;
24072 if (Array.isArray(record[0])) {
24073 record[0].forEach(function (o) {
24074 var m = o[0],
24075 args = o.slice(1);
24076 _this8._shadow[m].apply(_this8._shadow, args);
24077 geo[m].apply(geo, args);
24078 });
24079 } else {
24080 this._shadow[record[0]].apply(this._shadow, record[1]);
24081 geo[record[0]].apply(geo, record[1]);
24082 }
24083 this._updating = updating;
24084 };
24085
24086 return GeometryEditor;
24087}(Eventable(Class));
24088
24089GeometryEditor.mergeOptions(options$35);
24090
24091var TextEditable = {
24092 startEditText: function startEditText() {
24093 if (!this.getMap()) {
24094 return this;
24095 }
24096 this.hide();
24097 this.endEditText();
24098 this._prepareEditor();
24099
24100 this._fireEvent('edittextstart');
24101 return this;
24102 },
24103 endEditText: function endEditText() {
24104 if (this._textEditor) {
24105 var html = this._textEditor.innerHTML;
24106 html = html.replace(/<p>/ig, '').replace(/<\/p>/ig, '<br/>');
24107 this._textEditor.innerHTML = html;
24108
24109 var content = this._textEditor.innerText.replace(/[\r\n]+$/gi, '');
24110 this.setContent(content);
24111 off(this._textEditor, 'mousedown dblclick', stopPropagation);
24112 this.getMap().off('mousedown', this.endEditText, this);
24113 this._editUIMarker.remove();
24114 delete this._editUIMarker;
24115 this._textEditor.onkeyup = null;
24116 delete this._textEditor;
24117 this.show();
24118
24119 this._fireEvent('edittextend');
24120 }
24121 return this;
24122 },
24123 isEditingText: function isEditingText() {
24124 if (this._textEditor) {
24125 return true;
24126 }
24127 return false;
24128 },
24129 getTextEditor: function getTextEditor() {
24130 return this._editUIMarker;
24131 },
24132 _prepareEditor: function _prepareEditor() {
24133 var map = this.getMap();
24134 var editContainer = this._createEditor();
24135 this._textEditor = editContainer;
24136 map.on('mousedown', this.endEditText, this);
24137 var offset = this._getEditorOffset();
24138 this._editUIMarker = new UIMarker(this.getCoordinates(), {
24139 'animation': null,
24140 'content': editContainer,
24141 'dx': offset.dx,
24142 'dy': offset.dy
24143 }).addTo(map);
24144 this._setCursorToLast(this._textEditor);
24145 },
24146 _getEditorOffset: function _getEditorOffset() {
24147 var symbol = this._getInternalSymbol() || {};
24148 var dx = 0,
24149 dy = 0;
24150 var textAlign = symbol['textHorizontalAlignment'];
24151 if (textAlign === 'middle' || isNil(textAlign)) {
24152 dx = (symbol['textDx'] || 0) - 2;
24153 dy = (symbol['textDy'] || 0) - 2;
24154 } else {
24155 dx = (symbol['markerDx'] || 0) - 2;
24156 dy = (symbol['markerDy'] || 0) - 2;
24157 }
24158 return {
24159 'dx': dx,
24160 'dy': dy
24161 };
24162 },
24163 _createEditor: function _createEditor() {
24164 var content = this.getContent();
24165 var labelSize = this.getSize(),
24166 symbol = this._getInternalSymbol() || {},
24167 width = labelSize.width,
24168 textColor = symbol['textFill'] || '#000000',
24169 textSize = symbol['textSize'] || 12,
24170 height = labelSize.height,
24171 lineColor = symbol['markerLineColor'] || '#000',
24172 fill = symbol['markerFill'] || '#3398CC',
24173 spacing = symbol['textLineSpacing'] || 0;
24174 var editor = createEl('div');
24175 editor.contentEditable = true;
24176 editor.style.cssText = 'background:' + fill + '; border:1px solid ' + lineColor + ';\n color:' + textColor + ';font-size:' + textSize + 'px;width:' + (width - 2) + 'px;height:' + (height - 2) + 'px;margin: auto;\n line-height:' + (textSize + spacing) + 'px;outline: 0; padding:0; margin:0;word-wrap: break-word;\n overflow: hidden;-webkit-user-modify: read-write-plaintext-only;';
24177
24178 editor.innerText = content;
24179 on(editor, 'mousedown dblclick', stopPropagation);
24180 editor.onkeyup = function (event) {
24181 var h = editor.style.height || 0;
24182 if (event.keyCode === 13) {
24183 editor.style.height = parseInt(h) + textSize / 2 + 'px';
24184 }
24185 };
24186 return editor;
24187 },
24188 _setCursorToLast: function _setCursorToLast(obj) {
24189 var range = void 0;
24190 if (window.getSelection) {
24191 obj.focus();
24192 range = window.getSelection();
24193 range.selectAllChildren(obj);
24194 range.collapseToEnd();
24195 } else if (document.selection) {
24196 range = document.selection.createRange();
24197 range.moveToElementText(obj);
24198 range.collapse(false);
24199 range.select();
24200 }
24201 }
24202};
24203
24204TextMarker.include(TextEditable);
24205
24206Geometry.include({
24207 animate: function animate(styles, options, step) {
24208 var _this = this;
24209
24210 if (this._animPlayer) {
24211 this._animPlayer.finish();
24212 }
24213 if (isFunction(options)) {
24214 step = options;
24215 }
24216 if (!options) {
24217 options = {};
24218 }
24219 var map = this.getMap(),
24220 projection = this._getProjection(),
24221 symbol = this.getSymbol() || {},
24222 stylesToAnimate = this._prepareAnimationStyles(styles);
24223 var preTranslate = void 0;
24224
24225 var isFocusing = options['focus'];
24226 delete this._animationStarted;
24227
24228 if (map) {
24229 var renderer = map._getRenderer();
24230 var framer = function framer(fn) {
24231 renderer.callInNextFrame(fn);
24232 };
24233 options['framer'] = framer;
24234 }
24235
24236 var player = Animation.animate(stylesToAnimate, options, function (frame) {
24237 if (map && map.isRemoved()) {
24238 player.finish();
24239 return;
24240 }
24241 if (map && !_this._animationStarted && isFocusing) {
24242 map.onMoveStart();
24243 }
24244 var styles = frame.styles;
24245 for (var p in styles) {
24246 if (p !== 'symbol' && p !== 'translate' && styles.hasOwnProperty(p)) {
24247 var fnName = 'set' + p[0].toUpperCase() + p.slice(1);
24248 _this[fnName](styles[p]);
24249 }
24250 }
24251 var translate = styles['translate'];
24252 if (translate) {
24253 var toTranslate = translate;
24254 if (preTranslate) {
24255 toTranslate = translate.sub(preTranslate);
24256 }
24257 preTranslate = translate;
24258 _this.translate(toTranslate);
24259 }
24260 var dSymbol = styles['symbol'];
24261 if (dSymbol) {
24262 _this.setSymbol(extendSymbol(symbol, dSymbol));
24263 }
24264 if (map && isFocusing) {
24265 var pcenter = projection.project(_this.getCenter());
24266 map._setPrjCenter(pcenter);
24267 var e = map._parseEventFromCoord(projection.unproject(pcenter));
24268 if (player.playState !== 'running') {
24269 map.onMoveEnd(e);
24270 } else {
24271 map.onMoving(e);
24272 }
24273 }
24274 _this._fireAnimateEvent(player.playState);
24275 if (step) {
24276 step(frame);
24277 }
24278 });
24279 this._animPlayer = player;
24280 return this._animPlayer.play();
24281 },
24282
24283 _prepareAnimationStyles: function _prepareAnimationStyles(styles) {
24284 var symbol = this._getInternalSymbol();
24285 var stylesToAnimate = {};
24286 for (var p in styles) {
24287 if (styles.hasOwnProperty(p)) {
24288 var v = styles[p];
24289 if (p !== 'translate' && p !== 'symbol') {
24290 var fnName = 'get' + p[0].toUpperCase() + p.substring(1);
24291 var current = this[fnName]();
24292 stylesToAnimate[p] = [current, v];
24293 } else if (p === 'symbol') {
24294 var symbolToAnimate = void 0;
24295 if (Array.isArray(styles['symbol'])) {
24296 if (!Array.isArray(symbol)) {
24297 throw new Error('geometry\'symbol isn\'t a composite symbol, while the symbol in styles is.');
24298 }
24299 symbolToAnimate = [];
24300 var symbolInStyles = styles['symbol'];
24301 for (var i = 0; i < symbolInStyles.length; i++) {
24302 if (!symbolInStyles[i]) {
24303 symbolToAnimate.push(null);
24304 continue;
24305 }
24306 var a = {};
24307 for (var sp in symbolInStyles[i]) {
24308 if (symbolInStyles[i].hasOwnProperty(sp)) {
24309 a[sp] = [symbol[i][sp], symbolInStyles[i][sp]];
24310 }
24311 }
24312 symbolToAnimate.push(a);
24313 }
24314 } else {
24315 if (Array.isArray(symbol)) {
24316 throw new Error('geometry\'symbol is a composite symbol, while the symbol in styles isn\'t.');
24317 }
24318 symbolToAnimate = {};
24319 for (var _sp in v) {
24320 if (v.hasOwnProperty(_sp)) {
24321 symbolToAnimate[_sp] = [symbol[_sp], v[_sp]];
24322 }
24323 }
24324 }
24325 stylesToAnimate['symbol'] = symbolToAnimate;
24326 } else if (p === 'translate') {
24327 stylesToAnimate['translate'] = new Coordinate(v);
24328 }
24329 }
24330 }
24331 return stylesToAnimate;
24332 },
24333
24334 _fireAnimateEvent: function _fireAnimateEvent(playState) {
24335 if (playState === 'finished') {
24336 delete this._animationStarted;
24337 this._fireEvent('animateend');
24338 } else if (playState === 'running') {
24339 if (this._animationStarted) {
24340 this._fireEvent('animating');
24341 } else {
24342 this._fireEvent('animatestart');
24343 this._animationStarted = true;
24344 }
24345 }
24346 }
24347});
24348
24349var DRAG_STAGE_LAYER_ID = INTERNAL_LAYER_PREFIX + '_drag_stage';
24350
24351var EVENTS$2 = Browser$1.touch ? 'touchstart mousedown' : 'mousedown';
24352
24353var GeometryDragHandler = function (_Handler) {
24354 inherits(GeometryDragHandler, _Handler);
24355
24356 function GeometryDragHandler(target) {
24357 classCallCheck(this, GeometryDragHandler);
24358 return possibleConstructorReturn(this, _Handler.call(this, target));
24359 }
24360
24361 GeometryDragHandler.prototype.addHooks = function addHooks() {
24362 this.target.on(EVENTS$2, this._startDrag, this);
24363 };
24364
24365 GeometryDragHandler.prototype.removeHooks = function removeHooks() {
24366 this._endDrag();
24367 this.target.off(EVENTS$2, this._startDrag, this);
24368 delete this.container;
24369 };
24370
24371 GeometryDragHandler.prototype._prepareDragHandler = function _prepareDragHandler() {
24372 this._dragHandler = new DragHandler(this.container);
24373 this._dragHandler.on('dragging', this._dragging, this).on('mouseup', this._endDrag, this).enable();
24374 };
24375
24376 GeometryDragHandler.prototype._prepareShadow = function _prepareShadow() {
24377 var target = this.target;
24378 this._prepareDragStageLayer();
24379 if (this._shadow) {
24380 this._shadow.remove();
24381 }
24382
24383 var shadow = this._shadow = target.copy();
24384 this._shadow.setSymbol(target._getInternalSymbol());
24385 if (target.options['dragShadow']) {
24386 var symbol = lowerSymbolOpacity(shadow._getInternalSymbol(), 0.5);
24387 shadow.setSymbol(symbol);
24388 }
24389 shadow.setId(null);
24390 this._prepareShadowConnectors();
24391 };
24392
24393 GeometryDragHandler.prototype._prepareShadowConnectors = function _prepareShadowConnectors() {
24394 var target = this.target;
24395 var shadow = this._shadow;
24396 var resources = this._dragStageLayer._getRenderer().resources;
24397
24398 var shadowConnectors = [];
24399 if (ConnectorLine._hasConnectors(target)) {
24400 var connectors = ConnectorLine._getConnectors(target);
24401
24402 for (var i = 0, l = connectors.length; i < l; i++) {
24403 var targetConn = connectors[i];
24404 var connOptions = targetConn.config(),
24405 connSymbol = targetConn._getInternalSymbol();
24406 connOptions['symbol'] = lowerSymbolOpacity(connSymbol, 0.5);
24407 var conn = void 0;
24408 if (targetConn.getConnectSource() === target) {
24409 conn = new targetConn.constructor(shadow, targetConn.getConnectTarget(), connOptions);
24410 } else {
24411 conn = new targetConn.constructor(targetConn.getConnectSource(), shadow, connOptions);
24412 }
24413 shadowConnectors.push(conn);
24414 if (targetConn.getLayer() && targetConn.getLayer()._getRenderer()) {
24415 resources.merge(targetConn.getLayer()._getRenderer().resources);
24416 }
24417 }
24418 }
24419 this._shadowConnectors = shadowConnectors;
24420 shadowConnectors.push(shadow);
24421 this._dragStageLayer.bringToFront().addGeometry(shadowConnectors);
24422 };
24423
24424 GeometryDragHandler.prototype._onTargetUpdated = function _onTargetUpdated() {
24425 if (this._shadow) {
24426 this._shadow.setSymbol(this.target._getSymbol());
24427 }
24428 };
24429
24430 GeometryDragHandler.prototype._prepareDragStageLayer = function _prepareDragStageLayer() {
24431 var map = this.target.getMap(),
24432 layer = this.target.getLayer();
24433 this._dragStageLayer = map.getLayer(DRAG_STAGE_LAYER_ID);
24434 if (!this._dragStageLayer) {
24435 this._dragStageLayer = new VectorLayer(DRAG_STAGE_LAYER_ID, {
24436 enableAltitude: layer.options['enableAltitude'],
24437 altitudeProperty: layer.options['altitudeProperty']
24438 });
24439 map.addLayer(this._dragStageLayer);
24440 }
24441
24442 var resources = new ResourceCache();
24443 resources.merge(layer._getRenderer().resources);
24444 this._dragStageLayer._getRenderer().resources = resources;
24445 };
24446
24447 GeometryDragHandler.prototype._startDrag = function _startDrag(param) {
24448 var map = this.target.getMap();
24449 if (!map) {
24450 return;
24451 }
24452 var parent = this.target._getParent();
24453 if (parent) {
24454 return;
24455 }
24456 if (this.isDragging()) {
24457 return;
24458 }
24459 var domEvent = param['domEvent'];
24460 if (domEvent.touches && domEvent.touches.length > 1 || domEvent.button === 2) {
24461 return;
24462 }
24463 this.container = map._panels.mapWrapper || map._containerDOM;
24464 this.target.on('click', this._endDrag, this);
24465 this._lastCoord = this._correctCoord(param['coordinate']);
24466 this._lastPoint = param['containerPoint'];
24467 this._prepareDragHandler();
24468 this._dragHandler.onMouseDown(param['domEvent']);
24469
24470 on(this.container, 'mouseleave', this._endDrag, this);
24471 this._startParam = param;
24472 this._moved = false;
24473
24474 return;
24475 };
24476
24477 GeometryDragHandler.prototype._dragging = function _dragging(param) {
24478 var target = this.target;
24479 var map = target.getMap(),
24480 e = map._parseEvent(param['domEvent']);
24481
24482 var domEvent = e['domEvent'];
24483 if (domEvent.touches && domEvent.touches.length > 1) {
24484 return;
24485 }
24486
24487 if (!this._moved) {
24488 this._moved = true;
24489 target.on('symbolchange', this._onTargetUpdated, this);
24490 this._isDragging = true;
24491 this._prepareShadow();
24492 if (!target.options['dragShadow']) {
24493 target.hide();
24494 }
24495 this._shadow._fireEvent('dragstart', e);
24496
24497 this.target._fireEvent('dragstart', this._startParam || e);
24498 delete this._startParam;
24499 return;
24500 }
24501 if (!this._shadow) {
24502 return;
24503 }
24504 var axis = this._shadow.options['dragOnAxis'],
24505 coord = this._correctCoord(e['coordinate']),
24506 point = e['containerPoint'];
24507 this._lastPoint = this._lastPoint || point;
24508 this._lastCoord = this._lastCoord || coord;
24509 var pointOffset = point.sub(this._lastPoint);
24510 var coordOffset = coord.sub(this._lastCoord);
24511 if (axis === 'x') {
24512 pointOffset.y = coordOffset.y = 0;
24513 } else if (axis === 'y') {
24514 pointOffset.x = coordOffset.x = 0;
24515 }
24516 this._lastPoint = point;
24517 this._lastCoord = coord;
24518 this._shadow.translate(coordOffset);
24519 if (!target.options['dragShadow']) {
24520 target.translate(coordOffset);
24521 }
24522 e['coordOffset'] = coordOffset;
24523 e['pointOffset'] = pointOffset;
24524 this._shadow._fireEvent('dragging', e);
24525
24526 target._fireEvent('dragging', e);
24527 };
24528
24529 GeometryDragHandler.prototype._endDrag = function _endDrag(param) {
24530 if (this._dragHandler) {
24531 this._dragHandler.disable();
24532 delete this._dragHandler;
24533 }
24534 if (this.container) {
24535 off(this.container, 'mouseleave', this._endDrag, this);
24536 }
24537 if (!this.target) {
24538 return;
24539 }
24540 var target = this.target;
24541 target.off('click', this._endDrag, this);
24542
24543 target.off('symbolchange', this._onTargetUpdated, this);
24544
24545 delete this._lastCoord;
24546 delete this._lastPoint;
24547
24548 this._isDragging = false;
24549
24550 var map = target.getMap();
24551 if (this.enabled() && map) {
24552 var e = map._parseEvent(param ? param['domEvent'] : null);
24553 this._updateTargetAndRemoveShadow(e);
24554 if (this._moved) {
24555 target._fireEvent('dragend', e);
24556 }
24557 }
24558 };
24559
24560 GeometryDragHandler.prototype.isDragging = function isDragging() {
24561 if (!this._isDragging) {
24562 return false;
24563 }
24564 return true;
24565 };
24566
24567 GeometryDragHandler.prototype._updateTargetAndRemoveShadow = function _updateTargetAndRemoveShadow(eventParam) {
24568 var target = this.target,
24569 map = target.getMap();
24570 if (!target.options['dragShadow']) {
24571 target.show();
24572 }
24573 var shadow = this._shadow;
24574 if (shadow) {
24575 if (target.options['dragShadow']) {
24576 target.setCoordinates(shadow.getCoordinates());
24577 }
24578 shadow._fireEvent('dragend', eventParam);
24579 shadow.remove();
24580 delete this._shadow;
24581 }
24582 if (this._shadowConnectors) {
24583 map.getLayer(DRAG_STAGE_LAYER_ID).removeGeometry(this._shadowConnectors);
24584 delete this._shadowConnectors;
24585 }
24586 if (this._dragStageLayer) {
24587 this._dragStageLayer.remove();
24588 }
24589 };
24590
24591 GeometryDragHandler.prototype._correctCoord = function _correctCoord(coord) {
24592 var map = this.target.getMap();
24593 if (!map.getPitch()) {
24594 return coord;
24595 }
24596 var painter = this.target._getPainter();
24597 if (!painter.getMinAltitude()) {
24598 return coord;
24599 }
24600 var alt = (painter.getMinAltitude() + painter.getMaxAltitude()) / 2;
24601 return map.locateByPoint(coord, 0, -alt);
24602 };
24603
24604 return GeometryDragHandler;
24605}(Handler$1);
24606
24607Geometry.mergeOptions({
24608 'draggable': false,
24609 'dragShadow': true,
24610 'dragOnAxis': null
24611});
24612
24613Geometry.addInitHook('addHandler', 'draggable', GeometryDragHandler);
24614
24615Geometry.include({
24616 isDragging: function isDragging() {
24617 if (this._getParent()) {
24618 return this._getParent().isDragging();
24619 }
24620 if (this['draggable']) {
24621 return this['draggable'].isDragging();
24622 }
24623 return false;
24624 }
24625});
24626
24627Geometry.include({
24628 startEdit: function startEdit(opts) {
24629 if (!this.getMap() || !this.options['editable']) {
24630 return this;
24631 }
24632 this.endEdit();
24633 this._editor = new GeometryEditor(this, opts);
24634 this._editor.start();
24635
24636 this.fire('editstart');
24637 return this;
24638 },
24639 endEdit: function endEdit() {
24640 if (this._editor) {
24641 this._editor.stop();
24642 delete this._editor;
24643
24644 this.fire('editend');
24645 }
24646 return this;
24647 },
24648 redoEdit: function redoEdit() {
24649 if (!this.isEditing()) {
24650 return this;
24651 }
24652 this._editor.redo();
24653
24654 this.fire('redoedit');
24655 return this;
24656 },
24657 undoEdit: function undoEdit() {
24658 if (!this.isEditing()) {
24659 return this;
24660 }
24661 this._editor.undo();
24662
24663 this.fire('undoedit');
24664 return this;
24665 },
24666 isEditing: function isEditing() {
24667 if (this._editor) {
24668 return this._editor.isEditing();
24669 }
24670 return false;
24671 }
24672});
24673
24674Geometry.include({
24675 _onEvent: function _onEvent(event, type) {
24676 if (!this.getMap()) {
24677 return;
24678 }
24679 var eventType = type || this._getEventTypeToFire(event);
24680 if (eventType === 'contextmenu' && this.listens('contextmenu')) {
24681 stopPropagation(event);
24682 preventDefault(event);
24683 }
24684 var params = this._getEventParams(event);
24685 this._fireEvent(eventType, params);
24686 },
24687
24688 _getEventTypeToFire: function _getEventTypeToFire(domEvent) {
24689 return domEvent.type;
24690 },
24691
24692 _getEventParams: function _getEventParams(e) {
24693 var map = this.getMap();
24694 var eventParam = {
24695 'domEvent': e
24696 };
24697 var actual = e.touches && e.touches.length > 0 ? e.touches[0] : e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches[0] : e;
24698 if (actual) {
24699 var containerPoint = getEventContainerPoint(actual, map._containerDOM);
24700 eventParam['coordinate'] = map.containerPointToCoordinate(containerPoint);
24701 eventParam['containerPoint'] = containerPoint;
24702 eventParam['viewPoint'] = map.containerPointToViewPoint(containerPoint);
24703 eventParam['pont2d'] = map._containerPointToPoint(containerPoint);
24704 }
24705 return eventParam;
24706 }
24707});
24708
24709Geometry.include({
24710 setInfoWindow: function setInfoWindow(options) {
24711 this.removeInfoWindow();
24712 if (options instanceof InfoWindow) {
24713 this._infoWindow = options;
24714 this._infoWinOptions = extend({}, this._infoWindow.options);
24715 this._infoWindow.addTo(this);
24716 return this;
24717 }
24718 this._infoWinOptions = extend({}, options);
24719 if (this._infoWindow) {
24720 this._infoWindow.setOptions(options);
24721 } else if (this.getMap()) {
24722 this._bindInfoWindow(this._infoWinOptions);
24723 }
24724
24725 return this;
24726 },
24727 getInfoWindow: function getInfoWindow() {
24728 if (!this._infoWindow) {
24729 return null;
24730 }
24731 return this._infoWindow;
24732 },
24733 openInfoWindow: function openInfoWindow(coordinate) {
24734 if (!this.getMap()) {
24735 return this;
24736 }
24737 if (!coordinate) {
24738 coordinate = this.getCenter();
24739 }
24740 if (!this._infoWindow) {
24741 if (this._infoWinOptions && this.getMap()) {
24742 this._bindInfoWindow(this._infoWinOptions);
24743 this._infoWindow.show(coordinate);
24744 }
24745 } else {
24746 this._infoWindow.show(coordinate);
24747 }
24748 return this;
24749 },
24750 closeInfoWindow: function closeInfoWindow() {
24751 if (this._infoWindow) {
24752 this._infoWindow.hide();
24753 }
24754 return this;
24755 },
24756 removeInfoWindow: function removeInfoWindow() {
24757 this._unbindInfoWindow();
24758 delete this._infoWinOptions;
24759 delete this._infoWindow;
24760 return this;
24761 },
24762 _bindInfoWindow: function _bindInfoWindow(options) {
24763 this._infoWindow = new InfoWindow(options);
24764 this._infoWindow.addTo(this);
24765
24766 return this;
24767 },
24768 _unbindInfoWindow: function _unbindInfoWindow() {
24769 if (this._infoWindow) {
24770 this.closeInfoWindow();
24771 this._infoWindow.remove();
24772 delete this._infoWindow;
24773 }
24774 return this;
24775 }
24776});
24777
24778var LRUCache = function () {
24779 function LRUCache(max, onRemove) {
24780 classCallCheck(this, LRUCache);
24781
24782 this.max = max;
24783 this.onRemove = onRemove;
24784 this.reset();
24785 }
24786
24787 LRUCache.prototype.reset = function reset() {
24788 for (var key in this.data) {
24789 this.onRemove(this.data[key]);
24790 }
24791
24792 this.data = {};
24793 this.order = [];
24794
24795 return this;
24796 };
24797
24798 LRUCache.prototype.clear = function clear() {
24799 this.reset();
24800 delete this.onRemove;
24801 };
24802
24803 LRUCache.prototype.add = function add(key, data) {
24804
24805 if (this.has(key)) {
24806 this.order.splice(this.order.indexOf(key), 1);
24807 this.data[key] = data;
24808 this.order.push(key);
24809 } else {
24810 this.data[key] = data;
24811 this.order.push(key);
24812
24813 if (this.order.length > this.max) {
24814 var removedData = this.getAndRemove(this.order[0]);
24815 if (removedData) this.onRemove(removedData);
24816 }
24817 }
24818
24819 return this;
24820 };
24821
24822 LRUCache.prototype.has = function has(key) {
24823 return key in this.data;
24824 };
24825
24826 LRUCache.prototype.keys = function keys() {
24827 return this.order;
24828 };
24829
24830 LRUCache.prototype.getAndRemove = function getAndRemove(key) {
24831 if (!this.has(key)) {
24832 return null;
24833 }
24834
24835 var data = this.data[key];
24836
24837 delete this.data[key];
24838 this.order.splice(this.order.indexOf(key), 1);
24839
24840 return data;
24841 };
24842
24843 LRUCache.prototype.get = function get$$1(key) {
24844 if (!this.has(key)) {
24845 return null;
24846 }
24847
24848 var data = this.data[key];
24849 return data;
24850 };
24851
24852 LRUCache.prototype.remove = function remove(key) {
24853 if (!this.has(key)) {
24854 return this;
24855 }
24856
24857 var data = this.data[key];
24858 delete this.data[key];
24859 this.onRemove(data);
24860 this.order.splice(this.order.indexOf(key), 1);
24861
24862 return this;
24863 };
24864
24865 LRUCache.prototype.setMaxSize = function setMaxSize(max) {
24866 this.max = max;
24867
24868 while (this.order.length > this.max) {
24869 var removedData = this.getAndRemove(this.order[0]);
24870 if (removedData) this.onRemove(removedData);
24871 }
24872
24873 return this;
24874 };
24875
24876 return LRUCache;
24877}();
24878
24879var TileLayerCanvasRenderer = function (_CanvasRenderer) {
24880 inherits(TileLayerCanvasRenderer, _CanvasRenderer);
24881
24882 function TileLayerCanvasRenderer(layer) {
24883 classCallCheck(this, TileLayerCanvasRenderer);
24884
24885 var _this = possibleConstructorReturn(this, _CanvasRenderer.call(this, layer));
24886
24887 _this.tilesInView = {};
24888 _this.tilesLoading = {};
24889 _this._parentTiles = [];
24890 _this._childTiles = [];
24891 _this.tileCache = new LRUCache(layer.options['maxCacheSize'], _this.deleteTile.bind(_this));
24892 return _this;
24893 }
24894
24895 TileLayerCanvasRenderer.prototype.draw = function draw() {
24896 var map = this.getMap();
24897 if (!this.isDrawable()) {
24898 return;
24899 }
24900 var mask2DExtent = this.prepareCanvas();
24901 if (mask2DExtent) {
24902 if (!mask2DExtent.intersects(this.canvasExtent2D)) {
24903 this.completeRender();
24904 return;
24905 }
24906 }
24907 var layer = this.layer;
24908 var tileGrids = layer.getTiles().tileGrids;
24909 if (!tileGrids || !tileGrids.length) {
24910 this.completeRender();
24911 return;
24912 }
24913
24914 var loadingCount = 0;
24915 var loading = false;
24916 var checkedTiles = {};
24917 var tiles = [],
24918 parentTiles = [],
24919 parentKeys = {},
24920 childTiles = [],
24921 childKeys = {},
24922 placeholders = [],
24923 placeholderKeys = {};
24924
24925 var tileQueue = {};
24926 var preLoadingCount = this._markTiles(),
24927 loadingLimit = this._getLoadLimit();
24928
24929 var l = tileGrids.length;
24930
24931 this._tileZoom = tileGrids[0]['zoom'];
24932 this._tileOffset = tileGrids[0]['offset'];
24933
24934 for (var i = 0; i < l; i++) {
24935 var tileGrid = tileGrids[i];
24936 var allTiles = tileGrid['tiles'];
24937
24938 var placeholder = this._generatePlaceHolder(tileGrid.zoom);
24939
24940 for (var _i = 0, _l = allTiles.length; _i < _l; _i++) {
24941 var tile = allTiles[_i],
24942 tileId = tile['id'];
24943
24944 var cached = this._getCachedTile(tileId);
24945 var tileLoading = false;
24946 if (this._isLoadingTile(tileId)) {
24947 tileLoading = loading = true;
24948 this.tilesLoading[tileId].current = true;
24949 } else if (cached) {
24950 if (this.getTileOpacity(cached.image) < 1) {
24951 tileLoading = loading = true;
24952 }
24953 tiles.push(cached);
24954 } else {
24955 tileLoading = loading = true;
24956 var hitLimit = loadingLimit && loadingCount + preLoadingCount[0] > loadingLimit;
24957 if (!hitLimit && (!map.isInteracting() || map.isMoving() || map.isRotating())) {
24958 loadingCount++;
24959 tileQueue[tileId + '@' + tile['point'].toArray().join()] = tile;
24960 }
24961 }
24962 if (!tileLoading) continue;
24963 if (checkedTiles[tile.dupKey]) {
24964 continue;
24965 }
24966
24967 checkedTiles[tile.dupKey] = 1;
24968 if (placeholder && !placeholderKeys[tile.dupKey]) {
24969 tile.cache = false;
24970 placeholders.push({
24971 image: placeholder,
24972 info: tile
24973 });
24974
24975 placeholderKeys[tile.dupKey] = 1;
24976 }
24977
24978 var parentTile = this._findParentTile(tile);
24979 if (parentTile) {
24980 var dupKey = parentTile.info.dupKey;
24981 if (parentKeys[dupKey] === undefined) {
24982 parentKeys[dupKey] = parentTiles.length;
24983 parentTiles.push(parentTile);
24984 }
24985 } else {
24986 var children = this._findChildTiles(tile);
24987 if (children.length) {
24988 children.forEach(function (c) {
24989 if (!childKeys[c.info.dupKey]) {
24990 childTiles.push(c);
24991 childKeys[c.info.dupKey] = 1;
24992 }
24993 });
24994 }
24995 }
24996 }
24997 }
24998
24999 this._drawTiles(tiles, parentTiles, childTiles, placeholders);
25000 if (!loadingCount) {
25001 if (!loading) {
25002 if (!map.isAnimating() && this._parentTiles.length > 0) {
25003 this._parentTiles = [];
25004 this._childTiles = [];
25005 this.setToRedraw();
25006 }
25007 this.completeRender();
25008 }
25009 } else {
25010 this.loadTileQueue(tileQueue);
25011 }
25012 this._retireTiles();
25013 };
25014
25015 TileLayerCanvasRenderer.prototype.isTileCachedOrLoading = function isTileCachedOrLoading(tileId) {
25016 return this.tilesLoading[tileId] || this.tilesInView[tileId] || this.tileCache.has(tileId);
25017 };
25018
25019 TileLayerCanvasRenderer.prototype._drawTiles = function _drawTiles(tiles, parentTiles, childTiles, placeholders) {
25020 var _this2 = this;
25021
25022 if (parentTiles.length) {
25023 parentTiles.sort(function (t1, t2) {
25024 return Math.abs(t2.info.z - _this2._tileZoom) - Math.abs(t1.info.z - _this2._tileZoom);
25025 });
25026 this._parentTiles = parentTiles;
25027 }
25028 if (childTiles.length) {
25029 this._childTiles = childTiles;
25030 }
25031
25032 var context = { tiles: tiles, parentTiles: parentTiles, childTiles: childTiles };
25033 this.onDrawTileStart(context);
25034
25035 this._parentTiles.forEach(function (t) {
25036 return _this2._drawTileAndCache(t);
25037 });
25038 this._childTiles.forEach(function (t) {
25039 return _this2._drawTileOffset(t.info, t.image);
25040 });
25041
25042 placeholders.forEach(function (t) {
25043 return _this2._drawTileOffset(t.info, t.image);
25044 });
25045
25046 var layer = this.layer,
25047 map = this.getMap();
25048 if (!layer.options['cascadeTiles'] || map.getPitch() <= layer.options['minPitchToCascade']) {
25049 tiles.forEach(function (t) {
25050 return _this2._drawTileAndCache(t);
25051 });
25052 } else {
25053 this.writeZoomStencil();
25054 var started = false;
25055 for (var i = 0, l = tiles.length; i < l; i++) {
25056 if (tiles[i].info.z !== this._tileZoom) {
25057 if (!started) {
25058 this.startZoomStencilTest();
25059 started = true;
25060 } else {
25061 this.resumeZoomStencilTest();
25062 }
25063 } else if (started) {
25064 this.pauseZoomStencilTest();
25065 }
25066 this._drawTileAndCache(tiles[i]);
25067 }
25068 this.endZoomStencilTest();
25069 }
25070
25071 this.onDrawTileEnd(context);
25072 };
25073
25074 TileLayerCanvasRenderer.prototype.writeZoomStencil = function writeZoomStencil() {};
25075
25076 TileLayerCanvasRenderer.prototype.startZoomStencilTest = function startZoomStencilTest() {};
25077
25078 TileLayerCanvasRenderer.prototype.endZoomStencilTest = function endZoomStencilTest() {};
25079
25080 TileLayerCanvasRenderer.prototype.pauseZoomStencilTest = function pauseZoomStencilTest() {};
25081
25082 TileLayerCanvasRenderer.prototype.resumeZoomStencilTest = function resumeZoomStencilTest() {};
25083
25084 TileLayerCanvasRenderer.prototype.onDrawTileStart = function onDrawTileStart() {};
25085
25086 TileLayerCanvasRenderer.prototype.onDrawTileEnd = function onDrawTileEnd() {};
25087
25088 TileLayerCanvasRenderer.prototype._drawTileOffset = function _drawTileOffset(info, image) {
25089 var offset = this._tileOffset;
25090 if (!offset[0] && !offset[1]) {
25091 this.drawTile(info, image);
25092 return;
25093 }
25094 var map = this.getMap();
25095
25096 var scale = map._getResolution(this._tileZoom) / map._getResolution(info.z);
25097 offset[0] *= scale;
25098 offset[1] *= scale;
25099 info.point._sub(offset);
25100 info.extent2d._sub(offset);
25101 this.drawTile(info, image);
25102
25103 info.point._add(offset);
25104 info.extent2d._add(offset);
25105 offset[0] /= scale;
25106 offset[1] /= scale;
25107 };
25108
25109 TileLayerCanvasRenderer.prototype._drawTileAndCache = function _drawTileAndCache(tile) {
25110 tile.current = true;
25111 this.tilesInView[tile.info.id] = tile;
25112 this._drawTileOffset(tile.info, tile.image);
25113 this.tileCache.add(tile.info.id, tile);
25114 };
25115
25116 TileLayerCanvasRenderer.prototype.drawOnInteracting = function drawOnInteracting() {
25117 this.draw();
25118 };
25119
25120 TileLayerCanvasRenderer.prototype.needToRedraw = function needToRedraw() {
25121 var map = this.getMap();
25122 if (map.getPitch()) {
25123 return _CanvasRenderer.prototype.needToRedraw.call(this);
25124 }
25125 if (map.isRotating() || map.isZooming()) {
25126 return true;
25127 }
25128 if (map.isMoving()) {
25129 return !!this.layer.options['forceRenderOnMoving'];
25130 }
25131 return _CanvasRenderer.prototype.needToRedraw.call(this);
25132 };
25133
25134 TileLayerCanvasRenderer.prototype.hitDetect = function hitDetect() {
25135 return false;
25136 };
25137
25138 TileLayerCanvasRenderer.prototype._getLoadLimit = function _getLoadLimit() {
25139 if (this.getMap().isInteracting()) {
25140 return this.layer.options['loadingLimitOnInteracting'];
25141 }
25142 return 0;
25143 };
25144
25145 TileLayerCanvasRenderer.prototype.isDrawable = function isDrawable() {
25146 if (this.getMap().getPitch()) {
25147 if (console) {
25148 console.warn('TileLayer with canvas renderer can\'t be pitched, use gl renderer (\'renderer\' : \'gl\') instead.');
25149 }
25150 this.clear();
25151 return false;
25152 }
25153 return true;
25154 };
25155
25156 TileLayerCanvasRenderer.prototype.clear = function clear() {
25157 this._retireTiles(true);
25158 this.tileCache.reset();
25159 this.tilesInView = {};
25160 this.tilesLoading = {};
25161 this._parentTiles = [];
25162 this._childTiles = [];
25163 _CanvasRenderer.prototype.clear.call(this);
25164 };
25165
25166 TileLayerCanvasRenderer.prototype._isLoadingTile = function _isLoadingTile(tileId) {
25167 return !!this.tilesLoading[tileId];
25168 };
25169
25170 TileLayerCanvasRenderer.prototype.clipCanvas = function clipCanvas(context) {
25171 var mask = this.layer.getMask();
25172 if (!mask) {
25173 return this._clipByPitch(context);
25174 }
25175 return _CanvasRenderer.prototype.clipCanvas.call(this, context);
25176 };
25177
25178 TileLayerCanvasRenderer.prototype._clipByPitch = function _clipByPitch(ctx) {
25179 var map = this.getMap();
25180 if (map.getPitch() <= map.options['maxVisualPitch']) {
25181 return false;
25182 }
25183 if (!this.layer.options['clipByPitch']) {
25184 return false;
25185 }
25186 var clipExtent = map.getContainerExtent();
25187 var r = Browser$1.retina ? 2 : 1;
25188 ctx.save();
25189 ctx.strokeStyle = 'rgba(0, 0, 0, 0)';
25190 ctx.beginPath();
25191 ctx.rect(0, Math.ceil(clipExtent.ymin) * r, Math.ceil(clipExtent.getWidth()) * r, Math.ceil(clipExtent.getHeight()) * r);
25192 ctx.stroke();
25193 ctx.clip();
25194 return true;
25195 };
25196
25197 TileLayerCanvasRenderer.prototype.loadTileQueue = function loadTileQueue(tileQueue) {
25198 for (var p in tileQueue) {
25199 if (tileQueue.hasOwnProperty(p)) {
25200 var tile = tileQueue[p];
25201 var tileImage = this.loadTile(tile);
25202 if (tileImage.loadTime === undefined) {
25203 this.tilesLoading[tile['id']] = {
25204 image: tileImage,
25205 current: true,
25206 info: tile
25207 };
25208 }
25209 }
25210 }
25211 };
25212
25213 TileLayerCanvasRenderer.prototype.loadTile = function loadTile(tile) {
25214 var tileSize = this.layer.getTileSize();
25215 var tileImage = new Image();
25216
25217 tileImage.width = tileSize['width'];
25218 tileImage.height = tileSize['height'];
25219
25220 tileImage.onload = this.onTileLoad.bind(this, tileImage, tile);
25221 tileImage.onerror = this.onTileError.bind(this, tileImage, tile);
25222
25223 var crossOrigin = this.layer.options['crossOrigin'];
25224 if (!isNil(crossOrigin)) {
25225 tileImage.crossOrigin = crossOrigin;
25226 }
25227 this.loadTileImage(tileImage, tile['url']);
25228 return tileImage;
25229 };
25230
25231 TileLayerCanvasRenderer.prototype.loadTileImage = function loadTileImage(tileImage, url) {
25232 return loadImage(tileImage, [url]);
25233 };
25234
25235 TileLayerCanvasRenderer.prototype.abortTileLoading = function abortTileLoading(tileImage) {
25236 if (!tileImage) return;
25237 tileImage.onload = falseFn;
25238 tileImage.onerror = falseFn;
25239 tileImage.src = emptyImageUrl;
25240 };
25241
25242 TileLayerCanvasRenderer.prototype.onTileLoad = function onTileLoad(tileImage, tileInfo) {
25243 if (!this.layer) {
25244 return;
25245 }
25246 var id = tileInfo['id'];
25247 if (!this.tilesInView) {
25248 return;
25249 }
25250 tileImage.loadTime = now();
25251 delete this.tilesLoading[id];
25252 this._addTileToCache(tileInfo, tileImage);
25253 this.setToRedraw();
25254
25255 this.layer.fire('tileload', { tile: tileInfo, tileImage: tileImage });
25256 };
25257
25258 TileLayerCanvasRenderer.prototype.onTileError = function onTileError(tileImage, tileInfo) {
25259 if (!this.layer) {
25260 return;
25261 }
25262 if (tileImage instanceof Image) {
25263 this.abortTileLoading(tileImage);
25264 }
25265 tileImage.loadTime = 0;
25266 delete this.tilesLoading[tileInfo['id']];
25267 this._addTileToCache(tileInfo, tileImage);
25268 this.setToRedraw();
25269
25270 this.layer.fire('tileerror', { tile: tileInfo });
25271 };
25272
25273 TileLayerCanvasRenderer.prototype.drawTile = function drawTile(tileInfo, tileImage) {
25274 if (!tileImage || !this.getMap()) {
25275 return;
25276 }
25277 var point = tileInfo.point,
25278 tileZoom = tileInfo.z,
25279 tileId = tileInfo.id;
25280 var map = this.getMap(),
25281 tileSize = tileInfo.size,
25282 zoom = map.getZoom(),
25283 ctx = this.context,
25284 cp = map._pointToContainerPoint(point, tileZoom),
25285 bearing = map.getBearing(),
25286 transformed = bearing || zoom !== tileZoom;
25287 var opacity = this.getTileOpacity(tileImage);
25288 var alpha = ctx.globalAlpha;
25289 if (opacity < 1) {
25290 ctx.globalAlpha = opacity;
25291 this.setToRedraw();
25292 }
25293 if (!transformed) {
25294 cp._round();
25295 }
25296 var x = cp.x,
25297 y = cp.y;
25298 var w = tileSize[0],
25299 h = tileSize[1];
25300 if (transformed) {
25301 w++;
25302 h++;
25303 ctx.save();
25304 ctx.translate(x, y);
25305 if (bearing) {
25306 ctx.rotate(-bearing * Math.PI / 180);
25307 }
25308 if (zoom !== tileZoom) {
25309 var scale = map._getResolution(tileZoom) / map._getResolution();
25310 ctx.scale(scale, scale);
25311 }
25312 x = y = 0;
25313 }
25314 Canvas.image(ctx, tileImage, x, y, w, h);
25315 if (this.layer.options['debug']) {
25316 var p = new Point(x, y),
25317 color = this.layer.options['debugOutline'],
25318 xyz = tileId.split('__');
25319 ctx.save();
25320 ctx.strokeStyle = color;
25321 ctx.fillStyle = color;
25322 ctx.strokeWidth = 10;
25323 ctx.font = '15px monospace';
25324 Canvas.rectangle(ctx, p, tileSize, 1, 0);
25325 Canvas.fillText(ctx, 'x:' + xyz[2] + ', y:' + xyz[1] + ', z:' + xyz[3], p.add(10, 20), color);
25326 Canvas.drawCross(ctx, p.add(w / 2, h / 2), 2, color);
25327 ctx.restore();
25328 }
25329 if (transformed) {
25330 ctx.restore();
25331 }
25332 if (ctx.globalAlpha !== alpha) {
25333 ctx.globalAlpha = alpha;
25334 }
25335 this.setCanvasUpdated();
25336 };
25337
25338 TileLayerCanvasRenderer.prototype._findChildTiles = function _findChildTiles(info) {
25339 var layer = this._getLayerOfTile(info.layer);
25340 if (!layer.options['background']) {
25341 return [];
25342 }
25343 var map = this.getMap();
25344 var children = [];
25345 var min = info.extent2d.getMin(),
25346 max = info.extent2d.getMax(),
25347 pmin = layer._project(map._pointToPrj(min, info.z)),
25348 pmax = layer._project(map._pointToPrj(max, info.z));
25349 var zoomDiff = 3;
25350 for (var i = 1; i < zoomDiff; i++) {
25351 this._findChildTilesAt(children, pmin, pmax, layer, info.z + i);
25352 }
25353
25354 return children;
25355 };
25356
25357 TileLayerCanvasRenderer.prototype._findChildTilesAt = function _findChildTilesAt(children, pmin, pmax, layer, childZoom) {
25358 var layerId = layer.getId(),
25359 res = layer.getSpatialReference().getResolution(childZoom);
25360 var dmin = layer._getTileConfig().getTileIndex(pmin, res),
25361 dmax = layer._getTileConfig().getTileIndex(pmax, res);
25362 var sx = Math.min(dmin.idx, dmax.idx),
25363 ex = Math.max(dmin.idx, dmax.idx);
25364 var sy = Math.min(dmin.idy, dmax.idy),
25365 ey = Math.max(dmin.idy, dmax.idy);
25366 var id = void 0,
25367 tile = void 0;
25368 for (var i = sx; i < ex; i++) {
25369 for (var ii = sy; ii < ey; ii++) {
25370 id = layer._getTileId({ idx: i, idy: ii }, childZoom, layerId);
25371 if (this.tileCache.has(id)) {
25372 tile = this.tileCache.getAndRemove(id);
25373 children.push(tile);
25374 this.tileCache.add(id, tile);
25375 }
25376 }
25377 }
25378 };
25379
25380 TileLayerCanvasRenderer.prototype._findParentTile = function _findParentTile(info) {
25381 var map = this.getMap(),
25382 layer = this._getLayerOfTile(info.layer);
25383 if (!layer.options['background']) {
25384 return null;
25385 }
25386 var sr = layer.getSpatialReference();
25387 var d = sr.getZoomDirection(),
25388 zoomDiff = layer.options['backgroundZoomDiff'];
25389 var center = info.extent2d.getCenter(),
25390 prj = layer._project(map._pointToPrj(center, info.z));
25391 for (var diff = 1; diff <= zoomDiff; diff++) {
25392 var z = info.z - d * diff;
25393 var res = sr.getResolution(z);
25394 var tileIndex = layer._getTileConfig().getTileIndex(prj, res);
25395 var id = layer._getTileId(tileIndex, z, info.layer);
25396 if (this.tileCache.has(id)) {
25397 var tile = this.tileCache.getAndRemove(id);
25398 this.tileCache.add(id, tile);
25399 return tile;
25400 }
25401 }
25402 return null;
25403 };
25404
25405 TileLayerCanvasRenderer.prototype._getLayerOfTile = function _getLayerOfTile(layerId) {
25406 return this.layer.getChildLayer ? this.layer.getChildLayer(layerId) : this.layer;
25407 };
25408
25409 TileLayerCanvasRenderer.prototype._getCachedTile = function _getCachedTile(tileId) {
25410 var tilesInView = this.tilesInView;
25411 var cached = this.tileCache.getAndRemove(tileId);
25412 if (cached) {
25413 tilesInView[tileId] = cached;
25414 var tilesLoading = this.tilesLoading;
25415 if (tilesLoading && tilesLoading[tileId]) {
25416 tilesLoading[tileId].current = false;
25417 this.abortTileLoading(tilesLoading[tileId]);
25418 delete tilesLoading[tileId];
25419 }
25420 } else {
25421 cached = tilesInView[tileId];
25422 }
25423 return cached;
25424 };
25425
25426 TileLayerCanvasRenderer.prototype._addTileToCache = function _addTileToCache(tileInfo, tileImage) {
25427 this.tilesInView[tileInfo.id] = {
25428 image: tileImage,
25429 current: true,
25430 info: tileInfo
25431 };
25432 };
25433
25434 TileLayerCanvasRenderer.prototype.getTileOpacity = function getTileOpacity(tileImage) {
25435 if (!this.layer.options['fadeAnimation'] || !tileImage.loadTime) {
25436 return 1;
25437 }
25438 return Math.min(1, (now() - tileImage.loadTime) / (1000 / 60 * 10));
25439 };
25440
25441 TileLayerCanvasRenderer.prototype.onRemove = function onRemove() {
25442 this.clear();
25443 delete this.tileCache;
25444 delete this._tilePlaceHolder;
25445 _CanvasRenderer.prototype.onRemove.call(this);
25446 };
25447
25448 TileLayerCanvasRenderer.prototype._markTiles = function _markTiles() {
25449 var a = 0,
25450 b = 0;
25451 if (this.tilesLoading) {
25452 for (var p in this.tilesLoading) {
25453 this.tilesLoading[p].current = false;
25454 a++;
25455 }
25456 }
25457 if (this.tilesInView) {
25458 for (var _p in this.tilesInView) {
25459 this.tilesInView[_p].current = false;
25460 b++;
25461 }
25462 }
25463 return [a, b];
25464 };
25465
25466 TileLayerCanvasRenderer.prototype._retireTiles = function _retireTiles(force) {
25467 for (var i in this.tilesLoading) {
25468 var tile = this.tilesLoading[i];
25469 if (force || !tile.current) {
25470 if (tile.image) {
25471 this.abortTileLoading(tile.image);
25472 }
25473 this.deleteTile(tile);
25474 delete this.tilesLoading[i];
25475 }
25476 }
25477 for (var _i2 in this.tilesInView) {
25478 var _tile = this.tilesInView[_i2];
25479 if (!_tile.current) {
25480 delete this.tilesInView[_i2];
25481 if (!this.tileCache.has(_i2)) {
25482 this.deleteTile(_tile);
25483 }
25484 }
25485 }
25486 };
25487
25488 TileLayerCanvasRenderer.prototype.deleteTile = function deleteTile(tile) {
25489 if (!tile || !tile.image) {
25490 return;
25491 }
25492 tile.image.onload = null;
25493 tile.image.onerror = null;
25494 };
25495
25496 TileLayerCanvasRenderer.prototype._generatePlaceHolder = function _generatePlaceHolder(z) {
25497 var map = this.getMap();
25498 var placeholder = this.layer.options['placeholder'];
25499 if (!placeholder || map.getPitch()) {
25500 return null;
25501 }
25502 var tileSize = this.layer.getTileSize(),
25503 scale = map._getResolution(z) / map._getResolution(),
25504 canvas = this._tilePlaceHolder = this._tilePlaceHolder || Canvas.createCanvas(1, 1);
25505 canvas.width = tileSize.width * scale;
25506 canvas.height = tileSize.height * scale;
25507 if (isFunction(placeholder)) {
25508 placeholder(canvas);
25509 } else {
25510 defaultPlaceholder(canvas);
25511 }
25512 return canvas;
25513 };
25514
25515 return TileLayerCanvasRenderer;
25516}(CanvasRenderer);
25517
25518TileLayer.registerRenderer('canvas', TileLayerCanvasRenderer);
25519
25520function falseFn() {
25521 return false;
25522}
25523
25524function defaultPlaceholder(canvas) {
25525 var ctx = canvas.getContext('2d'),
25526 cw = canvas.width,
25527 ch = canvas.height,
25528 w = cw / 16,
25529 h = ch / 16;
25530 ctx.beginPath();
25531 for (var i = 0; i < 16; i++) {
25532 ctx.moveTo(0, i * h);
25533 ctx.lineTo(cw, i * h);
25534 ctx.moveTo(i * w, 0);
25535 ctx.lineTo(i * w, ch);
25536 }
25537 ctx.strokeStyle = 'rgba(180, 180, 180, 0.1)';
25538 ctx.lineWidth = 1;
25539 ctx.stroke();
25540 ctx.beginPath();
25541 var path = [[0, 0], [cw, 0], [0, ch], [cw, ch], [0, 0], [0, ch], [cw, 0], [cw, ch], [0, ch / 2], [cw, ch / 2], [cw / 2, 0], [cw / 2, ch]];
25542 for (var _i3 = 1; _i3 < path.length; _i3 += 2) {
25543 ctx.moveTo(path[_i3 - 1][0], path[_i3 - 1][1]);
25544 ctx.lineTo(path[_i3][0], path[_i3][1]);
25545 }
25546 ctx.lineWidth = 1 * 4;
25547 ctx.stroke();
25548}
25549
25550var TileLayerGLRenderer$1 = function (_ImageGLRenderable) {
25551 inherits(TileLayerGLRenderer, _ImageGLRenderable);
25552
25553 function TileLayerGLRenderer() {
25554 classCallCheck(this, TileLayerGLRenderer);
25555 return possibleConstructorReturn(this, _ImageGLRenderable.apply(this, arguments));
25556 }
25557
25558 TileLayerGLRenderer.prototype.isDrawable = function isDrawable() {
25559 return true;
25560 };
25561
25562 TileLayerGLRenderer.prototype.needToRedraw = function needToRedraw() {
25563 var map = this.getMap();
25564 if (this._gl() && !map.getPitch() && map.isZooming() && !map.isMoving() && !map.isRotating()) {
25565 return true;
25566 }
25567 return _ImageGLRenderable.prototype.needToRedraw.call(this);
25568 };
25569
25570 TileLayerGLRenderer.prototype.drawTile = function drawTile(tileInfo, tileImage) {
25571 var map = this.getMap();
25572 if (!tileInfo || !map) {
25573 return;
25574 }
25575 if (tileImage.src === emptyImageUrl) {
25576 return;
25577 }
25578
25579 var scale = map.getGLScale(tileInfo.z),
25580 w = tileInfo.size[0] * scale,
25581 h = tileInfo.size[1] * scale;
25582 if (tileInfo.cache !== false) {
25583 this._bindGLBuffer(tileImage, w, h);
25584 }
25585 if (!this._gl()) {
25586 _ImageGLRenderable.prototype.drawTile.call(this, tileInfo, tileImage);
25587 return;
25588 }
25589 var point = tileInfo.point;
25590 var x = point.x * scale,
25591 y = point.y * scale;
25592 var opacity = this.getTileOpacity(tileImage);
25593 this.drawGLImage(tileImage, x, y, w, h, opacity);
25594
25595 if (opacity < 1) {
25596 this.setToRedraw();
25597 } else {
25598 this.setCanvasUpdated();
25599 }
25600 };
25601
25602 TileLayerGLRenderer.prototype.writeZoomStencil = function writeZoomStencil() {
25603 var gl = this.gl;
25604 gl.stencilFunc(gl.ALWAYS, 1, 0xFF);
25605 gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);
25606 };
25607
25608 TileLayerGLRenderer.prototype.startZoomStencilTest = function startZoomStencilTest() {
25609 var gl = this.gl;
25610 gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
25611 gl.stencilFunc(gl.EQUAL, 0, 0xFF);
25612 };
25613
25614 TileLayerGLRenderer.prototype.endZoomStencilTest = function endZoomStencilTest() {
25615 this.pauseZoomStencilTest();
25616 };
25617
25618 TileLayerGLRenderer.prototype.pauseZoomStencilTest = function pauseZoomStencilTest() {
25619 var gl = this.gl;
25620 gl.stencilFunc(gl.ALWAYS, 1, 0xFF);
25621 };
25622
25623 TileLayerGLRenderer.prototype.resumeZoomStencilTest = function resumeZoomStencilTest() {
25624 var gl = this.gl;
25625 gl.stencilFunc(gl.EQUAL, 0, 0xFF);
25626 };
25627
25628 TileLayerGLRenderer.prototype._bindGLBuffer = function _bindGLBuffer(image, w, h) {
25629 if (!image.glBuffer) {
25630 image.glBuffer = this.bufferTileData(0, 0, w, h);
25631 }
25632 };
25633
25634 TileLayerGLRenderer.prototype.loadTileImage = function loadTileImage(tileImage, url) {
25635 tileImage.crossOrigin = this.layer.options['crossOrigin'] || '';
25636 tileImage.src = url;
25637 return;
25638 };
25639
25640 TileLayerGLRenderer.prototype.onCanvasCreate = function onCanvasCreate() {
25641 this.createCanvas2();
25642 };
25643
25644 TileLayerGLRenderer.prototype.createContext = function createContext() {
25645 _ImageGLRenderable.prototype.createContext.call(this);
25646 this.createGLContext();
25647 };
25648
25649 TileLayerGLRenderer.prototype.resizeCanvas = function resizeCanvas(canvasSize) {
25650 if (!this.canvas) {
25651 return;
25652 }
25653 _ImageGLRenderable.prototype.resizeCanvas.call(this, canvasSize);
25654 this.resizeGLCanvas();
25655 };
25656
25657 TileLayerGLRenderer.prototype.clearCanvas = function clearCanvas() {
25658 if (!this.canvas) {
25659 return;
25660 }
25661 _ImageGLRenderable.prototype.clearCanvas.call(this);
25662 this.clearGLCanvas();
25663 };
25664
25665 TileLayerGLRenderer.prototype.getCanvasImage = function getCanvasImage() {
25666 if (!this._gl()) {
25667 return _ImageGLRenderable.prototype.getCanvasImage.call(this);
25668 }
25669 var img = _ImageGLRenderable.prototype.getCanvasImage.call(this);
25670 if (img) {
25671 img.image = this.canvas2;
25672 }
25673 return img;
25674 };
25675
25676 TileLayerGLRenderer.prototype._gl = function _gl() {
25677 return this.getMap() && !!this.getMap().getPitch() || this.layer && !!this.layer.options['fragmentShader'];
25678 };
25679
25680 TileLayerGLRenderer.prototype.deleteTile = function deleteTile(tile) {
25681 _ImageGLRenderable.prototype.deleteTile.call(this, tile);
25682 if (tile && tile.image) {
25683 this.disposeImage(tile.image);
25684 }
25685 };
25686
25687 TileLayerGLRenderer.prototype.onRemove = function onRemove() {
25688 this.removeGLCanvas();
25689 };
25690
25691 return TileLayerGLRenderer;
25692}(ImageGLRenderable(TileLayerCanvasRenderer));
25693
25694TileLayer.registerRenderer('gl', TileLayerGLRenderer$1);
25695
25696function _loadTile(tile) {
25697 var tileSize = this.layer.getTileSize(),
25698 canvasClass = this.canvas.constructor,
25699 map = this.getMap();
25700 var r = Browser$1.retina ? 2 : 1;
25701 var tileCanvas = Canvas.createCanvas(tileSize['width'] * r, tileSize['height'] * r, canvasClass);
25702 tileCanvas['layer'] = this.layer;
25703 var me = this;
25704 var extent = new Extent(map.pointToCoordinate(tile['point']), map.pointToCoordinate(tile['point'].add(tileSize.toPoint())), map.getProjection());
25705 this.layer.drawTile(tileCanvas, {
25706 'url': tile['url'],
25707 'point': tile['point'],
25708 'center': map.pointToCoordinate(tile['point'].add(tileSize['width'] / 2, tileSize['height'] / 2)),
25709 'extent': extent,
25710 'z': tile['z'],
25711 'x': tile['x'],
25712 'y': tile['y']
25713 }, function (error) {
25714 if (error) {
25715 me.onTileError(tileCanvas, tile);
25716 return;
25717 }
25718 me.onTileLoad(tileCanvas, tile);
25719 });
25720 return tileCanvas;
25721}
25722
25723var CanvasRenderer$2 = function (_TileLayerCanvasRende) {
25724 inherits(CanvasRenderer, _TileLayerCanvasRende);
25725
25726 function CanvasRenderer() {
25727 classCallCheck(this, CanvasRenderer);
25728 return possibleConstructorReturn(this, _TileLayerCanvasRende.apply(this, arguments));
25729 }
25730
25731 CanvasRenderer.prototype.loadTile = function loadTile() {
25732 return _loadTile.apply(this, arguments);
25733 };
25734
25735 return CanvasRenderer;
25736}(TileLayerCanvasRenderer);
25737
25738var GLRenderer = function (_TileLayerGLRenderer) {
25739 inherits(GLRenderer, _TileLayerGLRenderer);
25740
25741 function GLRenderer() {
25742 classCallCheck(this, GLRenderer);
25743 return possibleConstructorReturn(this, _TileLayerGLRenderer.apply(this, arguments));
25744 }
25745
25746 GLRenderer.prototype.loadTile = function loadTile() {
25747 return _loadTile.apply(this, arguments);
25748 };
25749
25750 return GLRenderer;
25751}(TileLayerCanvasRenderer);
25752
25753CanvasTileLayer.registerRenderer('canvas', CanvasRenderer$2);
25754CanvasTileLayer.registerRenderer('gl', GLRenderer);
25755
25756var OverlayLayerRenderer = function (_CanvasRenderer) {
25757 inherits(OverlayLayerRenderer, _CanvasRenderer);
25758
25759 function OverlayLayerRenderer() {
25760 classCallCheck(this, OverlayLayerRenderer);
25761 return possibleConstructorReturn(this, _CanvasRenderer.apply(this, arguments));
25762 }
25763
25764 OverlayLayerRenderer.prototype.checkResources = function checkResources() {
25765 var geometries = this._geosToCheck;
25766 if (!this._resourceChecked && !geometries) {
25767 geometries = this.layer._geoList;
25768 }
25769 if (!isArrayHasData(geometries)) {
25770 return [];
25771 }
25772 var resources = [];
25773 var cache = {};
25774
25775 for (var i = geometries.length - 1; i >= 0; i--) {
25776 var geo = geometries[i];
25777 var res = geo._getExternalResources();
25778 if (!res.length) {
25779 continue;
25780 }
25781 if (!this.resources) {
25782 resources.push.apply(resources, res);
25783 } else {
25784 for (var _i = 0; _i < res.length; _i++) {
25785 var url = res[_i][0];
25786 if (!this.resources.isResourceLoaded(res[_i]) && !cache[url]) {
25787 resources.push(res[_i]);
25788 cache[url] = 1;
25789 }
25790 }
25791 }
25792 }
25793 this._resourceChecked = true;
25794 delete this._geosToCheck;
25795 return resources;
25796 };
25797
25798 OverlayLayerRenderer.prototype.render = function render() {
25799 this.layer._sortGeometries();
25800 return _CanvasRenderer.prototype.render.apply(this, arguments);
25801 };
25802
25803 OverlayLayerRenderer.prototype._addGeoToCheckRes = function _addGeoToCheckRes(res) {
25804 if (!res) {
25805 return;
25806 }
25807 if (!Array.isArray(res)) {
25808 res = [res];
25809 }
25810 if (!this._geosToCheck) {
25811 this._geosToCheck = [];
25812 }
25813 pushIn(this._geosToCheck, res);
25814 };
25815
25816 OverlayLayerRenderer.prototype.onGeometryAdd = function onGeometryAdd(geometries) {
25817 this._addGeoToCheckRes(geometries);
25818 redraw(this);
25819 };
25820
25821 OverlayLayerRenderer.prototype.onGeometryRemove = function onGeometryRemove() {
25822 redraw(this);
25823 };
25824
25825 OverlayLayerRenderer.prototype.onGeometrySymbolChange = function onGeometrySymbolChange(e) {
25826 this._addGeoToCheckRes(e.target);
25827 redraw(this);
25828 };
25829
25830 OverlayLayerRenderer.prototype.onGeometryShapeChange = function onGeometryShapeChange() {
25831 redraw(this);
25832 };
25833
25834 OverlayLayerRenderer.prototype.onGeometryPositionChange = function onGeometryPositionChange() {
25835 redraw(this);
25836 };
25837
25838 OverlayLayerRenderer.prototype.onGeometryZIndexChange = function onGeometryZIndexChange() {
25839 redraw(this);
25840 };
25841
25842 OverlayLayerRenderer.prototype.onGeometryShow = function onGeometryShow() {
25843 redraw(this);
25844 };
25845
25846 OverlayLayerRenderer.prototype.onGeometryHide = function onGeometryHide() {
25847 redraw(this);
25848 };
25849
25850 OverlayLayerRenderer.prototype.onGeometryPropertiesChange = function onGeometryPropertiesChange() {
25851 redraw(this);
25852 };
25853
25854 return OverlayLayerRenderer;
25855}(CanvasRenderer);
25856
25857function redraw(renderer) {
25858 if (renderer.layer.options['drawImmediate']) {
25859 renderer.render();
25860 }
25861 renderer.setToRedraw();
25862}
25863
25864var VectorLayerRenderer = function (_OverlayLayerCanvasRe) {
25865 inherits(VectorLayerRenderer, _OverlayLayerCanvasRe);
25866
25867 function VectorLayerRenderer() {
25868 classCallCheck(this, VectorLayerRenderer);
25869 return possibleConstructorReturn(this, _OverlayLayerCanvasRe.apply(this, arguments));
25870 }
25871
25872 VectorLayerRenderer.prototype.checkResources = function checkResources() {
25873 var _this2 = this;
25874
25875 var resources = _OverlayLayerCanvasRe.prototype.checkResources.apply(this, arguments);
25876 var style = this.layer.getStyle();
25877 if (style) {
25878 if (!Array.isArray(style)) {
25879 style = [style];
25880 }
25881 style.forEach(function (s) {
25882 var res = getExternalResources(s['symbol'], true);
25883 for (var i = 0, l = res.length; i < l; i++) {
25884 if (!_this2.resources.isResourceLoaded(res[i])) {
25885 resources.push(res[i]);
25886 }
25887 }
25888 });
25889 }
25890 return resources;
25891 };
25892
25893 VectorLayerRenderer.prototype.needToRedraw = function needToRedraw() {
25894 var map = this.getMap();
25895 if (map.isInteracting() && this.layer.options['enableAltitude']) {
25896 return true;
25897 }
25898
25899 if (map.isZooming() && !map.isRotating() && !map.getPitch() && !this._hasPoint && this.layer.constructor === VectorLayer) {
25900 return false;
25901 }
25902 return _OverlayLayerCanvasRe.prototype.needToRedraw.call(this);
25903 };
25904
25905 VectorLayerRenderer.prototype.draw = function draw() {
25906 if (!this.getMap()) {
25907 return;
25908 }
25909 if (!this.layer.isVisible() || this.layer.isEmpty()) {
25910 this.clearCanvas();
25911 this.completeRender();
25912 return;
25913 }
25914
25915 this.prepareCanvas();
25916
25917 this.drawGeos();
25918
25919 this.completeRender();
25920 };
25921
25922 VectorLayerRenderer.prototype.isBlank = function isBlank() {
25923 if (!this.context) {
25924 return false;
25925 }
25926 return !this.context.canvas._drawn;
25927 };
25928
25929 VectorLayerRenderer.prototype.drawOnInteracting = function drawOnInteracting() {
25930 if (!this._geosToDraw) {
25931 return;
25932 }
25933 this._updateDisplayExtent();
25934 for (var i = 0, l = this._geosToDraw.length; i < l; i++) {
25935 if (!this._geosToDraw[i].isVisible()) {
25936 continue;
25937 }
25938 this._geosToDraw[i]._paint(this._displayExtent);
25939 }
25940 };
25941
25942 VectorLayerRenderer.prototype.show = function show() {
25943 this.layer.forEach(function (geo) {
25944 geo._repaint();
25945 });
25946 _OverlayLayerCanvasRe.prototype.show.apply(this, arguments);
25947 };
25948
25949 VectorLayerRenderer.prototype.forEachGeo = function forEachGeo(fn, context) {
25950 this.layer.forEach(fn, context);
25951 };
25952
25953 VectorLayerRenderer.prototype.drawGeos = function drawGeos() {
25954 this._updateDisplayExtent();
25955 this.prepareToDraw();
25956
25957 this.forEachGeo(this.checkGeo, this);
25958 for (var i = 0, len = this._geosToDraw.length; i < len; i++) {
25959 this._geosToDraw[i]._paint();
25960 }
25961 };
25962
25963 VectorLayerRenderer.prototype.prepareToDraw = function prepareToDraw() {
25964 this._hasPoint = false;
25965 this._geosToDraw = [];
25966 };
25967
25968 VectorLayerRenderer.prototype.checkGeo = function checkGeo(geo) {
25969 if (!geo || !geo.isVisible() || !geo.getMap() || !geo.getLayer() || !geo.getLayer().isCanvasRender()) {
25970 return;
25971 }
25972
25973 var painter = geo._getPainter(),
25974 extent2D = painter.get2DExtent(this.resources);
25975 if (!extent2D || !extent2D.intersects(this._displayExtent)) {
25976 return;
25977 }
25978 if (painter.hasPoint()) {
25979 this._hasPoint = true;
25980 }
25981 this._geosToDraw.push(geo);
25982 };
25983
25984 VectorLayerRenderer.prototype.onZoomEnd = function onZoomEnd() {
25985 delete this.canvasExtent2D;
25986 _OverlayLayerCanvasRe.prototype.onZoomEnd.apply(this, arguments);
25987 };
25988
25989 VectorLayerRenderer.prototype.onRemove = function onRemove() {
25990 this.forEachGeo(function (g) {
25991 g.onHide();
25992 });
25993 delete this._geosToDraw;
25994 };
25995
25996 VectorLayerRenderer.prototype.onGeometryPropertiesChange = function onGeometryPropertiesChange(param) {
25997 if (param) {
25998 this.layer._styleGeometry(param['target']);
25999 }
26000 _OverlayLayerCanvasRe.prototype.onGeometryPropertiesChange.call(this, param);
26001 };
26002
26003 VectorLayerRenderer.prototype._updateDisplayExtent = function _updateDisplayExtent() {
26004 var extent2D = this.canvasExtent2D;
26005 if (this._maskExtent) {
26006 if (!this._maskExtent.intersects(extent2D)) {
26007 this.completeRender();
26008 return;
26009 }
26010 extent2D = extent2D.intersection(this._maskExtent);
26011 }
26012 this._displayExtent = extent2D;
26013 };
26014
26015 VectorLayerRenderer.prototype.identify = function identify(coordinate) {
26016 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26017
26018 var geometries = this._geosToDraw;
26019 if (!geometries) {
26020 return [];
26021 }
26022 return this.layer._hitGeos(geometries, coordinate, options);
26023 };
26024
26025 return VectorLayerRenderer;
26026}(OverlayLayerRenderer);
26027
26028VectorLayer.registerRenderer('canvas', VectorLayerRenderer);
26029
26030var MapRenderer = function (_Class) {
26031 inherits(MapRenderer, _Class);
26032
26033 function MapRenderer(map) {
26034 classCallCheck(this, MapRenderer);
26035
26036 var _this = possibleConstructorReturn(this, _Class.call(this));
26037
26038 _this.map = map;
26039 _this._handlerQueue = {};
26040 return _this;
26041 }
26042
26043 MapRenderer.prototype.callInNextFrame = function callInNextFrame(fn) {
26044 this._handlerQueue.push(fn);
26045 };
26046
26047 MapRenderer.prototype.executeFrameCallbacks = function executeFrameCallbacks() {
26048 var running = this._handlerQueue;
26049 this._handlerQueue = [];
26050 for (var i = 0, l = running.length; i < l; i++) {
26051 running[i]();
26052 }
26053 };
26054
26055 MapRenderer.prototype.offsetPlatform = function offsetPlatform(offset) {
26056 if (!this.map._panels.front) {
26057 return this;
26058 }
26059 if (offset.x === 0 && offset.y === 0) {
26060 return this;
26061 }
26062 var pos = this.map.offsetPlatform().add(offset)._round();
26063 var panels = this.map._panels;
26064 offsetDom(panels.back, pos);
26065 offsetDom(panels.front, pos);
26066 return this;
26067 };
26068
26069 MapRenderer.prototype.resetContainer = function resetContainer() {
26070 if (!this.map) {
26071 return;
26072 }
26073 this.map._resetMapViewPoint();
26074 if (this.map._panels.front) {
26075 var pos = new Point(0, 0);
26076 offsetDom(this.map._panels.back, pos);
26077 offsetDom(this.map._panels.front, pos);
26078 }
26079 };
26080
26081 MapRenderer.prototype.onZoomEnd = function onZoomEnd() {
26082 this.resetContainer();
26083 };
26084
26085 MapRenderer.prototype.onLoad = function onLoad() {
26086 this._frameLoop();
26087 };
26088
26089 return MapRenderer;
26090}(Class);
26091
26092var MapCanvasRenderer = function (_MapRenderer) {
26093 inherits(MapCanvasRenderer, _MapRenderer);
26094
26095 function MapCanvasRenderer(map) {
26096 classCallCheck(this, MapCanvasRenderer);
26097
26098 var _this = possibleConstructorReturn(this, _MapRenderer.call(this, map));
26099
26100 _this._containerIsCanvas = !!map._containerDOM.getContext;
26101 _this._registerEvents();
26102 _this._loopTime = 0;
26103 return _this;
26104 }
26105
26106 MapCanvasRenderer.prototype.load = function load() {
26107 this.initContainer();
26108 };
26109
26110 MapCanvasRenderer.prototype.renderFrame = function renderFrame(framestamp) {
26111 if (!this.map) {
26112 return false;
26113 }
26114 var map = this.map;
26115 map._fireEvent('framestart');
26116 this.updateMapDOM();
26117 var layers = this._getAllLayerToRender();
26118 this.drawLayers(layers, framestamp);
26119 this.drawLayerCanvas(layers);
26120
26121 map._fireEvent('frameend');
26122 this._recordView();
26123
26124 this._mapview = this._getMapView();
26125 delete this._spatialRefChanged;
26126 this._fireLayerLoadEvents();
26127 this.executeFrameCallbacks();
26128 this._needRedraw = false;
26129 return true;
26130 };
26131
26132 MapCanvasRenderer.prototype.updateMapDOM = function updateMapDOM() {
26133 var map = this.map;
26134
26135 if (map.isZooming()) {
26136 return;
26137 }
26138 var offset = map._getViewPointFrameOffset();
26139 if (offset) {
26140 map.offsetPlatform(offset);
26141 }
26142 };
26143
26144 MapCanvasRenderer.prototype.drawLayers = function drawLayers(layers, framestamp) {
26145 var map = this.map,
26146 isInteracting = map.isInteracting(),
26147 canvasIds = [],
26148 updatedIds = [],
26149 fps = map.options['fpsOnInteracting'] || 0,
26150 timeLimit = fps === 0 ? 0 : 1000 / fps,
26151 layerLimit = this.map.options['layerCanvasLimitOnInteracting'],
26152 l = layers.length;
26153 var baseLayer = map.getBaseLayer();
26154 var t = 0;
26155 for (var i = 0; i < l; i++) {
26156 var layer = layers[i];
26157 if (!layer.isVisible()) {
26158 continue;
26159 }
26160 var isCanvas = layer.isCanvasRender();
26161 if (isCanvas) {
26162 canvasIds.push(layer.getId());
26163 }
26164 var renderer = layer._getRenderer();
26165 if (!renderer) {
26166 continue;
26167 }
26168
26169 var needsRedraw = this._checkLayerRedraw(layer);
26170 if (isCanvas && renderer.isCanvasUpdated()) {
26171 if (!needsRedraw) {
26172 updatedIds.push(layer.getId());
26173 }
26174 this.setToRedraw();
26175 }
26176 delete renderer.__shouldZoomTransform;
26177 if (!needsRedraw) {
26178 if (isCanvas && isInteracting) {
26179 if (map.isZooming() && !map.getPitch()) {
26180 renderer.prepareRender();
26181 renderer.__shouldZoomTransform = true;
26182 } else if (map.getPitch() || map.isRotating()) {
26183 renderer.clearCanvas();
26184 }
26185 }
26186 continue;
26187 }
26188
26189 if (isInteracting && isCanvas) {
26190 if (layerLimit > 0 && l - 1 - i > layerLimit && layer !== baseLayer) {
26191 layer._getRenderer().clearCanvas();
26192 continue;
26193 }
26194 t += this._drawCanvasLayerOnInteracting(layer, t, timeLimit, framestamp);
26195 } else if (isInteracting && renderer.drawOnInteracting) {
26196 if (renderer.prepareRender) {
26197 renderer.prepareRender();
26198 }
26199 renderer.drawOnInteracting(this._eventParam, framestamp);
26200 } else {
26201 renderer.render(framestamp);
26202 }
26203
26204 if (isCanvas) {
26205 updatedIds.push(layer.getId());
26206 this.setToRedraw();
26207 }
26208 }
26209
26210 var preCanvasIds = this._canvasIds || [];
26211 var preUpdatedIds = this._updatedIds || [];
26212 this._canvasIds = canvasIds;
26213 this._updatedIds = updatedIds;
26214 if (!this._needToRedraw()) {
26215 var sep = '---';
26216 if (preCanvasIds.join(sep) !== canvasIds.join(sep) || preUpdatedIds.join(sep) !== updatedIds.join(sep)) {
26217 this.setToRedraw();
26218 }
26219 }
26220 };
26221
26222 MapCanvasRenderer.prototype._checkLayerRedraw = function _checkLayerRedraw(layer) {
26223 if (this.isSpatialReferenceChanged()) {
26224 return true;
26225 }
26226 var map = this.map;
26227 var renderer = layer._getRenderer();
26228 if (layer.isCanvasRender()) {
26229 return renderer.testIfNeedRedraw();
26230 } else {
26231 if (renderer.needToRedraw && renderer.needToRedraw()) {
26232 return true;
26233 }
26234
26235 return map.isInteracting() || this.isViewChanged();
26236 }
26237 };
26238
26239 MapCanvasRenderer.prototype._drawCanvasLayerOnInteracting = function _drawCanvasLayerOnInteracting(layer, t, timeLimit, framestamp) {
26240 var map = this.map,
26241 renderer = layer._getRenderer(),
26242 drawTime = renderer.getDrawTime(),
26243 inTime = timeLimit === 0 || timeLimit > 0 && t + drawTime <= timeLimit;
26244 if (renderer.mustRenderOnInteracting && renderer.mustRenderOnInteracting()) {
26245 renderer.render(framestamp);
26246 } else if (renderer.drawOnInteracting && (layer === map.getBaseLayer() || inTime || map.isZooming() && layer.options['forceRenderOnZooming'] || map.isMoving() && layer.options['forceRenderOnMoving'] || map.isRotating() && layer.options['forceRenderOnRotating'])) {
26247 renderer.prepareRender();
26248 renderer.prepareCanvas();
26249 renderer.drawOnInteracting(this._eventParam, framestamp);
26250 return drawTime;
26251 } else if (map.isZooming() && !map.getPitch() && !map.isRotating()) {
26252 renderer.prepareRender();
26253 renderer.__shouldZoomTransform = true;
26254 } else if (map.getPitch() || map.isRotating()) {
26255 renderer.clearCanvas();
26256 }
26257 if (renderer.drawOnInteracting && !inTime) {
26258 renderer.onSkipDrawOnInteracting(this._eventParam, framestamp);
26259 }
26260 return 0;
26261 };
26262
26263 MapCanvasRenderer.prototype._fireLayerLoadEvents = function _fireLayerLoadEvents() {
26264 if (this._updatedIds && this._updatedIds.length > 0) {
26265 var map = this.map;
26266
26267 this._updatedIds.reverse().forEach(function (id) {
26268 var layer = map.getLayer(id);
26269 if (!layer) {
26270 return;
26271 }
26272 var renderer = layer._getRenderer();
26273 if (!renderer || !renderer.isRenderComplete()) {
26274 return;
26275 }
26276
26277 layer.fire('layerload');
26278 });
26279 }
26280 };
26281
26282 MapCanvasRenderer.prototype._needToRedraw = function _needToRedraw() {
26283 return this._needRedraw;
26284 };
26285
26286 MapCanvasRenderer.prototype.setToRedraw = function setToRedraw() {
26287 this._needRedraw = true;
26288 };
26289
26290 MapCanvasRenderer.prototype.drawLayerCanvas = function drawLayerCanvas(layers) {
26291 var map = this.map;
26292 if (!map) {
26293 return;
26294 }
26295 if (!this._needToRedraw() && !this.isViewChanged()) {
26296 return;
26297 }
26298 if (!this.canvas) {
26299 this.createCanvas();
26300 }
26301
26302 map._fireEvent('renderstart', {
26303 'context': this.context
26304 });
26305
26306 if (!this._updateCanvasSize()) {
26307 this.clearCanvas();
26308 }
26309
26310 var interacting = map.isInteracting(),
26311 limit = map.options['layerCanvasLimitOnInteracting'];
26312 var len = layers.length;
26313
26314 var baseLayerImage = void 0;
26315 var images = [];
26316 for (var i = 0; i < len; i++) {
26317 if (!layers[i].isVisible() || !layers[i].isCanvasRender()) {
26318 continue;
26319 }
26320 var renderer = layers[i]._getRenderer();
26321 if (!renderer) {
26322 continue;
26323 }
26324 var layerImage = this._getLayerImage(layers[i]);
26325 if (layerImage && layerImage['image']) {
26326 if (layers[i] === map.getBaseLayer()) {
26327 baseLayerImage = [layers[i], layerImage];
26328 } else {
26329 images.push([layers[i], layerImage]);
26330 }
26331 }
26332 }
26333
26334 if (baseLayerImage) {
26335 this._drawLayerCanvasImage(baseLayerImage[0], baseLayerImage[1]);
26336 this._drawFog();
26337 }
26338
26339 len = images.length;
26340 var start = interacting && limit >= 0 && len > limit ? len - limit : 0;
26341 for (var _i = start; _i < len; _i++) {
26342 this._drawLayerCanvasImage(images[_i][0], images[_i][1]);
26343 }
26344
26345 this._drawCenterCross();
26346
26347 map._fireEvent('renderend', {
26348 'context': this.context
26349 });
26350 };
26351
26352 MapCanvasRenderer.prototype.updateMapSize = function updateMapSize(size) {
26353 if (!size || this._containerIsCanvas) {
26354 return;
26355 }
26356 var width = size['width'] + 'px',
26357 height = size['height'] + 'px';
26358 var panels = this.map._panels;
26359 panels.mapWrapper.style.width = width;
26360 panels.mapWrapper.style.height = height;
26361 this._updateCanvasSize();
26362 };
26363
26364 MapCanvasRenderer.prototype.getMainPanel = function getMainPanel() {
26365 if (!this.map) {
26366 return null;
26367 }
26368 if (this._containerIsCanvas) {
26369 return this.map._containerDOM;
26370 }
26371 if (this.map._panels) {
26372 return this.map._panels.mapWrapper;
26373 }
26374 return null;
26375 };
26376
26377 MapCanvasRenderer.prototype.toDataURL = function toDataURL(mimeType) {
26378 if (!this.canvas) {
26379 return null;
26380 }
26381 return this.canvas.toDataURL(mimeType);
26382 };
26383
26384 MapCanvasRenderer.prototype.remove = function remove() {
26385 if (Browser$1.webgl && typeof document !== 'undefined') {
26386 removeDomEvent(document, 'visibilitychange', this._onVisibilitychange, this);
26387 }
26388 if (this._resizeInterval) {
26389 clearInterval(this._resizeInterval);
26390 }
26391 delete this.context;
26392 delete this.canvas;
26393 delete this.map;
26394 delete this._spatialRefChanged;
26395 this._cancelFrameLoop();
26396 };
26397
26398 MapCanvasRenderer.prototype.hitDetect = function hitDetect(point) {
26399 var map = this.map;
26400 if (!map || !map.options['hitDetect'] || map.isInteracting()) {
26401 return;
26402 }
26403 var layers = map._getLayers();
26404 var cursor = 'default';
26405 var limit = map.options['hitDetectLimit'] || 0;
26406 var counter = 0;
26407 for (var i = layers.length - 1; i >= 0; i--) {
26408 var layer = layers[i];
26409 if (layer.isEmpty && layer.isEmpty()) {
26410 continue;
26411 }
26412 var renderer = layer._getRenderer();
26413 if (!renderer || !renderer.hitDetect) {
26414 continue;
26415 }
26416 if (renderer.isBlank && renderer.isBlank()) {
26417 continue;
26418 }
26419 if (layer.options['cursor'] !== 'default' && renderer.hitDetect(point)) {
26420 cursor = layer.options['cursor'] || 'pointer';
26421 break;
26422 }
26423 counter++;
26424 if (limit > 0 && counter > limit) {
26425 break;
26426 }
26427 }
26428
26429 map._trySetCursor(cursor);
26430 };
26431
26432 MapCanvasRenderer.prototype._getLayerImage = function _getLayerImage(layer) {
26433 var renderer = layer._getRenderer();
26434 if (renderer.getCanvasImage) {
26435 return renderer.getCanvasImage();
26436 }
26437 return null;
26438 };
26439
26440 MapCanvasRenderer.prototype.initContainer = function initContainer() {
26441 var panels = this.map._panels;
26442
26443 function createContainer(name, className, cssText, enableSelect) {
26444 var c = createEl('div', className);
26445 if (cssText) {
26446 c.style.cssText = cssText;
26447 }
26448 panels[name] = c;
26449 if (!enableSelect) {
26450 preventSelection(c);
26451 }
26452 return c;
26453 }
26454 var containerDOM = this.map._containerDOM;
26455
26456 if (this._containerIsCanvas) {
26457 return;
26458 }
26459
26460 containerDOM.innerHTML = '';
26461
26462 var POSITION0 = 'position:absolute;top:0px;left:0px;';
26463
26464 var mapWrapper = createContainer('mapWrapper', 'maptalks-wrapper', 'position:absolute;overflow:hidden;', true),
26465 mapAllLayers = createContainer('allLayers', 'maptalks-all-layers', POSITION0 + 'padding:0px;margin:0px;z-index:0;overflow:visible;', true),
26466 backStatic = createContainer('backStatic', 'maptalks-back-static', POSITION0 + 'z-index:0;', true),
26467 back = createContainer('back', 'maptalks-back', POSITION0 + 'z-index:1;'),
26468 backLayer = createContainer('backLayer', 'maptalks-back-layer', POSITION0),
26469 canvasContainer = createContainer('canvasContainer', 'maptalks-canvas-layer', POSITION0 + 'border:none;z-index:2;'),
26470 frontStatic = createContainer('frontStatic', 'maptalks-front-static', POSITION0 + 'z-index:3;', true),
26471 front = createContainer('front', 'maptalks-front', POSITION0 + 'z-index:4;', true),
26472 frontLayer = createContainer('frontLayer', 'maptalks-front-layer', POSITION0 + 'z-index:0;'),
26473 ui = createContainer('ui', 'maptalks-ui', POSITION0 + 'border:none;z-index:1;', true),
26474 control = createContainer('control', 'maptalks-control', 'z-index:1', true);
26475
26476 containerDOM.appendChild(mapWrapper);
26477
26478 mapAllLayers.appendChild(backStatic);
26479 back.appendChild(backLayer);
26480 mapAllLayers.appendChild(back);
26481 mapAllLayers.appendChild(canvasContainer);
26482 front.appendChild(frontLayer);
26483 mapAllLayers.appendChild(frontStatic);
26484 mapAllLayers.appendChild(front);
26485 front.appendChild(ui);
26486
26487 mapWrapper.appendChild(mapAllLayers);
26488 mapWrapper.appendChild(control);
26489
26490 this.createCanvas();
26491
26492 this.resetContainer();
26493 var mapSize = this.map._getContainerDomSize();
26494 this.updateMapSize(mapSize);
26495 };
26496
26497 MapCanvasRenderer.prototype.isViewChanged = function isViewChanged() {
26498 var previous = this._mapview;
26499 var view = this._getMapView();
26500 if (!previous || !equalMapView(previous, view)) {
26501 return true;
26502 }
26503 return false;
26504 };
26505
26506 MapCanvasRenderer.prototype._recordView = function _recordView() {
26507 var map = this.map;
26508 if (!map._onViewChange || map.isInteracting() || map.isAnimating()) {
26509 return;
26510 }
26511 if (!equalMapView(map.getView(), map._getCurrentView())) {
26512 map._onViewChange(map.getView());
26513 }
26514 };
26515
26516 MapCanvasRenderer.prototype.isSpatialReferenceChanged = function isSpatialReferenceChanged() {
26517 return this._spatialRefChanged;
26518 };
26519
26520 MapCanvasRenderer.prototype._getMapView = function _getMapView() {
26521 var map = this.map;
26522 var center = map._getPrjCenter();
26523 return {
26524 x: center.x,
26525 y: center.y,
26526 zoom: map.getZoom(),
26527 pitch: map.getPitch(),
26528 bearing: map.getBearing(),
26529 width: map.width,
26530 height: map.height
26531 };
26532 };
26533
26534 MapCanvasRenderer.prototype._frameLoop = function _frameLoop(framestamp) {
26535 var _this2 = this;
26536
26537 if (!this.map) {
26538 this._cancelFrameLoop();
26539 return;
26540 }
26541 this.renderFrame(framestamp);
26542
26543 this._animationFrame = requestAnimFrame(function (framestamp) {
26544 _this2._frameLoop(framestamp);
26545 });
26546 };
26547
26548 MapCanvasRenderer.prototype._cancelFrameLoop = function _cancelFrameLoop() {
26549 if (this._animationFrame) {
26550 cancelAnimFrame(this._animationFrame);
26551 }
26552 };
26553
26554 MapCanvasRenderer.prototype._drawLayerCanvasImage = function _drawLayerCanvasImage(layer, layerImage) {
26555 var ctx = this.context;
26556 var point = layerImage['point'].round();
26557 if (Browser$1.retina) {
26558 point._multi(2);
26559 }
26560 var canvasImage = layerImage['image'];
26561 if (point.x + canvasImage.width <= 0 || point.y + canvasImage.height <= 0) {
26562 return;
26563 }
26564
26565 var op = layer.options['opacity'];
26566 if (!isNumber(op)) {
26567 op = 1;
26568 }
26569 if (op <= 0) {
26570 return;
26571 }
26572 var imgOp = layerImage['opacity'];
26573 if (!isNumber(imgOp)) {
26574 imgOp = 1;
26575 }
26576 if (imgOp <= 0) {
26577 return;
26578 }
26579 var alpha = ctx.globalAlpha;
26580
26581 if (op < 1) {
26582 ctx.globalAlpha *= op;
26583 }
26584 if (imgOp < 1) {
26585 ctx.globalAlpha *= imgOp;
26586 }
26587 if (layer.options['cssFilter']) {
26588 ctx.filter = layer.options['cssFilter'];
26589 }
26590 var matrix = this._zoomMatrix;
26591 var shouldTransform = !!layer._getRenderer().__shouldZoomTransform;
26592 var renderer = layer.getRenderer();
26593 var clipped = renderer.clipCanvas(this.context);
26594 if (matrix && shouldTransform) {
26595 ctx.save();
26596 ctx.setTransform.apply(ctx, matrix);
26597 }
26598
26599 ctx.drawImage(canvasImage, point.x, point.y);
26600 if (matrix && shouldTransform) {
26601 ctx.restore();
26602 }
26603 if (clipped) {
26604 ctx.restore();
26605 }
26606 if (ctx.filter !== 'none') {
26607 ctx.filter = 'none';
26608 }
26609 ctx.globalAlpha = alpha;
26610 };
26611
26612 MapCanvasRenderer.prototype._drawCenterCross = function _drawCenterCross() {
26613 var cross = this.map.options['centerCross'];
26614 if (cross) {
26615 var ctx = this.context;
26616 var p = new Point(this.canvas.width / 2, this.canvas.height / 2);
26617 if (isFunction(cross)) {
26618 cross(ctx, p);
26619 } else {
26620 Canvas.drawCross(this.context, p, 2, '#f00');
26621 }
26622 }
26623 };
26624
26625 MapCanvasRenderer.prototype._drawFog = function _drawFog() {
26626 var map = this.map;
26627 if (map.getPitch() <= map.options['maxVisualPitch'] || !map.options['fog']) {
26628 return;
26629 }
26630 var fogThickness = 30,
26631 r = Browser$1.retina ? 2 : 1;
26632 var ctx = this.context,
26633 clipExtent = map.getContainerExtent();
26634 var top = (map.height - map._getVisualHeight(75)) * r;
26635 if (top < 0) top = 0;
26636 var bottom = clipExtent.ymin * r,
26637 h = Math.ceil(bottom - top),
26638 color = map.options['fogColor'].join();
26639 var gradient = ctx.createLinearGradient(0, top, 0, bottom + fogThickness);
26640 var landscape = 1 - fogThickness / (h + fogThickness);
26641 gradient.addColorStop(0, 'rgba(' + color + ', 0)');
26642 gradient.addColorStop(0.3, 'rgba(' + color + ', 0.3)');
26643 gradient.addColorStop(landscape, 'rgba(' + color + ', 1)');
26644 gradient.addColorStop(1, 'rgba(' + color + ', 0)');
26645 ctx.beginPath();
26646 ctx.fillStyle = gradient;
26647 ctx.fillRect(0, top, Math.ceil(clipExtent.getWidth()) * r, Math.ceil(h + fogThickness));
26648 };
26649
26650 MapCanvasRenderer.prototype._getAllLayerToRender = function _getAllLayerToRender() {
26651 return this.map._getLayers();
26652 };
26653
26654 MapCanvasRenderer.prototype.clearCanvas = function clearCanvas() {
26655 if (!this.canvas) {
26656 return;
26657 }
26658 Canvas.clearRect(this.context, 0, 0, this.canvas.width, this.canvas.height);
26659 };
26660
26661 MapCanvasRenderer.prototype._updateCanvasSize = function _updateCanvasSize() {
26662 if (!this.canvas || this._containerIsCanvas) {
26663 return false;
26664 }
26665 var map = this.map,
26666 mapSize = map.getSize(),
26667 canvas = this.canvas,
26668 r = Browser$1.retina ? 2 : 1;
26669 if (mapSize['width'] * r === canvas.width && mapSize['height'] * r === canvas.height) {
26670 return false;
26671 }
26672
26673
26674 canvas.height = r * mapSize['height'];
26675 canvas.width = r * mapSize['width'];
26676 if (canvas.style) {
26677 canvas.style.width = mapSize['width'] + 'px';
26678 canvas.style.height = mapSize['height'] + 'px';
26679 }
26680
26681 return true;
26682 };
26683
26684 MapCanvasRenderer.prototype.createCanvas = function createCanvas() {
26685 if (this._containerIsCanvas) {
26686 this.canvas = this.map._containerDOM;
26687 } else {
26688 this.canvas = createEl('canvas');
26689 this._updateCanvasSize();
26690 this.map._panels.canvasContainer.appendChild(this.canvas);
26691 }
26692 this.context = this.canvas.getContext('2d');
26693 };
26694
26695 MapCanvasRenderer.prototype._checkSize = function _checkSize() {
26696 if (!this.map || this.map.isInteracting()) {
26697 return;
26698 }
26699
26700 computeDomPosition(this.map._containerDOM);
26701 this.map.checkSize();
26702 };
26703
26704 MapCanvasRenderer.prototype._setCheckSizeInterval = function _setCheckSizeInterval(interval) {
26705 var _this3 = this;
26706
26707 clearInterval(this._resizeInterval);
26708 this._checkSizeInterval = interval;
26709 this._resizeInterval = setInterval(function () {
26710 if (!_this3.map || _this3.map.isRemoved()) {
26711 clearInterval(_this3._resizeInterval);
26712 } else {
26713 _this3._checkSize();
26714 }
26715 }, this._checkSizeInterval);
26716 };
26717
26718 MapCanvasRenderer.prototype._registerEvents = function _registerEvents() {
26719 var _this4 = this;
26720
26721 var map = this.map;
26722
26723 if (map.options['checkSize'] && !IS_NODE && typeof window !== 'undefined') {
26724 this._setCheckSizeInterval(1000);
26725 }
26726 if (!Browser$1.mobile) {
26727 map.on('_mousemove', this._onMapMouseMove, this);
26728 }
26729
26730 map.on('_dragrotatestart _dragrotating _dragrotateend _movestart _moving _moveend _zoomstart', function (param) {
26731 _this4._eventParam = param;
26732 });
26733
26734 map.on('_zooming', function (param) {
26735 if (!map.getPitch()) {
26736 _this4._zoomMatrix = param['matrix']['container'];
26737 }
26738 _this4._eventParam = param;
26739 });
26740
26741 map.on('_zoomend', function (param) {
26742 _this4._eventParam = param;
26743 delete _this4._zoomMatrix;
26744 });
26745
26746 map.on('_spatialreferencechange', function () {
26747 _this4._spatialRefChanged = true;
26748 });
26749
26750 if (Browser$1.webgl && typeof document !== 'undefined') {
26751 addDomEvent(document, 'visibilitychange', this._onVisibilitychange, this);
26752 }
26753 };
26754
26755 MapCanvasRenderer.prototype._onMapMouseMove = function _onMapMouseMove(param) {
26756 var _this5 = this;
26757
26758 var map = this.map;
26759 if (map.isInteracting() || !map.options['hitDetect']) {
26760 return;
26761 }
26762 if (this._hitDetectFrame) {
26763 cancelAnimFrame(this._hitDetectFrame);
26764 }
26765 this._hitDetectFrame = requestAnimFrame(function () {
26766 _this5.hitDetect(param['containerPoint']);
26767 });
26768 };
26769
26770 MapCanvasRenderer.prototype._getCanvasLayers = function _getCanvasLayers() {
26771 return this.map._getLayers(function (layer) {
26772 return layer.isCanvasRender();
26773 });
26774 };
26775
26776 MapCanvasRenderer.prototype._onVisibilitychange = function _onVisibilitychange() {
26777 if (document.visibilityState !== 'visible') {
26778 return;
26779 }
26780 var layers = this._getAllLayerToRender();
26781 for (var i = 0, l = layers.length; i < l; i++) {
26782 var renderer = layers[i].getRenderer();
26783 if (renderer && renderer.canvas && renderer.setToRedraw) {
26784 renderer.setToRedraw();
26785 }
26786 }
26787 };
26788
26789 return MapCanvasRenderer;
26790}(MapRenderer);
26791
26792Map.registerRenderer('canvas', MapCanvasRenderer);
26793
26794Map.mergeOptions({
26795 'fog': true,
26796 'fogColor': [233, 233, 233]
26797});
26798
26799
26800
26801var index$6 = Object.freeze({
26802 ResourceCache: ResourceCache,
26803 CanvasRenderer: CanvasRenderer,
26804 ImageGLRenderable: ImageGLRenderable,
26805 MapRenderer: MapRenderer,
26806 MapCanvasRenderer: MapCanvasRenderer,
26807 Renderable: Renderable,
26808 ImageLayerCanvasRenderer: ImageLayerCanvasRenderer,
26809 ImageLayerGLRenderer: ImageLayerGLRenderer,
26810 TileLayerCanvasRenderer: TileLayerCanvasRenderer,
26811 TileLayerGLRenderer: TileLayerGLRenderer$1,
26812 CanvasTileLayerCanvasRenderer: CanvasRenderer$2,
26813 CanvasTileLayerGLRenderer: GLRenderer,
26814 OverlayLayerCanvasRenderer: OverlayLayerRenderer,
26815 VectorLayerCanvasRenderer: VectorLayerRenderer,
26816 CanvasLayerRenderer: CanvasLayerRenderer
26817});
26818
26819var CenterPointRenderer = {
26820 _getRenderPoints: function _getRenderPoints() {
26821 return [[this._getCenter2DPoint(this.getMap().getGLZoom())], null];
26822 }
26823};
26824
26825Marker.include(CenterPointRenderer);
26826
26827Ellipse.include(CenterPointRenderer);
26828
26829Circle.include(CenterPointRenderer);
26830
26831Sector.include(CenterPointRenderer);
26832
26833Rectangle.include({
26834 _getRenderPoints: function _getRenderPoints(placement) {
26835 var map = this.getMap();
26836 if (placement === 'vertex') {
26837 var shell = this._trimRing(this.getShell());
26838 var points = [];
26839 for (var i = 0, len = shell.length; i < len; i++) {
26840 points.push(map.coordToPoint(shell[i], map.getGLZoom()));
26841 }
26842 return [points, null];
26843 } else {
26844 var c = map.coordToPoint(this.getCenter(), map.getGLZoom());
26845 return [[c], null];
26846 }
26847 }
26848});
26849
26850var PolyRenderer = {
26851 _getRenderPoints: function _getRenderPoints(placement) {
26852 var map = this.getMap();
26853 var glZoom = map.getGLZoom();
26854 var points = void 0,
26855 rotations = null;
26856 if (placement === 'point') {
26857 points = this._getPath2DPoints(this._getPrjCoordinates(), false, glZoom);
26858 if (points && points.length > 0 && Array.isArray(points[0])) {
26859 points = points[0].concat(points[1]);
26860 }
26861 } else if (placement === 'vertex') {
26862 points = this._getPath2DPoints(this._getPrjCoordinates(), false, glZoom);
26863 rotations = [];
26864 if (points && points.length > 0 && Array.isArray(points[0])) {
26865 for (var i = 0, l = points.length; i < l; i++) {
26866 for (var ii = 0, ll = points[i].length; ii < ll; ii++) {
26867 if (ii === 0) {
26868 rotations.push([points[i][ii], points[i][ii + 1]]);
26869 } else {
26870 rotations.push([points[i][ii - 1], points[i][ii]]);
26871 }
26872 }
26873 }
26874 points = points[0].concat(points[1]);
26875 } else {
26876 for (var _i = 0, _l = points.length; _i < _l; _i++) {
26877 if (_i === 0) {
26878 rotations.push([points[_i], points[_i + 1]]);
26879 } else {
26880 rotations.push([points[_i - 1], points[_i]]);
26881 }
26882 }
26883 }
26884 } else if (placement === 'line') {
26885 points = [];
26886 rotations = [];
26887 var vertice = this._getPath2DPoints(this._getPrjCoordinates(), false, glZoom),
26888 isSplitted = vertice.length > 0 && Array.isArray(vertice[0]);
26889 if (isSplitted) {
26890 var ring = void 0;
26891 for (var _i2 = 1, _l2 = vertice.length; _i2 < _l2; _i2++) {
26892 ring = vertice[_i2];
26893 if (this instanceof Polygon && ring.length > 0 && !ring[0].equals(ring[ring.length - 1])) {
26894 ring.push(ring[0]);
26895 }
26896 for (var _ii = 1, _ll = ring.length; _ii < _ll; _ii++) {
26897 points.push(ring[_ii].add(ring[_ii - 1])._multi(0.5));
26898 rotations.push([ring[_ii - 1], ring[_ii]]);
26899 }
26900 }
26901 } else {
26902 if (this instanceof Polygon && vertice.length > 0 && !vertice[0].equals(vertice[vertice.length - 1])) {
26903 vertice.push(vertice[0]);
26904 }
26905 for (var _i3 = 1, _l3 = vertice.length; _i3 < _l3; _i3++) {
26906 points.push(vertice[_i3].add(vertice[_i3 - 1])._multi(0.5));
26907 rotations.push([vertice[_i3 - 1], vertice[_i3]]);
26908 }
26909 }
26910 } else if (placement === 'vertex-first') {
26911 var coords = this._getPrjCoordinates();
26912 points = [map._prjToPoint(coords[0], glZoom)];
26913 rotations = [[map._prjToPoint(coords[0], glZoom), map._prjToPoint(coords[1], glZoom)]];
26914 } else if (placement === 'vertex-last') {
26915 var _coords = this._getPrjCoordinates();
26916 var _l4 = _coords.length;
26917 points = [map._prjToPoint(_coords[_l4 - 1], glZoom)];
26918 rotations = [[map._prjToPoint(_coords[_l4 - 2], glZoom), map._prjToPoint(_coords[_l4 - 1], glZoom)]];
26919 } else {
26920 var pcenter = this._getProjection().project(this.getCenter());
26921 points = [map._prjToPoint(pcenter, glZoom)];
26922 }
26923 return [points, rotations];
26924 }
26925};
26926
26927LineString.include(PolyRenderer);
26928
26929Polygon.include(PolyRenderer);
26930
26931Geometry.include({
26932 _redrawWhenPitch: function _redrawWhenPitch() {
26933 return false;
26934 },
26935
26936 _redrawWhenRotate: function _redrawWhenRotate() {
26937 return false;
26938 }
26939});
26940
26941var el = {
26942 _redrawWhenPitch: function _redrawWhenPitch() {
26943 return true;
26944 },
26945
26946 _redrawWhenRotate: function _redrawWhenRotate() {
26947 return this instanceof Ellipse || this instanceof Sector;
26948 },
26949
26950 _paintAsPath: function _paintAsPath() {
26951 var map = this.getMap();
26952 var altitude = this._getPainter().getAltitude();
26953
26954 return altitude > 0 || map.getPitch() || this instanceof Ellipse && map.getBearing();
26955 },
26956
26957 _getPaintParams: function _getPaintParams() {
26958 var map = this.getMap();
26959 if (this._paintAsPath()) {
26960 return Polygon.prototype._getPaintParams.call(this, true);
26961 }
26962 var pcenter = this._getPrjCoordinates();
26963 var pt = map._prjToPoint(pcenter, map.getGLZoom());
26964 var size = this._getRenderSize();
26965 return [pt, size['width'], size['height']];
26966 },
26967
26968
26969 _paintOn: function _paintOn() {
26970 if (this._paintAsPath()) {
26971 return Canvas.polygon.apply(Canvas, arguments);
26972 } else {
26973 return Canvas.ellipse.apply(Canvas, arguments);
26974 }
26975 },
26976
26977 _getRenderSize: function _getRenderSize() {
26978 var map = this.getMap(),
26979 z = map.getGLZoom();
26980 var prjExtent = this._getPrjExtent();
26981 var pmin = map._prjToPoint(prjExtent.getMin(), z),
26982 pmax = map._prjToPoint(prjExtent.getMax(), z);
26983 return new Size(Math.abs(pmax.x - pmin.x) / 2, Math.abs(pmax.y - pmin.y) / 2);
26984 }
26985};
26986
26987Ellipse.include(el);
26988
26989Circle.include(el);
26990
26991Rectangle.include({
26992 _getPaintParams: function _getPaintParams() {
26993 var map = this.getMap();
26994 var pointZoom = map.getGLZoom();
26995 var shell = this._getPrjShell();
26996 var points = this._getPath2DPoints(shell, false, pointZoom);
26997 return [points];
26998 },
26999
27000
27001 _paintOn: Canvas.polygon
27002});
27003
27004Sector.include(el, {
27005 _redrawWhenPitch: function _redrawWhenPitch() {
27006 return true;
27007 },
27008
27009 _getPaintParams: function _getPaintParams() {
27010 if (this._paintAsPath()) {
27011 return Polygon.prototype._getPaintParams.call(this, true);
27012 }
27013 var map = this.getMap();
27014 var pt = map._prjToPoint(this._getPrjCoordinates(), map.getGLZoom());
27015 var size = this._getRenderSize();
27016 return [pt, size['width'], [this.getStartAngle(), this.getEndAngle()]];
27017 },
27018
27019
27020 _paintOn: function _paintOn() {
27021 if (this._paintAsPath()) {
27022 return Canvas.polygon.apply(Canvas, arguments);
27023 } else {
27024 var r = this.getMap().getBearing();
27025 var args = arguments;
27026 if (r) {
27027 args[3] = args[3].slice(0);
27028 args[3][0] += r;
27029 args[3][1] += r;
27030 }
27031 return Canvas.sector.apply(Canvas, args);
27032 }
27033 }
27034
27035});
27036
27037Path.include({
27038 _paintAsPath: function _paintAsPath() {
27039 return true;
27040 }
27041});
27042
27043LineString.include({
27044
27045 arrowStyles: {
27046 'classic': [3, 4]
27047 },
27048
27049 _getArrowShape: function _getArrowShape(prePoint, point, lineWidth, arrowStyle, tolerance) {
27050 if (!tolerance) {
27051 tolerance = 0;
27052 }
27053 var width = lineWidth * arrowStyle[0],
27054 height = lineWidth * arrowStyle[1] + tolerance,
27055 hw = width / 2 + tolerance;
27056
27057 var normal = void 0;
27058 if (point.nextCtrlPoint || point.prevCtrlPoint) {
27059 if (point.prevCtrlPoint) {
27060 normal = point.sub(new Point(point.prevCtrlPoint));
27061 } else {
27062 normal = point.sub(new Point(point.nextCtrlPoint));
27063 }
27064 } else {
27065 normal = point.sub(prePoint);
27066 }
27067 normal._unit();
27068 var p1 = point.sub(normal.multi(height));
27069 normal._perp();
27070 var p0 = p1.add(normal.multi(hw));
27071 normal._multi(-1);
27072 var p2 = p1.add(normal.multi(hw));
27073 return [p0, point, p2, p0];
27074 },
27075 _getPaintParams: function _getPaintParams() {
27076 var prjVertexes = this._getPrjCoordinates();
27077 var points = this._getPath2DPoints(prjVertexes, false, this.getMap().getGLZoom());
27078 return [points];
27079 },
27080 _paintOn: function _paintOn(ctx, points, lineOpacity, fillOpacity, dasharray) {
27081 if (this.options['smoothness']) {
27082 Canvas.paintSmoothLine(ctx, points, lineOpacity, this.options['smoothness'], false, this._animIdx, this._animTailRatio);
27083 } else {
27084 Canvas.path(ctx, points, lineOpacity, null, dasharray);
27085 }
27086 this._paintArrow(ctx, points, lineOpacity);
27087 },
27088 _getArrowPlacement: function _getArrowPlacement() {
27089 return this.options['arrowPlacement'];
27090 },
27091 _getArrowStyle: function _getArrowStyle() {
27092 var arrowStyle = this.options['arrowStyle'];
27093 if (arrowStyle) {
27094 return Array.isArray(arrowStyle) ? arrowStyle : this.arrowStyles[arrowStyle];
27095 }
27096 return null;
27097 },
27098 _getArrows: function _getArrows(points, lineWidth, tolerance) {
27099 var arrowStyle = this._getArrowStyle();
27100 if (!arrowStyle || points.length < 2) {
27101 return [];
27102 }
27103 var isSplitted = points.length > 0 && Array.isArray(points[0]);
27104 var segments = isSplitted ? points : [points];
27105 var placement = this._getArrowPlacement();
27106 var arrows = [];
27107 var map = this.getMap(),
27108 first = map.coordToContainerPoint(this.getFirstCoordinate()),
27109 last = map.coordToContainerPoint(this.getLastCoordinate());
27110 for (var i = segments.length - 1; i >= 0; i--) {
27111 if (placement === 'vertex-first' || placement === 'vertex-firstlast' && segments[i][0].closeTo(first, 0.01)) {
27112 arrows.push(this._getArrowShape(segments[i][1], segments[i][0], lineWidth, arrowStyle, tolerance));
27113 }
27114 if (placement === 'vertex-last' || placement === 'vertex-firstlast' && segments[i][segments[i].length - 1].closeTo(last, 0.01)) {
27115 arrows.push(this._getArrowShape(segments[i][segments[i].length - 2], segments[i][segments[i].length - 1], lineWidth, arrowStyle, tolerance));
27116 } else if (placement === 'point') {
27117 this._getArrowPoints(arrows, segments[i], lineWidth, arrowStyle, tolerance);
27118 }
27119 }
27120 return arrows;
27121 },
27122 _getArrowPoints: function _getArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance) {
27123 for (var ii = 0, ll = segments.length - 1; ii < ll; ii++) {
27124 arrows.push(this._getArrowShape(segments[ii], segments[ii + 1], lineWidth, arrowStyle, tolerance));
27125 }
27126 },
27127 _paintArrow: function _paintArrow(ctx, points, lineOpacity) {
27128 var lineWidth = this._getInternalSymbol()['lineWidth'];
27129 if (!isNumber(lineWidth) || lineWidth < 3) {
27130 lineWidth = 3;
27131 }
27132 var arrows = this._getArrows(points, lineWidth);
27133 if (!arrows.length) {
27134 return;
27135 }
27136 if (ctx.setLineDash) {
27137 ctx.setLineDash([]);
27138 }
27139 for (var i = arrows.length - 1; i >= 0; i--) {
27140 ctx.fillStyle = ctx.strokeStyle;
27141 Canvas.polygon(ctx, arrows[i], lineOpacity, lineOpacity);
27142 }
27143 }
27144});
27145
27146Polygon.include({
27147 _getPaintParams: function _getPaintParams(disableSimplify) {
27148 var maxZoom = this.getMap().getGLZoom();
27149 var prjVertexes = this._getPrjShell();
27150 var points = this._getPath2DPoints(prjVertexes, disableSimplify, maxZoom);
27151
27152 var isSplitted = points.length > 0 && Array.isArray(points[0]);
27153 if (isSplitted) {
27154 points = [[points[0]], [points[1]]];
27155 }
27156 var prjHoles = this._getPrjHoles();
27157 var holePoints = [];
27158 if (prjHoles && prjHoles.length > 0) {
27159 for (var i = 0; i < prjHoles.length; i++) {
27160 var hole = this._getPath2DPoints(prjHoles[i], disableSimplify, maxZoom);
27161 if (Array.isArray(hole) && isSplitted) {
27162 if (Array.isArray(hole[0])) {
27163 points[0].push(hole[0]);
27164 points[1].push(hole[1]);
27165 } else {
27166 points[0].push(hole);
27167 }
27168 } else {
27169 holePoints.push(hole);
27170 }
27171 }
27172 }
27173 if (!isSplitted) {
27174 points = [points];
27175 pushIn(points, holePoints);
27176 }
27177 return [points];
27178 },
27179 _paintOn: function _paintOn(ctx, points, lineOpacity, fillOpacity, dasharray) {
27180 Canvas.polygon(ctx, points, lineOpacity, fillOpacity, dasharray, this.options['smoothness']);
27181 }
27182});
27183
27184
27185
27186typeof console !== 'undefined' && console.log('maptalks v0.40.5');
27187
27188/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(107), __webpack_require__(24)))
27189
27190/***/ }),
27191/* 2 */
27192/***/ (function(module, exports, __webpack_require__) {
27193
27194var freeGlobal = __webpack_require__(23);
27195
27196/** Detect free variable `self`. */
27197var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
27198
27199/** Used as a reference to the global object. */
27200var root = freeGlobal || freeSelf || Function('return this')();
27201
27202module.exports = root;
27203
27204
27205/***/ }),
27206/* 3 */
27207/***/ (function(module, exports, __webpack_require__) {
27208
27209var baseIsEqual = __webpack_require__(38);
27210
27211/**
27212 * Performs a deep comparison between two values to determine if they are
27213 * equivalent.
27214 *
27215 * **Note:** This method supports comparing arrays, array buffers, booleans,
27216 * date objects, error objects, maps, numbers, `Object` objects, regexes,
27217 * sets, strings, symbols, and typed arrays. `Object` objects are compared
27218 * by their own, not inherited, enumerable properties. Functions and DOM
27219 * nodes are compared by strict equality, i.e. `===`.
27220 *
27221 * @static
27222 * @memberOf _
27223 * @since 0.1.0
27224 * @category Lang
27225 * @param {*} value The value to compare.
27226 * @param {*} other The other value to compare.
27227 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
27228 * @example
27229 *
27230 * var object = { 'a': 1 };
27231 * var other = { 'a': 1 };
27232 *
27233 * _.isEqual(object, other);
27234 * // => true
27235 *
27236 * object === other;
27237 * // => false
27238 */
27239function isEqual(value, other) {
27240 return baseIsEqual(value, other);
27241}
27242
27243module.exports = isEqual;
27244
27245
27246/***/ }),
27247/* 4 */
27248/***/ (function(module, exports, __webpack_require__) {
27249
27250var baseIsNative = __webpack_require__(51),
27251 getValue = __webpack_require__(56);
27252
27253/**
27254 * Gets the native function at `key` of `object`.
27255 *
27256 * @private
27257 * @param {Object} object The object to query.
27258 * @param {string} key The key of the method to get.
27259 * @returns {*} Returns the function if it's native, else `undefined`.
27260 */
27261function getNative(object, key) {
27262 var value = getValue(object, key);
27263 return baseIsNative(value) ? value : undefined;
27264}
27265
27266module.exports = getNative;
27267
27268
27269/***/ }),
27270/* 5 */
27271/***/ (function(module, exports, __webpack_require__) {
27272
27273var listCacheClear = __webpack_require__(41),
27274 listCacheDelete = __webpack_require__(42),
27275 listCacheGet = __webpack_require__(43),
27276 listCacheHas = __webpack_require__(44),
27277 listCacheSet = __webpack_require__(45);
27278
27279/**
27280 * Creates an list cache object.
27281 *
27282 * @private
27283 * @constructor
27284 * @param {Array} [entries] The key-value pairs to cache.
27285 */
27286function ListCache(entries) {
27287 var index = -1,
27288 length = entries == null ? 0 : entries.length;
27289
27290 this.clear();
27291 while (++index < length) {
27292 var entry = entries[index];
27293 this.set(entry[0], entry[1]);
27294 }
27295}
27296
27297// Add methods to `ListCache`.
27298ListCache.prototype.clear = listCacheClear;
27299ListCache.prototype['delete'] = listCacheDelete;
27300ListCache.prototype.get = listCacheGet;
27301ListCache.prototype.has = listCacheHas;
27302ListCache.prototype.set = listCacheSet;
27303
27304module.exports = ListCache;
27305
27306
27307/***/ }),
27308/* 6 */
27309/***/ (function(module, exports, __webpack_require__) {
27310
27311var eq = __webpack_require__(21);
27312
27313/**
27314 * Gets the index at which the `key` is found in `array` of key-value pairs.
27315 *
27316 * @private
27317 * @param {Array} array The array to inspect.
27318 * @param {*} key The key to search for.
27319 * @returns {number} Returns the index of the matched value, else `-1`.
27320 */
27321function assocIndexOf(array, key) {
27322 var length = array.length;
27323 while (length--) {
27324 if (eq(array[length][0], key)) {
27325 return length;
27326 }
27327 }
27328 return -1;
27329}
27330
27331module.exports = assocIndexOf;
27332
27333
27334/***/ }),
27335/* 7 */
27336/***/ (function(module, exports, __webpack_require__) {
27337
27338var Symbol = __webpack_require__(16),
27339 getRawTag = __webpack_require__(52),
27340 objectToString = __webpack_require__(53);
27341
27342/** `Object#toString` result references. */
27343var nullTag = '[object Null]',
27344 undefinedTag = '[object Undefined]';
27345
27346/** Built-in value references. */
27347var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
27348
27349/**
27350 * The base implementation of `getTag` without fallbacks for buggy environments.
27351 *
27352 * @private
27353 * @param {*} value The value to query.
27354 * @returns {string} Returns the `toStringTag`.
27355 */
27356function baseGetTag(value) {
27357 if (value == null) {
27358 return value === undefined ? undefinedTag : nullTag;
27359 }
27360 return (symToStringTag && symToStringTag in Object(value))
27361 ? getRawTag(value)
27362 : objectToString(value);
27363}
27364
27365module.exports = baseGetTag;
27366
27367
27368/***/ }),
27369/* 8 */
27370/***/ (function(module, exports, __webpack_require__) {
27371
27372var getNative = __webpack_require__(4);
27373
27374/* Built-in method references that are verified to be native. */
27375var nativeCreate = getNative(Object, 'create');
27376
27377module.exports = nativeCreate;
27378
27379
27380/***/ }),
27381/* 9 */
27382/***/ (function(module, exports, __webpack_require__) {
27383
27384var isKeyable = __webpack_require__(65);
27385
27386/**
27387 * Gets the data for `map`.
27388 *
27389 * @private
27390 * @param {Object} map The map to query.
27391 * @param {string} key The reference key.
27392 * @returns {*} Returns the map data.
27393 */
27394function getMapData(map, key) {
27395 var data = map.__data__;
27396 return isKeyable(key)
27397 ? data[typeof key == 'string' ? 'string' : 'hash']
27398 : data.map;
27399}
27400
27401module.exports = getMapData;
27402
27403
27404/***/ }),
27405/* 10 */
27406/***/ (function(module, exports) {
27407
27408/**
27409 * Checks if `value` is object-like. A value is object-like if it's not `null`
27410 * and has a `typeof` result of "object".
27411 *
27412 * @static
27413 * @memberOf _
27414 * @since 4.0.0
27415 * @category Lang
27416 * @param {*} value The value to check.
27417 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
27418 * @example
27419 *
27420 * _.isObjectLike({});
27421 * // => true
27422 *
27423 * _.isObjectLike([1, 2, 3]);
27424 * // => true
27425 *
27426 * _.isObjectLike(_.noop);
27427 * // => false
27428 *
27429 * _.isObjectLike(null);
27430 * // => false
27431 */
27432function isObjectLike(value) {
27433 return value != null && typeof value == 'object';
27434}
27435
27436module.exports = isObjectLike;
27437
27438
27439/***/ }),
27440/* 11 */
27441/***/ (function(module, exports, __webpack_require__) {
27442
27443"use strict";
27444
27445
27446if ("development".NODE_ENV === 'production') {
27447 module.exports = __webpack_require__(35);
27448} else {
27449 module.exports = __webpack_require__(36);
27450}
27451
27452
27453/***/ }),
27454/* 12 */
27455/***/ (function(module, exports, __webpack_require__) {
27456
27457"use strict";
27458/*
27459object-assign
27460(c) Sindre Sorhus
27461@license MIT
27462*/
27463
27464
27465/* eslint-disable no-unused-vars */
27466var getOwnPropertySymbols = Object.getOwnPropertySymbols;
27467var hasOwnProperty = Object.prototype.hasOwnProperty;
27468var propIsEnumerable = Object.prototype.propertyIsEnumerable;
27469
27470function toObject(val) {
27471 if (val === null || val === undefined) {
27472 throw new TypeError('Object.assign cannot be called with null or undefined');
27473 }
27474
27475 return Object(val);
27476}
27477
27478function shouldUseNative() {
27479 try {
27480 if (!Object.assign) {
27481 return false;
27482 }
27483
27484 // Detect buggy property enumeration order in older V8 versions.
27485
27486 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
27487 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
27488 test1[5] = 'de';
27489 if (Object.getOwnPropertyNames(test1)[0] === '5') {
27490 return false;
27491 }
27492
27493 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
27494 var test2 = {};
27495 for (var i = 0; i < 10; i++) {
27496 test2['_' + String.fromCharCode(i)] = i;
27497 }
27498 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
27499 return test2[n];
27500 });
27501 if (order2.join('') !== '0123456789') {
27502 return false;
27503 }
27504
27505 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
27506 var test3 = {};
27507 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
27508 test3[letter] = letter;
27509 });
27510 if (Object.keys(Object.assign({}, test3)).join('') !==
27511 'abcdefghijklmnopqrst') {
27512 return false;
27513 }
27514
27515 return true;
27516 } catch (err) {
27517 // We don't expect any of the above to throw, but better to be safe.
27518 return false;
27519 }
27520}
27521
27522module.exports = shouldUseNative() ? Object.assign : function (target, source) {
27523 var from;
27524 var to = toObject(target);
27525 var symbols;
27526
27527 for (var s = 1; s < arguments.length; s++) {
27528 from = Object(arguments[s]);
27529
27530 for (var key in from) {
27531 if (hasOwnProperty.call(from, key)) {
27532 to[key] = from[key];
27533 }
27534 }
27535
27536 if (getOwnPropertySymbols) {
27537 symbols = getOwnPropertySymbols(from);
27538 for (var i = 0; i < symbols.length; i++) {
27539 if (propIsEnumerable.call(from, symbols[i])) {
27540 to[symbols[i]] = from[symbols[i]];
27541 }
27542 }
27543 }
27544 }
27545
27546 return to;
27547};
27548
27549
27550/***/ }),
27551/* 13 */
27552/***/ (function(module, exports, __webpack_require__) {
27553
27554"use strict";
27555
27556
27557/**
27558 * Copyright (c) 2013-present, Facebook, Inc.
27559 *
27560 * This source code is licensed under the MIT license found in the
27561 * LICENSE file in the root directory of this source tree.
27562 *
27563 *
27564 */
27565
27566function makeEmptyFunction(arg) {
27567 return function () {
27568 return arg;
27569 };
27570}
27571
27572/**
27573 * This function accepts and discards inputs; it has no side effects. This is
27574 * primarily useful idiomatically for overridable function endpoints which
27575 * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
27576 */
27577var emptyFunction = function emptyFunction() {};
27578
27579emptyFunction.thatReturns = makeEmptyFunction;
27580emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
27581emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
27582emptyFunction.thatReturnsNull = makeEmptyFunction(null);
27583emptyFunction.thatReturnsThis = function () {
27584 return this;
27585};
27586emptyFunction.thatReturnsArgument = function (arg) {
27587 return arg;
27588};
27589
27590module.exports = emptyFunction;
27591
27592/***/ }),
27593/* 14 */
27594/***/ (function(module, exports, __webpack_require__) {
27595
27596"use strict";
27597/**
27598 * Copyright (c) 2013-present, Facebook, Inc.
27599 *
27600 * This source code is licensed under the MIT license found in the
27601 * LICENSE file in the root directory of this source tree.
27602 */
27603
27604
27605
27606var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
27607
27608module.exports = ReactPropTypesSecret;
27609
27610
27611/***/ }),
27612/* 15 */
27613/***/ (function(module, exports, __webpack_require__) {
27614
27615var getNative = __webpack_require__(4),
27616 root = __webpack_require__(2);
27617
27618/* Built-in method references that are verified to be native. */
27619var Map = getNative(root, 'Map');
27620
27621module.exports = Map;
27622
27623
27624/***/ }),
27625/* 16 */
27626/***/ (function(module, exports, __webpack_require__) {
27627
27628var root = __webpack_require__(2);
27629
27630/** Built-in value references. */
27631var Symbol = root.Symbol;
27632
27633module.exports = Symbol;
27634
27635
27636/***/ }),
27637/* 17 */
27638/***/ (function(module, exports) {
27639
27640/**
27641 * Checks if `value` is classified as an `Array` object.
27642 *
27643 * @static
27644 * @memberOf _
27645 * @since 0.1.0
27646 * @category Lang
27647 * @param {*} value The value to check.
27648 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
27649 * @example
27650 *
27651 * _.isArray([1, 2, 3]);
27652 * // => true
27653 *
27654 * _.isArray(document.body.children);
27655 * // => false
27656 *
27657 * _.isArray('abc');
27658 * // => false
27659 *
27660 * _.isArray(_.noop);
27661 * // => false
27662 */
27663var isArray = Array.isArray;
27664
27665module.exports = isArray;
27666
27667
27668/***/ }),
27669/* 18 */
27670/***/ (function(module, exports, __webpack_require__) {
27671
27672"use strict";
27673/**
27674 * Copyright (c) 2013-present, Facebook, Inc.
27675 *
27676 * This source code is licensed under the MIT license found in the
27677 * LICENSE file in the root directory of this source tree.
27678 *
27679 */
27680
27681
27682
27683/**
27684 * Use invariant() to assert state which your program assumes to be true.
27685 *
27686 * Provide sprintf-style format (only %s is supported) and arguments
27687 * to provide information about what broke and what you were
27688 * expecting.
27689 *
27690 * The invariant message will be stripped in production, but the invariant
27691 * will remain to ensure logic does not differ in production.
27692 */
27693
27694var validateFormat = function validateFormat(format) {};
27695
27696if ("development".NODE_ENV !== 'production') {
27697 validateFormat = function validateFormat(format) {
27698 if (format === undefined) {
27699 throw new Error('invariant requires an error message argument');
27700 }
27701 };
27702}
27703
27704function invariant(condition, format, a, b, c, d, e, f) {
27705 validateFormat(format);
27706
27707 if (!condition) {
27708 var error;
27709 if (format === undefined) {
27710 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
27711 } else {
27712 var args = [a, b, c, d, e, f];
27713 var argIndex = 0;
27714 error = new Error(format.replace(/%s/g, function () {
27715 return args[argIndex++];
27716 }));
27717 error.name = 'Invariant Violation';
27718 }
27719
27720 error.framesToPop = 1; // we don't care about invariant's own frame
27721 throw error;
27722 }
27723}
27724
27725module.exports = invariant;
27726
27727/***/ }),
27728/* 19 */
27729/***/ (function(module, exports, __webpack_require__) {
27730
27731"use strict";
27732/**
27733 * Copyright (c) 2013-present, Facebook, Inc.
27734 *
27735 * This source code is licensed under the MIT license found in the
27736 * LICENSE file in the root directory of this source tree.
27737 *
27738 */
27739
27740
27741
27742var emptyObject = {};
27743
27744if ("development".NODE_ENV !== 'production') {
27745 Object.freeze(emptyObject);
27746}
27747
27748module.exports = emptyObject;
27749
27750/***/ }),
27751/* 20 */
27752/***/ (function(module, exports, __webpack_require__) {
27753
27754"use strict";
27755/**
27756 * Copyright (c) 2013-present, Facebook, Inc.
27757 *
27758 * This source code is licensed under the MIT license found in the
27759 * LICENSE file in the root directory of this source tree.
27760 */
27761
27762
27763
27764var printWarning = function() {};
27765
27766if ("development".NODE_ENV !== 'production') {
27767 var ReactPropTypesSecret = __webpack_require__(14);
27768 var loggedTypeFailures = {};
27769
27770 printWarning = function(text) {
27771 var message = 'Warning: ' + text;
27772 if (typeof console !== 'undefined') {
27773 console.error(message);
27774 }
27775 try {
27776 // --- Welcome to debugging React ---
27777 // This error was thrown as a convenience so that you can use this stack
27778 // to find the callsite that caused this warning to fire.
27779 throw new Error(message);
27780 } catch (x) {}
27781 };
27782}
27783
27784/**
27785 * Assert that the values match with the type specs.
27786 * Error messages are memorized and will only be shown once.
27787 *
27788 * @param {object} typeSpecs Map of name to a ReactPropType
27789 * @param {object} values Runtime values that need to be type-checked
27790 * @param {string} location e.g. "prop", "context", "child context"
27791 * @param {string} componentName Name of the component for error messages.
27792 * @param {?Function} getStack Returns the component stack.
27793 * @private
27794 */
27795function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
27796 if ("development".NODE_ENV !== 'production') {
27797 for (var typeSpecName in typeSpecs) {
27798 if (typeSpecs.hasOwnProperty(typeSpecName)) {
27799 var error;
27800 // Prop type validation may throw. In case they do, we don't want to
27801 // fail the render phase where it didn't fail before. So we log it.
27802 // After these have been cleaned up, we'll let them throw.
27803 try {
27804 // This is intentionally an invariant that gets caught. It's the same
27805 // behavior as without this statement except with a better message.
27806 if (typeof typeSpecs[typeSpecName] !== 'function') {
27807 var err = Error(
27808 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
27809 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
27810 );
27811 err.name = 'Invariant Violation';
27812 throw err;
27813 }
27814 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
27815 } catch (ex) {
27816 error = ex;
27817 }
27818 if (error && !(error instanceof Error)) {
27819 printWarning(
27820 (componentName || 'React class') + ': type specification of ' +
27821 location + ' `' + typeSpecName + '` is invalid; the type checker ' +
27822 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
27823 'You may have forgotten to pass an argument to the type checker ' +
27824 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
27825 'shape all require an argument).'
27826 )
27827
27828 }
27829 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
27830 // Only monitor this failure once because there tends to be a lot of the
27831 // same error.
27832 loggedTypeFailures[error.message] = true;
27833
27834 var stack = getStack ? getStack() : '';
27835
27836 printWarning(
27837 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
27838 );
27839 }
27840 }
27841 }
27842 }
27843}
27844
27845module.exports = checkPropTypes;
27846
27847
27848/***/ }),
27849/* 21 */
27850/***/ (function(module, exports) {
27851
27852/**
27853 * Performs a
27854 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
27855 * comparison between two values to determine if they are equivalent.
27856 *
27857 * @static
27858 * @memberOf _
27859 * @since 4.0.0
27860 * @category Lang
27861 * @param {*} value The value to compare.
27862 * @param {*} other The other value to compare.
27863 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
27864 * @example
27865 *
27866 * var object = { 'a': 1 };
27867 * var other = { 'a': 1 };
27868 *
27869 * _.eq(object, object);
27870 * // => true
27871 *
27872 * _.eq(object, other);
27873 * // => false
27874 *
27875 * _.eq('a', 'a');
27876 * // => true
27877 *
27878 * _.eq('a', Object('a'));
27879 * // => false
27880 *
27881 * _.eq(NaN, NaN);
27882 * // => true
27883 */
27884function eq(value, other) {
27885 return value === other || (value !== value && other !== other);
27886}
27887
27888module.exports = eq;
27889
27890
27891/***/ }),
27892/* 22 */
27893/***/ (function(module, exports, __webpack_require__) {
27894
27895var baseGetTag = __webpack_require__(7),
27896 isObject = __webpack_require__(25);
27897
27898/** `Object#toString` result references. */
27899var asyncTag = '[object AsyncFunction]',
27900 funcTag = '[object Function]',
27901 genTag = '[object GeneratorFunction]',
27902 proxyTag = '[object Proxy]';
27903
27904/**
27905 * Checks if `value` is classified as a `Function` object.
27906 *
27907 * @static
27908 * @memberOf _
27909 * @since 0.1.0
27910 * @category Lang
27911 * @param {*} value The value to check.
27912 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
27913 * @example
27914 *
27915 * _.isFunction(_);
27916 * // => true
27917 *
27918 * _.isFunction(/abc/);
27919 * // => false
27920 */
27921function isFunction(value) {
27922 if (!isObject(value)) {
27923 return false;
27924 }
27925 // The use of `Object#toString` avoids issues with the `typeof` operator
27926 // in Safari 9 which returns 'object' for typed arrays and other constructors.
27927 var tag = baseGetTag(value);
27928 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
27929}
27930
27931module.exports = isFunction;
27932
27933
27934/***/ }),
27935/* 23 */
27936/***/ (function(module, exports, __webpack_require__) {
27937
27938/* WEBPACK VAR INJECTION */(function(global) {/** Detect free variable `global` from Node.js. */
27939var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
27940
27941module.exports = freeGlobal;
27942
27943/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(24)))
27944
27945/***/ }),
27946/* 24 */
27947/***/ (function(module, exports) {
27948
27949var g;
27950
27951// This works in non-strict mode
27952g = (function() {
27953 return this;
27954})();
27955
27956try {
27957 // This works if eval is allowed (see CSP)
27958 g = g || Function("return this")() || (1,eval)("this");
27959} catch(e) {
27960 // This works if the window reference is available
27961 if(typeof window === "object")
27962 g = window;
27963}
27964
27965// g can still be undefined, but nothing to do about it...
27966// We return undefined, instead of nothing here, so it's
27967// easier to handle this case. if(!global) { ...}
27968
27969module.exports = g;
27970
27971
27972/***/ }),
27973/* 25 */
27974/***/ (function(module, exports) {
27975
27976/**
27977 * Checks if `value` is the
27978 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
27979 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
27980 *
27981 * @static
27982 * @memberOf _
27983 * @since 0.1.0
27984 * @category Lang
27985 * @param {*} value The value to check.
27986 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
27987 * @example
27988 *
27989 * _.isObject({});
27990 * // => true
27991 *
27992 * _.isObject([1, 2, 3]);
27993 * // => true
27994 *
27995 * _.isObject(_.noop);
27996 * // => true
27997 *
27998 * _.isObject(null);
27999 * // => false
28000 */
28001function isObject(value) {
28002 var type = typeof value;
28003 return value != null && (type == 'object' || type == 'function');
28004}
28005
28006module.exports = isObject;
28007
28008
28009/***/ }),
28010/* 26 */
28011/***/ (function(module, exports) {
28012
28013/** Used for built-in method references. */
28014var funcProto = Function.prototype;
28015
28016/** Used to resolve the decompiled source of functions. */
28017var funcToString = funcProto.toString;
28018
28019/**
28020 * Converts `func` to its source code.
28021 *
28022 * @private
28023 * @param {Function} func The function to convert.
28024 * @returns {string} Returns the source code.
28025 */
28026function toSource(func) {
28027 if (func != null) {
28028 try {
28029 return funcToString.call(func);
28030 } catch (e) {}
28031 try {
28032 return (func + '');
28033 } catch (e) {}
28034 }
28035 return '';
28036}
28037
28038module.exports = toSource;
28039
28040
28041/***/ }),
28042/* 27 */
28043/***/ (function(module, exports, __webpack_require__) {
28044
28045var mapCacheClear = __webpack_require__(57),
28046 mapCacheDelete = __webpack_require__(64),
28047 mapCacheGet = __webpack_require__(66),
28048 mapCacheHas = __webpack_require__(67),
28049 mapCacheSet = __webpack_require__(68);
28050
28051/**
28052 * Creates a map cache object to store key-value pairs.
28053 *
28054 * @private
28055 * @constructor
28056 * @param {Array} [entries] The key-value pairs to cache.
28057 */
28058function MapCache(entries) {
28059 var index = -1,
28060 length = entries == null ? 0 : entries.length;
28061
28062 this.clear();
28063 while (++index < length) {
28064 var entry = entries[index];
28065 this.set(entry[0], entry[1]);
28066 }
28067}
28068
28069// Add methods to `MapCache`.
28070MapCache.prototype.clear = mapCacheClear;
28071MapCache.prototype['delete'] = mapCacheDelete;
28072MapCache.prototype.get = mapCacheGet;
28073MapCache.prototype.has = mapCacheHas;
28074MapCache.prototype.set = mapCacheSet;
28075
28076module.exports = MapCache;
28077
28078
28079/***/ }),
28080/* 28 */
28081/***/ (function(module, exports, __webpack_require__) {
28082
28083var SetCache = __webpack_require__(69),
28084 arraySome = __webpack_require__(72),
28085 cacheHas = __webpack_require__(73);
28086
28087/** Used to compose bitmasks for value comparisons. */
28088var COMPARE_PARTIAL_FLAG = 1,
28089 COMPARE_UNORDERED_FLAG = 2;
28090
28091/**
28092 * A specialized version of `baseIsEqualDeep` for arrays with support for
28093 * partial deep comparisons.
28094 *
28095 * @private
28096 * @param {Array} array The array to compare.
28097 * @param {Array} other The other array to compare.
28098 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
28099 * @param {Function} customizer The function to customize comparisons.
28100 * @param {Function} equalFunc The function to determine equivalents of values.
28101 * @param {Object} stack Tracks traversed `array` and `other` objects.
28102 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
28103 */
28104function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
28105 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
28106 arrLength = array.length,
28107 othLength = other.length;
28108
28109 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
28110 return false;
28111 }
28112 // Assume cyclic values are equal.
28113 var stacked = stack.get(array);
28114 if (stacked && stack.get(other)) {
28115 return stacked == other;
28116 }
28117 var index = -1,
28118 result = true,
28119 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
28120
28121 stack.set(array, other);
28122 stack.set(other, array);
28123
28124 // Ignore non-index properties.
28125 while (++index < arrLength) {
28126 var arrValue = array[index],
28127 othValue = other[index];
28128
28129 if (customizer) {
28130 var compared = isPartial
28131 ? customizer(othValue, arrValue, index, other, array, stack)
28132 : customizer(arrValue, othValue, index, array, other, stack);
28133 }
28134 if (compared !== undefined) {
28135 if (compared) {
28136 continue;
28137 }
28138 result = false;
28139 break;
28140 }
28141 // Recursively compare arrays (susceptible to call stack limits).
28142 if (seen) {
28143 if (!arraySome(other, function(othValue, othIndex) {
28144 if (!cacheHas(seen, othIndex) &&
28145 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
28146 return seen.push(othIndex);
28147 }
28148 })) {
28149 result = false;
28150 break;
28151 }
28152 } else if (!(
28153 arrValue === othValue ||
28154 equalFunc(arrValue, othValue, bitmask, customizer, stack)
28155 )) {
28156 result = false;
28157 break;
28158 }
28159 }
28160 stack['delete'](array);
28161 stack['delete'](other);
28162 return result;
28163}
28164
28165module.exports = equalArrays;
28166
28167
28168/***/ }),
28169/* 29 */
28170/***/ (function(module, exports, __webpack_require__) {
28171
28172/* WEBPACK VAR INJECTION */(function(module) {var root = __webpack_require__(2),
28173 stubFalse = __webpack_require__(90);
28174
28175/** Detect free variable `exports`. */
28176var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
28177
28178/** Detect free variable `module`. */
28179var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
28180
28181/** Detect the popular CommonJS extension `module.exports`. */
28182var moduleExports = freeModule && freeModule.exports === freeExports;
28183
28184/** Built-in value references. */
28185var Buffer = moduleExports ? root.Buffer : undefined;
28186
28187/* Built-in method references for those with the same name as other `lodash` methods. */
28188var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
28189
28190/**
28191 * Checks if `value` is a buffer.
28192 *
28193 * @static
28194 * @memberOf _
28195 * @since 4.3.0
28196 * @category Lang
28197 * @param {*} value The value to check.
28198 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
28199 * @example
28200 *
28201 * _.isBuffer(new Buffer(2));
28202 * // => true
28203 *
28204 * _.isBuffer(new Uint8Array(2));
28205 * // => false
28206 */
28207var isBuffer = nativeIsBuffer || stubFalse;
28208
28209module.exports = isBuffer;
28210
28211/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(30)(module)))
28212
28213/***/ }),
28214/* 30 */
28215/***/ (function(module, exports) {
28216
28217module.exports = function(module) {
28218 if(!module.webpackPolyfill) {
28219 module.deprecate = function() {};
28220 module.paths = [];
28221 // module.parent = undefined by default
28222 if(!module.children) module.children = [];
28223 Object.defineProperty(module, "loaded", {
28224 enumerable: true,
28225 get: function() {
28226 return module.l;
28227 }
28228 });
28229 Object.defineProperty(module, "id", {
28230 enumerable: true,
28231 get: function() {
28232 return module.i;
28233 }
28234 });
28235 module.webpackPolyfill = 1;
28236 }
28237 return module;
28238};
28239
28240
28241/***/ }),
28242/* 31 */
28243/***/ (function(module, exports, __webpack_require__) {
28244
28245var baseIsTypedArray = __webpack_require__(92),
28246 baseUnary = __webpack_require__(93),
28247 nodeUtil = __webpack_require__(94);
28248
28249/* Node.js helper references. */
28250var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
28251
28252/**
28253 * Checks if `value` is classified as a typed array.
28254 *
28255 * @static
28256 * @memberOf _
28257 * @since 3.0.0
28258 * @category Lang
28259 * @param {*} value The value to check.
28260 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
28261 * @example
28262 *
28263 * _.isTypedArray(new Uint8Array);
28264 * // => true
28265 *
28266 * _.isTypedArray([]);
28267 * // => false
28268 */
28269var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
28270
28271module.exports = isTypedArray;
28272
28273
28274/***/ }),
28275/* 32 */
28276/***/ (function(module, exports) {
28277
28278/** Used as references for various `Number` constants. */
28279var MAX_SAFE_INTEGER = 9007199254740991;
28280
28281/**
28282 * Checks if `value` is a valid array-like length.
28283 *
28284 * **Note:** This method is loosely based on
28285 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
28286 *
28287 * @static
28288 * @memberOf _
28289 * @since 4.0.0
28290 * @category Lang
28291 * @param {*} value The value to check.
28292 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
28293 * @example
28294 *
28295 * _.isLength(3);
28296 * // => true
28297 *
28298 * _.isLength(Number.MIN_VALUE);
28299 * // => false
28300 *
28301 * _.isLength(Infinity);
28302 * // => false
28303 *
28304 * _.isLength('3');
28305 * // => false
28306 */
28307function isLength(value) {
28308 return typeof value == 'number' &&
28309 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
28310}
28311
28312module.exports = isLength;
28313
28314
28315/***/ }),
28316/* 33 */
28317/***/ (function(module, __webpack_exports__, __webpack_require__) {
28318
28319"use strict";
28320Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
28321
28322// EXTERNAL MODULE: ./node_modules/maptalks/dist/maptalks.css
28323var maptalks = __webpack_require__(34);
28324var maptalks_default = /*#__PURE__*/__webpack_require__.n(maptalks);
28325
28326// EXTERNAL MODULE: ./node_modules/react/index.js
28327var react = __webpack_require__(11);
28328var react_default = /*#__PURE__*/__webpack_require__.n(react);
28329
28330// EXTERNAL MODULE: ./node_modules/lodash/isEqual.js
28331var isEqual = __webpack_require__(3);
28332var isEqual_default = /*#__PURE__*/__webpack_require__.n(isEqual);
28333
28334// EXTERNAL MODULE: ./node_modules/prop-types/index.js
28335var prop_types = __webpack_require__(0);
28336var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types);
28337
28338// EXTERNAL MODULE: ./node_modules/maptalks/dist/maptalks.es.js
28339var maptalks_es = __webpack_require__(1);
28340
28341// CONCATENATED MODULE: ./src/map/index.js
28342var _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; }; }();
28343
28344function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28345
28346function _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; }
28347
28348function _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; }
28349
28350
28351
28352
28353
28354
28355var map_Map = function (_React$Component) {
28356 _inherits(Map, _React$Component);
28357
28358 function Map(props) {
28359 _classCallCheck(this, Map);
28360
28361 var _this = _possibleConstructorReturn(this, (Map.__proto__ || Object.getPrototypeOf(Map)).call(this, props));
28362
28363 _this.setRef = function () {
28364 var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
28365
28366 _this.container = x;
28367 };
28368
28369 _this.state = {
28370 isLoad: false,
28371 isMounted: false
28372 };
28373
28374 /**
28375 * map
28376 * @type {null}
28377 */
28378 _this.map = null;
28379
28380 _this.container = null;
28381
28382 _this.events = {};
28383 return _this;
28384 }
28385
28386 _createClass(Map, [{
28387 key: 'getChildContext',
28388 value: function getChildContext() {
28389 return {
28390 map: this.map
28391 };
28392 }
28393
28394 // shouldComponentUpdate (nextProps) {
28395 // // const { isMounted } = this.state;
28396 // const { children } = nextProps;
28397 // return children.length > 0;
28398 // }
28399
28400 // componentWillUpdate(nextProps, nextState)
28401 // componentDidUpdate(prevProps, prevState)
28402
28403 }, {
28404 key: 'componentWillReceiveProps',
28405 value: function componentWillReceiveProps(nextProps) {
28406 var _props = this.props,
28407 center = _props.center,
28408 zoom = _props.zoom,
28409 spatialReference = _props.spatialReference,
28410 cursor = _props.cursor,
28411 maxExtent = _props.maxExtent,
28412 maxZoom = _props.maxZoom,
28413 minZoom = _props.minZoom,
28414 pitch = _props.pitch,
28415 bearing = _props.bearing,
28416 fov = _props.fov;
28417
28418 if (!this.map) {
28419 return null;
28420 }
28421
28422 if (!isEqual_default()(nextProps.center, center) || !isEqual_default()(nextProps.zoom, zoom)) {
28423 if (!isEqual_default()(nextProps.center, center) && isEqual_default()(nextProps.zoom, zoom)) {
28424 this.map.setCenter(nextProps.center);
28425 }
28426 if (isEqual_default()(nextProps.center, center) && !isEqual_default()(nextProps.zoom, zoom)) {
28427 this.map.setZoom(nextProps.zoom);
28428 }
28429 if (!isEqual_default()(nextProps.center, center) && !isEqual_default()(nextProps.zoom, zoom)) {
28430 this.map.setCenterAndZoom(nextProps.center, nextProps.zoom);
28431 }
28432 }
28433
28434 if (!isEqual_default()(nextProps.spatialReference, spatialReference)) {
28435 this.map.setSpatialReference(nextProps.zoom);
28436 }
28437 if (!isEqual_default()(nextProps.cursor, cursor)) {
28438 this.map.setCursor(nextProps.cursor);
28439 }
28440 if (!isEqual_default()(nextProps.maxExtent, maxExtent)) {
28441 this.map.setMaxExtent(nextProps.maxExtent);
28442 }
28443 if (!isEqual_default()(nextProps.maxZoom, maxZoom)) {
28444 this.map.setMaxZoom(nextProps.maxZoom);
28445 }
28446 if (!isEqual_default()(nextProps.minZoom, minZoom)) {
28447 this.map.setMinZoom(nextProps.minZoom);
28448 }
28449 if (!isEqual_default()(nextProps.fov, fov)) {
28450 this.map.setFov(nextProps.fov);
28451 }
28452 if (!isEqual_default()(nextProps.bearing, bearing)) {
28453 this.map.setBearing(nextProps.bearing);
28454 }
28455 if (!isEqual_default()(nextProps.pitch, pitch)) {
28456 this.map.setPitch(nextProps.pitch);
28457 }
28458 return null;
28459 }
28460
28461 /**
28462 * set base layers
28463 * @param layers
28464 * @returns {null}
28465 */
28466
28467 }, {
28468 key: 'setBaseLayer',
28469 value: function setBaseLayer(layers) {
28470 if (!this.map) {
28471 return null;
28472 }
28473 if (layers && layers.length > 0) {
28474 this.map.setBaseLayer();
28475 }
28476 }
28477
28478 /**
28479 * set layers
28480 * @param layers
28481 * @returns {null}
28482 */
28483
28484 }, {
28485 key: 'setLayers',
28486 value: function setLayers(layers) {
28487 if (!this.map) {
28488 return null;
28489 }
28490 if (layers && layers.length > 0) {
28491 // map.addLayer();
28492 }
28493 }
28494 }, {
28495 key: 'componentDidMount',
28496 value: function componentDidMount() {
28497 var _props2 = this.props,
28498 center = _props2.center,
28499 zoom = _props2.zoom,
28500 events = _props2.events,
28501 fov = _props2.fov,
28502 bearing = _props2.bearing,
28503 pitch = _props2.pitch;
28504
28505 var options = {
28506 zoom: zoom,
28507 center: center,
28508 fov: Math.max(0.01, Math.min(59, fov)),
28509 bearing: bearing,
28510 pitch: pitch
28511 };
28512 this.map = new maptalks_es["e" /* Map */](this.container, options);
28513 if (this.map.isLoaded()) {
28514 this.setState({
28515 isLoad: true
28516 });
28517 for (var key in events) {
28518 if (key === 'onload') {
28519 events[key](this.map, this);
28520 } else {
28521 this.map.on(key, events[key], this);
28522 }
28523 }
28524 }
28525 this.setState({
28526 isMounted: true
28527 });
28528 }
28529 }, {
28530 key: 'componentWillUnmount',
28531 value: function componentWillUnmount() {
28532 if (this.map) {
28533 this.map = null;
28534 this.setState({
28535 isMounted: false
28536 });
28537 }
28538 }
28539 }, {
28540 key: 'render',
28541 value: function render() {
28542 var _state = this.state,
28543 isMounted = _state.isMounted,
28544 isLoad = _state.isLoad;
28545 var _props3 = this.props,
28546 className = _props3.className,
28547 children = _props3.children;
28548
28549 return react_default.a.createElement(
28550 'div',
28551 { ref: this.setRef, className: className },
28552 isMounted && isLoad ? children : null
28553 );
28554 }
28555 }]);
28556
28557 return Map;
28558}(react_default.a.Component);
28559
28560map_Map.defaultProps = {};
28561map_Map.childContextTypes = {
28562 map: prop_types_default.a.instanceOf(maptalks_es["e" /* Map */])
28563};
28564
28565
28566/* harmony default export */ var src_map = (map_Map);
28567// CONCATENATED MODULE: ./src/layers/Layer.js
28568var Layer__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; }; }();
28569
28570function Layer__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28571
28572function Layer__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; }
28573
28574function Layer__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; }
28575
28576
28577
28578
28579
28580var Layer_TileLayer = function (_React$Component) {
28581 Layer__inherits(TileLayer, _React$Component);
28582
28583 function TileLayer(props, context) {
28584 Layer__classCallCheck(this, TileLayer);
28585
28586 var _this = Layer__possibleConstructorReturn(this, (TileLayer.__proto__ || Object.getPrototypeOf(TileLayer)).call(this, props, context));
28587
28588 _this.layer = null;
28589 return _this;
28590 }
28591
28592 Layer__createClass(TileLayer, [{
28593 key: 'render',
28594 value: function render() {
28595 return null;
28596 }
28597
28598 /**
28599 * create layer
28600 * @param nextProps
28601 */
28602
28603 }, {
28604 key: 'createLayer',
28605 value: function createLayer(nextProps) {
28606 if (nextProps) {
28607 var map = this.context.map;
28608
28609 if (!map) return;
28610 if (this.layer) {
28611 map.removeLayer(this.layer);
28612 }
28613 var id = nextProps.id;
28614
28615 this.layer = new maptalks_es["c" /* Layer */](id, nextProps);
28616 map.addLayer(this.layer);
28617 }
28618 }
28619 }, {
28620 key: 'componentDidMount',
28621 value: function componentDidMount() {
28622 this.createLayer(this.props);
28623 }
28624 }, {
28625 key: 'componentWillReceiveProps',
28626 value: function componentWillReceiveProps(nextProps) {
28627 this.createLayer(nextProps);
28628 return null;
28629 }
28630 }, {
28631 key: 'componentWillUnmount',
28632 value: function componentWillUnmount() {
28633 var map = this.context.map;
28634
28635 if (!map || !this.layer) return;
28636 map.removeLayer(this.layer);
28637 }
28638 }]);
28639
28640 return TileLayer;
28641}(react_default.a.Component);
28642
28643Layer_TileLayer.defaultProps = {
28644 attribution: null,
28645 minZoom: null,
28646 maxZoom: null,
28647 visible: true,
28648 opacity: 1,
28649 globalCompositeOperation: null,
28650 renderer: 'canvas',
28651 debugOutline: '#0f0',
28652 cssFilter: null,
28653 forceRenderOnMoving: false,
28654 forceRenderOnZooming: false,
28655 forceRenderOnRotating: false
28656};
28657Layer_TileLayer.contextTypes = {
28658 map: prop_types_default.a.instanceOf(maptalks_es["e" /* Map */])
28659};
28660
28661
28662/* harmony default export */ var Layer = (Layer_TileLayer);
28663// CONCATENATED MODULE: ./src/layers/tile/TileLayer.js
28664var TileLayer__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; }; }();
28665
28666function TileLayer__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28667
28668function TileLayer__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; }
28669
28670function TileLayer__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; }
28671
28672
28673
28674
28675
28676var TileLayer_TileLayer = function (_Layer) {
28677 TileLayer__inherits(TileLayer, _Layer);
28678
28679 function TileLayer(props, context) {
28680 TileLayer__classCallCheck(this, TileLayer);
28681
28682 /**
28683 * layer state
28684 * @type {{isAdd: boolean}}
28685 */
28686 var _this = TileLayer__possibleConstructorReturn(this, (TileLayer.__proto__ || Object.getPrototypeOf(TileLayer)).call(this, props, context));
28687
28688 _this.state = {
28689 isAdd: false
28690 };
28691
28692 _this.layer = null;
28693 return _this;
28694 }
28695
28696 /**
28697 * create layer
28698 * @param nextProps
28699 */
28700
28701
28702 TileLayer__createClass(TileLayer, [{
28703 key: 'createLayer',
28704 value: function createLayer(nextProps) {
28705 var _this2 = this;
28706
28707 if (nextProps) {
28708 var map = this.context.map;
28709
28710 if (!map) return;
28711 if (this.layer) {
28712 map.removeLayer(this.layer);
28713 }
28714 var id = nextProps.id;
28715
28716 this.layer = new maptalks_es["l" /* TileLayer */](id, nextProps);
28717 this.layer.on('add', function () {
28718 _this2.setState({
28719 isAdd: true
28720 });
28721 });
28722 map.addLayer(this.layer);
28723 }
28724 }
28725 }]);
28726
28727 return TileLayer;
28728}(Layer);
28729
28730TileLayer_TileLayer.defaultProps = {
28731 subdomains: null,
28732 repeatWorld: true,
28733 background: true,
28734 backgroundZoomDiff: 6,
28735 loadingLimitOnInteracting: 3,
28736 placeholder: false,
28737 crossOrigin: null,
28738 tileSize: [256, 256],
28739 offset: [0, 0],
28740 tileSystem: null,
28741 fadeAnimation: true,
28742 debug: false,
28743 spatialReference: null,
28744 maxCacheSize: 256,
28745 clipByPitch: true,
28746 maxAvailableZoom: null,
28747 cascadeTiles: true,
28748 minPitchToCascade: 35
28749};
28750TileLayer_TileLayer.propTypes = {
28751 urlTemplate: prop_types_default.a.oneOfType([prop_types_default.a.string, prop_types_default.a.func]).isRequired,
28752 subdomains: prop_types_default.a.oneOfType([prop_types_default.a.arrayOf(prop_types_default.a.string), prop_types_default.a.arrayOf(prop_types_default.a.number)]),
28753 repeatWorld: prop_types_default.a.bool,
28754 background: prop_types_default.a.bool,
28755 backgroundZoomDiff: prop_types_default.a.number,
28756 loadingLimitOnInteracting: prop_types_default.a.number,
28757 placeholder: prop_types_default.a.bool,
28758 crossOrigin: prop_types_default.a.string,
28759 tileSize: prop_types_default.a.arrayOf(prop_types_default.a.number),
28760 offset: prop_types_default.a.arrayOf(prop_types_default.a.number),
28761 tileSystem: prop_types_default.a.arrayOf(prop_types_default.a.number),
28762 fadeAnimation: prop_types_default.a.bool,
28763 debug: prop_types_default.a.bool,
28764 spatialReference: prop_types_default.a.object,
28765 maxCacheSize: prop_types_default.a.number,
28766 clipByPitch: prop_types_default.a.bool,
28767 maxAvailableZoom: prop_types_default.a.number,
28768 cascadeTiles: prop_types_default.a.bool,
28769 minPitchToCascade: prop_types_default.a.number
28770};
28771
28772
28773/* harmony default export */ var tile_TileLayer = (TileLayer_TileLayer);
28774// CONCATENATED MODULE: ./src/layers/OverlayLayer.js
28775var OverlayLayer__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; }; }();
28776
28777function OverlayLayer__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28778
28779function OverlayLayer__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; }
28780
28781function OverlayLayer__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; }
28782
28783
28784
28785
28786
28787var OverlayLayer_OverlayLayer = function (_Layer) {
28788 OverlayLayer__inherits(OverlayLayer, _Layer);
28789
28790 function OverlayLayer(props, context) {
28791 OverlayLayer__classCallCheck(this, OverlayLayer);
28792
28793 var _this = OverlayLayer__possibleConstructorReturn(this, (OverlayLayer.__proto__ || Object.getPrototypeOf(OverlayLayer)).call(this, props, context));
28794
28795 _this.layer = null;
28796 return _this;
28797 }
28798
28799 /**
28800 * create layer
28801 * @param nextProps
28802 */
28803
28804
28805 OverlayLayer__createClass(OverlayLayer, [{
28806 key: 'createLayer',
28807 value: function createLayer(nextProps) {
28808 if (nextProps) {
28809 var map = this.context.map;
28810
28811 if (!map) return;
28812 if (this.layer) {
28813 map.removeLayer(this.layer);
28814 }
28815 var id = nextProps.id,
28816 geometries = nextProps.geometries;
28817
28818 this.layer = new maptalks_es["j" /* OverlayLayer */](id, geometries, nextProps);
28819 map.addLayer(this.layer);
28820 }
28821 }
28822 }]);
28823
28824 return OverlayLayer;
28825}(Layer);
28826
28827OverlayLayer_OverlayLayer.defaultProps = {
28828 drawImmediate: false
28829};
28830OverlayLayer_OverlayLayer.propTypes = {
28831 drawImmediate: prop_types_default.a.bool
28832};
28833
28834
28835/* harmony default export */ var layers_OverlayLayer = (OverlayLayer_OverlayLayer);
28836// CONCATENATED MODULE: ./src/layers/VectorLayer.js
28837var VectorLayer__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; }; }();
28838
28839function VectorLayer__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28840
28841function VectorLayer__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; }
28842
28843function VectorLayer__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; }
28844
28845
28846
28847
28848
28849var VectorLayer_VectorLayer = function (_OverlayLayer) {
28850 VectorLayer__inherits(VectorLayer, _OverlayLayer);
28851
28852 function VectorLayer(props, context) {
28853 VectorLayer__classCallCheck(this, VectorLayer);
28854
28855 var _this = VectorLayer__possibleConstructorReturn(this, (VectorLayer.__proto__ || Object.getPrototypeOf(VectorLayer)).call(this, props, context));
28856
28857 _this.layer = null;
28858
28859 /**
28860 * layer state
28861 * @type {{isAdd: boolean}}
28862 */
28863 _this.state = {
28864 isAdd: false
28865 };
28866 return _this;
28867 }
28868
28869 /**
28870 * create layer
28871 * @param nextProps
28872 */
28873
28874
28875 VectorLayer__createClass(VectorLayer, [{
28876 key: 'createLayer',
28877 value: function createLayer(nextProps) {
28878 var _this2 = this;
28879
28880 if (nextProps) {
28881 var map = this.context.map;
28882
28883 if (!map) return;
28884 if (this.layer) {
28885 map.removeLayer(this.layer);
28886 }
28887 var id = nextProps.id,
28888 geometries = nextProps.geometries;
28889
28890 this.layer = new maptalks_es["m" /* VectorLayer */](id, geometries, nextProps);
28891 this.layer.on('add', function () {
28892 _this2.setState({
28893 isAdd: true
28894 });
28895 });
28896 map.addLayer(this.layer);
28897 }
28898 }
28899 }, {
28900 key: 'componentWillReceiveProps',
28901 value: function componentWillReceiveProps(nextProps) {
28902 this.createLayer(nextProps);
28903 }
28904 }, {
28905 key: 'getChildContext',
28906 value: function getChildContext() {
28907 return {
28908 layer: this.layer
28909 };
28910 }
28911
28912 /**
28913 * render
28914 * @returns {*}
28915 */
28916
28917 }, {
28918 key: 'render',
28919 value: function render() {
28920 var isAdd = this.state.isAdd;
28921
28922 console.log(isAdd);
28923 var children = this.props.children;
28924
28925 return isAdd ? children : null;
28926 }
28927 }]);
28928
28929 return VectorLayer;
28930}(layers_OverlayLayer);
28931
28932VectorLayer_VectorLayer.defaultProps = {
28933 cursor: 'default',
28934 enableSimplify: true,
28935 geometryEvents: true,
28936 defaultIconSize: [20, 20],
28937 cacheVectorOnCanvas: true,
28938 cacheSvgOnCanvas: true,
28939 enableAltitude: false,
28940 altitudeProperty: 'altitude',
28941 drawAltitude: false
28942};
28943VectorLayer_VectorLayer.propTypes = {
28944 cursor: prop_types_default.a.string,
28945 enableSimplify: prop_types_default.a.bool,
28946 geometryEvents: prop_types_default.a.bool,
28947 defaultIconSize: prop_types_default.a.arrayOf(prop_types_default.a.number),
28948 cacheVectorOnCanvas: prop_types_default.a.bool,
28949 cacheSvgOnCanvas: prop_types_default.a.bool,
28950 enableAltitude: prop_types_default.a.bool,
28951 altitudeProperty: prop_types_default.a.string,
28952 drawAltitude: prop_types_default.a.bool
28953};
28954VectorLayer_VectorLayer.childContextTypes = {
28955 layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */])
28956};
28957
28958
28959/* harmony default export */ var layers_VectorLayer = (VectorLayer_VectorLayer);
28960// CONCATENATED MODULE: ./src/layers/index.js
28961// import Layer from './Layer';
28962
28963// import GroupTileLayer from './tile/GroupTileLayer';
28964// import WMSTileLayer from './tile/WMSTileLayer';
28965// import CanvasTileLayer from './tile/CanvasTileLayer';
28966// import ImageLayer from './ImageLayer';
28967
28968
28969// import CanvasLayer from './CanvasLayer';
28970// import ParticleLayer from './ParticleLayer';
28971// import TileSystem from './tile/tileinfo/TileSystem';
28972// import TileConfig from './tile/tileinfo/TileConfig';
28973
28974
28975// CONCATENATED MODULE: ./src/geometry/Geometry.js
28976var Geometry__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; }; }();
28977
28978function Geometry__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28979
28980function Geometry__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; }
28981
28982function Geometry__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; }
28983
28984
28985
28986
28987
28988var Geometry_Geometry = function (_React$Component) {
28989 Geometry__inherits(Geometry, _React$Component);
28990
28991 /**
28992 * super class
28993 * @param props
28994 * @param context
28995 */
28996 function Geometry(props, context) {
28997 Geometry__classCallCheck(this, Geometry);
28998
28999 /**
29000 * geometry
29001 * @type {null}
29002 */
29003 var _this = Geometry__possibleConstructorReturn(this, (Geometry.__proto__ || Object.getPrototypeOf(Geometry)).call(this, props, context));
29004
29005 _this.geometry = null;
29006 return _this;
29007 }
29008
29009 /**
29010 * create geometry
29011 * @param nextProps
29012 */
29013
29014
29015 Geometry__createClass(Geometry, [{
29016 key: 'createGeometry',
29017 value: function createGeometry(nextProps) {
29018 if (nextProps) {
29019 var layer = this.context.layer;
29020
29021 if (!layer) return;
29022 this.geometry = new maptalks_es["b" /* Geometry */]();
29023 layer.addGeometry(this.geometry);
29024 }
29025 }
29026 }, {
29027 key: 'componentDidMount',
29028 value: function componentDidMount() {
29029 this.createGeometry(this.props);
29030 }
29031 }, {
29032 key: 'componentWillReceiveProps',
29033 value: function componentWillReceiveProps(nextProps) {
29034 this.createGeometry(nextProps);
29035 return null;
29036 }
29037 }, {
29038 key: 'componentWillUnmount',
29039 value: function componentWillUnmount() {
29040 var layer = this.context.layer;
29041
29042 if (!layer) return;
29043 layer.removeGeometry(this.geometry);
29044 }
29045
29046 /**
29047 * render
29048 * @returns {null}
29049 */
29050
29051 }, {
29052 key: 'render',
29053 value: function render() {
29054 return null;
29055 }
29056 }]);
29057
29058 return Geometry;
29059}(react_default.a.Component);
29060
29061Geometry_Geometry.contextTypes = {
29062 layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */])
29063};
29064
29065
29066/* harmony default export */ var geometry_Geometry = (Geometry_Geometry);
29067// CONCATENATED MODULE: ./src/geometry/Marker.js
29068var Marker__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; }; }();
29069
29070function Marker__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29071
29072function Marker__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; }
29073
29074function Marker__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; }
29075
29076
29077
29078
29079
29080
29081var Marker_Marker = function (_Geometry) {
29082 Marker__inherits(Marker, _Geometry);
29083
29084 /**
29085 * super class
29086 * @param props
29087 * @param context
29088 */
29089 function Marker(props, context) {
29090 Marker__classCallCheck(this, Marker);
29091
29092 /**
29093 * geometry
29094 * @type {null}
29095 */
29096 var _this = Marker__possibleConstructorReturn(this, (Marker.__proto__ || Object.getPrototypeOf(Marker)).call(this, props, context));
29097
29098 _this.geometry = null;
29099 return _this;
29100 }
29101
29102 /**
29103 * create geometry
29104 * @param nextProps
29105 */
29106
29107
29108 Marker__createClass(Marker, [{
29109 key: 'createGeometry',
29110 value: function createGeometry(nextProps) {
29111 if (nextProps) {
29112 var layer = this.context.layer;
29113
29114 if (!layer) return;
29115 var id = nextProps.id,
29116 coordinates = nextProps.coordinates,
29117 options = nextProps.options;
29118
29119 this.geometry = new maptalks_es["f" /* Marker */](coordinates, options);
29120 this.geometry.setId(id);
29121 this.geometry.setProperties(options);
29122 layer.addGeometry(this.geometry);
29123 }
29124 }
29125 }, {
29126 key: 'componentDidMount',
29127 value: function componentDidMount() {
29128 this.createGeometry(this.props);
29129 }
29130 }, {
29131 key: 'componentWillReceiveProps',
29132 value: function componentWillReceiveProps(nextProps) {
29133 var _props = this.props,
29134 id = _props.id,
29135 coordinates = _props.coordinates,
29136 options = _props.options;
29137
29138 if (!this.geometry) {
29139 return null;
29140 }
29141 if (!isEqual_default()(nextProps.id, id)) {
29142 this.geometry.setId(nextProps.id);
29143 }
29144 if (!isEqual_default()(nextProps.coordinates, coordinates)) {
29145 this.geometry.setCoordinates(nextProps.coordinates);
29146 }
29147 if (!isEqual_default()(nextProps.options, options)) {
29148 this.geometry.setProperties(nextProps.options);
29149 }
29150 }
29151 }, {
29152 key: 'componentWillUnmount',
29153 value: function componentWillUnmount() {
29154 var layer = this.context.layer;
29155
29156 if (!layer) return;
29157 layer.removeGeometry(this.geometry);
29158 }
29159
29160 /**
29161 * render
29162 * @returns {null}
29163 */
29164
29165 }, {
29166 key: 'render',
29167 value: function render() {
29168 return null;
29169 }
29170 }]);
29171
29172 return Marker;
29173}(geometry_Geometry);
29174
29175Marker_Marker.propTypes = {
29176 id: prop_types_default.a.oneOfType([prop_types_default.a.number, prop_types_default.a.string]).isRequired,
29177 coordinates: prop_types_default.a.arrayOf(prop_types_default.a.number),
29178 options: prop_types_default.a.any
29179};
29180Marker_Marker.contextTypes = {
29181 layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */])
29182};
29183
29184
29185/* harmony default export */ var geometry_Marker = (Marker_Marker);
29186// CONCATENATED MODULE: ./src/geometry/LineString.js
29187var LineString__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; }; }();
29188
29189function LineString__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29190
29191function LineString__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; }
29192
29193function LineString__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; }
29194
29195
29196
29197
29198
29199
29200var LineString_LineString = function (_Geometry) {
29201 LineString__inherits(LineString, _Geometry);
29202
29203 /**
29204 * super class
29205 * @param props
29206 * @param context
29207 */
29208 function LineString(props, context) {
29209 LineString__classCallCheck(this, LineString);
29210
29211 /**
29212 * geometry
29213 * @type {null}
29214 */
29215 var _this = LineString__possibleConstructorReturn(this, (LineString.__proto__ || Object.getPrototypeOf(LineString)).call(this, props, context));
29216
29217 _this.geometry = null;
29218 return _this;
29219 }
29220
29221 /**
29222 * create geometry
29223 * @param nextProps
29224 */
29225
29226
29227 LineString__createClass(LineString, [{
29228 key: 'createGeometry',
29229 value: function createGeometry(nextProps) {
29230 if (nextProps) {
29231 var layer = this.context.layer;
29232
29233 if (!layer) return;
29234 var id = nextProps.id,
29235 coordinates = nextProps.coordinates,
29236 options = nextProps.options;
29237
29238 this.geometry = new maptalks_es["d" /* LineString */](coordinates, options);
29239 this.geometry.setId(id);
29240 this.geometry.setProperties(options);
29241 layer.addGeometry(this.geometry);
29242 }
29243 }
29244 }, {
29245 key: 'componentDidMount',
29246 value: function componentDidMount() {
29247 this.createGeometry(this.props);
29248 }
29249 }, {
29250 key: 'componentWillReceiveProps',
29251 value: function componentWillReceiveProps(nextProps) {
29252 var _props = this.props,
29253 id = _props.id,
29254 coordinates = _props.coordinates,
29255 options = _props.options;
29256
29257 if (!this.geometry) {
29258 return null;
29259 }
29260 if (!isEqual_default()(nextProps.id, id)) {
29261 this.geometry.setId(nextProps.id);
29262 }
29263 if (!isEqual_default()(nextProps.coordinates, coordinates)) {
29264 this.geometry.setCoordinates(nextProps.coordinates);
29265 }
29266 if (!isEqual_default()(nextProps.options, options)) {
29267 this.geometry.setProperties(nextProps.options);
29268 }
29269 }
29270 }, {
29271 key: 'componentWillUnmount',
29272 value: function componentWillUnmount() {
29273 var layer = this.context.layer;
29274
29275 if (!layer) return;
29276 layer.removeGeometry(this.geometry);
29277 }
29278
29279 /**
29280 * render
29281 * @returns {null}
29282 */
29283
29284 }, {
29285 key: 'render',
29286 value: function render() {
29287 return null;
29288 }
29289 }]);
29290
29291 return LineString;
29292}(geometry_Geometry);
29293
29294LineString_LineString.propTypes = {
29295 id: prop_types_default.a.oneOfType([prop_types_default.a.number, prop_types_default.a.string]).isRequired,
29296 coordinates: prop_types_default.a.arrayOf(prop_types_default.a.any),
29297 options: prop_types_default.a.any
29298};
29299LineString_LineString.contextTypes = {
29300 layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */])
29301};
29302
29303
29304/* harmony default export */ var geometry_LineString = (LineString_LineString);
29305// CONCATENATED MODULE: ./src/geometry/Polygon.js
29306var Polygon__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; }; }();
29307
29308function Polygon__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29309
29310function Polygon__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; }
29311
29312function Polygon__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; }
29313
29314
29315
29316
29317
29318
29319var Polygon_Polygon = function (_Geometry) {
29320 Polygon__inherits(Polygon, _Geometry);
29321
29322 /**
29323 * super class
29324 * @param props
29325 * @param context
29326 */
29327 function Polygon(props, context) {
29328 Polygon__classCallCheck(this, Polygon);
29329
29330 /**
29331 * geometry
29332 * @type {null}
29333 */
29334 var _this = Polygon__possibleConstructorReturn(this, (Polygon.__proto__ || Object.getPrototypeOf(Polygon)).call(this, props, context));
29335
29336 _this.geometry = null;
29337 return _this;
29338 }
29339
29340 /**
29341 * create geometry
29342 * @param nextProps
29343 */
29344
29345
29346 Polygon__createClass(Polygon, [{
29347 key: 'createGeometry',
29348 value: function createGeometry(nextProps) {
29349 if (nextProps) {
29350 var layer = this.context.layer;
29351
29352 if (!layer) return;
29353 var id = nextProps.id,
29354 coordinates = nextProps.coordinates,
29355 options = nextProps.options;
29356
29357 this.geometry = new maptalks_es["k" /* Polygon */](coordinates, options);
29358 this.geometry.setId(id);
29359 this.geometry.setProperties(options);
29360 layer.addGeometry(this.geometry);
29361 }
29362 }
29363 }, {
29364 key: 'componentDidMount',
29365 value: function componentDidMount() {
29366 this.createGeometry(this.props);
29367 }
29368 }, {
29369 key: 'componentWillReceiveProps',
29370 value: function componentWillReceiveProps(nextProps) {
29371 var _props = this.props,
29372 id = _props.id,
29373 coordinates = _props.coordinates,
29374 options = _props.options;
29375
29376 if (!this.geometry) {
29377 return null;
29378 }
29379 if (!isEqual_default()(nextProps.id, id)) {
29380 this.geometry.setId(nextProps.id);
29381 }
29382 if (!isEqual_default()(nextProps.coordinates, coordinates)) {
29383 this.geometry.setCoordinates(nextProps.coordinates);
29384 }
29385 if (!isEqual_default()(nextProps.options, options)) {
29386 this.geometry.setProperties(nextProps.options);
29387 }
29388 }
29389 }, {
29390 key: 'componentWillUnmount',
29391 value: function componentWillUnmount() {
29392 var layer = this.context.layer;
29393
29394 if (!layer) return;
29395 layer.removeGeometry(this.geometry);
29396 }
29397
29398 /**
29399 * render
29400 * @returns {null}
29401 */
29402
29403 }, {
29404 key: 'render',
29405 value: function render() {
29406 return null;
29407 }
29408 }]);
29409
29410 return Polygon;
29411}(geometry_Geometry);
29412
29413Polygon_Polygon.propTypes = {
29414 id: prop_types_default.a.oneOfType([prop_types_default.a.number, prop_types_default.a.string]).isRequired,
29415 coordinates: prop_types_default.a.arrayOf(prop_types_default.a.array),
29416 options: prop_types_default.a.any
29417};
29418Polygon_Polygon.contextTypes = {
29419 layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */])
29420};
29421
29422
29423/* harmony default export */ var geometry_Polygon = (Polygon_Polygon);
29424// CONCATENATED MODULE: ./src/geometry/MultiPoint.js
29425var MultiPoint__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; }; }();
29426
29427function MultiPoint__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29428
29429function MultiPoint__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; }
29430
29431function MultiPoint__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; }
29432
29433
29434
29435
29436
29437
29438var MultiPoint_MultiPoint = function (_Geometry) {
29439 MultiPoint__inherits(MultiPoint, _Geometry);
29440
29441 /**
29442 * super class
29443 * @param props
29444 * @param context
29445 */
29446 function MultiPoint(props, context) {
29447 MultiPoint__classCallCheck(this, MultiPoint);
29448
29449 /**
29450 * geometry
29451 * @type {null}
29452 */
29453 var _this = MultiPoint__possibleConstructorReturn(this, (MultiPoint.__proto__ || Object.getPrototypeOf(MultiPoint)).call(this, props, context));
29454
29455 _this.geometry = null;
29456 return _this;
29457 }
29458
29459 /**
29460 * create geometry
29461 * @param nextProps
29462 */
29463
29464
29465 MultiPoint__createClass(MultiPoint, [{
29466 key: 'createGeometry',
29467 value: function createGeometry(nextProps) {
29468 if (nextProps) {
29469 var layer = this.context.layer;
29470
29471 if (!layer) return;
29472 var id = nextProps.id,
29473 coordinates = nextProps.coordinates,
29474 options = nextProps.options;
29475
29476 this.geometry = new maptalks_es["h" /* MultiPoint */](coordinates, options);
29477 this.geometry.setId(id);
29478 this.geometry.setProperties(options);
29479 layer.addGeometry(this.geometry);
29480 }
29481 }
29482 }, {
29483 key: 'componentDidMount',
29484 value: function componentDidMount() {
29485 this.createGeometry(this.props);
29486 }
29487 }, {
29488 key: 'componentWillReceiveProps',
29489 value: function componentWillReceiveProps(nextProps) {
29490 var _props = this.props,
29491 id = _props.id,
29492 coordinates = _props.coordinates,
29493 options = _props.options;
29494
29495 if (!this.geometry) {
29496 return null;
29497 }
29498 if (!isEqual_default()(nextProps.id, id)) {
29499 this.geometry.setId(nextProps.id);
29500 }
29501 if (!isEqual_default()(nextProps.coordinates, coordinates)) {
29502 this.geometry.setCoordinates(nextProps.coordinates);
29503 }
29504 if (!isEqual_default()(nextProps.options, options)) {
29505 this.geometry.setProperties(nextProps.options);
29506 }
29507 }
29508 }, {
29509 key: 'componentWillUnmount',
29510 value: function componentWillUnmount() {
29511 var layer = this.context.layer;
29512
29513 if (!layer) return;
29514 layer.removeGeometry(this.geometry);
29515 }
29516
29517 /**
29518 * render
29519 * @returns {null}
29520 */
29521
29522 }, {
29523 key: 'render',
29524 value: function render() {
29525 return null;
29526 }
29527 }]);
29528
29529 return MultiPoint;
29530}(geometry_Geometry);
29531
29532MultiPoint_MultiPoint.propTypes = {
29533 id: prop_types_default.a.oneOfType([prop_types_default.a.number, prop_types_default.a.string]).isRequired,
29534 coordinates: prop_types_default.a.arrayOf(prop_types_default.a.arrayOf(prop_types_default.a.number)),
29535 options: prop_types_default.a.any
29536};
29537MultiPoint_MultiPoint.contextTypes = {
29538 layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */])
29539};
29540
29541
29542/* harmony default export */ var geometry_MultiPoint = (MultiPoint_MultiPoint);
29543// CONCATENATED MODULE: ./src/geometry/MultiLineString.js
29544var MultiLineString__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; }; }();
29545
29546function MultiLineString__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29547
29548function MultiLineString__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; }
29549
29550function MultiLineString__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; }
29551
29552
29553
29554
29555
29556
29557var MultiLineString_MultiLineString = function (_Geometry) {
29558 MultiLineString__inherits(MultiLineString, _Geometry);
29559
29560 /**
29561 * super class
29562 * @param props
29563 * @param context
29564 */
29565 function MultiLineString(props, context) {
29566 MultiLineString__classCallCheck(this, MultiLineString);
29567
29568 /**
29569 * geometry
29570 * @type {null}
29571 */
29572 var _this = MultiLineString__possibleConstructorReturn(this, (MultiLineString.__proto__ || Object.getPrototypeOf(MultiLineString)).call(this, props, context));
29573
29574 _this.geometry = null;
29575 return _this;
29576 }
29577
29578 /**
29579 * create geometry
29580 * @param nextProps
29581 */
29582
29583
29584 MultiLineString__createClass(MultiLineString, [{
29585 key: 'createGeometry',
29586 value: function createGeometry(nextProps) {
29587 if (nextProps) {
29588 var layer = this.context.layer;
29589
29590 if (!layer) return;
29591 var id = nextProps.id,
29592 coordinates = nextProps.coordinates,
29593 options = nextProps.options;
29594
29595 this.geometry = new maptalks_es["g" /* MultiLineString */](coordinates, options);
29596 this.geometry.setId(id);
29597 this.geometry.setProperties(options);
29598 layer.addGeometry(this.geometry);
29599 }
29600 }
29601 }, {
29602 key: 'componentDidMount',
29603 value: function componentDidMount() {
29604 this.createGeometry(this.props);
29605 }
29606 }, {
29607 key: 'componentWillReceiveProps',
29608 value: function componentWillReceiveProps(nextProps) {
29609 var _props = this.props,
29610 id = _props.id,
29611 coordinates = _props.coordinates,
29612 options = _props.options;
29613
29614 if (!this.geometry) {
29615 return null;
29616 }
29617 if (!isEqual_default()(nextProps.id, id)) {
29618 this.geometry.setId(nextProps.id);
29619 }
29620 if (!isEqual_default()(nextProps.coordinates, coordinates)) {
29621 this.geometry.setCoordinates(nextProps.coordinates);
29622 }
29623 if (!isEqual_default()(nextProps.options, options)) {
29624 this.geometry.setProperties(nextProps.options);
29625 }
29626 }
29627 }, {
29628 key: 'componentWillUnmount',
29629 value: function componentWillUnmount() {
29630 var layer = this.context.layer;
29631
29632 if (!layer) return;
29633 layer.removeGeometry(this.geometry);
29634 }
29635
29636 /**
29637 * render
29638 * @returns {null}
29639 */
29640
29641 }, {
29642 key: 'render',
29643 value: function render() {
29644 return null;
29645 }
29646 }]);
29647
29648 return MultiLineString;
29649}(geometry_Geometry);
29650
29651MultiLineString_MultiLineString.propTypes = {
29652 id: prop_types_default.a.oneOfType([prop_types_default.a.number, prop_types_default.a.string]).isRequired,
29653 coordinates: prop_types_default.a.arrayOf(prop_types_default.a.arrayOf(prop_types_default.a.arrayOf(prop_types_default.a.number))),
29654 options: prop_types_default.a.any
29655};
29656MultiLineString_MultiLineString.contextTypes = {
29657 layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */])
29658};
29659
29660
29661/* harmony default export */ var geometry_MultiLineString = (MultiLineString_MultiLineString);
29662// CONCATENATED MODULE: ./src/geometry/MultiPolygon.js
29663var MultiPolygon__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; }; }();
29664
29665function MultiPolygon__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29666
29667function MultiPolygon__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; }
29668
29669function MultiPolygon__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; }
29670
29671
29672
29673
29674
29675
29676var MultiPolygon_MultiPolygon = function (_Geometry) {
29677 MultiPolygon__inherits(MultiPolygon, _Geometry);
29678
29679 /**
29680 * super class
29681 * @param props
29682 * @param context
29683 */
29684 function MultiPolygon(props, context) {
29685 MultiPolygon__classCallCheck(this, MultiPolygon);
29686
29687 /**
29688 * geometry
29689 * @type {null}
29690 */
29691 var _this = MultiPolygon__possibleConstructorReturn(this, (MultiPolygon.__proto__ || Object.getPrototypeOf(MultiPolygon)).call(this, props, context));
29692
29693 _this.geometry = null;
29694 return _this;
29695 }
29696
29697 /**
29698 * create geometry
29699 * @param nextProps
29700 */
29701
29702
29703 MultiPolygon__createClass(MultiPolygon, [{
29704 key: 'createGeometry',
29705 value: function createGeometry(nextProps) {
29706 if (nextProps) {
29707 var layer = this.context.layer;
29708
29709 if (!layer) return;
29710 var id = nextProps.id,
29711 coordinates = nextProps.coordinates,
29712 options = nextProps.options;
29713
29714 this.geometry = new maptalks_es["i" /* MultiPolygon */](coordinates, options);
29715 this.geometry.setId(id);
29716 this.geometry.setProperties(options);
29717 layer.addGeometry(this.geometry);
29718 }
29719 }
29720 }, {
29721 key: 'componentDidMount',
29722 value: function componentDidMount() {
29723 this.createGeometry(this.props);
29724 }
29725 }, {
29726 key: 'componentWillReceiveProps',
29727 value: function componentWillReceiveProps(nextProps) {
29728 var _props = this.props,
29729 id = _props.id,
29730 coordinates = _props.coordinates,
29731 options = _props.options;
29732
29733 if (!this.geometry) {
29734 return null;
29735 }
29736 if (!isEqual_default()(nextProps.id, id)) {
29737 this.geometry.setId(nextProps.id);
29738 }
29739 if (!isEqual_default()(nextProps.coordinates, coordinates)) {
29740 this.geometry.setCoordinates(nextProps.coordinates);
29741 }
29742 if (!isEqual_default()(nextProps.options, options)) {
29743 this.geometry.setProperties(nextProps.options);
29744 }
29745 }
29746 }, {
29747 key: 'componentWillUnmount',
29748 value: function componentWillUnmount() {
29749 var layer = this.context.layer;
29750
29751 if (!layer) return;
29752 layer.removeGeometry(this.geometry);
29753 }
29754
29755 /**
29756 * render
29757 * @returns {null}
29758 */
29759
29760 }, {
29761 key: 'render',
29762 value: function render() {
29763 return null;
29764 }
29765 }]);
29766
29767 return MultiPolygon;
29768}(geometry_Geometry);
29769
29770MultiPolygon_MultiPolygon.propTypes = {
29771 id: prop_types_default.a.oneOfType([prop_types_default.a.number, prop_types_default.a.string]).isRequired,
29772 coordinates: prop_types_default.a.arrayOf(prop_types_default.a.array),
29773 options: prop_types_default.a.any
29774};
29775MultiPolygon_MultiPolygon.contextTypes = {
29776 layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */])
29777};
29778
29779
29780/* harmony default export */ var geometry_MultiPolygon = (MultiPolygon_MultiPolygon);
29781// CONCATENATED MODULE: ./src/geometry/Circle.js
29782var Circle__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; }; }();
29783
29784function Circle__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29785
29786function Circle__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; }
29787
29788function Circle__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; }
29789
29790
29791
29792
29793
29794
29795var Circle_Circle = function (_Geometry) {
29796 Circle__inherits(Circle, _Geometry);
29797
29798 /**
29799 * super class
29800 * @param props
29801 * @param context
29802 */
29803 function Circle(props, context) {
29804 Circle__classCallCheck(this, Circle);
29805
29806 /**
29807 * geometry
29808 * @type {null}
29809 */
29810 var _this = Circle__possibleConstructorReturn(this, (Circle.__proto__ || Object.getPrototypeOf(Circle)).call(this, props, context));
29811
29812 _this.geometry = null;
29813 return _this;
29814 }
29815
29816 /**
29817 * create geometry
29818 * @param nextProps
29819 */
29820
29821
29822 Circle__createClass(Circle, [{
29823 key: 'createGeometry',
29824 value: function createGeometry(nextProps) {
29825 if (nextProps) {
29826 var layer = this.context.layer;
29827
29828 if (!layer) return;
29829 var id = nextProps.id,
29830 center = nextProps.center,
29831 radius = nextProps.radius,
29832 options = nextProps.options;
29833
29834 this.geometry = new maptalks_es["a" /* Circle */](center, radius, options);
29835 this.geometry.setId(id);
29836 this.geometry.setProperties(options);
29837 layer.addGeometry(this.geometry);
29838 }
29839 }
29840 }, {
29841 key: 'componentDidMount',
29842 value: function componentDidMount() {
29843 this.createGeometry(this.props);
29844 }
29845 }, {
29846 key: 'componentWillReceiveProps',
29847 value: function componentWillReceiveProps(nextProps) {
29848 console.log(nextProps);
29849 var _props = this.props,
29850 id = _props.id,
29851 center = _props.center,
29852 radius = _props.radius,
29853 options = _props.options;
29854
29855 if (!this.geometry) {
29856 return null;
29857 }
29858 if (!isEqual_default()(nextProps.id, id)) {
29859 this.geometry.setId(nextProps.id);
29860 }
29861 if (!isEqual_default()(nextProps.center, center)) {
29862 this.geometry.setCoordinates(nextProps.center);
29863 }
29864 if (!isEqual_default()(nextProps.radius, radius)) {
29865 this.geometry.setRadius(nextProps.radius);
29866 }
29867 if (!isEqual_default()(nextProps.options, options)) {
29868 this.geometry.setProperties(nextProps.options);
29869 }
29870 }
29871 }, {
29872 key: 'componentWillUnmount',
29873 value: function componentWillUnmount() {
29874 var layer = this.context.layer;
29875
29876 if (!layer) return;
29877 layer.removeGeometry(this.geometry);
29878 }
29879
29880 /**
29881 * render
29882 * @returns {null}
29883 */
29884
29885 }, {
29886 key: 'render',
29887 value: function render() {
29888 return null;
29889 }
29890 }]);
29891
29892 return Circle;
29893}(geometry_Geometry);
29894
29895Circle_Circle.propTypes = {
29896 id: prop_types_default.a.oneOfType([prop_types_default.a.number, prop_types_default.a.string]).isRequired,
29897 center: prop_types_default.a.arrayOf(prop_types_default.a.number),
29898 radius: prop_types_default.a.number,
29899 options: prop_types_default.a.any
29900};
29901Circle_Circle.contextTypes = {
29902 layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */])
29903};
29904
29905
29906/* harmony default export */ var geometry_Circle = (Circle_Circle);
29907// CONCATENATED MODULE: ./src/geometry/index.js
29908
29909
29910
29911
29912
29913
29914
29915// import GeometryCollection from './GeometryCollection';
29916// import GeoJSON from './GeoJSON';
29917
29918// import Ellipse from './Ellipse';
29919// import Rectangle from './Rectangle';
29920// import Sector from './Sector';
29921// import Curve from './Curve';
29922// import ArcCurve from './ArcCurve';
29923// import CubicBezierCurve from './CubicBezierCurve';
29924// import QuadBezierCurve from './QuadBezierCurve';
29925// import TextMarker from './TextMarker';
29926// import TextBox from './TextBox';
29927// import Label from './Label';
29928// import { ConnectorLine, ArcConnectorLine } from './ConnectorLine';
29929
29930
29931// CONCATENATED MODULE: ./src/index.js
29932/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Map", function() { return src_map; });
29933/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "TileLayer", function() { return tile_TileLayer; });
29934/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "OverlayLayer", function() { return layers_OverlayLayer; });
29935/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "VectorLayer", function() { return layers_VectorLayer; });
29936/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Circle", function() { return geometry_Circle; });
29937/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Geometry", function() { return geometry_Geometry; });
29938/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "LineString", function() { return geometry_LineString; });
29939/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Marker", function() { return geometry_Marker; });
29940/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "MultiLineString", function() { return geometry_MultiLineString; });
29941/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "MultiPoint", function() { return geometry_MultiPoint; });
29942/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "MultiPolygon", function() { return geometry_MultiPolygon; });
29943/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Polygon", function() { return geometry_Polygon; });
29944
29945
29946
29947
29948
29949
29950
29951/* harmony default export */ var src = __webpack_exports__["default"] = ({
29952 Map: src_map,
29953 TileLayer: tile_TileLayer,
29954 OverlayLayer: layers_OverlayLayer,
29955 VectorLayer: layers_VectorLayer,
29956 Circle: geometry_Circle,
29957 Geometry: geometry_Geometry,
29958 LineString: geometry_LineString,
29959 Marker: geometry_Marker,
29960 MultiLineString: geometry_MultiLineString,
29961 MultiPoint: geometry_MultiPoint,
29962 MultiPolygon: geometry_MultiPolygon,
29963 Polygon: geometry_Polygon
29964});
29965
29966/***/ }),
29967/* 34 */
29968/***/ (function(module, exports) {
29969
29970// removed by extract-text-webpack-plugin
29971
29972/***/ }),
29973/* 35 */
29974/***/ (function(module, exports, __webpack_require__) {
29975
29976"use strict";
29977/** @license React v16.4.1
29978 * react.production.min.js
29979 *
29980 * Copyright (c) 2013-present, Facebook, Inc.
29981 *
29982 * This source code is licensed under the MIT license found in the
29983 * LICENSE file in the root directory of this source tree.
29984 */
29985
29986var k=__webpack_require__(12),n=__webpack_require__(18),p=__webpack_require__(19),q=__webpack_require__(13),r="function"===typeof Symbol&&Symbol.for,t=r?Symbol.for("react.element"):60103,u=r?Symbol.for("react.portal"):60106,v=r?Symbol.for("react.fragment"):60107,w=r?Symbol.for("react.strict_mode"):60108,x=r?Symbol.for("react.profiler"):60114,y=r?Symbol.for("react.provider"):60109,z=r?Symbol.for("react.context"):60110,A=r?Symbol.for("react.async_mode"):60111,B=
29987r?Symbol.for("react.forward_ref"):60112;r&&Symbol.for("react.timeout");var C="function"===typeof Symbol&&Symbol.iterator;function D(a){for(var b=arguments.length-1,e="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;c<b;c++)e+="&args[]="+encodeURIComponent(arguments[c+1]);n(!1,"Minified React error #"+a+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",e)}
29988var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}};function F(a,b,e){this.props=a;this.context=b;this.refs=p;this.updater=e||E}F.prototype.isReactComponent={};F.prototype.setState=function(a,b){"object"!==typeof a&&"function"!==typeof a&&null!=a?D("85"):void 0;this.updater.enqueueSetState(this,a,b,"setState")};F.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};function G(){}
29989G.prototype=F.prototype;function H(a,b,e){this.props=a;this.context=b;this.refs=p;this.updater=e||E}var I=H.prototype=new G;I.constructor=H;k(I,F.prototype);I.isPureReactComponent=!0;var J={current:null},K=Object.prototype.hasOwnProperty,L={key:!0,ref:!0,__self:!0,__source:!0};
29990function M(a,b,e){var c=void 0,d={},g=null,h=null;if(null!=b)for(c in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(g=""+b.key),b)K.call(b,c)&&!L.hasOwnProperty(c)&&(d[c]=b[c]);var f=arguments.length-2;if(1===f)d.children=e;else if(1<f){for(var l=Array(f),m=0;m<f;m++)l[m]=arguments[m+2];d.children=l}if(a&&a.defaultProps)for(c in f=a.defaultProps,f)void 0===d[c]&&(d[c]=f[c]);return{$$typeof:t,type:a,key:g,ref:h,props:d,_owner:J.current}}
29991function N(a){return"object"===typeof a&&null!==a&&a.$$typeof===t}function escape(a){var b={"=":"=0",":":"=2"};return"$"+(""+a).replace(/[=:]/g,function(a){return b[a]})}var O=/\/+/g,P=[];function Q(a,b,e,c){if(P.length){var d=P.pop();d.result=a;d.keyPrefix=b;d.func=e;d.context=c;d.count=0;return d}return{result:a,keyPrefix:b,func:e,context:c,count:0}}function R(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>P.length&&P.push(a)}
29992function S(a,b,e,c){var d=typeof a;if("undefined"===d||"boolean"===d)a=null;var g=!1;if(null===a)g=!0;else switch(d){case "string":case "number":g=!0;break;case "object":switch(a.$$typeof){case t:case u:g=!0}}if(g)return e(c,a,""===b?"."+T(a,0):b),1;g=0;b=""===b?".":b+":";if(Array.isArray(a))for(var h=0;h<a.length;h++){d=a[h];var f=b+T(d,h);g+=S(d,f,e,c)}else if(null===a||"undefined"===typeof a?f=null:(f=C&&a[C]||a["@@iterator"],f="function"===typeof f?f:null),"function"===typeof f)for(a=f.call(a),
29993h=0;!(d=a.next()).done;)d=d.value,f=b+T(d,h++),g+=S(d,f,e,c);else"object"===d&&(e=""+a,D("31","[object Object]"===e?"object with keys {"+Object.keys(a).join(", ")+"}":e,""));return g}function T(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(a.key):b.toString(36)}function U(a,b){a.func.call(a.context,b,a.count++)}
29994function V(a,b,e){var c=a.result,d=a.keyPrefix;a=a.func.call(a.context,b,a.count++);Array.isArray(a)?W(a,c,e,q.thatReturnsArgument):null!=a&&(N(a)&&(b=d+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(O,"$&/")+"/")+e,a={$$typeof:t,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}),c.push(a))}function W(a,b,e,c,d){var g="";null!=e&&(g=(""+e).replace(O,"$&/")+"/");b=Q(b,g,c,d);null==a||S(a,"",V,b);R(b)}
29995var X={Children:{map:function(a,b,e){if(null==a)return a;var c=[];W(a,c,null,b,e);return c},forEach:function(a,b,e){if(null==a)return a;b=Q(null,null,b,e);null==a||S(a,"",U,b);R(b)},count:function(a){return null==a?0:S(a,"",q.thatReturnsNull,null)},toArray:function(a){var b=[];W(a,b,null,q.thatReturnsArgument);return b},only:function(a){N(a)?void 0:D("143");return a}},createRef:function(){return{current:null}},Component:F,PureComponent:H,createContext:function(a,b){void 0===b&&(b=null);a={$$typeof:z,
29996_calculateChangedBits:b,_defaultValue:a,_currentValue:a,_currentValue2:a,_changedBits:0,_changedBits2:0,Provider:null,Consumer:null};a.Provider={$$typeof:y,_context:a};return a.Consumer=a},forwardRef:function(a){return{$$typeof:B,render:a}},Fragment:v,StrictMode:w,unstable_AsyncMode:A,unstable_Profiler:x,createElement:M,cloneElement:function(a,b,e){null===a||void 0===a?D("267",a):void 0;var c=void 0,d=k({},a.props),g=a.key,h=a.ref,f=a._owner;if(null!=b){void 0!==b.ref&&(h=b.ref,f=J.current);void 0!==
29997b.key&&(g=""+b.key);var l=void 0;a.type&&a.type.defaultProps&&(l=a.type.defaultProps);for(c in b)K.call(b,c)&&!L.hasOwnProperty(c)&&(d[c]=void 0===b[c]&&void 0!==l?l[c]:b[c])}c=arguments.length-2;if(1===c)d.children=e;else if(1<c){l=Array(c);for(var m=0;m<c;m++)l[m]=arguments[m+2];d.children=l}return{$$typeof:t,type:a.type,key:g,ref:h,props:d,_owner:f}},createFactory:function(a){var b=M.bind(null,a);b.type=a;return b},isValidElement:N,version:"16.4.1",__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:J,
29998assign:k}},Y={default:X},Z=Y&&X||Y;module.exports=Z.default?Z.default:Z;
29999
30000
30001/***/ }),
30002/* 36 */
30003/***/ (function(module, exports, __webpack_require__) {
30004
30005"use strict";
30006/** @license React v16.4.1
30007 * react.development.js
30008 *
30009 * Copyright (c) 2013-present, Facebook, Inc.
30010 *
30011 * This source code is licensed under the MIT license found in the
30012 * LICENSE file in the root directory of this source tree.
30013 */
30014
30015
30016
30017
30018
30019if ("development".NODE_ENV !== "production") {
30020 (function() {
30021'use strict';
30022
30023var _assign = __webpack_require__(12);
30024var invariant = __webpack_require__(18);
30025var emptyObject = __webpack_require__(19);
30026var warning = __webpack_require__(37);
30027var emptyFunction = __webpack_require__(13);
30028var checkPropTypes = __webpack_require__(20);
30029
30030// TODO: this is special because it gets imported during build.
30031
30032var ReactVersion = '16.4.1';
30033
30034// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
30035// nor polyfill, then a plain number is used for performance.
30036var hasSymbol = typeof Symbol === 'function' && Symbol.for;
30037
30038var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
30039var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
30040var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
30041var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
30042var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
30043var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
30044var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
30045var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
30046var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
30047var REACT_TIMEOUT_TYPE = hasSymbol ? Symbol.for('react.timeout') : 0xead1;
30048
30049var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
30050var FAUX_ITERATOR_SYMBOL = '@@iterator';
30051
30052function getIteratorFn(maybeIterable) {
30053 if (maybeIterable === null || typeof maybeIterable === 'undefined') {
30054 return null;
30055 }
30056 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
30057 if (typeof maybeIterator === 'function') {
30058 return maybeIterator;
30059 }
30060 return null;
30061}
30062
30063// Relying on the `invariant()` implementation lets us
30064// have preserve the format and params in the www builds.
30065
30066// Exports ReactDOM.createRoot
30067
30068
30069// Experimental error-boundary API that can recover from errors within a single
30070// render phase
30071
30072// Suspense
30073var enableSuspense = false;
30074// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
30075
30076
30077// In some cases, StrictMode should also double-render lifecycles.
30078// This can be confusing for tests though,
30079// And it can be bad for performance in production.
30080// This feature flag can be used to control the behavior:
30081
30082
30083// To preserve the "Pause on caught exceptions" behavior of the debugger, we
30084// replay the begin phase of a failed component inside invokeGuardedCallback.
30085
30086
30087// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
30088
30089
30090// Warn about legacy context API
30091
30092
30093// Gather advanced timing metrics for Profiler subtrees.
30094
30095
30096// Only used in www builds.
30097
30098/**
30099 * Forked from fbjs/warning:
30100 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
30101 *
30102 * Only change is we use console.warn instead of console.error,
30103 * and do nothing when 'console' is not supported.
30104 * This really simplifies the code.
30105 * ---
30106 * Similar to invariant but only logs a warning if the condition is not met.
30107 * This can be used to log issues in development environments in critical
30108 * paths. Removing the logging code for production environments will keep the
30109 * same logic and follow the same code paths.
30110 */
30111
30112var lowPriorityWarning = function () {};
30113
30114{
30115 var printWarning = function (format) {
30116 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
30117 args[_key - 1] = arguments[_key];
30118 }
30119
30120 var argIndex = 0;
30121 var message = 'Warning: ' + format.replace(/%s/g, function () {
30122 return args[argIndex++];
30123 });
30124 if (typeof console !== 'undefined') {
30125 console.warn(message);
30126 }
30127 try {
30128 // --- Welcome to debugging React ---
30129 // This error was thrown as a convenience so that you can use this stack
30130 // to find the callsite that caused this warning to fire.
30131 throw new Error(message);
30132 } catch (x) {}
30133 };
30134
30135 lowPriorityWarning = function (condition, format) {
30136 if (format === undefined) {
30137 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
30138 }
30139 if (!condition) {
30140 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
30141 args[_key2 - 2] = arguments[_key2];
30142 }
30143
30144 printWarning.apply(undefined, [format].concat(args));
30145 }
30146 };
30147}
30148
30149var lowPriorityWarning$1 = lowPriorityWarning;
30150
30151var didWarnStateUpdateForUnmountedComponent = {};
30152
30153function warnNoop(publicInstance, callerName) {
30154 {
30155 var _constructor = publicInstance.constructor;
30156 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
30157 var warningKey = componentName + '.' + callerName;
30158 if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
30159 return;
30160 }
30161 warning(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
30162 didWarnStateUpdateForUnmountedComponent[warningKey] = true;
30163 }
30164}
30165
30166/**
30167 * This is the abstract API for an update queue.
30168 */
30169var ReactNoopUpdateQueue = {
30170 /**
30171 * Checks whether or not this composite component is mounted.
30172 * @param {ReactClass} publicInstance The instance we want to test.
30173 * @return {boolean} True if mounted, false otherwise.
30174 * @protected
30175 * @final
30176 */
30177 isMounted: function (publicInstance) {
30178 return false;
30179 },
30180
30181 /**
30182 * Forces an update. This should only be invoked when it is known with
30183 * certainty that we are **not** in a DOM transaction.
30184 *
30185 * You may want to call this when you know that some deeper aspect of the
30186 * component's state has changed but `setState` was not called.
30187 *
30188 * This will not invoke `shouldComponentUpdate`, but it will invoke
30189 * `componentWillUpdate` and `componentDidUpdate`.
30190 *
30191 * @param {ReactClass} publicInstance The instance that should rerender.
30192 * @param {?function} callback Called after component is updated.
30193 * @param {?string} callerName name of the calling function in the public API.
30194 * @internal
30195 */
30196 enqueueForceUpdate: function (publicInstance, callback, callerName) {
30197 warnNoop(publicInstance, 'forceUpdate');
30198 },
30199
30200 /**
30201 * Replaces all of the state. Always use this or `setState` to mutate state.
30202 * You should treat `this.state` as immutable.
30203 *
30204 * There is no guarantee that `this.state` will be immediately updated, so
30205 * accessing `this.state` after calling this method may return the old value.
30206 *
30207 * @param {ReactClass} publicInstance The instance that should rerender.
30208 * @param {object} completeState Next state.
30209 * @param {?function} callback Called after component is updated.
30210 * @param {?string} callerName name of the calling function in the public API.
30211 * @internal
30212 */
30213 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
30214 warnNoop(publicInstance, 'replaceState');
30215 },
30216
30217 /**
30218 * Sets a subset of the state. This only exists because _pendingState is
30219 * internal. This provides a merging strategy that is not available to deep
30220 * properties which is confusing. TODO: Expose pendingState or don't use it
30221 * during the merge.
30222 *
30223 * @param {ReactClass} publicInstance The instance that should rerender.
30224 * @param {object} partialState Next partial state to be merged with state.
30225 * @param {?function} callback Called after component is updated.
30226 * @param {?string} Name of the calling function in the public API.
30227 * @internal
30228 */
30229 enqueueSetState: function (publicInstance, partialState, callback, callerName) {
30230 warnNoop(publicInstance, 'setState');
30231 }
30232};
30233
30234/**
30235 * Base class helpers for the updating state of a component.
30236 */
30237function Component(props, context, updater) {
30238 this.props = props;
30239 this.context = context;
30240 this.refs = emptyObject;
30241 // We initialize the default updater but the real one gets injected by the
30242 // renderer.
30243 this.updater = updater || ReactNoopUpdateQueue;
30244}
30245
30246Component.prototype.isReactComponent = {};
30247
30248/**
30249 * Sets a subset of the state. Always use this to mutate
30250 * state. You should treat `this.state` as immutable.
30251 *
30252 * There is no guarantee that `this.state` will be immediately updated, so
30253 * accessing `this.state` after calling this method may return the old value.
30254 *
30255 * There is no guarantee that calls to `setState` will run synchronously,
30256 * as they may eventually be batched together. You can provide an optional
30257 * callback that will be executed when the call to setState is actually
30258 * completed.
30259 *
30260 * When a function is provided to setState, it will be called at some point in
30261 * the future (not synchronously). It will be called with the up to date
30262 * component arguments (state, props, context). These values can be different
30263 * from this.* because your function may be called after receiveProps but before
30264 * shouldComponentUpdate, and this new state, props, and context will not yet be
30265 * assigned to this.
30266 *
30267 * @param {object|function} partialState Next partial state or function to
30268 * produce next partial state to be merged with current state.
30269 * @param {?function} callback Called after state is updated.
30270 * @final
30271 * @protected
30272 */
30273Component.prototype.setState = function (partialState, callback) {
30274 !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
30275 this.updater.enqueueSetState(this, partialState, callback, 'setState');
30276};
30277
30278/**
30279 * Forces an update. This should only be invoked when it is known with
30280 * certainty that we are **not** in a DOM transaction.
30281 *
30282 * You may want to call this when you know that some deeper aspect of the
30283 * component's state has changed but `setState` was not called.
30284 *
30285 * This will not invoke `shouldComponentUpdate`, but it will invoke
30286 * `componentWillUpdate` and `componentDidUpdate`.
30287 *
30288 * @param {?function} callback Called after update is complete.
30289 * @final
30290 * @protected
30291 */
30292Component.prototype.forceUpdate = function (callback) {
30293 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
30294};
30295
30296/**
30297 * Deprecated APIs. These APIs used to exist on classic React classes but since
30298 * we would like to deprecate them, we're not going to move them over to this
30299 * modern base class. Instead, we define a getter that warns if it's accessed.
30300 */
30301{
30302 var deprecatedAPIs = {
30303 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
30304 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
30305 };
30306 var defineDeprecationWarning = function (methodName, info) {
30307 Object.defineProperty(Component.prototype, methodName, {
30308 get: function () {
30309 lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
30310 return undefined;
30311 }
30312 });
30313 };
30314 for (var fnName in deprecatedAPIs) {
30315 if (deprecatedAPIs.hasOwnProperty(fnName)) {
30316 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
30317 }
30318 }
30319}
30320
30321function ComponentDummy() {}
30322ComponentDummy.prototype = Component.prototype;
30323
30324/**
30325 * Convenience component with default shallow equality check for sCU.
30326 */
30327function PureComponent(props, context, updater) {
30328 this.props = props;
30329 this.context = context;
30330 this.refs = emptyObject;
30331 this.updater = updater || ReactNoopUpdateQueue;
30332}
30333
30334var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
30335pureComponentPrototype.constructor = PureComponent;
30336// Avoid an extra prototype jump for these methods.
30337_assign(pureComponentPrototype, Component.prototype);
30338pureComponentPrototype.isPureReactComponent = true;
30339
30340// an immutable object with a single mutable value
30341function createRef() {
30342 var refObject = {
30343 current: null
30344 };
30345 {
30346 Object.seal(refObject);
30347 }
30348 return refObject;
30349}
30350
30351/**
30352 * Keeps track of the current owner.
30353 *
30354 * The current owner is the component who should own any components that are
30355 * currently being constructed.
30356 */
30357var ReactCurrentOwner = {
30358 /**
30359 * @internal
30360 * @type {ReactComponent}
30361 */
30362 current: null
30363};
30364
30365var hasOwnProperty = Object.prototype.hasOwnProperty;
30366
30367var RESERVED_PROPS = {
30368 key: true,
30369 ref: true,
30370 __self: true,
30371 __source: true
30372};
30373
30374var specialPropKeyWarningShown = void 0;
30375var specialPropRefWarningShown = void 0;
30376
30377function hasValidRef(config) {
30378 {
30379 if (hasOwnProperty.call(config, 'ref')) {
30380 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
30381 if (getter && getter.isReactWarning) {
30382 return false;
30383 }
30384 }
30385 }
30386 return config.ref !== undefined;
30387}
30388
30389function hasValidKey(config) {
30390 {
30391 if (hasOwnProperty.call(config, 'key')) {
30392 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
30393 if (getter && getter.isReactWarning) {
30394 return false;
30395 }
30396 }
30397 }
30398 return config.key !== undefined;
30399}
30400
30401function defineKeyPropWarningGetter(props, displayName) {
30402 var warnAboutAccessingKey = function () {
30403 if (!specialPropKeyWarningShown) {
30404 specialPropKeyWarningShown = true;
30405 warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
30406 }
30407 };
30408 warnAboutAccessingKey.isReactWarning = true;
30409 Object.defineProperty(props, 'key', {
30410 get: warnAboutAccessingKey,
30411 configurable: true
30412 });
30413}
30414
30415function defineRefPropWarningGetter(props, displayName) {
30416 var warnAboutAccessingRef = function () {
30417 if (!specialPropRefWarningShown) {
30418 specialPropRefWarningShown = true;
30419 warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
30420 }
30421 };
30422 warnAboutAccessingRef.isReactWarning = true;
30423 Object.defineProperty(props, 'ref', {
30424 get: warnAboutAccessingRef,
30425 configurable: true
30426 });
30427}
30428
30429/**
30430 * Factory method to create a new React element. This no longer adheres to
30431 * the class pattern, so do not use new to call it. Also, no instanceof check
30432 * will work. Instead test $$typeof field against Symbol.for('react.element') to check
30433 * if something is a React Element.
30434 *
30435 * @param {*} type
30436 * @param {*} key
30437 * @param {string|object} ref
30438 * @param {*} self A *temporary* helper to detect places where `this` is
30439 * different from the `owner` when React.createElement is called, so that we
30440 * can warn. We want to get rid of owner and replace string `ref`s with arrow
30441 * functions, and as long as `this` and owner are the same, there will be no
30442 * change in behavior.
30443 * @param {*} source An annotation object (added by a transpiler or otherwise)
30444 * indicating filename, line number, and/or other information.
30445 * @param {*} owner
30446 * @param {*} props
30447 * @internal
30448 */
30449var ReactElement = function (type, key, ref, self, source, owner, props) {
30450 var element = {
30451 // This tag allows us to uniquely identify this as a React Element
30452 $$typeof: REACT_ELEMENT_TYPE,
30453
30454 // Built-in properties that belong on the element
30455 type: type,
30456 key: key,
30457 ref: ref,
30458 props: props,
30459
30460 // Record the component responsible for creating this element.
30461 _owner: owner
30462 };
30463
30464 {
30465 // The validation flag is currently mutative. We put it on
30466 // an external backing store so that we can freeze the whole object.
30467 // This can be replaced with a WeakMap once they are implemented in
30468 // commonly used development environments.
30469 element._store = {};
30470
30471 // To make comparing ReactElements easier for testing purposes, we make
30472 // the validation flag non-enumerable (where possible, which should
30473 // include every environment we run tests in), so the test framework
30474 // ignores it.
30475 Object.defineProperty(element._store, 'validated', {
30476 configurable: false,
30477 enumerable: false,
30478 writable: true,
30479 value: false
30480 });
30481 // self and source are DEV only properties.
30482 Object.defineProperty(element, '_self', {
30483 configurable: false,
30484 enumerable: false,
30485 writable: false,
30486 value: self
30487 });
30488 // Two elements created in two different places should be considered
30489 // equal for testing purposes and therefore we hide it from enumeration.
30490 Object.defineProperty(element, '_source', {
30491 configurable: false,
30492 enumerable: false,
30493 writable: false,
30494 value: source
30495 });
30496 if (Object.freeze) {
30497 Object.freeze(element.props);
30498 Object.freeze(element);
30499 }
30500 }
30501
30502 return element;
30503};
30504
30505/**
30506 * Create and return a new ReactElement of the given type.
30507 * See https://reactjs.org/docs/react-api.html#createelement
30508 */
30509function createElement(type, config, children) {
30510 var propName = void 0;
30511
30512 // Reserved names are extracted
30513 var props = {};
30514
30515 var key = null;
30516 var ref = null;
30517 var self = null;
30518 var source = null;
30519
30520 if (config != null) {
30521 if (hasValidRef(config)) {
30522 ref = config.ref;
30523 }
30524 if (hasValidKey(config)) {
30525 key = '' + config.key;
30526 }
30527
30528 self = config.__self === undefined ? null : config.__self;
30529 source = config.__source === undefined ? null : config.__source;
30530 // Remaining properties are added to a new props object
30531 for (propName in config) {
30532 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
30533 props[propName] = config[propName];
30534 }
30535 }
30536 }
30537
30538 // Children can be more than one argument, and those are transferred onto
30539 // the newly allocated props object.
30540 var childrenLength = arguments.length - 2;
30541 if (childrenLength === 1) {
30542 props.children = children;
30543 } else if (childrenLength > 1) {
30544 var childArray = Array(childrenLength);
30545 for (var i = 0; i < childrenLength; i++) {
30546 childArray[i] = arguments[i + 2];
30547 }
30548 {
30549 if (Object.freeze) {
30550 Object.freeze(childArray);
30551 }
30552 }
30553 props.children = childArray;
30554 }
30555
30556 // Resolve default props
30557 if (type && type.defaultProps) {
30558 var defaultProps = type.defaultProps;
30559 for (propName in defaultProps) {
30560 if (props[propName] === undefined) {
30561 props[propName] = defaultProps[propName];
30562 }
30563 }
30564 }
30565 {
30566 if (key || ref) {
30567 if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
30568 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
30569 if (key) {
30570 defineKeyPropWarningGetter(props, displayName);
30571 }
30572 if (ref) {
30573 defineRefPropWarningGetter(props, displayName);
30574 }
30575 }
30576 }
30577 }
30578 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
30579}
30580
30581/**
30582 * Return a function that produces ReactElements of a given type.
30583 * See https://reactjs.org/docs/react-api.html#createfactory
30584 */
30585
30586
30587function cloneAndReplaceKey(oldElement, newKey) {
30588 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
30589
30590 return newElement;
30591}
30592
30593/**
30594 * Clone and return a new ReactElement using element as the starting point.
30595 * See https://reactjs.org/docs/react-api.html#cloneelement
30596 */
30597function cloneElement(element, config, children) {
30598 !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
30599
30600 var propName = void 0;
30601
30602 // Original props are copied
30603 var props = _assign({}, element.props);
30604
30605 // Reserved names are extracted
30606 var key = element.key;
30607 var ref = element.ref;
30608 // Self is preserved since the owner is preserved.
30609 var self = element._self;
30610 // Source is preserved since cloneElement is unlikely to be targeted by a
30611 // transpiler, and the original source is probably a better indicator of the
30612 // true owner.
30613 var source = element._source;
30614
30615 // Owner will be preserved, unless ref is overridden
30616 var owner = element._owner;
30617
30618 if (config != null) {
30619 if (hasValidRef(config)) {
30620 // Silently steal the ref from the parent.
30621 ref = config.ref;
30622 owner = ReactCurrentOwner.current;
30623 }
30624 if (hasValidKey(config)) {
30625 key = '' + config.key;
30626 }
30627
30628 // Remaining properties override existing props
30629 var defaultProps = void 0;
30630 if (element.type && element.type.defaultProps) {
30631 defaultProps = element.type.defaultProps;
30632 }
30633 for (propName in config) {
30634 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
30635 if (config[propName] === undefined && defaultProps !== undefined) {
30636 // Resolve default props
30637 props[propName] = defaultProps[propName];
30638 } else {
30639 props[propName] = config[propName];
30640 }
30641 }
30642 }
30643 }
30644
30645 // Children can be more than one argument, and those are transferred onto
30646 // the newly allocated props object.
30647 var childrenLength = arguments.length - 2;
30648 if (childrenLength === 1) {
30649 props.children = children;
30650 } else if (childrenLength > 1) {
30651 var childArray = Array(childrenLength);
30652 for (var i = 0; i < childrenLength; i++) {
30653 childArray[i] = arguments[i + 2];
30654 }
30655 props.children = childArray;
30656 }
30657
30658 return ReactElement(element.type, key, ref, self, source, owner, props);
30659}
30660
30661/**
30662 * Verifies the object is a ReactElement.
30663 * See https://reactjs.org/docs/react-api.html#isvalidelement
30664 * @param {?object} object
30665 * @return {boolean} True if `object` is a valid component.
30666 * @final
30667 */
30668function isValidElement(object) {
30669 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
30670}
30671
30672var ReactDebugCurrentFrame = {};
30673
30674{
30675 // Component that is being worked on
30676 ReactDebugCurrentFrame.getCurrentStack = null;
30677
30678 ReactDebugCurrentFrame.getStackAddendum = function () {
30679 var impl = ReactDebugCurrentFrame.getCurrentStack;
30680 if (impl) {
30681 return impl();
30682 }
30683 return null;
30684 };
30685}
30686
30687var SEPARATOR = '.';
30688var SUBSEPARATOR = ':';
30689
30690/**
30691 * Escape and wrap key so it is safe to use as a reactid
30692 *
30693 * @param {string} key to be escaped.
30694 * @return {string} the escaped key.
30695 */
30696function escape(key) {
30697 var escapeRegex = /[=:]/g;
30698 var escaperLookup = {
30699 '=': '=0',
30700 ':': '=2'
30701 };
30702 var escapedString = ('' + key).replace(escapeRegex, function (match) {
30703 return escaperLookup[match];
30704 });
30705
30706 return '$' + escapedString;
30707}
30708
30709/**
30710 * TODO: Test that a single child and an array with one item have the same key
30711 * pattern.
30712 */
30713
30714var didWarnAboutMaps = false;
30715
30716var userProvidedKeyEscapeRegex = /\/+/g;
30717function escapeUserProvidedKey(text) {
30718 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
30719}
30720
30721var POOL_SIZE = 10;
30722var traverseContextPool = [];
30723function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
30724 if (traverseContextPool.length) {
30725 var traverseContext = traverseContextPool.pop();
30726 traverseContext.result = mapResult;
30727 traverseContext.keyPrefix = keyPrefix;
30728 traverseContext.func = mapFunction;
30729 traverseContext.context = mapContext;
30730 traverseContext.count = 0;
30731 return traverseContext;
30732 } else {
30733 return {
30734 result: mapResult,
30735 keyPrefix: keyPrefix,
30736 func: mapFunction,
30737 context: mapContext,
30738 count: 0
30739 };
30740 }
30741}
30742
30743function releaseTraverseContext(traverseContext) {
30744 traverseContext.result = null;
30745 traverseContext.keyPrefix = null;
30746 traverseContext.func = null;
30747 traverseContext.context = null;
30748 traverseContext.count = 0;
30749 if (traverseContextPool.length < POOL_SIZE) {
30750 traverseContextPool.push(traverseContext);
30751 }
30752}
30753
30754/**
30755 * @param {?*} children Children tree container.
30756 * @param {!string} nameSoFar Name of the key path so far.
30757 * @param {!function} callback Callback to invoke with each child found.
30758 * @param {?*} traverseContext Used to pass information throughout the traversal
30759 * process.
30760 * @return {!number} The number of children in this subtree.
30761 */
30762function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
30763 var type = typeof children;
30764
30765 if (type === 'undefined' || type === 'boolean') {
30766 // All of the above are perceived as null.
30767 children = null;
30768 }
30769
30770 var invokeCallback = false;
30771
30772 if (children === null) {
30773 invokeCallback = true;
30774 } else {
30775 switch (type) {
30776 case 'string':
30777 case 'number':
30778 invokeCallback = true;
30779 break;
30780 case 'object':
30781 switch (children.$$typeof) {
30782 case REACT_ELEMENT_TYPE:
30783 case REACT_PORTAL_TYPE:
30784 invokeCallback = true;
30785 }
30786 }
30787 }
30788
30789 if (invokeCallback) {
30790 callback(traverseContext, children,
30791 // If it's the only child, treat the name as if it was wrapped in an array
30792 // so that it's consistent if the number of children grows.
30793 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
30794 return 1;
30795 }
30796
30797 var child = void 0;
30798 var nextName = void 0;
30799 var subtreeCount = 0; // Count of children found in the current subtree.
30800 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
30801
30802 if (Array.isArray(children)) {
30803 for (var i = 0; i < children.length; i++) {
30804 child = children[i];
30805 nextName = nextNamePrefix + getComponentKey(child, i);
30806 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
30807 }
30808 } else {
30809 var iteratorFn = getIteratorFn(children);
30810 if (typeof iteratorFn === 'function') {
30811 {
30812 // Warn about using Maps as children
30813 if (iteratorFn === children.entries) {
30814 !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', ReactDebugCurrentFrame.getStackAddendum()) : void 0;
30815 didWarnAboutMaps = true;
30816 }
30817 }
30818
30819 var iterator = iteratorFn.call(children);
30820 var step = void 0;
30821 var ii = 0;
30822 while (!(step = iterator.next()).done) {
30823 child = step.value;
30824 nextName = nextNamePrefix + getComponentKey(child, ii++);
30825 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
30826 }
30827 } else if (type === 'object') {
30828 var addendum = '';
30829 {
30830 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
30831 }
30832 var childrenString = '' + children;
30833 invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
30834 }
30835 }
30836
30837 return subtreeCount;
30838}
30839
30840/**
30841 * Traverses children that are typically specified as `props.children`, but
30842 * might also be specified through attributes:
30843 *
30844 * - `traverseAllChildren(this.props.children, ...)`
30845 * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
30846 *
30847 * The `traverseContext` is an optional argument that is passed through the
30848 * entire traversal. It can be used to store accumulations or anything else that
30849 * the callback might find relevant.
30850 *
30851 * @param {?*} children Children tree object.
30852 * @param {!function} callback To invoke upon traversing each child.
30853 * @param {?*} traverseContext Context for traversal.
30854 * @return {!number} The number of children in this subtree.
30855 */
30856function traverseAllChildren(children, callback, traverseContext) {
30857 if (children == null) {
30858 return 0;
30859 }
30860
30861 return traverseAllChildrenImpl(children, '', callback, traverseContext);
30862}
30863
30864/**
30865 * Generate a key string that identifies a component within a set.
30866 *
30867 * @param {*} component A component that could contain a manual key.
30868 * @param {number} index Index that is used if a manual key is not provided.
30869 * @return {string}
30870 */
30871function getComponentKey(component, index) {
30872 // Do some typechecking here since we call this blindly. We want to ensure
30873 // that we don't block potential future ES APIs.
30874 if (typeof component === 'object' && component !== null && component.key != null) {
30875 // Explicit key
30876 return escape(component.key);
30877 }
30878 // Implicit key determined by the index in the set
30879 return index.toString(36);
30880}
30881
30882function forEachSingleChild(bookKeeping, child, name) {
30883 var func = bookKeeping.func,
30884 context = bookKeeping.context;
30885
30886 func.call(context, child, bookKeeping.count++);
30887}
30888
30889/**
30890 * Iterates through children that are typically specified as `props.children`.
30891 *
30892 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
30893 *
30894 * The provided forEachFunc(child, index) will be called for each
30895 * leaf child.
30896 *
30897 * @param {?*} children Children tree container.
30898 * @param {function(*, int)} forEachFunc
30899 * @param {*} forEachContext Context for forEachContext.
30900 */
30901function forEachChildren(children, forEachFunc, forEachContext) {
30902 if (children == null) {
30903 return children;
30904 }
30905 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
30906 traverseAllChildren(children, forEachSingleChild, traverseContext);
30907 releaseTraverseContext(traverseContext);
30908}
30909
30910function mapSingleChildIntoContext(bookKeeping, child, childKey) {
30911 var result = bookKeeping.result,
30912 keyPrefix = bookKeeping.keyPrefix,
30913 func = bookKeeping.func,
30914 context = bookKeeping.context;
30915
30916
30917 var mappedChild = func.call(context, child, bookKeeping.count++);
30918 if (Array.isArray(mappedChild)) {
30919 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
30920 } else if (mappedChild != null) {
30921 if (isValidElement(mappedChild)) {
30922 mappedChild = cloneAndReplaceKey(mappedChild,
30923 // Keep both the (mapped) and old keys if they differ, just as
30924 // traverseAllChildren used to do for objects as children
30925 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
30926 }
30927 result.push(mappedChild);
30928 }
30929}
30930
30931function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
30932 var escapedPrefix = '';
30933 if (prefix != null) {
30934 escapedPrefix = escapeUserProvidedKey(prefix) + '/';
30935 }
30936 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
30937 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
30938 releaseTraverseContext(traverseContext);
30939}
30940
30941/**
30942 * Maps children that are typically specified as `props.children`.
30943 *
30944 * See https://reactjs.org/docs/react-api.html#reactchildrenmap
30945 *
30946 * The provided mapFunction(child, key, index) will be called for each
30947 * leaf child.
30948 *
30949 * @param {?*} children Children tree container.
30950 * @param {function(*, int)} func The map function.
30951 * @param {*} context Context for mapFunction.
30952 * @return {object} Object containing the ordered map of results.
30953 */
30954function mapChildren(children, func, context) {
30955 if (children == null) {
30956 return children;
30957 }
30958 var result = [];
30959 mapIntoWithKeyPrefixInternal(children, result, null, func, context);
30960 return result;
30961}
30962
30963/**
30964 * Count the number of children that are typically specified as
30965 * `props.children`.
30966 *
30967 * See https://reactjs.org/docs/react-api.html#reactchildrencount
30968 *
30969 * @param {?*} children Children tree container.
30970 * @return {number} The number of children.
30971 */
30972function countChildren(children) {
30973 return traverseAllChildren(children, emptyFunction.thatReturnsNull, null);
30974}
30975
30976/**
30977 * Flatten a children object (typically specified as `props.children`) and
30978 * return an array with appropriately re-keyed children.
30979 *
30980 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
30981 */
30982function toArray(children) {
30983 var result = [];
30984 mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
30985 return result;
30986}
30987
30988/**
30989 * Returns the first child in a collection of children and verifies that there
30990 * is only one child in the collection.
30991 *
30992 * See https://reactjs.org/docs/react-api.html#reactchildrenonly
30993 *
30994 * The current implementation of this function assumes that a single child gets
30995 * passed without a wrapper, but the purpose of this helper function is to
30996 * abstract away the particular structure of children.
30997 *
30998 * @param {?object} children Child collection structure.
30999 * @return {ReactElement} The first and only `ReactElement` contained in the
31000 * structure.
31001 */
31002function onlyChild(children) {
31003 !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
31004 return children;
31005}
31006
31007function createContext(defaultValue, calculateChangedBits) {
31008 if (calculateChangedBits === undefined) {
31009 calculateChangedBits = null;
31010 } else {
31011 {
31012 !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warning(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
31013 }
31014 }
31015
31016 var context = {
31017 $$typeof: REACT_CONTEXT_TYPE,
31018 _calculateChangedBits: calculateChangedBits,
31019 _defaultValue: defaultValue,
31020 _currentValue: defaultValue,
31021 // As a workaround to support multiple concurrent renderers, we categorize
31022 // some renderers as primary and others as secondary. We only expect
31023 // there to be two concurrent renderers at most: React Native (primary) and
31024 // Fabric (secondary); React DOM (primary) and React ART (secondary).
31025 // Secondary renderers store their context values on separate fields.
31026 _currentValue2: defaultValue,
31027 _changedBits: 0,
31028 _changedBits2: 0,
31029 // These are circular
31030 Provider: null,
31031 Consumer: null
31032 };
31033
31034 context.Provider = {
31035 $$typeof: REACT_PROVIDER_TYPE,
31036 _context: context
31037 };
31038 context.Consumer = context;
31039
31040 {
31041 context._currentRenderer = null;
31042 context._currentRenderer2 = null;
31043 }
31044
31045 return context;
31046}
31047
31048function forwardRef(render) {
31049 {
31050 !(typeof render === 'function') ? warning(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render) : void 0;
31051
31052 if (render != null) {
31053 !(render.defaultProps == null && render.propTypes == null) ? warning(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
31054 }
31055 }
31056
31057 return {
31058 $$typeof: REACT_FORWARD_REF_TYPE,
31059 render: render
31060 };
31061}
31062
31063var describeComponentFrame = function (name, source, ownerName) {
31064 return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
31065};
31066
31067function isValidElementType(type) {
31068 return typeof type === 'string' || typeof type === 'function' ||
31069 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
31070 type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_TIMEOUT_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
31071}
31072
31073function getComponentName(fiber) {
31074 var type = fiber.type;
31075
31076 if (typeof type === 'function') {
31077 return type.displayName || type.name;
31078 }
31079 if (typeof type === 'string') {
31080 return type;
31081 }
31082 switch (type) {
31083 case REACT_ASYNC_MODE_TYPE:
31084 return 'AsyncMode';
31085 case REACT_CONTEXT_TYPE:
31086 return 'Context.Consumer';
31087 case REACT_FRAGMENT_TYPE:
31088 return 'ReactFragment';
31089 case REACT_PORTAL_TYPE:
31090 return 'ReactPortal';
31091 case REACT_PROFILER_TYPE:
31092 return 'Profiler(' + fiber.pendingProps.id + ')';
31093 case REACT_PROVIDER_TYPE:
31094 return 'Context.Provider';
31095 case REACT_STRICT_MODE_TYPE:
31096 return 'StrictMode';
31097 case REACT_TIMEOUT_TYPE:
31098 return 'Timeout';
31099 }
31100 if (typeof type === 'object' && type !== null) {
31101 switch (type.$$typeof) {
31102 case REACT_FORWARD_REF_TYPE:
31103 var functionName = type.render.displayName || type.render.name || '';
31104 return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
31105 }
31106 }
31107 return null;
31108}
31109
31110/**
31111 * ReactElementValidator provides a wrapper around a element factory
31112 * which validates the props passed to the element. This is intended to be
31113 * used only in DEV and could be replaced by a static type checker for languages
31114 * that support it.
31115 */
31116
31117var currentlyValidatingElement = void 0;
31118var propTypesMisspellWarningShown = void 0;
31119
31120var getDisplayName = function () {};
31121var getStackAddendum = function () {};
31122
31123{
31124 currentlyValidatingElement = null;
31125
31126 propTypesMisspellWarningShown = false;
31127
31128 getDisplayName = function (element) {
31129 if (element == null) {
31130 return '#empty';
31131 } else if (typeof element === 'string' || typeof element === 'number') {
31132 return '#text';
31133 } else if (typeof element.type === 'string') {
31134 return element.type;
31135 }
31136
31137 var type = element.type;
31138 if (type === REACT_FRAGMENT_TYPE) {
31139 return 'React.Fragment';
31140 } else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
31141 var functionName = type.render.displayName || type.render.name || '';
31142 return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
31143 } else {
31144 return type.displayName || type.name || 'Unknown';
31145 }
31146 };
31147
31148 getStackAddendum = function () {
31149 var stack = '';
31150 if (currentlyValidatingElement) {
31151 var name = getDisplayName(currentlyValidatingElement);
31152 var owner = currentlyValidatingElement._owner;
31153 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
31154 }
31155 stack += ReactDebugCurrentFrame.getStackAddendum() || '';
31156 return stack;
31157 };
31158}
31159
31160function getDeclarationErrorAddendum() {
31161 if (ReactCurrentOwner.current) {
31162 var name = getComponentName(ReactCurrentOwner.current);
31163 if (name) {
31164 return '\n\nCheck the render method of `' + name + '`.';
31165 }
31166 }
31167 return '';
31168}
31169
31170function getSourceInfoErrorAddendum(elementProps) {
31171 if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
31172 var source = elementProps.__source;
31173 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
31174 var lineNumber = source.lineNumber;
31175 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
31176 }
31177 return '';
31178}
31179
31180/**
31181 * Warn if there's no key explicitly set on dynamic arrays of children or
31182 * object keys are not valid. This allows us to keep track of children between
31183 * updates.
31184 */
31185var ownerHasKeyUseWarning = {};
31186
31187function getCurrentComponentErrorInfo(parentType) {
31188 var info = getDeclarationErrorAddendum();
31189
31190 if (!info) {
31191 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
31192 if (parentName) {
31193 info = '\n\nCheck the top-level render call using <' + parentName + '>.';
31194 }
31195 }
31196 return info;
31197}
31198
31199/**
31200 * Warn if the element doesn't have an explicit key assigned to it.
31201 * This element is in an array. The array could grow and shrink or be
31202 * reordered. All children that haven't already been validated are required to
31203 * have a "key" property assigned to it. Error statuses are cached so a warning
31204 * will only be shown once.
31205 *
31206 * @internal
31207 * @param {ReactElement} element Element that requires a key.
31208 * @param {*} parentType element's parent's type.
31209 */
31210function validateExplicitKey(element, parentType) {
31211 if (!element._store || element._store.validated || element.key != null) {
31212 return;
31213 }
31214 element._store.validated = true;
31215
31216 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
31217 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
31218 return;
31219 }
31220 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
31221
31222 // Usually the current owner is the offender, but if it accepts children as a
31223 // property, it may be the creator of the child that's responsible for
31224 // assigning it a key.
31225 var childOwner = '';
31226 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
31227 // Give the component that originally created this child.
31228 childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.';
31229 }
31230
31231 currentlyValidatingElement = element;
31232 {
31233 warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getStackAddendum());
31234 }
31235 currentlyValidatingElement = null;
31236}
31237
31238/**
31239 * Ensure that every element either is passed in a static location, in an
31240 * array with an explicit keys property defined, or in an object literal
31241 * with valid key property.
31242 *
31243 * @internal
31244 * @param {ReactNode} node Statically passed child of any type.
31245 * @param {*} parentType node's parent's type.
31246 */
31247function validateChildKeys(node, parentType) {
31248 if (typeof node !== 'object') {
31249 return;
31250 }
31251 if (Array.isArray(node)) {
31252 for (var i = 0; i < node.length; i++) {
31253 var child = node[i];
31254 if (isValidElement(child)) {
31255 validateExplicitKey(child, parentType);
31256 }
31257 }
31258 } else if (isValidElement(node)) {
31259 // This element was passed in a valid location.
31260 if (node._store) {
31261 node._store.validated = true;
31262 }
31263 } else if (node) {
31264 var iteratorFn = getIteratorFn(node);
31265 if (typeof iteratorFn === 'function') {
31266 // Entry iterators used to provide implicit keys,
31267 // but now we print a separate warning for them later.
31268 if (iteratorFn !== node.entries) {
31269 var iterator = iteratorFn.call(node);
31270 var step = void 0;
31271 while (!(step = iterator.next()).done) {
31272 if (isValidElement(step.value)) {
31273 validateExplicitKey(step.value, parentType);
31274 }
31275 }
31276 }
31277 }
31278 }
31279}
31280
31281/**
31282 * Given an element, validate that its props follow the propTypes definition,
31283 * provided by the type.
31284 *
31285 * @param {ReactElement} element
31286 */
31287function validatePropTypes(element) {
31288 var type = element.type;
31289 var name = void 0,
31290 propTypes = void 0;
31291 if (typeof type === 'function') {
31292 // Class or functional component
31293 name = type.displayName || type.name;
31294 propTypes = type.propTypes;
31295 } else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
31296 // ForwardRef
31297 var functionName = type.render.displayName || type.render.name || '';
31298 name = functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
31299 propTypes = type.propTypes;
31300 } else {
31301 return;
31302 }
31303 if (propTypes) {
31304 currentlyValidatingElement = element;
31305 checkPropTypes(propTypes, element.props, 'prop', name, getStackAddendum);
31306 currentlyValidatingElement = null;
31307 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
31308 propTypesMisspellWarningShown = true;
31309 warning(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
31310 }
31311 if (typeof type.getDefaultProps === 'function') {
31312 !type.getDefaultProps.isReactClassApproved ? warning(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
31313 }
31314}
31315
31316/**
31317 * Given a fragment, validate that it can only be provided with fragment props
31318 * @param {ReactElement} fragment
31319 */
31320function validateFragmentProps(fragment) {
31321 currentlyValidatingElement = fragment;
31322
31323 var keys = Object.keys(fragment.props);
31324 for (var i = 0; i < keys.length; i++) {
31325 var key = keys[i];
31326 if (key !== 'children' && key !== 'key') {
31327 warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
31328 break;
31329 }
31330 }
31331
31332 if (fragment.ref !== null) {
31333 warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
31334 }
31335
31336 currentlyValidatingElement = null;
31337}
31338
31339function createElementWithValidation(type, props, children) {
31340 var validType = isValidElementType(type);
31341
31342 // We warn in this case but don't throw. We expect the element creation to
31343 // succeed and there will likely be errors in render.
31344 if (!validType) {
31345 var info = '';
31346 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
31347 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
31348 }
31349
31350 var sourceInfo = getSourceInfoErrorAddendum(props);
31351 if (sourceInfo) {
31352 info += sourceInfo;
31353 } else {
31354 info += getDeclarationErrorAddendum();
31355 }
31356
31357 info += getStackAddendum() || '';
31358
31359 var typeString = void 0;
31360 if (type === null) {
31361 typeString = 'null';
31362 } else if (Array.isArray(type)) {
31363 typeString = 'array';
31364 } else {
31365 typeString = typeof type;
31366 }
31367
31368 warning(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
31369 }
31370
31371 var element = createElement.apply(this, arguments);
31372
31373 // The result can be nullish if a mock or a custom function is used.
31374 // TODO: Drop this when these are no longer allowed as the type argument.
31375 if (element == null) {
31376 return element;
31377 }
31378
31379 // Skip key warning if the type isn't valid since our key validation logic
31380 // doesn't expect a non-string/function type and can throw confusing errors.
31381 // We don't want exception behavior to differ between dev and prod.
31382 // (Rendering will throw with a helpful message and as soon as the type is
31383 // fixed, the key warnings will appear.)
31384 if (validType) {
31385 for (var i = 2; i < arguments.length; i++) {
31386 validateChildKeys(arguments[i], type);
31387 }
31388 }
31389
31390 if (type === REACT_FRAGMENT_TYPE) {
31391 validateFragmentProps(element);
31392 } else {
31393 validatePropTypes(element);
31394 }
31395
31396 return element;
31397}
31398
31399function createFactoryWithValidation(type) {
31400 var validatedFactory = createElementWithValidation.bind(null, type);
31401 validatedFactory.type = type;
31402 // Legacy hook: remove it
31403 {
31404 Object.defineProperty(validatedFactory, 'type', {
31405 enumerable: false,
31406 get: function () {
31407 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
31408 Object.defineProperty(this, 'type', {
31409 value: type
31410 });
31411 return type;
31412 }
31413 });
31414 }
31415
31416 return validatedFactory;
31417}
31418
31419function cloneElementWithValidation(element, props, children) {
31420 var newElement = cloneElement.apply(this, arguments);
31421 for (var i = 2; i < arguments.length; i++) {
31422 validateChildKeys(arguments[i], newElement.type);
31423 }
31424 validatePropTypes(newElement);
31425 return newElement;
31426}
31427
31428var React = {
31429 Children: {
31430 map: mapChildren,
31431 forEach: forEachChildren,
31432 count: countChildren,
31433 toArray: toArray,
31434 only: onlyChild
31435 },
31436
31437 createRef: createRef,
31438 Component: Component,
31439 PureComponent: PureComponent,
31440
31441 createContext: createContext,
31442 forwardRef: forwardRef,
31443
31444 Fragment: REACT_FRAGMENT_TYPE,
31445 StrictMode: REACT_STRICT_MODE_TYPE,
31446 unstable_AsyncMode: REACT_ASYNC_MODE_TYPE,
31447 unstable_Profiler: REACT_PROFILER_TYPE,
31448
31449 createElement: createElementWithValidation,
31450 cloneElement: cloneElementWithValidation,
31451 createFactory: createFactoryWithValidation,
31452 isValidElement: isValidElement,
31453
31454 version: ReactVersion,
31455
31456 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
31457 ReactCurrentOwner: ReactCurrentOwner,
31458 // Used by renderers to avoid bundling object-assign twice in UMD bundles:
31459 assign: _assign
31460 }
31461};
31462
31463if (enableSuspense) {
31464 React.Timeout = REACT_TIMEOUT_TYPE;
31465}
31466
31467{
31468 _assign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
31469 // These should not be included in production.
31470 ReactDebugCurrentFrame: ReactDebugCurrentFrame,
31471 // Shim for React DOM 16.0.0 which still destructured (but not used) this.
31472 // TODO: remove in React 17.0.
31473 ReactComponentTreeHook: {}
31474 });
31475}
31476
31477
31478
31479var React$2 = Object.freeze({
31480 default: React
31481});
31482
31483var React$3 = ( React$2 && React ) || React$2;
31484
31485// TODO: decide on the top-level export form.
31486// This is hacky but makes it work with both Rollup and Jest.
31487var react = React$3.default ? React$3.default : React$3;
31488
31489module.exports = react;
31490 })();
31491}
31492
31493
31494/***/ }),
31495/* 37 */
31496/***/ (function(module, exports, __webpack_require__) {
31497
31498"use strict";
31499/**
31500 * Copyright (c) 2014-present, Facebook, Inc.
31501 *
31502 * This source code is licensed under the MIT license found in the
31503 * LICENSE file in the root directory of this source tree.
31504 *
31505 */
31506
31507
31508
31509var emptyFunction = __webpack_require__(13);
31510
31511/**
31512 * Similar to invariant but only logs a warning if the condition is not met.
31513 * This can be used to log issues in development environments in critical
31514 * paths. Removing the logging code for production environments will keep the
31515 * same logic and follow the same code paths.
31516 */
31517
31518var warning = emptyFunction;
31519
31520if ("development".NODE_ENV !== 'production') {
31521 var printWarning = function printWarning(format) {
31522 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
31523 args[_key - 1] = arguments[_key];
31524 }
31525
31526 var argIndex = 0;
31527 var message = 'Warning: ' + format.replace(/%s/g, function () {
31528 return args[argIndex++];
31529 });
31530 if (typeof console !== 'undefined') {
31531 console.error(message);
31532 }
31533 try {
31534 // --- Welcome to debugging React ---
31535 // This error was thrown as a convenience so that you can use this stack
31536 // to find the callsite that caused this warning to fire.
31537 throw new Error(message);
31538 } catch (x) {}
31539 };
31540
31541 warning = function warning(condition, format) {
31542 if (format === undefined) {
31543 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
31544 }
31545
31546 if (format.indexOf('Failed Composite propType: ') === 0) {
31547 return; // Ignore CompositeComponent proptype check.
31548 }
31549
31550 if (!condition) {
31551 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
31552 args[_key2 - 2] = arguments[_key2];
31553 }
31554
31555 printWarning.apply(undefined, [format].concat(args));
31556 }
31557 };
31558}
31559
31560module.exports = warning;
31561
31562/***/ }),
31563/* 38 */
31564/***/ (function(module, exports, __webpack_require__) {
31565
31566var baseIsEqualDeep = __webpack_require__(39),
31567 isObjectLike = __webpack_require__(10);
31568
31569/**
31570 * The base implementation of `_.isEqual` which supports partial comparisons
31571 * and tracks traversed objects.
31572 *
31573 * @private
31574 * @param {*} value The value to compare.
31575 * @param {*} other The other value to compare.
31576 * @param {boolean} bitmask The bitmask flags.
31577 * 1 - Unordered comparison
31578 * 2 - Partial comparison
31579 * @param {Function} [customizer] The function to customize comparisons.
31580 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
31581 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
31582 */
31583function baseIsEqual(value, other, bitmask, customizer, stack) {
31584 if (value === other) {
31585 return true;
31586 }
31587 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
31588 return value !== value && other !== other;
31589 }
31590 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
31591}
31592
31593module.exports = baseIsEqual;
31594
31595
31596/***/ }),
31597/* 39 */
31598/***/ (function(module, exports, __webpack_require__) {
31599
31600var Stack = __webpack_require__(40),
31601 equalArrays = __webpack_require__(28),
31602 equalByTag = __webpack_require__(74),
31603 equalObjects = __webpack_require__(78),
31604 getTag = __webpack_require__(100),
31605 isArray = __webpack_require__(17),
31606 isBuffer = __webpack_require__(29),
31607 isTypedArray = __webpack_require__(31);
31608
31609/** Used to compose bitmasks for value comparisons. */
31610var COMPARE_PARTIAL_FLAG = 1;
31611
31612/** `Object#toString` result references. */
31613var argsTag = '[object Arguments]',
31614 arrayTag = '[object Array]',
31615 objectTag = '[object Object]';
31616
31617/** Used for built-in method references. */
31618var objectProto = Object.prototype;
31619
31620/** Used to check objects for own properties. */
31621var hasOwnProperty = objectProto.hasOwnProperty;
31622
31623/**
31624 * A specialized version of `baseIsEqual` for arrays and objects which performs
31625 * deep comparisons and tracks traversed objects enabling objects with circular
31626 * references to be compared.
31627 *
31628 * @private
31629 * @param {Object} object The object to compare.
31630 * @param {Object} other The other object to compare.
31631 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
31632 * @param {Function} customizer The function to customize comparisons.
31633 * @param {Function} equalFunc The function to determine equivalents of values.
31634 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
31635 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
31636 */
31637function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
31638 var objIsArr = isArray(object),
31639 othIsArr = isArray(other),
31640 objTag = objIsArr ? arrayTag : getTag(object),
31641 othTag = othIsArr ? arrayTag : getTag(other);
31642
31643 objTag = objTag == argsTag ? objectTag : objTag;
31644 othTag = othTag == argsTag ? objectTag : othTag;
31645
31646 var objIsObj = objTag == objectTag,
31647 othIsObj = othTag == objectTag,
31648 isSameTag = objTag == othTag;
31649
31650 if (isSameTag && isBuffer(object)) {
31651 if (!isBuffer(other)) {
31652 return false;
31653 }
31654 objIsArr = true;
31655 objIsObj = false;
31656 }
31657 if (isSameTag && !objIsObj) {
31658 stack || (stack = new Stack);
31659 return (objIsArr || isTypedArray(object))
31660 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
31661 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
31662 }
31663 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
31664 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
31665 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
31666
31667 if (objIsWrapped || othIsWrapped) {
31668 var objUnwrapped = objIsWrapped ? object.value() : object,
31669 othUnwrapped = othIsWrapped ? other.value() : other;
31670
31671 stack || (stack = new Stack);
31672 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
31673 }
31674 }
31675 if (!isSameTag) {
31676 return false;
31677 }
31678 stack || (stack = new Stack);
31679 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
31680}
31681
31682module.exports = baseIsEqualDeep;
31683
31684
31685/***/ }),
31686/* 40 */
31687/***/ (function(module, exports, __webpack_require__) {
31688
31689var ListCache = __webpack_require__(5),
31690 stackClear = __webpack_require__(46),
31691 stackDelete = __webpack_require__(47),
31692 stackGet = __webpack_require__(48),
31693 stackHas = __webpack_require__(49),
31694 stackSet = __webpack_require__(50);
31695
31696/**
31697 * Creates a stack cache object to store key-value pairs.
31698 *
31699 * @private
31700 * @constructor
31701 * @param {Array} [entries] The key-value pairs to cache.
31702 */
31703function Stack(entries) {
31704 var data = this.__data__ = new ListCache(entries);
31705 this.size = data.size;
31706}
31707
31708// Add methods to `Stack`.
31709Stack.prototype.clear = stackClear;
31710Stack.prototype['delete'] = stackDelete;
31711Stack.prototype.get = stackGet;
31712Stack.prototype.has = stackHas;
31713Stack.prototype.set = stackSet;
31714
31715module.exports = Stack;
31716
31717
31718/***/ }),
31719/* 41 */
31720/***/ (function(module, exports) {
31721
31722/**
31723 * Removes all key-value entries from the list cache.
31724 *
31725 * @private
31726 * @name clear
31727 * @memberOf ListCache
31728 */
31729function listCacheClear() {
31730 this.__data__ = [];
31731 this.size = 0;
31732}
31733
31734module.exports = listCacheClear;
31735
31736
31737/***/ }),
31738/* 42 */
31739/***/ (function(module, exports, __webpack_require__) {
31740
31741var assocIndexOf = __webpack_require__(6);
31742
31743/** Used for built-in method references. */
31744var arrayProto = Array.prototype;
31745
31746/** Built-in value references. */
31747var splice = arrayProto.splice;
31748
31749/**
31750 * Removes `key` and its value from the list cache.
31751 *
31752 * @private
31753 * @name delete
31754 * @memberOf ListCache
31755 * @param {string} key The key of the value to remove.
31756 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
31757 */
31758function listCacheDelete(key) {
31759 var data = this.__data__,
31760 index = assocIndexOf(data, key);
31761
31762 if (index < 0) {
31763 return false;
31764 }
31765 var lastIndex = data.length - 1;
31766 if (index == lastIndex) {
31767 data.pop();
31768 } else {
31769 splice.call(data, index, 1);
31770 }
31771 --this.size;
31772 return true;
31773}
31774
31775module.exports = listCacheDelete;
31776
31777
31778/***/ }),
31779/* 43 */
31780/***/ (function(module, exports, __webpack_require__) {
31781
31782var assocIndexOf = __webpack_require__(6);
31783
31784/**
31785 * Gets the list cache value for `key`.
31786 *
31787 * @private
31788 * @name get
31789 * @memberOf ListCache
31790 * @param {string} key The key of the value to get.
31791 * @returns {*} Returns the entry value.
31792 */
31793function listCacheGet(key) {
31794 var data = this.__data__,
31795 index = assocIndexOf(data, key);
31796
31797 return index < 0 ? undefined : data[index][1];
31798}
31799
31800module.exports = listCacheGet;
31801
31802
31803/***/ }),
31804/* 44 */
31805/***/ (function(module, exports, __webpack_require__) {
31806
31807var assocIndexOf = __webpack_require__(6);
31808
31809/**
31810 * Checks if a list cache value for `key` exists.
31811 *
31812 * @private
31813 * @name has
31814 * @memberOf ListCache
31815 * @param {string} key The key of the entry to check.
31816 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
31817 */
31818function listCacheHas(key) {
31819 return assocIndexOf(this.__data__, key) > -1;
31820}
31821
31822module.exports = listCacheHas;
31823
31824
31825/***/ }),
31826/* 45 */
31827/***/ (function(module, exports, __webpack_require__) {
31828
31829var assocIndexOf = __webpack_require__(6);
31830
31831/**
31832 * Sets the list cache `key` to `value`.
31833 *
31834 * @private
31835 * @name set
31836 * @memberOf ListCache
31837 * @param {string} key The key of the value to set.
31838 * @param {*} value The value to set.
31839 * @returns {Object} Returns the list cache instance.
31840 */
31841function listCacheSet(key, value) {
31842 var data = this.__data__,
31843 index = assocIndexOf(data, key);
31844
31845 if (index < 0) {
31846 ++this.size;
31847 data.push([key, value]);
31848 } else {
31849 data[index][1] = value;
31850 }
31851 return this;
31852}
31853
31854module.exports = listCacheSet;
31855
31856
31857/***/ }),
31858/* 46 */
31859/***/ (function(module, exports, __webpack_require__) {
31860
31861var ListCache = __webpack_require__(5);
31862
31863/**
31864 * Removes all key-value entries from the stack.
31865 *
31866 * @private
31867 * @name clear
31868 * @memberOf Stack
31869 */
31870function stackClear() {
31871 this.__data__ = new ListCache;
31872 this.size = 0;
31873}
31874
31875module.exports = stackClear;
31876
31877
31878/***/ }),
31879/* 47 */
31880/***/ (function(module, exports) {
31881
31882/**
31883 * Removes `key` and its value from the stack.
31884 *
31885 * @private
31886 * @name delete
31887 * @memberOf Stack
31888 * @param {string} key The key of the value to remove.
31889 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
31890 */
31891function stackDelete(key) {
31892 var data = this.__data__,
31893 result = data['delete'](key);
31894
31895 this.size = data.size;
31896 return result;
31897}
31898
31899module.exports = stackDelete;
31900
31901
31902/***/ }),
31903/* 48 */
31904/***/ (function(module, exports) {
31905
31906/**
31907 * Gets the stack value for `key`.
31908 *
31909 * @private
31910 * @name get
31911 * @memberOf Stack
31912 * @param {string} key The key of the value to get.
31913 * @returns {*} Returns the entry value.
31914 */
31915function stackGet(key) {
31916 return this.__data__.get(key);
31917}
31918
31919module.exports = stackGet;
31920
31921
31922/***/ }),
31923/* 49 */
31924/***/ (function(module, exports) {
31925
31926/**
31927 * Checks if a stack value for `key` exists.
31928 *
31929 * @private
31930 * @name has
31931 * @memberOf Stack
31932 * @param {string} key The key of the entry to check.
31933 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
31934 */
31935function stackHas(key) {
31936 return this.__data__.has(key);
31937}
31938
31939module.exports = stackHas;
31940
31941
31942/***/ }),
31943/* 50 */
31944/***/ (function(module, exports, __webpack_require__) {
31945
31946var ListCache = __webpack_require__(5),
31947 Map = __webpack_require__(15),
31948 MapCache = __webpack_require__(27);
31949
31950/** Used as the size to enable large array optimizations. */
31951var LARGE_ARRAY_SIZE = 200;
31952
31953/**
31954 * Sets the stack `key` to `value`.
31955 *
31956 * @private
31957 * @name set
31958 * @memberOf Stack
31959 * @param {string} key The key of the value to set.
31960 * @param {*} value The value to set.
31961 * @returns {Object} Returns the stack cache instance.
31962 */
31963function stackSet(key, value) {
31964 var data = this.__data__;
31965 if (data instanceof ListCache) {
31966 var pairs = data.__data__;
31967 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
31968 pairs.push([key, value]);
31969 this.size = ++data.size;
31970 return this;
31971 }
31972 data = this.__data__ = new MapCache(pairs);
31973 }
31974 data.set(key, value);
31975 this.size = data.size;
31976 return this;
31977}
31978
31979module.exports = stackSet;
31980
31981
31982/***/ }),
31983/* 51 */
31984/***/ (function(module, exports, __webpack_require__) {
31985
31986var isFunction = __webpack_require__(22),
31987 isMasked = __webpack_require__(54),
31988 isObject = __webpack_require__(25),
31989 toSource = __webpack_require__(26);
31990
31991/**
31992 * Used to match `RegExp`
31993 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
31994 */
31995var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
31996
31997/** Used to detect host constructors (Safari). */
31998var reIsHostCtor = /^\[object .+?Constructor\]$/;
31999
32000/** Used for built-in method references. */
32001var funcProto = Function.prototype,
32002 objectProto = Object.prototype;
32003
32004/** Used to resolve the decompiled source of functions. */
32005var funcToString = funcProto.toString;
32006
32007/** Used to check objects for own properties. */
32008var hasOwnProperty = objectProto.hasOwnProperty;
32009
32010/** Used to detect if a method is native. */
32011var reIsNative = RegExp('^' +
32012 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
32013 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
32014);
32015
32016/**
32017 * The base implementation of `_.isNative` without bad shim checks.
32018 *
32019 * @private
32020 * @param {*} value The value to check.
32021 * @returns {boolean} Returns `true` if `value` is a native function,
32022 * else `false`.
32023 */
32024function baseIsNative(value) {
32025 if (!isObject(value) || isMasked(value)) {
32026 return false;
32027 }
32028 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
32029 return pattern.test(toSource(value));
32030}
32031
32032module.exports = baseIsNative;
32033
32034
32035/***/ }),
32036/* 52 */
32037/***/ (function(module, exports, __webpack_require__) {
32038
32039var Symbol = __webpack_require__(16);
32040
32041/** Used for built-in method references. */
32042var objectProto = Object.prototype;
32043
32044/** Used to check objects for own properties. */
32045var hasOwnProperty = objectProto.hasOwnProperty;
32046
32047/**
32048 * Used to resolve the
32049 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
32050 * of values.
32051 */
32052var nativeObjectToString = objectProto.toString;
32053
32054/** Built-in value references. */
32055var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
32056
32057/**
32058 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
32059 *
32060 * @private
32061 * @param {*} value The value to query.
32062 * @returns {string} Returns the raw `toStringTag`.
32063 */
32064function getRawTag(value) {
32065 var isOwn = hasOwnProperty.call(value, symToStringTag),
32066 tag = value[symToStringTag];
32067
32068 try {
32069 value[symToStringTag] = undefined;
32070 var unmasked = true;
32071 } catch (e) {}
32072
32073 var result = nativeObjectToString.call(value);
32074 if (unmasked) {
32075 if (isOwn) {
32076 value[symToStringTag] = tag;
32077 } else {
32078 delete value[symToStringTag];
32079 }
32080 }
32081 return result;
32082}
32083
32084module.exports = getRawTag;
32085
32086
32087/***/ }),
32088/* 53 */
32089/***/ (function(module, exports) {
32090
32091/** Used for built-in method references. */
32092var objectProto = Object.prototype;
32093
32094/**
32095 * Used to resolve the
32096 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
32097 * of values.
32098 */
32099var nativeObjectToString = objectProto.toString;
32100
32101/**
32102 * Converts `value` to a string using `Object.prototype.toString`.
32103 *
32104 * @private
32105 * @param {*} value The value to convert.
32106 * @returns {string} Returns the converted string.
32107 */
32108function objectToString(value) {
32109 return nativeObjectToString.call(value);
32110}
32111
32112module.exports = objectToString;
32113
32114
32115/***/ }),
32116/* 54 */
32117/***/ (function(module, exports, __webpack_require__) {
32118
32119var coreJsData = __webpack_require__(55);
32120
32121/** Used to detect methods masquerading as native. */
32122var maskSrcKey = (function() {
32123 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
32124 return uid ? ('Symbol(src)_1.' + uid) : '';
32125}());
32126
32127/**
32128 * Checks if `func` has its source masked.
32129 *
32130 * @private
32131 * @param {Function} func The function to check.
32132 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
32133 */
32134function isMasked(func) {
32135 return !!maskSrcKey && (maskSrcKey in func);
32136}
32137
32138module.exports = isMasked;
32139
32140
32141/***/ }),
32142/* 55 */
32143/***/ (function(module, exports, __webpack_require__) {
32144
32145var root = __webpack_require__(2);
32146
32147/** Used to detect overreaching core-js shims. */
32148var coreJsData = root['__core-js_shared__'];
32149
32150module.exports = coreJsData;
32151
32152
32153/***/ }),
32154/* 56 */
32155/***/ (function(module, exports) {
32156
32157/**
32158 * Gets the value at `key` of `object`.
32159 *
32160 * @private
32161 * @param {Object} [object] The object to query.
32162 * @param {string} key The key of the property to get.
32163 * @returns {*} Returns the property value.
32164 */
32165function getValue(object, key) {
32166 return object == null ? undefined : object[key];
32167}
32168
32169module.exports = getValue;
32170
32171
32172/***/ }),
32173/* 57 */
32174/***/ (function(module, exports, __webpack_require__) {
32175
32176var Hash = __webpack_require__(58),
32177 ListCache = __webpack_require__(5),
32178 Map = __webpack_require__(15);
32179
32180/**
32181 * Removes all key-value entries from the map.
32182 *
32183 * @private
32184 * @name clear
32185 * @memberOf MapCache
32186 */
32187function mapCacheClear() {
32188 this.size = 0;
32189 this.__data__ = {
32190 'hash': new Hash,
32191 'map': new (Map || ListCache),
32192 'string': new Hash
32193 };
32194}
32195
32196module.exports = mapCacheClear;
32197
32198
32199/***/ }),
32200/* 58 */
32201/***/ (function(module, exports, __webpack_require__) {
32202
32203var hashClear = __webpack_require__(59),
32204 hashDelete = __webpack_require__(60),
32205 hashGet = __webpack_require__(61),
32206 hashHas = __webpack_require__(62),
32207 hashSet = __webpack_require__(63);
32208
32209/**
32210 * Creates a hash object.
32211 *
32212 * @private
32213 * @constructor
32214 * @param {Array} [entries] The key-value pairs to cache.
32215 */
32216function Hash(entries) {
32217 var index = -1,
32218 length = entries == null ? 0 : entries.length;
32219
32220 this.clear();
32221 while (++index < length) {
32222 var entry = entries[index];
32223 this.set(entry[0], entry[1]);
32224 }
32225}
32226
32227// Add methods to `Hash`.
32228Hash.prototype.clear = hashClear;
32229Hash.prototype['delete'] = hashDelete;
32230Hash.prototype.get = hashGet;
32231Hash.prototype.has = hashHas;
32232Hash.prototype.set = hashSet;
32233
32234module.exports = Hash;
32235
32236
32237/***/ }),
32238/* 59 */
32239/***/ (function(module, exports, __webpack_require__) {
32240
32241var nativeCreate = __webpack_require__(8);
32242
32243/**
32244 * Removes all key-value entries from the hash.
32245 *
32246 * @private
32247 * @name clear
32248 * @memberOf Hash
32249 */
32250function hashClear() {
32251 this.__data__ = nativeCreate ? nativeCreate(null) : {};
32252 this.size = 0;
32253}
32254
32255module.exports = hashClear;
32256
32257
32258/***/ }),
32259/* 60 */
32260/***/ (function(module, exports) {
32261
32262/**
32263 * Removes `key` and its value from the hash.
32264 *
32265 * @private
32266 * @name delete
32267 * @memberOf Hash
32268 * @param {Object} hash The hash to modify.
32269 * @param {string} key The key of the value to remove.
32270 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
32271 */
32272function hashDelete(key) {
32273 var result = this.has(key) && delete this.__data__[key];
32274 this.size -= result ? 1 : 0;
32275 return result;
32276}
32277
32278module.exports = hashDelete;
32279
32280
32281/***/ }),
32282/* 61 */
32283/***/ (function(module, exports, __webpack_require__) {
32284
32285var nativeCreate = __webpack_require__(8);
32286
32287/** Used to stand-in for `undefined` hash values. */
32288var HASH_UNDEFINED = '__lodash_hash_undefined__';
32289
32290/** Used for built-in method references. */
32291var objectProto = Object.prototype;
32292
32293/** Used to check objects for own properties. */
32294var hasOwnProperty = objectProto.hasOwnProperty;
32295
32296/**
32297 * Gets the hash value for `key`.
32298 *
32299 * @private
32300 * @name get
32301 * @memberOf Hash
32302 * @param {string} key The key of the value to get.
32303 * @returns {*} Returns the entry value.
32304 */
32305function hashGet(key) {
32306 var data = this.__data__;
32307 if (nativeCreate) {
32308 var result = data[key];
32309 return result === HASH_UNDEFINED ? undefined : result;
32310 }
32311 return hasOwnProperty.call(data, key) ? data[key] : undefined;
32312}
32313
32314module.exports = hashGet;
32315
32316
32317/***/ }),
32318/* 62 */
32319/***/ (function(module, exports, __webpack_require__) {
32320
32321var nativeCreate = __webpack_require__(8);
32322
32323/** Used for built-in method references. */
32324var objectProto = Object.prototype;
32325
32326/** Used to check objects for own properties. */
32327var hasOwnProperty = objectProto.hasOwnProperty;
32328
32329/**
32330 * Checks if a hash value for `key` exists.
32331 *
32332 * @private
32333 * @name has
32334 * @memberOf Hash
32335 * @param {string} key The key of the entry to check.
32336 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
32337 */
32338function hashHas(key) {
32339 var data = this.__data__;
32340 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
32341}
32342
32343module.exports = hashHas;
32344
32345
32346/***/ }),
32347/* 63 */
32348/***/ (function(module, exports, __webpack_require__) {
32349
32350var nativeCreate = __webpack_require__(8);
32351
32352/** Used to stand-in for `undefined` hash values. */
32353var HASH_UNDEFINED = '__lodash_hash_undefined__';
32354
32355/**
32356 * Sets the hash `key` to `value`.
32357 *
32358 * @private
32359 * @name set
32360 * @memberOf Hash
32361 * @param {string} key The key of the value to set.
32362 * @param {*} value The value to set.
32363 * @returns {Object} Returns the hash instance.
32364 */
32365function hashSet(key, value) {
32366 var data = this.__data__;
32367 this.size += this.has(key) ? 0 : 1;
32368 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
32369 return this;
32370}
32371
32372module.exports = hashSet;
32373
32374
32375/***/ }),
32376/* 64 */
32377/***/ (function(module, exports, __webpack_require__) {
32378
32379var getMapData = __webpack_require__(9);
32380
32381/**
32382 * Removes `key` and its value from the map.
32383 *
32384 * @private
32385 * @name delete
32386 * @memberOf MapCache
32387 * @param {string} key The key of the value to remove.
32388 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
32389 */
32390function mapCacheDelete(key) {
32391 var result = getMapData(this, key)['delete'](key);
32392 this.size -= result ? 1 : 0;
32393 return result;
32394}
32395
32396module.exports = mapCacheDelete;
32397
32398
32399/***/ }),
32400/* 65 */
32401/***/ (function(module, exports) {
32402
32403/**
32404 * Checks if `value` is suitable for use as unique object key.
32405 *
32406 * @private
32407 * @param {*} value The value to check.
32408 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
32409 */
32410function isKeyable(value) {
32411 var type = typeof value;
32412 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
32413 ? (value !== '__proto__')
32414 : (value === null);
32415}
32416
32417module.exports = isKeyable;
32418
32419
32420/***/ }),
32421/* 66 */
32422/***/ (function(module, exports, __webpack_require__) {
32423
32424var getMapData = __webpack_require__(9);
32425
32426/**
32427 * Gets the map value for `key`.
32428 *
32429 * @private
32430 * @name get
32431 * @memberOf MapCache
32432 * @param {string} key The key of the value to get.
32433 * @returns {*} Returns the entry value.
32434 */
32435function mapCacheGet(key) {
32436 return getMapData(this, key).get(key);
32437}
32438
32439module.exports = mapCacheGet;
32440
32441
32442/***/ }),
32443/* 67 */
32444/***/ (function(module, exports, __webpack_require__) {
32445
32446var getMapData = __webpack_require__(9);
32447
32448/**
32449 * Checks if a map value for `key` exists.
32450 *
32451 * @private
32452 * @name has
32453 * @memberOf MapCache
32454 * @param {string} key The key of the entry to check.
32455 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
32456 */
32457function mapCacheHas(key) {
32458 return getMapData(this, key).has(key);
32459}
32460
32461module.exports = mapCacheHas;
32462
32463
32464/***/ }),
32465/* 68 */
32466/***/ (function(module, exports, __webpack_require__) {
32467
32468var getMapData = __webpack_require__(9);
32469
32470/**
32471 * Sets the map `key` to `value`.
32472 *
32473 * @private
32474 * @name set
32475 * @memberOf MapCache
32476 * @param {string} key The key of the value to set.
32477 * @param {*} value The value to set.
32478 * @returns {Object} Returns the map cache instance.
32479 */
32480function mapCacheSet(key, value) {
32481 var data = getMapData(this, key),
32482 size = data.size;
32483
32484 data.set(key, value);
32485 this.size += data.size == size ? 0 : 1;
32486 return this;
32487}
32488
32489module.exports = mapCacheSet;
32490
32491
32492/***/ }),
32493/* 69 */
32494/***/ (function(module, exports, __webpack_require__) {
32495
32496var MapCache = __webpack_require__(27),
32497 setCacheAdd = __webpack_require__(70),
32498 setCacheHas = __webpack_require__(71);
32499
32500/**
32501 *
32502 * Creates an array cache object to store unique values.
32503 *
32504 * @private
32505 * @constructor
32506 * @param {Array} [values] The values to cache.
32507 */
32508function SetCache(values) {
32509 var index = -1,
32510 length = values == null ? 0 : values.length;
32511
32512 this.__data__ = new MapCache;
32513 while (++index < length) {
32514 this.add(values[index]);
32515 }
32516}
32517
32518// Add methods to `SetCache`.
32519SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
32520SetCache.prototype.has = setCacheHas;
32521
32522module.exports = SetCache;
32523
32524
32525/***/ }),
32526/* 70 */
32527/***/ (function(module, exports) {
32528
32529/** Used to stand-in for `undefined` hash values. */
32530var HASH_UNDEFINED = '__lodash_hash_undefined__';
32531
32532/**
32533 * Adds `value` to the array cache.
32534 *
32535 * @private
32536 * @name add
32537 * @memberOf SetCache
32538 * @alias push
32539 * @param {*} value The value to cache.
32540 * @returns {Object} Returns the cache instance.
32541 */
32542function setCacheAdd(value) {
32543 this.__data__.set(value, HASH_UNDEFINED);
32544 return this;
32545}
32546
32547module.exports = setCacheAdd;
32548
32549
32550/***/ }),
32551/* 71 */
32552/***/ (function(module, exports) {
32553
32554/**
32555 * Checks if `value` is in the array cache.
32556 *
32557 * @private
32558 * @name has
32559 * @memberOf SetCache
32560 * @param {*} value The value to search for.
32561 * @returns {number} Returns `true` if `value` is found, else `false`.
32562 */
32563function setCacheHas(value) {
32564 return this.__data__.has(value);
32565}
32566
32567module.exports = setCacheHas;
32568
32569
32570/***/ }),
32571/* 72 */
32572/***/ (function(module, exports) {
32573
32574/**
32575 * A specialized version of `_.some` for arrays without support for iteratee
32576 * shorthands.
32577 *
32578 * @private
32579 * @param {Array} [array] The array to iterate over.
32580 * @param {Function} predicate The function invoked per iteration.
32581 * @returns {boolean} Returns `true` if any element passes the predicate check,
32582 * else `false`.
32583 */
32584function arraySome(array, predicate) {
32585 var index = -1,
32586 length = array == null ? 0 : array.length;
32587
32588 while (++index < length) {
32589 if (predicate(array[index], index, array)) {
32590 return true;
32591 }
32592 }
32593 return false;
32594}
32595
32596module.exports = arraySome;
32597
32598
32599/***/ }),
32600/* 73 */
32601/***/ (function(module, exports) {
32602
32603/**
32604 * Checks if a `cache` value for `key` exists.
32605 *
32606 * @private
32607 * @param {Object} cache The cache to query.
32608 * @param {string} key The key of the entry to check.
32609 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
32610 */
32611function cacheHas(cache, key) {
32612 return cache.has(key);
32613}
32614
32615module.exports = cacheHas;
32616
32617
32618/***/ }),
32619/* 74 */
32620/***/ (function(module, exports, __webpack_require__) {
32621
32622var Symbol = __webpack_require__(16),
32623 Uint8Array = __webpack_require__(75),
32624 eq = __webpack_require__(21),
32625 equalArrays = __webpack_require__(28),
32626 mapToArray = __webpack_require__(76),
32627 setToArray = __webpack_require__(77);
32628
32629/** Used to compose bitmasks for value comparisons. */
32630var COMPARE_PARTIAL_FLAG = 1,
32631 COMPARE_UNORDERED_FLAG = 2;
32632
32633/** `Object#toString` result references. */
32634var boolTag = '[object Boolean]',
32635 dateTag = '[object Date]',
32636 errorTag = '[object Error]',
32637 mapTag = '[object Map]',
32638 numberTag = '[object Number]',
32639 regexpTag = '[object RegExp]',
32640 setTag = '[object Set]',
32641 stringTag = '[object String]',
32642 symbolTag = '[object Symbol]';
32643
32644var arrayBufferTag = '[object ArrayBuffer]',
32645 dataViewTag = '[object DataView]';
32646
32647/** Used to convert symbols to primitives and strings. */
32648var symbolProto = Symbol ? Symbol.prototype : undefined,
32649 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
32650
32651/**
32652 * A specialized version of `baseIsEqualDeep` for comparing objects of
32653 * the same `toStringTag`.
32654 *
32655 * **Note:** This function only supports comparing values with tags of
32656 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
32657 *
32658 * @private
32659 * @param {Object} object The object to compare.
32660 * @param {Object} other The other object to compare.
32661 * @param {string} tag The `toStringTag` of the objects to compare.
32662 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
32663 * @param {Function} customizer The function to customize comparisons.
32664 * @param {Function} equalFunc The function to determine equivalents of values.
32665 * @param {Object} stack Tracks traversed `object` and `other` objects.
32666 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
32667 */
32668function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
32669 switch (tag) {
32670 case dataViewTag:
32671 if ((object.byteLength != other.byteLength) ||
32672 (object.byteOffset != other.byteOffset)) {
32673 return false;
32674 }
32675 object = object.buffer;
32676 other = other.buffer;
32677
32678 case arrayBufferTag:
32679 if ((object.byteLength != other.byteLength) ||
32680 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
32681 return false;
32682 }
32683 return true;
32684
32685 case boolTag:
32686 case dateTag:
32687 case numberTag:
32688 // Coerce booleans to `1` or `0` and dates to milliseconds.
32689 // Invalid dates are coerced to `NaN`.
32690 return eq(+object, +other);
32691
32692 case errorTag:
32693 return object.name == other.name && object.message == other.message;
32694
32695 case regexpTag:
32696 case stringTag:
32697 // Coerce regexes to strings and treat strings, primitives and objects,
32698 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
32699 // for more details.
32700 return object == (other + '');
32701
32702 case mapTag:
32703 var convert = mapToArray;
32704
32705 case setTag:
32706 var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
32707 convert || (convert = setToArray);
32708
32709 if (object.size != other.size && !isPartial) {
32710 return false;
32711 }
32712 // Assume cyclic values are equal.
32713 var stacked = stack.get(object);
32714 if (stacked) {
32715 return stacked == other;
32716 }
32717 bitmask |= COMPARE_UNORDERED_FLAG;
32718
32719 // Recursively compare objects (susceptible to call stack limits).
32720 stack.set(object, other);
32721 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
32722 stack['delete'](object);
32723 return result;
32724
32725 case symbolTag:
32726 if (symbolValueOf) {
32727 return symbolValueOf.call(object) == symbolValueOf.call(other);
32728 }
32729 }
32730 return false;
32731}
32732
32733module.exports = equalByTag;
32734
32735
32736/***/ }),
32737/* 75 */
32738/***/ (function(module, exports, __webpack_require__) {
32739
32740var root = __webpack_require__(2);
32741
32742/** Built-in value references. */
32743var Uint8Array = root.Uint8Array;
32744
32745module.exports = Uint8Array;
32746
32747
32748/***/ }),
32749/* 76 */
32750/***/ (function(module, exports) {
32751
32752/**
32753 * Converts `map` to its key-value pairs.
32754 *
32755 * @private
32756 * @param {Object} map The map to convert.
32757 * @returns {Array} Returns the key-value pairs.
32758 */
32759function mapToArray(map) {
32760 var index = -1,
32761 result = Array(map.size);
32762
32763 map.forEach(function(value, key) {
32764 result[++index] = [key, value];
32765 });
32766 return result;
32767}
32768
32769module.exports = mapToArray;
32770
32771
32772/***/ }),
32773/* 77 */
32774/***/ (function(module, exports) {
32775
32776/**
32777 * Converts `set` to an array of its values.
32778 *
32779 * @private
32780 * @param {Object} set The set to convert.
32781 * @returns {Array} Returns the values.
32782 */
32783function setToArray(set) {
32784 var index = -1,
32785 result = Array(set.size);
32786
32787 set.forEach(function(value) {
32788 result[++index] = value;
32789 });
32790 return result;
32791}
32792
32793module.exports = setToArray;
32794
32795
32796/***/ }),
32797/* 78 */
32798/***/ (function(module, exports, __webpack_require__) {
32799
32800var getAllKeys = __webpack_require__(79);
32801
32802/** Used to compose bitmasks for value comparisons. */
32803var COMPARE_PARTIAL_FLAG = 1;
32804
32805/** Used for built-in method references. */
32806var objectProto = Object.prototype;
32807
32808/** Used to check objects for own properties. */
32809var hasOwnProperty = objectProto.hasOwnProperty;
32810
32811/**
32812 * A specialized version of `baseIsEqualDeep` for objects with support for
32813 * partial deep comparisons.
32814 *
32815 * @private
32816 * @param {Object} object The object to compare.
32817 * @param {Object} other The other object to compare.
32818 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
32819 * @param {Function} customizer The function to customize comparisons.
32820 * @param {Function} equalFunc The function to determine equivalents of values.
32821 * @param {Object} stack Tracks traversed `object` and `other` objects.
32822 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
32823 */
32824function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
32825 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
32826 objProps = getAllKeys(object),
32827 objLength = objProps.length,
32828 othProps = getAllKeys(other),
32829 othLength = othProps.length;
32830
32831 if (objLength != othLength && !isPartial) {
32832 return false;
32833 }
32834 var index = objLength;
32835 while (index--) {
32836 var key = objProps[index];
32837 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
32838 return false;
32839 }
32840 }
32841 // Assume cyclic values are equal.
32842 var stacked = stack.get(object);
32843 if (stacked && stack.get(other)) {
32844 return stacked == other;
32845 }
32846 var result = true;
32847 stack.set(object, other);
32848 stack.set(other, object);
32849
32850 var skipCtor = isPartial;
32851 while (++index < objLength) {
32852 key = objProps[index];
32853 var objValue = object[key],
32854 othValue = other[key];
32855
32856 if (customizer) {
32857 var compared = isPartial
32858 ? customizer(othValue, objValue, key, other, object, stack)
32859 : customizer(objValue, othValue, key, object, other, stack);
32860 }
32861 // Recursively compare objects (susceptible to call stack limits).
32862 if (!(compared === undefined
32863 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
32864 : compared
32865 )) {
32866 result = false;
32867 break;
32868 }
32869 skipCtor || (skipCtor = key == 'constructor');
32870 }
32871 if (result && !skipCtor) {
32872 var objCtor = object.constructor,
32873 othCtor = other.constructor;
32874
32875 // Non `Object` object instances with different constructors are not equal.
32876 if (objCtor != othCtor &&
32877 ('constructor' in object && 'constructor' in other) &&
32878 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
32879 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
32880 result = false;
32881 }
32882 }
32883 stack['delete'](object);
32884 stack['delete'](other);
32885 return result;
32886}
32887
32888module.exports = equalObjects;
32889
32890
32891/***/ }),
32892/* 79 */
32893/***/ (function(module, exports, __webpack_require__) {
32894
32895var baseGetAllKeys = __webpack_require__(80),
32896 getSymbols = __webpack_require__(82),
32897 keys = __webpack_require__(85);
32898
32899/**
32900 * Creates an array of own enumerable property names and symbols of `object`.
32901 *
32902 * @private
32903 * @param {Object} object The object to query.
32904 * @returns {Array} Returns the array of property names and symbols.
32905 */
32906function getAllKeys(object) {
32907 return baseGetAllKeys(object, keys, getSymbols);
32908}
32909
32910module.exports = getAllKeys;
32911
32912
32913/***/ }),
32914/* 80 */
32915/***/ (function(module, exports, __webpack_require__) {
32916
32917var arrayPush = __webpack_require__(81),
32918 isArray = __webpack_require__(17);
32919
32920/**
32921 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
32922 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
32923 * symbols of `object`.
32924 *
32925 * @private
32926 * @param {Object} object The object to query.
32927 * @param {Function} keysFunc The function to get the keys of `object`.
32928 * @param {Function} symbolsFunc The function to get the symbols of `object`.
32929 * @returns {Array} Returns the array of property names and symbols.
32930 */
32931function baseGetAllKeys(object, keysFunc, symbolsFunc) {
32932 var result = keysFunc(object);
32933 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
32934}
32935
32936module.exports = baseGetAllKeys;
32937
32938
32939/***/ }),
32940/* 81 */
32941/***/ (function(module, exports) {
32942
32943/**
32944 * Appends the elements of `values` to `array`.
32945 *
32946 * @private
32947 * @param {Array} array The array to modify.
32948 * @param {Array} values The values to append.
32949 * @returns {Array} Returns `array`.
32950 */
32951function arrayPush(array, values) {
32952 var index = -1,
32953 length = values.length,
32954 offset = array.length;
32955
32956 while (++index < length) {
32957 array[offset + index] = values[index];
32958 }
32959 return array;
32960}
32961
32962module.exports = arrayPush;
32963
32964
32965/***/ }),
32966/* 82 */
32967/***/ (function(module, exports, __webpack_require__) {
32968
32969var arrayFilter = __webpack_require__(83),
32970 stubArray = __webpack_require__(84);
32971
32972/** Used for built-in method references. */
32973var objectProto = Object.prototype;
32974
32975/** Built-in value references. */
32976var propertyIsEnumerable = objectProto.propertyIsEnumerable;
32977
32978/* Built-in method references for those with the same name as other `lodash` methods. */
32979var nativeGetSymbols = Object.getOwnPropertySymbols;
32980
32981/**
32982 * Creates an array of the own enumerable symbols of `object`.
32983 *
32984 * @private
32985 * @param {Object} object The object to query.
32986 * @returns {Array} Returns the array of symbols.
32987 */
32988var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
32989 if (object == null) {
32990 return [];
32991 }
32992 object = Object(object);
32993 return arrayFilter(nativeGetSymbols(object), function(symbol) {
32994 return propertyIsEnumerable.call(object, symbol);
32995 });
32996};
32997
32998module.exports = getSymbols;
32999
33000
33001/***/ }),
33002/* 83 */
33003/***/ (function(module, exports) {
33004
33005/**
33006 * A specialized version of `_.filter` for arrays without support for
33007 * iteratee shorthands.
33008 *
33009 * @private
33010 * @param {Array} [array] The array to iterate over.
33011 * @param {Function} predicate The function invoked per iteration.
33012 * @returns {Array} Returns the new filtered array.
33013 */
33014function arrayFilter(array, predicate) {
33015 var index = -1,
33016 length = array == null ? 0 : array.length,
33017 resIndex = 0,
33018 result = [];
33019
33020 while (++index < length) {
33021 var value = array[index];
33022 if (predicate(value, index, array)) {
33023 result[resIndex++] = value;
33024 }
33025 }
33026 return result;
33027}
33028
33029module.exports = arrayFilter;
33030
33031
33032/***/ }),
33033/* 84 */
33034/***/ (function(module, exports) {
33035
33036/**
33037 * This method returns a new empty array.
33038 *
33039 * @static
33040 * @memberOf _
33041 * @since 4.13.0
33042 * @category Util
33043 * @returns {Array} Returns the new empty array.
33044 * @example
33045 *
33046 * var arrays = _.times(2, _.stubArray);
33047 *
33048 * console.log(arrays);
33049 * // => [[], []]
33050 *
33051 * console.log(arrays[0] === arrays[1]);
33052 * // => false
33053 */
33054function stubArray() {
33055 return [];
33056}
33057
33058module.exports = stubArray;
33059
33060
33061/***/ }),
33062/* 85 */
33063/***/ (function(module, exports, __webpack_require__) {
33064
33065var arrayLikeKeys = __webpack_require__(86),
33066 baseKeys = __webpack_require__(95),
33067 isArrayLike = __webpack_require__(99);
33068
33069/**
33070 * Creates an array of the own enumerable property names of `object`.
33071 *
33072 * **Note:** Non-object values are coerced to objects. See the
33073 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
33074 * for more details.
33075 *
33076 * @static
33077 * @since 0.1.0
33078 * @memberOf _
33079 * @category Object
33080 * @param {Object} object The object to query.
33081 * @returns {Array} Returns the array of property names.
33082 * @example
33083 *
33084 * function Foo() {
33085 * this.a = 1;
33086 * this.b = 2;
33087 * }
33088 *
33089 * Foo.prototype.c = 3;
33090 *
33091 * _.keys(new Foo);
33092 * // => ['a', 'b'] (iteration order is not guaranteed)
33093 *
33094 * _.keys('hi');
33095 * // => ['0', '1']
33096 */
33097function keys(object) {
33098 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
33099}
33100
33101module.exports = keys;
33102
33103
33104/***/ }),
33105/* 86 */
33106/***/ (function(module, exports, __webpack_require__) {
33107
33108var baseTimes = __webpack_require__(87),
33109 isArguments = __webpack_require__(88),
33110 isArray = __webpack_require__(17),
33111 isBuffer = __webpack_require__(29),
33112 isIndex = __webpack_require__(91),
33113 isTypedArray = __webpack_require__(31);
33114
33115/** Used for built-in method references. */
33116var objectProto = Object.prototype;
33117
33118/** Used to check objects for own properties. */
33119var hasOwnProperty = objectProto.hasOwnProperty;
33120
33121/**
33122 * Creates an array of the enumerable property names of the array-like `value`.
33123 *
33124 * @private
33125 * @param {*} value The value to query.
33126 * @param {boolean} inherited Specify returning inherited property names.
33127 * @returns {Array} Returns the array of property names.
33128 */
33129function arrayLikeKeys(value, inherited) {
33130 var isArr = isArray(value),
33131 isArg = !isArr && isArguments(value),
33132 isBuff = !isArr && !isArg && isBuffer(value),
33133 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
33134 skipIndexes = isArr || isArg || isBuff || isType,
33135 result = skipIndexes ? baseTimes(value.length, String) : [],
33136 length = result.length;
33137
33138 for (var key in value) {
33139 if ((inherited || hasOwnProperty.call(value, key)) &&
33140 !(skipIndexes && (
33141 // Safari 9 has enumerable `arguments.length` in strict mode.
33142 key == 'length' ||
33143 // Node.js 0.10 has enumerable non-index properties on buffers.
33144 (isBuff && (key == 'offset' || key == 'parent')) ||
33145 // PhantomJS 2 has enumerable non-index properties on typed arrays.
33146 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
33147 // Skip index properties.
33148 isIndex(key, length)
33149 ))) {
33150 result.push(key);
33151 }
33152 }
33153 return result;
33154}
33155
33156module.exports = arrayLikeKeys;
33157
33158
33159/***/ }),
33160/* 87 */
33161/***/ (function(module, exports) {
33162
33163/**
33164 * The base implementation of `_.times` without support for iteratee shorthands
33165 * or max array length checks.
33166 *
33167 * @private
33168 * @param {number} n The number of times to invoke `iteratee`.
33169 * @param {Function} iteratee The function invoked per iteration.
33170 * @returns {Array} Returns the array of results.
33171 */
33172function baseTimes(n, iteratee) {
33173 var index = -1,
33174 result = Array(n);
33175
33176 while (++index < n) {
33177 result[index] = iteratee(index);
33178 }
33179 return result;
33180}
33181
33182module.exports = baseTimes;
33183
33184
33185/***/ }),
33186/* 88 */
33187/***/ (function(module, exports, __webpack_require__) {
33188
33189var baseIsArguments = __webpack_require__(89),
33190 isObjectLike = __webpack_require__(10);
33191
33192/** Used for built-in method references. */
33193var objectProto = Object.prototype;
33194
33195/** Used to check objects for own properties. */
33196var hasOwnProperty = objectProto.hasOwnProperty;
33197
33198/** Built-in value references. */
33199var propertyIsEnumerable = objectProto.propertyIsEnumerable;
33200
33201/**
33202 * Checks if `value` is likely an `arguments` object.
33203 *
33204 * @static
33205 * @memberOf _
33206 * @since 0.1.0
33207 * @category Lang
33208 * @param {*} value The value to check.
33209 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
33210 * else `false`.
33211 * @example
33212 *
33213 * _.isArguments(function() { return arguments; }());
33214 * // => true
33215 *
33216 * _.isArguments([1, 2, 3]);
33217 * // => false
33218 */
33219var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
33220 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
33221 !propertyIsEnumerable.call(value, 'callee');
33222};
33223
33224module.exports = isArguments;
33225
33226
33227/***/ }),
33228/* 89 */
33229/***/ (function(module, exports, __webpack_require__) {
33230
33231var baseGetTag = __webpack_require__(7),
33232 isObjectLike = __webpack_require__(10);
33233
33234/** `Object#toString` result references. */
33235var argsTag = '[object Arguments]';
33236
33237/**
33238 * The base implementation of `_.isArguments`.
33239 *
33240 * @private
33241 * @param {*} value The value to check.
33242 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
33243 */
33244function baseIsArguments(value) {
33245 return isObjectLike(value) && baseGetTag(value) == argsTag;
33246}
33247
33248module.exports = baseIsArguments;
33249
33250
33251/***/ }),
33252/* 90 */
33253/***/ (function(module, exports) {
33254
33255/**
33256 * This method returns `false`.
33257 *
33258 * @static
33259 * @memberOf _
33260 * @since 4.13.0
33261 * @category Util
33262 * @returns {boolean} Returns `false`.
33263 * @example
33264 *
33265 * _.times(2, _.stubFalse);
33266 * // => [false, false]
33267 */
33268function stubFalse() {
33269 return false;
33270}
33271
33272module.exports = stubFalse;
33273
33274
33275/***/ }),
33276/* 91 */
33277/***/ (function(module, exports) {
33278
33279/** Used as references for various `Number` constants. */
33280var MAX_SAFE_INTEGER = 9007199254740991;
33281
33282/** Used to detect unsigned integer values. */
33283var reIsUint = /^(?:0|[1-9]\d*)$/;
33284
33285/**
33286 * Checks if `value` is a valid array-like index.
33287 *
33288 * @private
33289 * @param {*} value The value to check.
33290 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
33291 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
33292 */
33293function isIndex(value, length) {
33294 var type = typeof value;
33295 length = length == null ? MAX_SAFE_INTEGER : length;
33296
33297 return !!length &&
33298 (type == 'number' ||
33299 (type != 'symbol' && reIsUint.test(value))) &&
33300 (value > -1 && value % 1 == 0 && value < length);
33301}
33302
33303module.exports = isIndex;
33304
33305
33306/***/ }),
33307/* 92 */
33308/***/ (function(module, exports, __webpack_require__) {
33309
33310var baseGetTag = __webpack_require__(7),
33311 isLength = __webpack_require__(32),
33312 isObjectLike = __webpack_require__(10);
33313
33314/** `Object#toString` result references. */
33315var argsTag = '[object Arguments]',
33316 arrayTag = '[object Array]',
33317 boolTag = '[object Boolean]',
33318 dateTag = '[object Date]',
33319 errorTag = '[object Error]',
33320 funcTag = '[object Function]',
33321 mapTag = '[object Map]',
33322 numberTag = '[object Number]',
33323 objectTag = '[object Object]',
33324 regexpTag = '[object RegExp]',
33325 setTag = '[object Set]',
33326 stringTag = '[object String]',
33327 weakMapTag = '[object WeakMap]';
33328
33329var arrayBufferTag = '[object ArrayBuffer]',
33330 dataViewTag = '[object DataView]',
33331 float32Tag = '[object Float32Array]',
33332 float64Tag = '[object Float64Array]',
33333 int8Tag = '[object Int8Array]',
33334 int16Tag = '[object Int16Array]',
33335 int32Tag = '[object Int32Array]',
33336 uint8Tag = '[object Uint8Array]',
33337 uint8ClampedTag = '[object Uint8ClampedArray]',
33338 uint16Tag = '[object Uint16Array]',
33339 uint32Tag = '[object Uint32Array]';
33340
33341/** Used to identify `toStringTag` values of typed arrays. */
33342var typedArrayTags = {};
33343typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
33344typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
33345typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
33346typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
33347typedArrayTags[uint32Tag] = true;
33348typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
33349typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
33350typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
33351typedArrayTags[errorTag] = typedArrayTags[funcTag] =
33352typedArrayTags[mapTag] = typedArrayTags[numberTag] =
33353typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
33354typedArrayTags[setTag] = typedArrayTags[stringTag] =
33355typedArrayTags[weakMapTag] = false;
33356
33357/**
33358 * The base implementation of `_.isTypedArray` without Node.js optimizations.
33359 *
33360 * @private
33361 * @param {*} value The value to check.
33362 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
33363 */
33364function baseIsTypedArray(value) {
33365 return isObjectLike(value) &&
33366 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
33367}
33368
33369module.exports = baseIsTypedArray;
33370
33371
33372/***/ }),
33373/* 93 */
33374/***/ (function(module, exports) {
33375
33376/**
33377 * The base implementation of `_.unary` without support for storing metadata.
33378 *
33379 * @private
33380 * @param {Function} func The function to cap arguments for.
33381 * @returns {Function} Returns the new capped function.
33382 */
33383function baseUnary(func) {
33384 return function(value) {
33385 return func(value);
33386 };
33387}
33388
33389module.exports = baseUnary;
33390
33391
33392/***/ }),
33393/* 94 */
33394/***/ (function(module, exports, __webpack_require__) {
33395
33396/* WEBPACK VAR INJECTION */(function(module) {var freeGlobal = __webpack_require__(23);
33397
33398/** Detect free variable `exports`. */
33399var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
33400
33401/** Detect free variable `module`. */
33402var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
33403
33404/** Detect the popular CommonJS extension `module.exports`. */
33405var moduleExports = freeModule && freeModule.exports === freeExports;
33406
33407/** Detect free variable `process` from Node.js. */
33408var freeProcess = moduleExports && freeGlobal.process;
33409
33410/** Used to access faster Node.js helpers. */
33411var nodeUtil = (function() {
33412 try {
33413 // Use `util.types` for Node.js 10+.
33414 var types = freeModule && freeModule.require && freeModule.require('util').types;
33415
33416 if (types) {
33417 return types;
33418 }
33419
33420 // Legacy `process.binding('util')` for Node.js < 10.
33421 return freeProcess && freeProcess.binding && freeProcess.binding('util');
33422 } catch (e) {}
33423}());
33424
33425module.exports = nodeUtil;
33426
33427/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(30)(module)))
33428
33429/***/ }),
33430/* 95 */
33431/***/ (function(module, exports, __webpack_require__) {
33432
33433var isPrototype = __webpack_require__(96),
33434 nativeKeys = __webpack_require__(97);
33435
33436/** Used for built-in method references. */
33437var objectProto = Object.prototype;
33438
33439/** Used to check objects for own properties. */
33440var hasOwnProperty = objectProto.hasOwnProperty;
33441
33442/**
33443 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
33444 *
33445 * @private
33446 * @param {Object} object The object to query.
33447 * @returns {Array} Returns the array of property names.
33448 */
33449function baseKeys(object) {
33450 if (!isPrototype(object)) {
33451 return nativeKeys(object);
33452 }
33453 var result = [];
33454 for (var key in Object(object)) {
33455 if (hasOwnProperty.call(object, key) && key != 'constructor') {
33456 result.push(key);
33457 }
33458 }
33459 return result;
33460}
33461
33462module.exports = baseKeys;
33463
33464
33465/***/ }),
33466/* 96 */
33467/***/ (function(module, exports) {
33468
33469/** Used for built-in method references. */
33470var objectProto = Object.prototype;
33471
33472/**
33473 * Checks if `value` is likely a prototype object.
33474 *
33475 * @private
33476 * @param {*} value The value to check.
33477 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
33478 */
33479function isPrototype(value) {
33480 var Ctor = value && value.constructor,
33481 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
33482
33483 return value === proto;
33484}
33485
33486module.exports = isPrototype;
33487
33488
33489/***/ }),
33490/* 97 */
33491/***/ (function(module, exports, __webpack_require__) {
33492
33493var overArg = __webpack_require__(98);
33494
33495/* Built-in method references for those with the same name as other `lodash` methods. */
33496var nativeKeys = overArg(Object.keys, Object);
33497
33498module.exports = nativeKeys;
33499
33500
33501/***/ }),
33502/* 98 */
33503/***/ (function(module, exports) {
33504
33505/**
33506 * Creates a unary function that invokes `func` with its argument transformed.
33507 *
33508 * @private
33509 * @param {Function} func The function to wrap.
33510 * @param {Function} transform The argument transform.
33511 * @returns {Function} Returns the new function.
33512 */
33513function overArg(func, transform) {
33514 return function(arg) {
33515 return func(transform(arg));
33516 };
33517}
33518
33519module.exports = overArg;
33520
33521
33522/***/ }),
33523/* 99 */
33524/***/ (function(module, exports, __webpack_require__) {
33525
33526var isFunction = __webpack_require__(22),
33527 isLength = __webpack_require__(32);
33528
33529/**
33530 * Checks if `value` is array-like. A value is considered array-like if it's
33531 * not a function and has a `value.length` that's an integer greater than or
33532 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
33533 *
33534 * @static
33535 * @memberOf _
33536 * @since 4.0.0
33537 * @category Lang
33538 * @param {*} value The value to check.
33539 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
33540 * @example
33541 *
33542 * _.isArrayLike([1, 2, 3]);
33543 * // => true
33544 *
33545 * _.isArrayLike(document.body.children);
33546 * // => true
33547 *
33548 * _.isArrayLike('abc');
33549 * // => true
33550 *
33551 * _.isArrayLike(_.noop);
33552 * // => false
33553 */
33554function isArrayLike(value) {
33555 return value != null && isLength(value.length) && !isFunction(value);
33556}
33557
33558module.exports = isArrayLike;
33559
33560
33561/***/ }),
33562/* 100 */
33563/***/ (function(module, exports, __webpack_require__) {
33564
33565var DataView = __webpack_require__(101),
33566 Map = __webpack_require__(15),
33567 Promise = __webpack_require__(102),
33568 Set = __webpack_require__(103),
33569 WeakMap = __webpack_require__(104),
33570 baseGetTag = __webpack_require__(7),
33571 toSource = __webpack_require__(26);
33572
33573/** `Object#toString` result references. */
33574var mapTag = '[object Map]',
33575 objectTag = '[object Object]',
33576 promiseTag = '[object Promise]',
33577 setTag = '[object Set]',
33578 weakMapTag = '[object WeakMap]';
33579
33580var dataViewTag = '[object DataView]';
33581
33582/** Used to detect maps, sets, and weakmaps. */
33583var dataViewCtorString = toSource(DataView),
33584 mapCtorString = toSource(Map),
33585 promiseCtorString = toSource(Promise),
33586 setCtorString = toSource(Set),
33587 weakMapCtorString = toSource(WeakMap);
33588
33589/**
33590 * Gets the `toStringTag` of `value`.
33591 *
33592 * @private
33593 * @param {*} value The value to query.
33594 * @returns {string} Returns the `toStringTag`.
33595 */
33596var getTag = baseGetTag;
33597
33598// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
33599if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
33600 (Map && getTag(new Map) != mapTag) ||
33601 (Promise && getTag(Promise.resolve()) != promiseTag) ||
33602 (Set && getTag(new Set) != setTag) ||
33603 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
33604 getTag = function(value) {
33605 var result = baseGetTag(value),
33606 Ctor = result == objectTag ? value.constructor : undefined,
33607 ctorString = Ctor ? toSource(Ctor) : '';
33608
33609 if (ctorString) {
33610 switch (ctorString) {
33611 case dataViewCtorString: return dataViewTag;
33612 case mapCtorString: return mapTag;
33613 case promiseCtorString: return promiseTag;
33614 case setCtorString: return setTag;
33615 case weakMapCtorString: return weakMapTag;
33616 }
33617 }
33618 return result;
33619 };
33620}
33621
33622module.exports = getTag;
33623
33624
33625/***/ }),
33626/* 101 */
33627/***/ (function(module, exports, __webpack_require__) {
33628
33629var getNative = __webpack_require__(4),
33630 root = __webpack_require__(2);
33631
33632/* Built-in method references that are verified to be native. */
33633var DataView = getNative(root, 'DataView');
33634
33635module.exports = DataView;
33636
33637
33638/***/ }),
33639/* 102 */
33640/***/ (function(module, exports, __webpack_require__) {
33641
33642var getNative = __webpack_require__(4),
33643 root = __webpack_require__(2);
33644
33645/* Built-in method references that are verified to be native. */
33646var Promise = getNative(root, 'Promise');
33647
33648module.exports = Promise;
33649
33650
33651/***/ }),
33652/* 103 */
33653/***/ (function(module, exports, __webpack_require__) {
33654
33655var getNative = __webpack_require__(4),
33656 root = __webpack_require__(2);
33657
33658/* Built-in method references that are verified to be native. */
33659var Set = getNative(root, 'Set');
33660
33661module.exports = Set;
33662
33663
33664/***/ }),
33665/* 104 */
33666/***/ (function(module, exports, __webpack_require__) {
33667
33668var getNative = __webpack_require__(4),
33669 root = __webpack_require__(2);
33670
33671/* Built-in method references that are verified to be native. */
33672var WeakMap = getNative(root, 'WeakMap');
33673
33674module.exports = WeakMap;
33675
33676
33677/***/ }),
33678/* 105 */
33679/***/ (function(module, exports, __webpack_require__) {
33680
33681"use strict";
33682/**
33683 * Copyright (c) 2013-present, Facebook, Inc.
33684 *
33685 * This source code is licensed under the MIT license found in the
33686 * LICENSE file in the root directory of this source tree.
33687 */
33688
33689
33690
33691var assign = __webpack_require__(12);
33692
33693var ReactPropTypesSecret = __webpack_require__(14);
33694var checkPropTypes = __webpack_require__(20);
33695
33696var printWarning = function() {};
33697
33698if ("development".NODE_ENV !== 'production') {
33699 printWarning = function(text) {
33700 var message = 'Warning: ' + text;
33701 if (typeof console !== 'undefined') {
33702 console.error(message);
33703 }
33704 try {
33705 // --- Welcome to debugging React ---
33706 // This error was thrown as a convenience so that you can use this stack
33707 // to find the callsite that caused this warning to fire.
33708 throw new Error(message);
33709 } catch (x) {}
33710 };
33711}
33712
33713function emptyFunctionThatReturnsNull() {
33714 return null;
33715}
33716
33717module.exports = function(isValidElement, throwOnDirectAccess) {
33718 /* global Symbol */
33719 var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
33720 var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
33721
33722 /**
33723 * Returns the iterator method function contained on the iterable object.
33724 *
33725 * Be sure to invoke the function with the iterable as context:
33726 *
33727 * var iteratorFn = getIteratorFn(myIterable);
33728 * if (iteratorFn) {
33729 * var iterator = iteratorFn.call(myIterable);
33730 * ...
33731 * }
33732 *
33733 * @param {?object} maybeIterable
33734 * @return {?function}
33735 */
33736 function getIteratorFn(maybeIterable) {
33737 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
33738 if (typeof iteratorFn === 'function') {
33739 return iteratorFn;
33740 }
33741 }
33742
33743 /**
33744 * Collection of methods that allow declaration and validation of props that are
33745 * supplied to React components. Example usage:
33746 *
33747 * var Props = require('ReactPropTypes');
33748 * var MyArticle = React.createClass({
33749 * propTypes: {
33750 * // An optional string prop named "description".
33751 * description: Props.string,
33752 *
33753 * // A required enum prop named "category".
33754 * category: Props.oneOf(['News','Photos']).isRequired,
33755 *
33756 * // A prop named "dialog" that requires an instance of Dialog.
33757 * dialog: Props.instanceOf(Dialog).isRequired
33758 * },
33759 * render: function() { ... }
33760 * });
33761 *
33762 * A more formal specification of how these methods are used:
33763 *
33764 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
33765 * decl := ReactPropTypes.{type}(.isRequired)?
33766 *
33767 * Each and every declaration produces a function with the same signature. This
33768 * allows the creation of custom validation functions. For example:
33769 *
33770 * var MyLink = React.createClass({
33771 * propTypes: {
33772 * // An optional string or URI prop named "href".
33773 * href: function(props, propName, componentName) {
33774 * var propValue = props[propName];
33775 * if (propValue != null && typeof propValue !== 'string' &&
33776 * !(propValue instanceof URI)) {
33777 * return new Error(
33778 * 'Expected a string or an URI for ' + propName + ' in ' +
33779 * componentName
33780 * );
33781 * }
33782 * }
33783 * },
33784 * render: function() {...}
33785 * });
33786 *
33787 * @internal
33788 */
33789
33790 var ANONYMOUS = '<<anonymous>>';
33791
33792 // Important!
33793 // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
33794 var ReactPropTypes = {
33795 array: createPrimitiveTypeChecker('array'),
33796 bool: createPrimitiveTypeChecker('boolean'),
33797 func: createPrimitiveTypeChecker('function'),
33798 number: createPrimitiveTypeChecker('number'),
33799 object: createPrimitiveTypeChecker('object'),
33800 string: createPrimitiveTypeChecker('string'),
33801 symbol: createPrimitiveTypeChecker('symbol'),
33802
33803 any: createAnyTypeChecker(),
33804 arrayOf: createArrayOfTypeChecker,
33805 element: createElementTypeChecker(),
33806 instanceOf: createInstanceTypeChecker,
33807 node: createNodeChecker(),
33808 objectOf: createObjectOfTypeChecker,
33809 oneOf: createEnumTypeChecker,
33810 oneOfType: createUnionTypeChecker,
33811 shape: createShapeTypeChecker,
33812 exact: createStrictShapeTypeChecker,
33813 };
33814
33815 /**
33816 * inlined Object.is polyfill to avoid requiring consumers ship their own
33817 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
33818 */
33819 /*eslint-disable no-self-compare*/
33820 function is(x, y) {
33821 // SameValue algorithm
33822 if (x === y) {
33823 // Steps 1-5, 7-10
33824 // Steps 6.b-6.e: +0 != -0
33825 return x !== 0 || 1 / x === 1 / y;
33826 } else {
33827 // Step 6.a: NaN == NaN
33828 return x !== x && y !== y;
33829 }
33830 }
33831 /*eslint-enable no-self-compare*/
33832
33833 /**
33834 * We use an Error-like object for backward compatibility as people may call
33835 * PropTypes directly and inspect their output. However, we don't use real
33836 * Errors anymore. We don't inspect their stack anyway, and creating them
33837 * is prohibitively expensive if they are created too often, such as what
33838 * happens in oneOfType() for any type before the one that matched.
33839 */
33840 function PropTypeError(message) {
33841 this.message = message;
33842 this.stack = '';
33843 }
33844 // Make `instanceof Error` still work for returned errors.
33845 PropTypeError.prototype = Error.prototype;
33846
33847 function createChainableTypeChecker(validate) {
33848 if ("development".NODE_ENV !== 'production') {
33849 var manualPropTypeCallCache = {};
33850 var manualPropTypeWarningCount = 0;
33851 }
33852 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
33853 componentName = componentName || ANONYMOUS;
33854 propFullName = propFullName || propName;
33855
33856 if (secret !== ReactPropTypesSecret) {
33857 if (throwOnDirectAccess) {
33858 // New behavior only for users of `prop-types` package
33859 var err = new Error(
33860 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
33861 'Use `PropTypes.checkPropTypes()` to call them. ' +
33862 'Read more at http://fb.me/use-check-prop-types'
33863 );
33864 err.name = 'Invariant Violation';
33865 throw err;
33866 } else if ("development".NODE_ENV !== 'production' && typeof console !== 'undefined') {
33867 // Old behavior for people using React.PropTypes
33868 var cacheKey = componentName + ':' + propName;
33869 if (
33870 !manualPropTypeCallCache[cacheKey] &&
33871 // Avoid spamming the console because they are often not actionable except for lib authors
33872 manualPropTypeWarningCount < 3
33873 ) {
33874 printWarning(
33875 'You are manually calling a React.PropTypes validation ' +
33876 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
33877 'and will throw in the standalone `prop-types` package. ' +
33878 'You may be seeing this warning due to a third-party PropTypes ' +
33879 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
33880 );
33881 manualPropTypeCallCache[cacheKey] = true;
33882 manualPropTypeWarningCount++;
33883 }
33884 }
33885 }
33886 if (props[propName] == null) {
33887 if (isRequired) {
33888 if (props[propName] === null) {
33889 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
33890 }
33891 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
33892 }
33893 return null;
33894 } else {
33895 return validate(props, propName, componentName, location, propFullName);
33896 }
33897 }
33898
33899 var chainedCheckType = checkType.bind(null, false);
33900 chainedCheckType.isRequired = checkType.bind(null, true);
33901
33902 return chainedCheckType;
33903 }
33904
33905 function createPrimitiveTypeChecker(expectedType) {
33906 function validate(props, propName, componentName, location, propFullName, secret) {
33907 var propValue = props[propName];
33908 var propType = getPropType(propValue);
33909 if (propType !== expectedType) {
33910 // `propValue` being instance of, say, date/regexp, pass the 'object'
33911 // check, but we can offer a more precise error message here rather than
33912 // 'of type `object`'.
33913 var preciseType = getPreciseType(propValue);
33914
33915 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
33916 }
33917 return null;
33918 }
33919 return createChainableTypeChecker(validate);
33920 }
33921
33922 function createAnyTypeChecker() {
33923 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
33924 }
33925
33926 function createArrayOfTypeChecker(typeChecker) {
33927 function validate(props, propName, componentName, location, propFullName) {
33928 if (typeof typeChecker !== 'function') {
33929 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
33930 }
33931 var propValue = props[propName];
33932 if (!Array.isArray(propValue)) {
33933 var propType = getPropType(propValue);
33934 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
33935 }
33936 for (var i = 0; i < propValue.length; i++) {
33937 var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
33938 if (error instanceof Error) {
33939 return error;
33940 }
33941 }
33942 return null;
33943 }
33944 return createChainableTypeChecker(validate);
33945 }
33946
33947 function createElementTypeChecker() {
33948 function validate(props, propName, componentName, location, propFullName) {
33949 var propValue = props[propName];
33950 if (!isValidElement(propValue)) {
33951 var propType = getPropType(propValue);
33952 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
33953 }
33954 return null;
33955 }
33956 return createChainableTypeChecker(validate);
33957 }
33958
33959 function createInstanceTypeChecker(expectedClass) {
33960 function validate(props, propName, componentName, location, propFullName) {
33961 if (!(props[propName] instanceof expectedClass)) {
33962 var expectedClassName = expectedClass.name || ANONYMOUS;
33963 var actualClassName = getClassName(props[propName]);
33964 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
33965 }
33966 return null;
33967 }
33968 return createChainableTypeChecker(validate);
33969 }
33970
33971 function createEnumTypeChecker(expectedValues) {
33972 if (!Array.isArray(expectedValues)) {
33973 "development".NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
33974 return emptyFunctionThatReturnsNull;
33975 }
33976
33977 function validate(props, propName, componentName, location, propFullName) {
33978 var propValue = props[propName];
33979 for (var i = 0; i < expectedValues.length; i++) {
33980 if (is(propValue, expectedValues[i])) {
33981 return null;
33982 }
33983 }
33984
33985 var valuesString = JSON.stringify(expectedValues);
33986 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
33987 }
33988 return createChainableTypeChecker(validate);
33989 }
33990
33991 function createObjectOfTypeChecker(typeChecker) {
33992 function validate(props, propName, componentName, location, propFullName) {
33993 if (typeof typeChecker !== 'function') {
33994 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
33995 }
33996 var propValue = props[propName];
33997 var propType = getPropType(propValue);
33998 if (propType !== 'object') {
33999 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
34000 }
34001 for (var key in propValue) {
34002 if (propValue.hasOwnProperty(key)) {
34003 var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
34004 if (error instanceof Error) {
34005 return error;
34006 }
34007 }
34008 }
34009 return null;
34010 }
34011 return createChainableTypeChecker(validate);
34012 }
34013
34014 function createUnionTypeChecker(arrayOfTypeCheckers) {
34015 if (!Array.isArray(arrayOfTypeCheckers)) {
34016 "development".NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
34017 return emptyFunctionThatReturnsNull;
34018 }
34019
34020 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
34021 var checker = arrayOfTypeCheckers[i];
34022 if (typeof checker !== 'function') {
34023 printWarning(
34024 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
34025 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
34026 );
34027 return emptyFunctionThatReturnsNull;
34028 }
34029 }
34030
34031 function validate(props, propName, componentName, location, propFullName) {
34032 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
34033 var checker = arrayOfTypeCheckers[i];
34034 if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
34035 return null;
34036 }
34037 }
34038
34039 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
34040 }
34041 return createChainableTypeChecker(validate);
34042 }
34043
34044 function createNodeChecker() {
34045 function validate(props, propName, componentName, location, propFullName) {
34046 if (!isNode(props[propName])) {
34047 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
34048 }
34049 return null;
34050 }
34051 return createChainableTypeChecker(validate);
34052 }
34053
34054 function createShapeTypeChecker(shapeTypes) {
34055 function validate(props, propName, componentName, location, propFullName) {
34056 var propValue = props[propName];
34057 var propType = getPropType(propValue);
34058 if (propType !== 'object') {
34059 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
34060 }
34061 for (var key in shapeTypes) {
34062 var checker = shapeTypes[key];
34063 if (!checker) {
34064 continue;
34065 }
34066 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
34067 if (error) {
34068 return error;
34069 }
34070 }
34071 return null;
34072 }
34073 return createChainableTypeChecker(validate);
34074 }
34075
34076 function createStrictShapeTypeChecker(shapeTypes) {
34077 function validate(props, propName, componentName, location, propFullName) {
34078 var propValue = props[propName];
34079 var propType = getPropType(propValue);
34080 if (propType !== 'object') {
34081 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
34082 }
34083 // We need to check all keys in case some are required but missing from
34084 // props.
34085 var allKeys = assign({}, props[propName], shapeTypes);
34086 for (var key in allKeys) {
34087 var checker = shapeTypes[key];
34088 if (!checker) {
34089 return new PropTypeError(
34090 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
34091 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
34092 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
34093 );
34094 }
34095 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
34096 if (error) {
34097 return error;
34098 }
34099 }
34100 return null;
34101 }
34102
34103 return createChainableTypeChecker(validate);
34104 }
34105
34106 function isNode(propValue) {
34107 switch (typeof propValue) {
34108 case 'number':
34109 case 'string':
34110 case 'undefined':
34111 return true;
34112 case 'boolean':
34113 return !propValue;
34114 case 'object':
34115 if (Array.isArray(propValue)) {
34116 return propValue.every(isNode);
34117 }
34118 if (propValue === null || isValidElement(propValue)) {
34119 return true;
34120 }
34121
34122 var iteratorFn = getIteratorFn(propValue);
34123 if (iteratorFn) {
34124 var iterator = iteratorFn.call(propValue);
34125 var step;
34126 if (iteratorFn !== propValue.entries) {
34127 while (!(step = iterator.next()).done) {
34128 if (!isNode(step.value)) {
34129 return false;
34130 }
34131 }
34132 } else {
34133 // Iterator will provide entry [k,v] tuples rather than values.
34134 while (!(step = iterator.next()).done) {
34135 var entry = step.value;
34136 if (entry) {
34137 if (!isNode(entry[1])) {
34138 return false;
34139 }
34140 }
34141 }
34142 }
34143 } else {
34144 return false;
34145 }
34146
34147 return true;
34148 default:
34149 return false;
34150 }
34151 }
34152
34153 function isSymbol(propType, propValue) {
34154 // Native Symbol.
34155 if (propType === 'symbol') {
34156 return true;
34157 }
34158
34159 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
34160 if (propValue['@@toStringTag'] === 'Symbol') {
34161 return true;
34162 }
34163
34164 // Fallback for non-spec compliant Symbols which are polyfilled.
34165 if (typeof Symbol === 'function' && propValue instanceof Symbol) {
34166 return true;
34167 }
34168
34169 return false;
34170 }
34171
34172 // Equivalent of `typeof` but with special handling for array and regexp.
34173 function getPropType(propValue) {
34174 var propType = typeof propValue;
34175 if (Array.isArray(propValue)) {
34176 return 'array';
34177 }
34178 if (propValue instanceof RegExp) {
34179 // Old webkits (at least until Android 4.0) return 'function' rather than
34180 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
34181 // passes PropTypes.object.
34182 return 'object';
34183 }
34184 if (isSymbol(propType, propValue)) {
34185 return 'symbol';
34186 }
34187 return propType;
34188 }
34189
34190 // This handles more types than `getPropType`. Only used for error messages.
34191 // See `createPrimitiveTypeChecker`.
34192 function getPreciseType(propValue) {
34193 if (typeof propValue === 'undefined' || propValue === null) {
34194 return '' + propValue;
34195 }
34196 var propType = getPropType(propValue);
34197 if (propType === 'object') {
34198 if (propValue instanceof Date) {
34199 return 'date';
34200 } else if (propValue instanceof RegExp) {
34201 return 'regexp';
34202 }
34203 }
34204 return propType;
34205 }
34206
34207 // Returns a string that is postfixed to a warning about an invalid type.
34208 // For example, "undefined" or "of type array"
34209 function getPostfixForTypeWarning(value) {
34210 var type = getPreciseType(value);
34211 switch (type) {
34212 case 'array':
34213 case 'object':
34214 return 'an ' + type;
34215 case 'boolean':
34216 case 'date':
34217 case 'regexp':
34218 return 'a ' + type;
34219 default:
34220 return type;
34221 }
34222 }
34223
34224 // Returns class name of the object, if any.
34225 function getClassName(propValue) {
34226 if (!propValue.constructor || !propValue.constructor.name) {
34227 return ANONYMOUS;
34228 }
34229 return propValue.constructor.name;
34230 }
34231
34232 ReactPropTypes.checkPropTypes = checkPropTypes;
34233 ReactPropTypes.PropTypes = ReactPropTypes;
34234
34235 return ReactPropTypes;
34236};
34237
34238
34239/***/ }),
34240/* 106 */
34241/***/ (function(module, exports, __webpack_require__) {
34242
34243"use strict";
34244/**
34245 * Copyright (c) 2013-present, Facebook, Inc.
34246 *
34247 * This source code is licensed under the MIT license found in the
34248 * LICENSE file in the root directory of this source tree.
34249 */
34250
34251
34252
34253var ReactPropTypesSecret = __webpack_require__(14);
34254
34255function emptyFunction() {}
34256
34257module.exports = function() {
34258 function shim(props, propName, componentName, location, propFullName, secret) {
34259 if (secret === ReactPropTypesSecret) {
34260 // It is still safe when called from React.
34261 return;
34262 }
34263 var err = new Error(
34264 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
34265 'Use PropTypes.checkPropTypes() to call them. ' +
34266 'Read more at http://fb.me/use-check-prop-types'
34267 );
34268 err.name = 'Invariant Violation';
34269 throw err;
34270 };
34271 shim.isRequired = shim;
34272 function getShim() {
34273 return shim;
34274 };
34275 // Important!
34276 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
34277 var ReactPropTypes = {
34278 array: shim,
34279 bool: shim,
34280 func: shim,
34281 number: shim,
34282 object: shim,
34283 string: shim,
34284 symbol: shim,
34285
34286 any: shim,
34287 arrayOf: getShim,
34288 element: shim,
34289 instanceOf: getShim,
34290 node: shim,
34291 objectOf: getShim,
34292 oneOf: getShim,
34293 oneOfType: getShim,
34294 shape: getShim,
34295 exact: getShim
34296 };
34297
34298 ReactPropTypes.checkPropTypes = emptyFunction;
34299 ReactPropTypes.PropTypes = ReactPropTypes;
34300
34301 return ReactPropTypes;
34302};
34303
34304
34305/***/ }),
34306/* 107 */
34307/***/ (function(module, exports) {
34308
34309// shim for using process in browser
34310var process = module.exports = {};
34311
34312// cached from whatever global is present so that test runners that stub it
34313// don't break things. But we need to wrap it in a try catch in case it is
34314// wrapped in strict mode code which doesn't define any globals. It's inside a
34315// function because try/catches deoptimize in certain engines.
34316
34317var cachedSetTimeout;
34318var cachedClearTimeout;
34319
34320function defaultSetTimout() {
34321 throw new Error('setTimeout has not been defined');
34322}
34323function defaultClearTimeout () {
34324 throw new Error('clearTimeout has not been defined');
34325}
34326(function () {
34327 try {
34328 if (typeof setTimeout === 'function') {
34329 cachedSetTimeout = setTimeout;
34330 } else {
34331 cachedSetTimeout = defaultSetTimout;
34332 }
34333 } catch (e) {
34334 cachedSetTimeout = defaultSetTimout;
34335 }
34336 try {
34337 if (typeof clearTimeout === 'function') {
34338 cachedClearTimeout = clearTimeout;
34339 } else {
34340 cachedClearTimeout = defaultClearTimeout;
34341 }
34342 } catch (e) {
34343 cachedClearTimeout = defaultClearTimeout;
34344 }
34345} ())
34346function runTimeout(fun) {
34347 if (cachedSetTimeout === setTimeout) {
34348 //normal enviroments in sane situations
34349 return setTimeout(fun, 0);
34350 }
34351 // if setTimeout wasn't available but was latter defined
34352 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
34353 cachedSetTimeout = setTimeout;
34354 return setTimeout(fun, 0);
34355 }
34356 try {
34357 // when when somebody has screwed with setTimeout but no I.E. maddness
34358 return cachedSetTimeout(fun, 0);
34359 } catch(e){
34360 try {
34361 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
34362 return cachedSetTimeout.call(null, fun, 0);
34363 } catch(e){
34364 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
34365 return cachedSetTimeout.call(this, fun, 0);
34366 }
34367 }
34368
34369
34370}
34371function runClearTimeout(marker) {
34372 if (cachedClearTimeout === clearTimeout) {
34373 //normal enviroments in sane situations
34374 return clearTimeout(marker);
34375 }
34376 // if clearTimeout wasn't available but was latter defined
34377 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
34378 cachedClearTimeout = clearTimeout;
34379 return clearTimeout(marker);
34380 }
34381 try {
34382 // when when somebody has screwed with setTimeout but no I.E. maddness
34383 return cachedClearTimeout(marker);
34384 } catch (e){
34385 try {
34386 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
34387 return cachedClearTimeout.call(null, marker);
34388 } catch (e){
34389 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
34390 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
34391 return cachedClearTimeout.call(this, marker);
34392 }
34393 }
34394
34395
34396
34397}
34398var queue = [];
34399var draining = false;
34400var currentQueue;
34401var queueIndex = -1;
34402
34403function cleanUpNextTick() {
34404 if (!draining || !currentQueue) {
34405 return;
34406 }
34407 draining = false;
34408 if (currentQueue.length) {
34409 queue = currentQueue.concat(queue);
34410 } else {
34411 queueIndex = -1;
34412 }
34413 if (queue.length) {
34414 drainQueue();
34415 }
34416}
34417
34418function drainQueue() {
34419 if (draining) {
34420 return;
34421 }
34422 var timeout = runTimeout(cleanUpNextTick);
34423 draining = true;
34424
34425 var len = queue.length;
34426 while(len) {
34427 currentQueue = queue;
34428 queue = [];
34429 while (++queueIndex < len) {
34430 if (currentQueue) {
34431 currentQueue[queueIndex].run();
34432 }
34433 }
34434 queueIndex = -1;
34435 len = queue.length;
34436 }
34437 currentQueue = null;
34438 draining = false;
34439 runClearTimeout(timeout);
34440}
34441
34442process.nextTick = function (fun) {
34443 var args = new Array(arguments.length - 1);
34444 if (arguments.length > 1) {
34445 for (var i = 1; i < arguments.length; i++) {
34446 args[i - 1] = arguments[i];
34447 }
34448 }
34449 queue.push(new Item(fun, args));
34450 if (queue.length === 1 && !draining) {
34451 runTimeout(drainQueue);
34452 }
34453};
34454
34455// v8 likes predictible objects
34456function Item(fun, array) {
34457 this.fun = fun;
34458 this.array = array;
34459}
34460Item.prototype.run = function () {
34461 this.fun.apply(null, this.array);
34462};
34463process.title = 'browser';
34464process.browser = true;
34465process.env = {};
34466process.argv = [];
34467process.version = ''; // empty string to avoid regexp issues
34468process.versions = {};
34469
34470function noop() {}
34471
34472process.on = noop;
34473process.addListener = noop;
34474process.once = noop;
34475process.off = noop;
34476process.removeListener = noop;
34477process.removeAllListeners = noop;
34478process.emit = noop;
34479process.prependListener = noop;
34480process.prependOnceListener = noop;
34481
34482process.listeners = function (name) { return [] }
34483
34484process.binding = function (name) {
34485 throw new Error('process.binding is not supported');
34486};
34487
34488process.cwd = function () { return '/' };
34489process.chdir = function (dir) {
34490 throw new Error('process.chdir is not supported');
34491};
34492process.umask = function() { return 0; };
34493
34494
34495/***/ })
34496/******/ ]);
34497});
34498//# sourceMappingURL=react-map.js.map
\No newline at end of file