PageSourceSearch

https://ubermoves.github.io/UberMoves/thirdparty/maptalks/maptalks.js

js ubermoves.github.io collected 2026-10-03 10:06:43 UTC 840,467 bytes, 31,772 lines download raw bytes

vendor: 6,649 bytes, lines 1-275
1/*!
2 * maptalks v0.45.1
3 * LICENSE : BSD-3-Clause
4 * (c) 2016-2019 maptalks.org
5 */
6(function (global, factory) {
7  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
8  typeof define === 'function' && define.amd ? define(['exports'], factory) :
9  (factory((global.maptalks = {})));
10}(this, (function (exports) { 'use strict';
11
12  var version = "0.45.1";
13
14  var INTERNAL_LAYER_PREFIX = '_maptalks__internal_layer_';
15  var GEOMETRY_COLLECTION_TYPES = ['MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection'];
16  var GEOJSON_TYPES = ['FeatureCollection', 'Feature', 'Point', 'LineString', 'Polygon'].concat(GEOMETRY_COLLECTION_TYPES);
17  var RESOURCE_PROPERTIES = ['markerFile', 'polygonPatternFile', 'linePatternFile', 'markerFillPatternFile', 'markerLinePatternFile'];
18  var RESOURCE_SIZE_PROPERTIES = [['markerWidth', 'markerHeight'], [], [null, 'lineWidth'], [], [null, 'markerLineWidth']];
19  var NUMERICAL_PROPERTIES = {
20    'lineWidth': 1,
21    'lineOpacity': 1,
22    'lineDx': 1,
23    'lineDy': 1,
24    'polygonOpacity': 1,
25    'markerWidth': 1,
26    'markerHeight': 1,
27    'markerDx': 1,
28    'markerDy': 1,
29    'markerOpacity': 1,
30    'markerFillOpacity': 1,
31    'markerLineWidth': 1,
32    'markerLineOpacity': 1,
33    'textSize': 1,
34    'textOpacity': 1,
35    'textHaloRadius': 1,
36    'textWrapWidth': 1,
37    'textLineSpacing': 1,
38    'textDx': 1,
39    'textDy': 1
40  };
41  var COLOR_PROPERTIES = ['lineColor', 'polygonFill', 'markerFill', 'markerLineColor', 'textFill'];
42
43  function now() {
44    return Date.now();
45  }
46  function extend(dest) {
47    for (var i = 1; i < arguments.length; i++) {
48      var src = arguments[i];
49
50      for (var k in src) {
51        dest[k] = src[k];
52      }
53    }
54
55    return dest;
56  }
57  function isNil(obj) {
58    return obj == null;
59  }
60  function isNumber(val) {
61    return typeof val === 'number' && !isNaN(val);
62  }
63  function isInteger(n) {
64    return (n | 0) === n;
65  }
66  function isObject(obj) {
67    return typeof obj === 'object' && !!obj;
68  }
69  function isString(obj) {
70    if (isNil(obj)) {
71      return false;
72    }
73
74    return typeof obj === 'string' || obj.constructor !== null && obj.constructor === String;
75  }
76  function isFunction(obj) {
77    if (isNil(obj)) {
78      return false;
79    }
80
81    return typeof obj === 'function' || obj.constructor !== null && obj.constructor === Function;
82  }
83  var hasOwnProperty = Object.prototype.hasOwnProperty;
84  function hasOwn(obj, key) {
85    return hasOwnProperty.call(obj, key);
86  }
87  function join(arr, seperator) {
88    if (arr.join) {
89      return arr.join(seperator || ',');
90    } else {
91      return Array.prototype.join.call(arr, seperator || ',');
92    }
93  }
94  var pi = Math.PI / 180;
95  function toRadian(d) {
96    return d * pi;
97  }
98  function toDegree(r) {
99    return r / pi;
100  }
101
102  var IS_NODE = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]' && !process.versions['electron'] && !process.versions['nw'] && !process.versions['node-webkit'];
103
104  var requestAnimFrame, cancelAnimFrame;
105
106  (function () {
107    if (IS_NODE) {
108      requestAnimFrame = function requestAnimFrame(fn) {
109        return setTimeout(fn, 16);
110      };
111
112      cancelAnimFrame = clearTimeout;
113      return;
114    }
115
116    var requestFn, cancelFn;
117    var timeToCall = 1000 / 30;
118
119    function timeoutDefer(fn) {
120      return setTimeout(fn, timeToCall);
121    }
122
123    function getPrefixed(name) {
124      return window['webkit' + name] || window['moz' + name] || window['ms' + name];
125    }
126
127    if (typeof window != 'undefined') {
128      requestFn = window['requestAnimationFrame'] || getPrefixed('RequestAnimationFrame') || timeoutDefer;
129
130      cancelFn = window['cancelAnimationFrame'] || getPrefixed('CancelAnimationFrame') || getPrefixed('CancelRequestAnimationFrame') || function (id) {
131        window.clearTimeout(id);
132      };
133    } else {
134      requestFn = timeoutDefer;
135      cancelFn = clearTimeout;
136    }
137
138    requestAnimFrame = function requestAnimFrame(fn) {
139      return requestFn(fn);
140    };
141
142    cancelAnimFrame = function cancelAnimFrame(id) {
143      if (id) {
144        cancelFn(id);
145      }
146    };
147  })();
148  function isSVG(url) {
149    var prefix = 'data:image/svg+xml';
150
151    if (url.length > 4 && url.slice(-4) === '.svg') {
152      return 1;
153    } else if (url.slice(0, prefix.length) === prefix) {
154      return 2;
155    }
156
157    return 0;
158  }
159  function loadImage(img, imgDesc) {
160    if (IS_NODE && loadImage.node) {
161      loadImage.node(img, imgDesc);
162      return;
163    }
164
165    img.src = imgDesc[0];
166  }
167  var uid = 0;
168  function UID() {
169    return uid++;
170  }
171  var GUID = UID;
172  function parseJSON(str) {
173    if (!str || !isString(str)) {
174      return str;
175    }
176
177    return JSON.parse(str);
178  }
179  function pushIn(dest) {
180    for (var i = 1; i < arguments.length; i++) {
181      var src = arguments[i];
182
183      if (src) {
184        for (var ii = 0, ll = src.length; ii < ll; ii++) {
185          dest.push(src[ii]);
186        }
187      }
188    }
189
190    return dest.length;
191  }
192  function removeFromArray(obj, array) {
193    var i = array.indexOf(obj);
194
195    if (i > -1) {
196      array.splice(i, 1);
197    }
198  }
199  function forEachCoord(arr, fn, context) {
200    if (!Array.isArray(arr)) {
201      return context ? fn.call(context, arr) : fn(arr);
202    }
203
204    var result = [];
205    var p, pp;
206
207    for (var i = 0, len = arr.length; i < len; i++) {
208      p = arr[i];
209
210      if (isNil(p)) {
211        result.push(null);
212        continue;
213      }
214
215      if (Array.isArray(p)) {
216        result.push(forEachCoord(p, fn, context));
217      } else {
218        pp = context ? fn.call(context, p) : fn(p);
219        result.push(pp);
220      }
221    }
222
223    return result;
224  }
225  function getValueOrDefault(v, d) {
226    return v === undefined ? d : v;
227  }
228  function sign(x) {
229    if (Math.sign) {
230      return Math.sign(x);
231    }
232
233    x = +x;
234
235    if (x === 0 || isNaN(x)) {
236      return Number(x);
237    }
238
239    return x > 0 ? 1 : -1;
240  }
241  function log2(x) {
242    if (Math.log2) {
243      return Math.log2(x);
244    }
245
246    var v = Math.log(x) * Math.LOG2E;
247    var rounded = Math.round(v);
248
249    if (Math.abs(rounded - v) < 1E-14) {
250      return rounded;
251    } else {
252      return v;
253    }
254  }
255  function interpolate(a, b, t) {
256    return a * (1 - t) + b * t;
257  }
258  function wrap(n, min, max) {
259    if (n === max || n === min) {
260      return n;
261    }
262
263    var d = max - min;
264    var w = ((n - min) % d + d) % d + min;
265    return w;
266  }
267  function clamp(n, min, max) {
268    return Math.min(max, Math.max(min, n));
269  }
270  function isArrayHasData(obj) {
271    return Array.isArray(obj) && obj.length > 0;
272  }
273  function isURL(url) {
274    if (!url) {
275      return false;
vendor: 84,124 bytes, lines 276-3390
276    }
277
278    var head = url.slice(0, 6);
279
280    if (head === 'http:/' || head === 'https:' || head === 'file:/') {
281      return true;
282    }
283
284    return false;
285  }
286  var cssUrlReWithQuote = /^url\((['"])(.+)\1\)$/i;
287  var cssUrlRe = /^url\(([^'"].*[^'"])\)$/i;
288  function isCssUrl(str) {
289    if (!isString(str)) {
290      return 0;
291    }
292
293    var head = str.slice(0, 6);
294
295    if (head === 'http:/' || head === 'https:') {
296      return 3;
297    }
298
299    if (cssUrlRe.test(str)) {
300      return 1;
301    }
302
303    if (cssUrlReWithQuote.test(str)) {
304      return 2;
305    }
306
307    return 0;
308  }
309  function extractCssUrl(str) {
310    var test = isCssUrl(str);
311    var matches;
312
313    if (test === 3) {
314      return str;
315    }
316
317    if (test === 1) {
318      matches = cssUrlRe.exec(str);
319      return matches[1];
320    } else if (test === 2) {
321      matches = cssUrlReWithQuote.exec(str);
322      return matches[2];
323    } else {
324      return str;
325    }
326  }
327  var b64chrs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
328  function btoa(input) {
329    if (typeof window !== 'undefined' && window.btoa) {
330      return window.btoa(input);
331    }
332
333    var str = String(input);
334    var output = '';
335
336    for (var block, charCode, idx = 0, map = b64chrs; str.charAt(idx | 0) || (map = '=', idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) {
337      charCode = str.charCodeAt(idx += 3 / 4);
338
339      if (charCode > 0xFF) {
340        throw new Error('\'btoa\' failed: The string to be encoded contains characters outside of the Latin1 range.');
341      }
342
343      block = block << 8 | charCode;
344    }
345
346    return output;
347  }
348  function b64toBlob(b64Data, contentType) {
349    var byteCharacters = atob(b64Data);
350    var arraybuffer = new ArrayBuffer(byteCharacters.length);
351    var view = new Uint8Array(arraybuffer);
352
353    for (var i = 0; i < byteCharacters.length; i++) {
354      view[i] = byteCharacters.charCodeAt(i) & 0xff;
355    }
356
357    var blob = new Blob([arraybuffer], {
358      type: contentType
359    });
360    return blob;
361  }
362  function computeDegree(x0, y0, x1, y1) {
363    var dx = x1 - x0;
364    var dy = y1 - y0;
365    return Math.atan2(dy, dx);
366  }
367  var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
368  function equalMapView(obj1, obj2) {
369    if (!obj1 && !obj2) {
370      return true;
371    } else if (!obj1 || !obj2) {
372      return false;
373    }
374
375    for (var p in obj1) {
376      if (p === 'center') {
377        if (!obj2[p] || !approx(obj1[p][0], obj2[p][0]) || !approx(obj1[p][1], obj2[p][1])) {
378          return false;
379        }
380      } else if (obj1[p] !== obj2[p]) {
381        return false;
382      }
383    }
384
385    return true;
386  }
387
388  function approx(val, expected, delta) {
389    if (delta == null) {
390      delta = 1e-6;
391    }
392
393    return val >= expected - delta && val <= expected + delta;
394  }
395
396  function flash(interval, count, cb, context) {
397    if (!interval) {
398      interval = 100;
399    }
400
401    if (!count) {
402      count = 4;
403    }
404
405    var me = this;
406    count *= 2;
407
408    if (this._flashTimeout) {
409      clearTimeout(this._flashTimeout);
410    }
411
412    function flashGeo() {
413      if (count === 0) {
414        me.show();
415
416        if (cb) {
417          if (context) {
418            cb.call(context);
419          } else {
420            cb();
421          }
422        }
423
424        return;
425      }
426
427      if (count % 2 === 0) {
428        me.hide();
429      } else {
430        me.show();
431      }
432
433      count--;
434      me._flashTimeout = setTimeout(flashGeo, interval);
435    }
436
437    this._flashTimeout = setTimeout(flashGeo, interval);
438    return this;
439  }
440  function _defaults(obj, defaults) {
441    var keys = Object.getOwnPropertyNames(defaults);
442
443    for (var i = 0; i < keys.length; i++) {
444      var key = keys[i];
445      var value = Object.getOwnPropertyDescriptor(defaults, key);
446
447      if (value && value.configurable && obj[key] === undefined) {
448        Object.defineProperty(obj, key, value);
449      }
450    }
451
452    return obj;
453  }
454
455  var types = ['Unknown', 'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection'];
456  function createFilter(filter) {
457    return new Function('f', "var p = (f && f.properties || {}); return " + compile(filter));
458  }
459
460  function compile(filter) {
461    if (!filter) return 'true';
462    var op = filter[0];
463    if (filter.length <= 1) return op === 'any' ? 'false' : 'true';
464    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';
465    return "(" + str + ")";
466  }
467
468  function compilePropertyReference(property) {
469    return property[0] === '$' ? 'f.' + property.substring(1) : 'p[' + JSON.stringify(property) + ']';
470  }
471
472  function compileComparisonOp(property, value, op, checkType) {
473    var left = compilePropertyReference(property);
474    var right = property === '$type' ? types.indexOf(value) : JSON.stringify(value);
475    return (checkType ? "typeof " + left + "=== typeof " + right + "&&" : '') + left + op + right;
476  }
477
478  function compileLogicalOp(expressions, op) {
479    return expressions.map(compile).join(op);
480  }
481
482  function compileInOp(property, values) {
483    if (property === '$type') values = values.map(function (value) {
484      return types.indexOf(value);
485    });
486    var left = JSON.stringify(values.sort(compare));
487    var right = compilePropertyReference(property);
488    if (values.length <= 200) return left + ".indexOf(" + right + ") !== -1";
489    return "function(v, a, i, j) {\n        while (i <= j) { var m = (i + j) >> 1;\n            if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;\n        }\n    return false; }(" + right + ", " + left + ",0," + (values.length - 1) + ")";
490  }
491
492  function compileHasOp(property) {
493    return property === '$id' ? '"id" in f' : JSON.stringify(property) + " in p";
494  }
495
496  function compileNegation(expression) {
497    return "!(" + expression + ")";
498  }
499
500  function compare(a, b) {
501    return a < b ? -1 : a > b ? 1 : 0;
502  }
503
504  function getFilterFeature(geometry) {
505    var json = geometry._toJSON(),
506        g = json['feature'];
507
508    g['type'] = types.indexOf(g['geometry']['type']);
509    g['subType'] = json['subType'];
510    return g;
511  }
512  function compileStyle(styles) {
513    if (!Array.isArray(styles)) {
514      return compileStyle([styles]);
515    }
516
517    var compiled = [];
518
519    for (var i = 0; i < styles.length; i++) {
520      var filter = void 0;
521
522      if (styles[i]['filter'] === true) {
523        filter = function filter() {
524          return true;
525        };
526      } else {
527        filter = createFilter(styles[i]['filter']);
528      }
529
530      compiled.push(extend$1({}, styles[i], {
531        filter: filter
532      }));
533    }
534
535    return compiled;
536  }
537
538  function extend$1(dest) {
539    for (var i = 1; i < arguments.length; i++) {
540      var src = arguments[i];
541
542      for (var k in src) {
543        dest[k] = src[k];
544      }
545    }
546
547    return dest;
548  }
549
550  function createFunction(parameters, defaultType) {
551    var fun;
552    var isFeatureConstant, isZoomConstant;
553
554    if (!isFunctionDefinition(parameters)) {
555      fun = function fun() {
556        return parameters;
557      };
558
559      isFeatureConstant = true;
560      isZoomConstant = true;
561    } else {
562      var zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';
563      var featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;
564      var zoomDependent = zoomAndFeatureDependent || !featureDependent;
565      var type = parameters.type || defaultType || 'exponential';
566      var innerFun;
567
568      if (type === 'exponential') {
569        innerFun = evaluateExponentialFunction;
570      } else if (type === 'interval') {
571        innerFun = evaluateIntervalFunction;
572      } else if (type === 'categorical') {
573        innerFun = evaluateCategoricalFunction;
574      } else if (type === 'identity') {
575        innerFun = evaluateIdentityFunction;
576      } else {
577        throw new Error('Unknown function type "' + type + '"');
578      }
579
580      if (zoomAndFeatureDependent) {
581        var featureFunctions = {};
582        var featureFunctionStops = [];
583
584        for (var s = 0; s < parameters.stops.length; s++) {
585          var stop = parameters.stops[s];
586
587          if (featureFunctions[stop[0].zoom] === undefined) {
588            featureFunctions[stop[0].zoom] = {
589              zoom: stop[0].zoom,
590              type: parameters.type,
591              property: parameters.property,
592              default: parameters.default,
593              stops: []
594            };
595          }
596
597          featureFunctions[stop[0].zoom].stops.push([stop[0].value, stop[1]]);
598        }
599
600        for (var z in featureFunctions) {
601          featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z])]);
602        }
603
604        fun = function fun(zoom, feature) {
605          var value = evaluateExponentialFunction({
606            stops: featureFunctionStops,
607            base: parameters.base
608          }, zoom)(zoom, feature);
609          return typeof value === 'function' ? value(zoom, feature) : value;
610        };
611
612        isFeatureConstant = false;
613        isZoomConstant = false;
614      } else if (zoomDependent) {
615        fun = function fun(zoom) {
616          var value = innerFun(parameters, zoom);
617          return typeof value === 'function' ? value(zoom) : value;
618        };
619
620        isFeatureConstant = true;
621        isZoomConstant = false;
622      } else {
623        fun = function fun(zoom, feature) {
624          var value = innerFun(parameters, feature ? feature[parameters.property] : null);
625          return typeof value === 'function' ? value(zoom, feature) : value;
626        };
627
628        isFeatureConstant = false;
629        isZoomConstant = true;
630      }
631    }
632
633    fun.isZoomConstant = isZoomConstant;
634    fun.isFeatureConstant = isFeatureConstant;
635    return fun;
636  }
637
638  function coalesce(a, b, c) {
639    if (a !== undefined) return a;
640    if (b !== undefined) return b;
641    if (c !== undefined) return c;
642    return null;
643  }
644
645  function evaluateCategoricalFunction(parameters, input) {
646    for (var i = 0; i < parameters.stops.length; i++) {
647      if (input === parameters.stops[i][0]) {
648        return parameters.stops[i][1];
649      }
650    }
651
652    return parameters.default;
653  }
654
655  function evaluateIntervalFunction(parameters, input) {
656    for (var i = 0; i < parameters.stops.length; i++) {
657      if (input < parameters.stops[i][0]) break;
658    }
659
660    return parameters.stops[Math.max(i - 1, 0)][1];
661  }
662
663  function evaluateExponentialFunction(parameters, input) {
664    var base = parameters.base !== undefined ? parameters.base : 1;
665    var i = 0;
666
667    while (true) {
668      if (i >= parameters.stops.length) break;else if (input <= parameters.stops[i][0]) break;else i++;
669    }
670
671    if (i === 0) {
672      return parameters.stops[i][1];
673    } else if (i === parameters.stops.length) {
674      return parameters.stops[i - 1][1];
675    } else {
676      return interpolate$1(input, base, parameters.stops[i - 1][0], parameters.stops[i][0], parameters.stops[i - 1][1], parameters.stops[i][1]);
677    }
678  }
679
680  function evaluateIdentityFunction(parameters, input) {
681    return coalesce(input, parameters.default);
682  }
683
684  function interpolate$1(input, base, inputLower, inputUpper, outputLower, outputUpper) {
685    if (typeof outputLower === 'function') {
686      return function () {
687        var evaluatedLower = outputLower.apply(undefined, arguments);
688        var evaluatedUpper = outputUpper.apply(undefined, arguments);
689        return interpolate$1(input, base, inputLower, inputUpper, evaluatedLower, evaluatedUpper);
690      };
691    } else if (outputLower.length) {
692      return interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper);
693    } else {
694      return interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper);
695    }
696  }
697
698  function interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper) {
699    var difference = inputUpper - inputLower;
700    var progress = input - inputLower;
701    var ratio;
702
703    if (base === 1) {
704      ratio = progress / difference;
705    } else {
706      ratio = (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
707    }
708
709    return outputLower * (1 - ratio) + outputUpper * ratio;
710  }
711
712  function interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper) {
713    var output = [];
714
715    for (var i = 0; i < outputLower.length; i++) {
716      output[i] = interpolateNumber(input, base, inputLower, inputUpper, outputLower[i], outputUpper[i]);
717    }
718
719    return output;
720  }
721
722  function isFunctionDefinition(obj) {
723    return obj && typeof obj === 'object' && (obj.stops || obj.property && obj.type === 'identity');
724  }
725  function hasFunctionDefinition(obj) {
726    for (var p in obj) {
727      if (isFunctionDefinition(obj[p])) {
728        return true;
729      }
730    }
731
732    return false;
733  }
734  function interpolated(parameters) {
735    return createFunction1(parameters, 'exponential');
736  }
737  function piecewiseConstant(parameters) {
738    return createFunction1(parameters, 'interval');
739  }
740  function loadFunctionTypes(obj, argFn) {
741    if (!obj) {
742      return null;
743    }
744
745    var hit = false;
746
747    if (Array.isArray(obj)) {
748      var multResult = [],
749          loaded;
750
751      for (var i = 0; i < obj.length; i++) {
752        loaded = loadFunctionTypes(obj[i], argFn);
753
754        if (!loaded) {
755          multResult.push(obj[i]);
756        } else {
757          multResult.push(loaded);
758          hit = true;
759        }
760      }
761
762      return hit ? multResult : obj;
763    }
764
765    var result = {
766      '__fn_types_loaded': true
767    },
768        props = [],
769        p;
770
771    for (p in obj) {
772      if (obj.hasOwnProperty(p)) {
773        props.push(p);
774      }
775    }
776
777    var buildFn = function buildFn(p) {
778      Object.defineProperty(result, p, {
779        get: function get() {
780          if (!this['__fn_' + p]) {
781            this['__fn_' + p] = interpolated(this['_' + p]);
782          }
783
784          return this['__fn_' + p].apply(this, argFn());
785        },
786        set: function set(v) {
787          this['_' + p] = v;
788        },
789        configurable: true,
790        enumerable: true
791      });
792    };
793
794    for (var _i = 0, len = props.length; _i < len; _i++) {
795      p = props[_i];
796
797      if (isFunctionDefinition(obj[p])) {
798        hit = true;
799        result['_' + p] = obj[p];
800        buildFn(p);
801      } else {
802        result[p] = obj[p];
803      }
804    }
805
806    return hit ? result : obj;
807  }
808  function getFunctionTypeResources(t) {
809    if (!t || !t.stops) {
810      return [];
811    }
812
813    var res = [];
814
815    for (var i = 0, l = t.stops.length; i < l; i++) {
816      res.push(t.stops[i][1]);
817    }
818
819    return res;
820  }
821
822  function createFunction1(parameters, defaultType) {
823    if (!isFunctionDefinition(parameters)) {
824      return function () {
825        return parameters;
826      };
827    }
828
829    parameters = JSON.parse(JSON.stringify(parameters));
830    var isZoomConstant = true;
831    var isFeatureConstant = true;
832    var stops = parameters.stops;
833
834    if (stops) {
835      for (var i = 0; i < stops.length; i++) {
836        if (isFunctionDefinition(stops[i][1])) {
837          var _fn = createFunction1(stops[i][1], defaultType);
838
839          isZoomConstant = isZoomConstant && _fn.isZoomConstant;
840          isFeatureConstant = isFeatureConstant && _fn.isFeatureConstant;
841          stops[i] = [stops[i][0], _fn];
842        }
843      }
844    }
845
846    var fn = createFunction(parameters, defaultType);
847    fn.isZoomConstant = isZoomConstant && fn.isZoomConstant;
848    fn.isFeatureConstant = isFeatureConstant && fn.isFeatureConstant;
849    return fn;
850  }
851
852
853
854  var index = /*#__PURE__*/Object.freeze({
855    createFilter: createFilter,
856    getFilterFeature: getFilterFeature,
857    compileStyle: compileStyle,
858    isFunctionDefinition: isFunctionDefinition,
859    hasFunctionDefinition: hasFunctionDefinition,
860    interpolated: interpolated,
861    piecewiseConstant: piecewiseConstant,
862    loadFunctionTypes: loadFunctionTypes,
863    getFunctionTypeResources: getFunctionTypeResources
864  });
865
866  function translateToSVGStyles(s) {
867    var result = {
868      'stroke': {
869        'stroke': s['markerLineColor'],
870        'stroke-width': s['markerLineWidth'],
871        'stroke-opacity': s['markerLineOpacity'],
872        'stroke-dasharray': null,
873        'stroke-linecap': 'butt',
874        'stroke-linejoin': 'round'
875      },
876      'fill': {
877        'fill': s['markerFill'],
878        'fill-opacity': s['markerFillOpacity']
879      }
880    };
881
882    if (result['stroke']['stroke-width'] === 0) {
883      result['stroke']['stroke-opacity'] = 0;
884    }
885
886    return result;
887  }
888  function getMarkerPathBase64(symbol, width, height) {
889    if (!symbol['markerPath']) {
890      return null;
891    }
892
893    var op = 1;
894    var styles = translateToSVGStyles(symbol);
895
896    if (isNumber(symbol['markerOpacity'])) {
897      op = symbol['markerOpacity'];
898    }
899
900    if (isNumber(symbol['opacity'])) {
901      op *= symbol['opacity'];
902    }
903
904    var svgStyles = {};
905
906    if (styles) {
907      for (var p in styles['stroke']) {
908        if (styles['stroke'].hasOwnProperty(p)) {
909          if (!isNil(styles['stroke'][p])) {
910            svgStyles[p] = styles['stroke'][p];
911          }
912        }
913      }
914
915      for (var _p in styles['fill']) {
916        if (styles['fill'].hasOwnProperty(_p)) {
917          if (!isNil(styles['fill'][_p])) {
918            svgStyles[_p] = styles['fill'][_p];
919          }
920        }
921      }
922    }
923
924    var pathes = Array.isArray(symbol['markerPath']) ? symbol['markerPath'] : [symbol['markerPath']];
925    var path;
926    var pathesToRender = [];
927
928    for (var i = 0; i < pathes.length; i++) {
929      path = isString(pathes[i]) ? {
930        'path': pathes[i]
931      } : pathes[i];
932      path = extend({}, path, svgStyles);
933      path['d'] = path['path'];
934      delete path['path'];
935      pathesToRender.push(path);
936    }
937
938    var svg = ['<svg version="1.1"', 'xmlns="http://www.w3.org/2000/svg"'];
939
940    if (op < 1) {
941      svg.push('opacity="' + op + '"');
942    }
943
944    if (symbol['markerPathWidth'] && symbol['markerPathHeight']) {
945      svg.push('viewBox="0 0 ' + symbol['markerPathWidth'] + ' ' + symbol['markerPathHeight'] + '"');
946    }
947
948    svg.push('preserveAspectRatio="none"');
949
950    if (width) {
951      svg.push('width="' + width + '"');
952    }
953
954    if (height) {
955      svg.push('height="' + height + '"');
956    }
957
958    svg.push('><defs></defs>');
959
960    for (var _i = 0; _i < pathesToRender.length; _i++) {
961      var strPath = '<path ';
962
963      for (var _p2 in pathesToRender[_i]) {
964        if (pathesToRender[_i].hasOwnProperty(_p2)) {
965          strPath += ' ' + _p2 + '="' + pathesToRender[_i][_p2] + '"';
966        }
967      }
968
969      strPath += '></path>';
970      svg.push(strPath);
971    }
972
973    svg.push('</svg>');
974    var b64 = 'data:image/svg+xml;base64,' + btoa(svg.join(' '));
975    return b64;
976  }
977  function getExternalResources(symbol, toAbsolute) {
978    if (!symbol) {
979      return [];
980    }
981
982    var symbols = symbol;
983
984    if (!Array.isArray(symbol)) {
985      symbols = [symbol];
986    }
987
988    var resources = [];
989    var props = RESOURCE_PROPERTIES;
990    var res, resSizeProp;
991    var w, h;
992
993    for (var i = symbols.length - 1; i >= 0; i--) {
994      symbol = symbols[i];
995
996      if (!symbol) {
997        continue;
998      }
999
1000      if (toAbsolute) {
1001        symbol = convertResourceUrl(symbol);
1002      }
1003
1004      for (var ii = 0; ii < props.length; ii++) {
1005        res = symbol[props[ii]];
1006
1007        if (isFunctionDefinition(res)) {
1008          res = getFunctionTypeResources(res);
1009        }
1010
1011        if (!res) {
1012          continue;
1013        }
1014
1015        if (!Array.isArray(res)) {
1016          res = [res];
1017        }
1018
1019        for (var iii = 0; iii < res.length; iii++) {
1020          if (res[iii].slice(0, 4) === 'url(') {
1021            res[iii] = extractCssUrl(res[iii]);
1022          }
1023
1024          resSizeProp = RESOURCE_SIZE_PROPERTIES[ii];
1025          resources.push([res[iii], symbol[resSizeProp[0]], symbol[resSizeProp[1]]]);
1026        }
1027      }
1028
1029      if (symbol['markerType'] === 'path' && symbol['markerPath']) {
1030        w = isFunctionDefinition(symbol['markerWidth']) ? 200 : symbol['markerWidth'];
1031        h = isFunctionDefinition(symbol['markerHeight']) ? 200 : symbol['markerHeight'];
1032
1033        if (isFunctionDefinition(symbol['markerPath'])) {
1034          res = getFunctionTypeResources(symbol['markerPath']);
1035          var path = symbol['markerPath'];
1036
1037          for (var _iii = 0; _iii < res.length; _iii++) {
1038            symbol['markerPath'] = res[_iii];
1039            resources.push([getMarkerPathBase64(symbol), w, h]);
1040          }
1041
1042          symbol['markerPath'] = path;
1043        } else {
1044          resources.push([getMarkerPathBase64(symbol), w, h]);
1045        }
1046      }
1047    }
1048
1049    return resources;
1050  }
1051  function convertResourceUrl(symbol) {
1052    if (!symbol) {
1053      return null;
1054    }
1055
1056    var s = symbol;
1057
1058    if (IS_NODE) {
1059      return s;
1060    }
1061
1062    var props = RESOURCE_PROPERTIES;
1063    var res;
1064
1065    for (var ii = 0, len = props.length; ii < len; ii++) {
1066      res = s[props[ii]];
1067
1068      if (!res) {
1069        continue;
1070      }
1071
1072      s[props[ii]] = _convertUrlToAbsolute(res);
1073    }
1074
1075    return s;
1076  }
1077
1078  function _convertUrlToAbsolute(res) {
1079    if (isFunctionDefinition(res)) {
1080      var stops = res.stops;
1081
1082      for (var i = 0; i < stops.length; i++) {
1083        stops[i][1] = _convertUrlToAbsolute(stops[i][1]);
1084      }
1085
1086      return res;
1087    }
1088
1089    var embed = 'data:';
1090
1091    if (res.slice(0, 4) === 'url(') {
1092      res = extractCssUrl(res);
1093    }
1094
1095    if (!isURL(res) && (res.length <= embed.length || res.substring(0, embed.length) !== embed)) {
1096      res = _absolute(location.href, res);
1097    }
1098
1099    return res;
1100  }
1101
1102  function _absolute(base, relative) {
1103    var stack = base.split('/'),
1104        parts = relative.split('/');
1105
1106    if (relative.slice(0, 1) === 0) {
1107      return stack.slice(0, 3).join('/') + relative;
1108    } else {
1109      stack.pop();
1110
1111      for (var i = 0; i < parts.length; i++) {
1112        if (parts[i] === '.') continue;
1113        if (parts[i] === '..') stack.pop();else stack.push(parts[i]);
1114      }
1115
1116      return stack.join('/');
1117    }
1118  }
1119
1120  function isGradient(g) {
1121    return g && g['colorStops'];
1122  }
1123  function getGradientStamp(g) {
1124    var keys = [g['type']];
1125
1126    if (g['places']) {
1127      keys.push(g['places'].join());
1128    }
1129
1130    if (g['colorStops']) {
1131      var stops = [];
1132
1133      for (var i = g['colorStops'].length - 1; i >= 0; i--) {
1134        stops.push(g['colorStops'][i].join());
1135      }
1136
1137      keys.push(stops.join(','));
1138    }
1139
1140    return keys.join('_');
1141  }
1142  function getSymbolStamp(symbol) {
1143    var keys = [];
1144
1145    if (Array.isArray(symbol)) {
1146      for (var i = 0; i < symbol.length; i++) {
1147        keys.push(getSymbolStamp(symbol[i]));
1148      }
1149
1150      return '[ ' + keys.join(' , ') + ' ]';
1151    }
1152
1153    for (var p in symbol) {
1154      if (hasOwn(symbol, p)) {
1155        if (!isFunction(symbol[p])) {
1156          if (isGradient(symbol[p])) {
1157            keys.push(p + '=' + getGradientStamp(symbol[p]));
1158          } else {
1159            keys.push(p + '=' + symbol[p]);
1160          }
1161        }
1162      }
1163    }
1164
1165    return keys.join(';');
1166  }
1167  function lowerSymbolOpacity(symbol, ratio) {
1168    function s(_symbol, _ratio) {
1169      var op = _symbol['opacity'];
1170
1171      if (isNil(op)) {
1172        _symbol['opacity'] = _ratio;
1173      } else {
1174        _symbol['opacity'] *= _ratio;
1175      }
1176    }
1177
1178    var lower;
1179
1180    if (Array.isArray(symbol)) {
1181      lower = [];
1182
1183      for (var i = 0; i < symbol.length; i++) {
1184        var d = extend({}, symbol[i]);
1185        s(d, ratio);
1186        lower.push(d);
1187      }
1188    } else {
1189      lower = extend({}, symbol);
1190      s(lower, ratio);
1191    }
1192
1193    return lower;
1194  }
1195  function extendSymbol(symbol) {
1196    var sources = Array.prototype.slice.call(arguments, 1);
1197
1198    if (!sources || !sources.length) {
1199      sources = [{}];
1200    }
1201
1202    if (Array.isArray(symbol)) {
1203      var s, dest;
1204      var result = [];
1205
1206      for (var i = 0, l = symbol.length; i < l; i++) {
1207        s = symbol[i];
1208        dest = {};
1209
1210        for (var ii = 0, ll = sources.length; ii < ll; ii++) {
1211          if (!Array.isArray(sources[ii])) {
1212            extend(dest, s, sources[ii] ? sources[ii] : {});
1213          } else if (!isNil(sources[ii][i])) {
1214            extend(dest, s, sources[ii][i]);
1215          } else {
1216            extend(dest, s ? s : {});
1217          }
1218        }
1219
1220        result.push(dest);
1221      }
1222
1223      return result;
1224    } else {
1225      var args = [{}, symbol];
1226      args.push.apply(args, sources);
1227      return extend.apply(this, args);
1228    }
1229  }
1230
1231
1232
1233  var index$1 = /*#__PURE__*/Object.freeze({
1234    now: now,
1235    extend: extend,
1236    isNil: isNil,
1237    isNumber: isNumber,
1238    isInteger: isInteger,
1239    isObject: isObject,
1240    isString: isString,
1241    isFunction: isFunction,
1242    hasOwn: hasOwn,
1243    join: join,
1244    toRadian: toRadian,
1245    toDegree: toDegree,
1246    IS_NODE: IS_NODE,
1247    get requestAnimFrame () { return requestAnimFrame; },
1248    get cancelAnimFrame () { return cancelAnimFrame; },
1249    isSVG: isSVG,
1250    loadImage: loadImage,
1251    UID: UID,
1252    GUID: GUID,
1253    parseJSON: parseJSON,
1254    pushIn: pushIn,
1255    removeFromArray: removeFromArray,
1256    forEachCoord: forEachCoord,
1257    getValueOrDefault: getValueOrDefault,
1258    sign: sign,
1259    log2: log2,
1260    interpolate: interpolate,
1261    wrap: wrap,
1262    clamp: clamp,
1263    isArrayHasData: isArrayHasData,
1264    isURL: isURL,
1265    isCssUrl: isCssUrl,
1266    extractCssUrl: extractCssUrl,
1267    btoa: btoa,
1268    b64toBlob: b64toBlob,
1269    computeDegree: computeDegree,
1270    emptyImageUrl: emptyImageUrl,
1271    equalMapView: equalMapView,
1272    flash: flash,
1273    _defaults: _defaults,
1274    translateToSVGStyles: translateToSVGStyles,
1275    getMarkerPathBase64: getMarkerPathBase64,
1276    getExternalResources: getExternalResources,
1277    convertResourceUrl: convertResourceUrl,
1278    isGradient: isGradient,
1279    getGradientStamp: getGradientStamp,
1280    getSymbolStamp: getSymbolStamp,
1281    lowerSymbolOpacity: lowerSymbolOpacity,
1282    extendSymbol: extendSymbol
1283  });
1284
1285  var Browser = {};
1286
1287  if (!IS_NODE) {
1288    var ua = navigator.userAgent.toLowerCase(),
1289        doc = document.documentElement,
1290        ie = 'ActiveXObject' in window,
1291        webkit = ua.indexOf('webkit') !== -1,
1292        phantomjs = ua.indexOf('phantom') !== -1,
1293        android23 = ua.search('android [23]') !== -1,
1294        chrome = ua.indexOf('chrome') !== -1,
1295        gecko = ua.indexOf('gecko') !== -1 && !webkit && !window.opera && !ie,
1296        mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1,
1297        msPointer = !window.PointerEvent && window.MSPointerEvent,
1298        pointer = window.PointerEvent && navigator.pointerEnabled || msPointer,
1299        ie3d = ie && 'transition' in doc.style,
1300        webkit3d = 'WebKitCSSMatrix' in window && 'm11' in new window.WebKitCSSMatrix() && !android23,
1301        gecko3d = 'MozPerspective' in doc.style,
1302        opera12 = 'OTransition' in doc.style,
1303        any3d = (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs;
1304    var chromeVersion = 0;
1305
1306    if (chrome) {
1307      chromeVersion = ua.match(/chrome\/([\d.]+)/)[1];
1308    }
1309
1310    var touch = !phantomjs && (pointer || 'ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch);
1311    var webgl;
1312
1313    try {
1314      var canvas = document.createElement('canvas');
1315      var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
1316      webgl = gl && gl instanceof WebGLRenderingContext;
1317    } catch (err) {
1318      webgl = false;
1319    }
1320
1321    var devicePixelRatio = window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI;
1322    Browser = {
1323      ie: ie,
1324      ielt9: ie && !document.addEventListener,
1325      edge: 'msLaunchUri' in navigator && !('documentMode' in document),
1326      webkit: webkit,
1327      gecko: gecko,
1328      android: ua.indexOf('android') !== -1,
1329      android23: android23,
1330      chrome: chrome,
1331      chromeVersion: chromeVersion,
1332      safari: !chrome && ua.indexOf('safari') !== -1,
1333      phantomjs: phantomjs,
1334      ie3d: ie3d,
1335      webkit3d: webkit3d,
1336      gecko3d: gecko3d,
1337      opera12: opera12,
1338      any3d: any3d,
1339      mobile: mobile,
1340      mobileWebkit: mobile && webkit,
1341      mobileWebkit3d: mobile && webkit3d,
1342      mobileOpera: mobile && window.opera,
1343      mobileGecko: mobile && gecko,
1344      touch: !!touch,
1345      msPointer: !!msPointer,
1346      pointer: !!pointer,
1347      retina: devicePixelRatio > 1,
1348      devicePixelRatio: devicePixelRatio,
1349      language: navigator.browserLanguage ? navigator.browserLanguage : navigator.language,
1350      ie9: ie && document.documentMode === 9,
1351      ie10: ie && document.documentMode === 10,
1352      webgl: webgl
1353    };
1354  }
1355
1356  var Browser$1 = Browser;
1357
1358  function _inheritsLoose(subClass, superClass) {
1359    subClass.prototype = Object.create(superClass.prototype);
1360    subClass.prototype.constructor = subClass;
1361    if (typeof document !== 'undefined' && document.documentMode < 11) { _defaults(subClass, superClass); } else { subClass.__proto__ = superClass;}
1362  }
1363
1364  function _assertThisInitialized(self) {
1365    if (self === void 0) {
1366      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1367    }
1368
1369    return self;
1370  }
1371
1372  var Position = function () {
1373    function Position(x, y) {
1374      if (!isNil(x) && !isNil(y)) {
1375        this.x = +x;
1376        this.y = +y;
1377      } else if (!isNil(x.x) && !isNil(x.y)) {
1378        this.x = +x.x;
1379        this.y = +x.y;
1380      } else if (Array.isArray(x)) {
1381        this.x = +x[0];
1382        this.y = +x[1];
1383      }
1384
1385      if (this._isNaN()) {
1386        throw new Error('Position is NaN');
1387      }
1388    }
1389
1390    var _proto = Position.prototype;
1391
1392    _proto.set = function set(x, y) {
1393      this.x = x;
1394      this.y = y;
1395      return this;
1396    };
1397
1398    _proto.abs = function abs() {
1399      return new this.constructor(Math.abs(this.x), Math.abs(this.y));
1400    };
1401
1402    _proto._abs = function _abs() {
1403      this.x = Math.abs(this.x);
1404      this.y = Math.abs(this.y);
1405      return this;
1406    };
1407
1408    _proto._round = function _round() {
1409      this.x = Math.round(this.x);
1410      this.y = Math.round(this.y);
1411      return this;
1412    };
1413
1414    _proto.round = function round() {
1415      return new this.constructor(Math.round(this.x), Math.round(this.y));
1416    };
1417
1418    _proto._ceil = function _ceil() {
1419      this.x = Math.ceil(this.x);
1420      this.y = Math.ceil(this.y);
1421      return this;
1422    };
1423
1424    _proto.ceil = function ceil() {
1425      return new this.constructor(Math.ceil(this.x), Math.ceil(this.y));
1426    };
1427
1428    _proto._floor = function _floor() {
1429      this.x = Math.floor(this.x);
1430      this.y = Math.floor(this.y);
1431      return this;
1432    };
1433
1434    _proto.floor = function floor() {
1435      return new this.constructor(Math.floor(this.x), Math.floor(this.y));
1436    };
1437
1438    _proto.copy = function copy() {
1439      return new this.constructor(this.x, this.y);
1440    };
1441
1442    _proto._add = function _add(x, y) {
1443      if (!isNil(x.x)) {
1444        this.x += x.x;
1445        this.y += x.y;
1446      } else if (!isNil(x[0])) {
1447        this.x += x[0];
1448        this.y += x[1];
1449      } else {
1450        this.x += x;
1451        this.y += y;
1452      }
1453
1454      return this;
1455    };
1456
1457    _proto.add = function add(x, y) {
1458      var nx, ny;
1459
1460      if (!isNil(x.x)) {
1461        nx = this.x + x.x;
1462        ny = this.y + x.y;
1463      } else if (!isNil(x[0])) {
1464        nx = this.x + x[0];
1465        ny = this.y + x[1];
1466      } else {
1467        nx = this.x + x;
1468        ny = this.y + y;
1469      }
1470
1471      return new this.constructor(nx, ny);
1472    };
1473
1474    _proto._sub = function _sub(x, y) {
1475      if (!isNil(x.x)) {
1476        this.x -= x.x;
1477        this.y -= x.y;
1478      } else if (!isNil(x[0])) {
1479        this.x -= x[0];
1480        this.y -= x[1];
1481      } else {
1482        this.x -= x;
1483        this.y -= y;
1484      }
1485
1486      return this;
1487    };
1488
1489    _proto._substract = function _substract() {
1490      return this._sub.apply(this, arguments);
1491    };
1492
1493    _proto.sub = function sub(x, y) {
1494      var nx, ny;
1495
1496      if (!isNil(x.x)) {
1497        nx = this.x - x.x;
1498        ny = this.y - x.y;
1499      } else if (!isNil(x[0])) {
1500        nx = this.x - x[0];
1501        ny = this.y - x[1];
1502      } else {
1503        nx = this.x - x;
1504        ny = this.y - y;
1505      }
1506
1507      return new this.constructor(nx, ny);
1508    };
1509
1510    _proto.substract = function substract() {
1511      return this.sub.apply(this, arguments);
1512    };
1513
1514    _proto.multi = function multi(ratio) {
1515      return new this.constructor(this.x * ratio, this.y * ratio);
1516    };
1517
1518    _proto._multi = function _multi(ratio) {
1519      this.x *= ratio;
1520      this.y *= ratio;
1521      return this;
1522    };
1523
1524    _proto.div = function div(n) {
1525      return this.multi(1 / n);
1526    };
1527
1528    _proto._div = function _div(n) {
1529      return this._multi(1 / n);
1530    };
1531
1532    _proto.equals = function equals(c) {
1533      if (!(c instanceof this.constructor)) {
1534        return false;
1535      }
1536
1537      return this.x === c.x && this.y === c.y;
1538    };
1539
1540    _proto._isNaN = function _isNaN() {
1541      return isNaN(this.x) || isNaN(this.y);
1542    };
1543
1544    _proto.isZero = function isZero() {
1545      return this.x === 0 && this.y === 0;
1546    };
1547
1548    _proto.toArray = function toArray() {
1549      return [this.x, this.y];
1550    };
1551
1552    _proto.toFixed = function toFixed(n) {
1553      return new this.constructor(this.x.toFixed(n), this.y.toFixed(n));
1554    };
1555
1556    _proto.toJSON = function toJSON() {
1557      return {
1558        x: this.x,
1559        y: this.y
1560      };
1561    };
1562
1563    return Position;
1564  }();
1565
1566  var Point = function (_Position) {
1567    _inheritsLoose(Point, _Position);
1568
1569    function Point() {
1570      return _Position.apply(this, arguments) || this;
1571    }
1572
1573    var _proto = Point.prototype;
1574
1575    _proto.closeTo = function closeTo(p, delta) {
1576      if (!delta) {
1577        delta = 0;
1578      }
1579
1580      return this.x >= p.x - delta && this.x <= p.x + delta && this.y >= p.y - delta && this.y <= p.y + delta;
1581    };
1582
1583    _proto.distanceTo = function distanceTo(point) {
1584      var x = point.x - this.x,
1585          y = point.y - this.y;
1586      return Math.sqrt(x * x + y * y);
1587    };
1588
1589    _proto.mag = function mag() {
1590      return Math.sqrt(this.x * this.x + this.y * this.y);
1591    };
1592
1593    _proto.unit = function unit() {
1594      return this.copy()._unit();
1595    };
1596
1597    _proto._unit = function _unit() {
1598      this._div(this.mag());
1599
1600      return this;
1601    };
1602
1603    _proto.perp = function perp() {
1604      return this.copy()._perp();
1605    };
1606
1607    _proto._perp = function _perp() {
1608      var y = this.y;
1609      this.y = this.x;
1610      this.x = -y;
1611      return this;
1612    };
1613
1614    _proto.angleWith = function angleWith(b) {
1615      return this.angleWithSep(b.x, b.y);
1616    };
1617
1618    _proto.angleWithSep = function angleWithSep(x, y) {
1619      return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
1620    };
1621
1622    _proto._rotate = function _rotate(angle) {
1623      var cos = Math.cos(angle),
1624          sin = Math.sin(angle),
1625          x = cos * this.x - sin * this.y,
1626          y = sin * this.x + cos * this.y;
1627      this.x = x;
1628      this.y = y;
1629      return this;
1630    };
1631
1632    _proto.rotate = function rotate(a) {
1633      return this.copy()._rotate(a);
1634    };
1635
1636    return Point;
1637  }(Position);
1638
1639  var Size = function () {
1640    function Size(width, height) {
1641      if (isNumber(width) && isNumber(height)) {
1642        this.width = width;
1643        this.height = height;
1644      } else if (isNumber(width['width'])) {
1645        this.width = width.width;
1646        this.height = width.height;
1647      } else if (Array.isArray(width)) {
1648        this.width = width[0];
1649        this.height = width[1];
1650      }
1651    }
1652
1653    var _proto = Size.prototype;
1654
1655    _proto.copy = function copy() {
1656      return new Size(this['width'], this['height']);
1657    };
1658
1659    _proto.add = function add(x, y) {
1660      var w, h;
1661
1662      if (x instanceof Size) {
1663        w = this.width + x.width;
1664        h = this.height + x.height;
1665      } else {
1666        w = this.width + x;
1667        h = this.height + y;
1668      }
1669
1670      return new Size(w, h);
1671    };
1672
1673    _proto.equals = function equals(size) {
1674      return this['width'] === size['width'] && this['height'] === size['height'];
1675    };
1676
1677    _proto.multi = function multi(ratio) {
1678      return new Size(this['width'] * ratio, this['height'] * ratio);
1679    };
1680
1681    _proto._multi = function _multi(ratio) {
1682      this['width'] *= ratio;
1683      this['height'] *= ratio;
1684      return this;
1685    };
1686
1687    _proto._round = function _round() {
1688      this['width'] = Math.round(this['width']);
1689      this['height'] = Math.round(this['height']);
1690      return this;
1691    };
1692
1693    _proto.toPoint = function toPoint() {
1694      return new Point(this['width'], this['height']);
1695    };
1696
1697    _proto.toArray = function toArray() {
1698      return [this['width'], this['height']];
1699    };
1700
1701    _proto.toJSON = function toJSON() {
1702      return {
1703        'width': this['width'],
1704        'height': this['height']
1705      };
1706    };
1707
1708    return Size;
1709  }();
1710
1711  function trim(str) {
1712    return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
1713  }
1714  var specialPattern = /[\b\t\r\v\f]/igm;
1715  function escapeSpecialChars(str) {
1716    if (!isString(str)) {
1717      return str;
1718    }
1719
1720    return str.replace(specialPattern, '');
1721  }
1722  function splitWords(chr) {
1723    return trim(chr).split(/\s+/);
1724  }
1725  var rulerCtx = typeof document !== 'undefined' ? document.createElement('canvas').getContext('2d') : null;
1726  function stringWidth(text, font) {
1727    if (stringWidth.node) {
1728      return stringWidth.node(text, font);
1729    }
1730
1731    rulerCtx.font = font;
1732    return rulerCtx.measureText(text).width;
1733  }
1734  var fontHeight = {};
1735  function stringLength(text, font) {
1736    if (stringLength.node) {
1737      return stringLength.node(text, font);
1738    } else {
1739      var w = stringWidth(text, font);
1740
1741      if (!font) {
1742        font = '_default_';
1743      }
1744
1745      if (!fontHeight[font]) {
1746        fontHeight[font] = getFontHeight(font);
1747      }
1748
1749      return new Size(w, fontHeight[font]);
1750    }
1751  }
1752  function getFontHeight(font) {
1753    var domRuler = getDomRuler();
1754
1755    if (font !== '_default_') {
1756      domRuler.style.font = font;
1757    }
1758
1759    domRuler.innerHTML = '秦';
1760    var h = domRuler.clientHeight;
1761    removeDomNode(domRuler);
1762    return h;
1763  }
1764  function splitContent(content, font, wrapWidth, textWidth) {
1765    if (!content || content.length === 0) {
1766      return [{
1767        'text': '',
1768        'width': 0
1769      }];
1770    }
1771
1772    var width = isNil(textWidth) ? stringWidth(content, font) : textWidth;
1773    var chrWidth = width / content.length,
1774        minChrCount = Math.floor(wrapWidth / chrWidth / 2);
1775
1776    if (chrWidth >= wrapWidth || minChrCount <= 0) {
1777      return [{
1778        'text': '',
1779        'width': wrapWidth
1780      }];
1781    }
1782
1783    if (width <= wrapWidth) return [{
1784      'text': content,
1785      'width': width
1786    }];
1787    var result = [];
1788    var testStr = content.substring(0, minChrCount),
1789        prew = chrWidth * minChrCount;
1790
1791    for (var i = minChrCount, l = content.length; i < l; i++) {
1792      var chr = content[i];
1793      var w = stringWidth(testStr + chr);
1794
1795      if (w >= wrapWidth) {
1796        result.push({
1797          'text': testStr,
1798          'width': prew
1799        });
1800        testStr = content.substring(i, minChrCount + i);
1801        i += minChrCount - 1;
1802        prew = chrWidth * minChrCount;
1803      } else {
1804        testStr += chr;
1805        prew = w;
1806      }
1807
1808      if (i >= l - 1) {
1809        prew = stringWidth(testStr);
1810        result.push({
1811          'text': testStr,
1812          'width': prew
1813        });
1814      }
1815    }
1816
1817    return result;
1818  }
1819  var contentExpRe = /\{([\w_]+)\}/g;
1820  function replaceVariable(str, props) {
1821    if (!isString(str)) {
1822      return str;
1823    }
1824
1825    return str.replace(contentExpRe, function (str, key) {
1826      if (!props) {
1827        return '';
1828      }
1829
1830      var value = props[key];
1831
1832      if (isNil(value)) {
1833        return '';
1834      } else if (Array.isArray(value)) {
1835        return value.join();
1836      }
1837
1838      return value;
1839    });
1840  }
1841  function getAlignPoint(size, horizontalAlignment, verticalAlignment) {
1842    var width = size['width'],
1843        height = size['height'];
1844    var alignW, alignH;
1845
1846    if (horizontalAlignment === 'left') {
1847      alignW = -width;
1848    } else if (horizontalAlignment === 'right') {
1849      alignW = 0;
1850    } else {
1851      alignW = -width / 2;
1852    }
1853
1854    if (verticalAlignment === 'top') {
1855      alignH = -height;
1856    } else if (verticalAlignment === 'bottom') {
1857      alignH = 0;
1858    } else {
1859      alignH = -height / 2;
1860    }
1861
1862    return new Point(alignW, alignH);
1863  }
1864  var DEFAULT_FONT = 'monospace';
1865  function getFont(style) {
1866    if (style['textFont']) {
1867      return style['textFont'];
1868    } else {
1869      return (style['textStyle'] && style['textStyle'] !== 'normal' ? style['textStyle'] + ' ' : '') + (style['textWeight'] && style['textWeight'] !== 'normal' ? style['textWeight'] + ' ' : '') + style['textSize'] + 'px ' + (!style['textFaceName'] ? DEFAULT_FONT : style['textFaceName'][0] === '"' ? style['textFaceName'] : '"' + style['textFaceName'] + '"');
1870    }
1871  }
1872  function splitTextToRow(text, style) {
1873    var font = getFont(style),
1874        lineSpacing = style['textLineSpacing'] || 0,
1875        size = stringLength(text, font),
1876        textWidth = size['width'],
1877        textHeight = size['height'],
1878        wrapChar = style['textWrapCharacter'],
1879        textRows = [];
1880    var wrapWidth = style['textWrapWidth'];
1881
1882    if (!wrapWidth || wrapWidth > textWidth) {
1883      wrapWidth = textWidth;
1884    }
1885
1886    if (!isString(text)) {
1887      text += '';
1888    }
1889
1890    var actualWidth = 0;
1891
1892    if (wrapChar && text.indexOf(wrapChar) >= 0) {
1893      var texts = text.split(wrapChar);
1894
1895      for (var i = 0, l = texts.length; i < l; i++) {
1896        var t = texts[i];
1897        var tWidth = stringWidth(t, font);
1898
1899        if (tWidth > wrapWidth) {
1900          var contents = splitContent(t, font, wrapWidth, tWidth);
1901
1902          for (var ii = 0, ll = contents.length; ii < ll; ii++) {
1903            var w = contents[ii].width;
1904
1905            if (w > actualWidth) {
1906              actualWidth = w;
1907            }
1908
1909            textRows.push({
1910              'text': contents[ii].text,
1911              'size': new Size(w, textHeight)
1912            });
1913          }
1914        } else {
1915          if (tWidth > actualWidth) {
1916            actualWidth = tWidth;
1917          }
1918
1919          textRows.push({
1920            'text': t,
1921            'size': new Size(tWidth, textHeight)
1922          });
1923        }
1924      }
1925    } else if (textWidth > wrapWidth) {
1926      var _contents = splitContent(text, font, wrapWidth, textWidth);
1927
1928      for (var _i = 0; _i < _contents.length; _i++) {
1929        var _w = _contents[_i].width;
1930
1931        if (_w > actualWidth) {
1932          actualWidth = _w;
1933        }
1934
1935        textRows.push({
1936          'text': _contents[_i].text,
1937          'size': new Size(_w, textHeight)
1938        });
1939      }
1940    } else {
1941      if (textWidth > actualWidth) {
1942        actualWidth = textWidth;
1943      }
1944
1945      textRows.push({
1946        'text': text,
1947        'size': size
1948      });
1949    }
1950
1951    var rowNum = textRows.length;
1952    var textSize = new Size(actualWidth, textHeight * rowNum + lineSpacing * (rowNum - 1));
1953    return {
1954      'total': rowNum,
1955      'size': textSize,
1956      'rows': textRows,
1957      'rawSize': size
1958    };
1959  }
1960
1961  var strings = /*#__PURE__*/Object.freeze({
1962    trim: trim,
1963    escapeSpecialChars: escapeSpecialChars,
1964    splitWords: splitWords,
1965    stringWidth: stringWidth,
1966    stringLength: stringLength,
1967    getFontHeight: getFontHeight,
1968    splitContent: splitContent,
1969    replaceVariable: replaceVariable,
1970    getAlignPoint: getAlignPoint,
1971    getFont: getFont,
1972    splitTextToRow: splitTextToRow
1973  });
1974
1975  var first = function first(props) {
1976    return props[0];
1977  };
1978
1979  var testProp = IS_NODE ? first : function (props) {
1980    var style = document.documentElement.style;
1981
1982    for (var i = 0; i < props.length; i++) {
1983      if (props[i] in style) {
1984        return props[i];
1985      }
1986    }
1987
1988    return false;
1989  };
1990  var TRANSFORM = testProp(['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']);
1991  var TRANSFORMORIGIN = testProp(['transformOrigin', 'WebkitTransformOrigin', 'OTransformOrigin', 'MozTransformOrigin', 'msTransformOrigin']);
1992  var TRANSITION = testProp(['transition', 'WebkitTransition', 'OTransition', 'MozTransition', 'msTransition']);
1993  var CSSFILTER = testProp(['filter', 'WebkitFilter', 'OFilter', 'MozFilter', 'msFilter']);
1994  function createEl(tagName, className) {
1995    var el = document.createElement(tagName);
1996
1997    if (className) {
1998      setClass(el, className);
1999    }
2000
2001    return el;
2002  }
2003  function createElOn(tagName, style, container) {
2004    var el = createEl(tagName);
2005
2006    if (style) {
2007      setStyle(el, style);
2008    }
2009
2010    if (container) {
2011      container.appendChild(el);
2012    }
2013
2014    return el;
2015  }
2016  function removeDomNode(node) {
2017    if (!node) {
2018      return this;
2019    }
2020
2021    if (Browser$1.ielt9 || Browser$1.ie9) {
2022      var d = createEl('div');
2023      d.appendChild(node);
2024      d.innerHTML = '';
2025      d = null;
2026    } else if (node.parentNode) {
2027      node.parentNode.removeChild(node);
2028    }
2029
2030    return this;
2031  }
2032  function addDomEvent(obj, typeArr, handler, context) {
2033    if (!obj || !obj.addEventListener || !typeArr || !handler) {
2034      return this;
2035    }
2036
2037    var eventHandler = function eventHandler(e) {
2038      if (!e) {
2039        e = window.event;
2040      }
2041
2042      handler.call(context || obj, e);
2043      return;
2044    };
2045
2046    var types = typeArr.split(' ');
2047
2048    for (var i = types.length - 1; i >= 0; i--) {
2049      var type = types[i];
2050
2051      if (!type) {
2052        continue;
2053      }
2054
2055      if (!obj['Z__' + type]) {
2056        obj['Z__' + type] = [];
2057      }
2058
2059      var hit = listensDomEvent(obj, type, handler);
2060
2061      if (hit >= 0) {
2062        removeDomEvent(obj, type, handler);
2063      }
2064
2065      obj['Z__' + type].push({
2066        callback: eventHandler,
2067        src: handler
2068      });
2069
2070      if (type === 'mousewheel' && Browser$1.gecko) {
2071        type = 'DOMMouseScroll';
2072      }
2073
2074      obj.addEventListener(type, eventHandler, false);
2075    }
2076
2077    return this;
2078  }
2079  function removeDomEvent(obj, typeArr, handler) {
2080    function doRemove(type, callback) {
2081      if (type === 'mousewheel' && Browser$1.gecko) {
2082        type = 'DOMMouseScroll';
2083      }
2084
2085      obj.removeEventListener(type, callback, false);
2086    }
2087
2088    if (!obj || !obj.removeEventListener || !typeArr) {
2089      return this;
2090    }
2091
2092    var types = typeArr.split(' ');
2093
2094    for (var i = types.length - 1; i >= 0; i--) {
2095      var type = types[i];
2096
2097      if (!type) {
2098        continue;
2099      }
2100
2101      if (!handler && obj['Z__' + type]) {
2102        var handlers = obj['Z__' + type];
2103
2104        for (var j = 0, jlen = handlers.length; j < jlen; j++) {
2105          doRemove(handlers[j].callback);
2106        }
2107
2108        delete obj['Z__' + type];
2109        return this;
2110      }
2111
2112      var hit = listensDomEvent(obj, type, handler);
2113
2114      if (hit < 0) {
2115        return this;
2116      }
2117
2118      var hitHandler = obj['Z__' + type][hit];
2119      doRemove(type, hitHandler.callback);
2120      obj['Z__' + type].splice(hit, 1);
2121    }
2122
2123    return this;
2124  }
2125  function listensDomEvent(obj, type, handler) {
2126    if (!obj || !obj['Z__' + type] || !handler) {
2127      return -1;
2128    }
2129
2130    var handlers = obj['Z__' + type];
2131
2132    for (var i = 0, len = handlers.length; i < len; i++) {
2133      if (handlers[i].src === handler) {
2134        return i;
2135      }
2136    }
2137
2138    return -1;
2139  }
2140  function preventDefault(event) {
2141    if (event.preventDefault) {
2142      event.preventDefault();
2143    } else {
2144      event.returnValue = false;
2145    }
2146
2147    return this;
2148  }
2149  function stopPropagation(e) {
2150    if (e.stopPropagation) {
2151      e.stopPropagation();
2152    } else {
2153      e.cancelBubble = true;
2154    }
2155
2156    return this;
2157  }
2158  function preventSelection(dom) {
2159    dom.onselectstart = function () {
2160      return false;
2161    };
2162
2163    dom.ondragstart = function () {
2164      return false;
2165    };
2166
2167    dom.setAttribute('unselectable', 'on');
2168    return this;
2169  }
2170  function offsetDom(dom, offset) {
2171    if (!dom) {
2172      return null;
2173    }
2174
2175    if (Browser$1.any3d) {
2176      setTransform(dom, offset);
2177    } else {
2178      dom.style.left = offset.x + 'px';
2179      dom.style.top = offset.y + 'px';
2180    }
2181
2182    return offset;
2183  }
2184  function computeDomPosition(dom) {
2185    var style = window.getComputedStyle(dom);
2186    var padding = [parseInt(style['padding-left']), parseInt(style['padding-top'])];
2187    var rect = dom.getBoundingClientRect();
2188    var offsetWidth = dom.offsetWidth,
2189        offsetHeight = dom.offsetHeight;
2190    var scaleX = offsetWidth ? rect.width / offsetWidth : 1,
2191        scaleY = offsetHeight ? rect.height / offsetHeight : 1;
2192    dom.__position = [rect.left + padding[0], rect.top + padding[1], scaleX, scaleY];
2193    return dom.__position;
2194  }
2195  function getEventContainerPoint(ev, dom) {
2196    if (!ev) {
2197      ev = window.event;
2198    }
2199
2200    var domPos = dom.__position;
2201
2202    if (!domPos) {
2203      domPos = computeDomPosition(dom);
2204    }
2205
2206    return new Point((ev.clientX - domPos[0] - dom.clientLeft) / domPos[2], (ev.clientY - domPos[1] - dom.clientTop) / domPos[3]);
2207  }
2208
2209  function endsWith(str, suffix) {
2210    var l = str.length - suffix.length;
2211    return l >= 0 && str.indexOf(suffix, l) === l;
2212  }
2213
2214  function setStyle(dom, strCss) {
2215    var cssText = dom.style.cssText;
2216
2217    if (!endsWith(cssText, ';')) {
2218      cssText += ';';
2219    }
2220
2221    dom.style.cssText = cssText + strCss;
2222    return this;
2223  }
2224  function hasClass(el, name) {
2225    if (el.classList !== undefined) {
2226      return el.classList.contains(name);
2227    }
2228
2229    var className = getClass(el);
2230    return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
2231  }
2232  function addClass(el, name) {
2233    if (el.classList !== undefined && !hasClass(el, name)) {
2234      var classes = splitWords(name);
2235
2236      for (var i = 0, len = classes.length; i < len; i++) {
2237        el.classList.add(classes[i]);
2238      }
2239    } else {
2240      var className = getClass(el);
2241      setClass(el, (className ? className + ' ' : '') + name);
2242    }
2243
2244    return this;
2245  }
2246  function setClass(el, name) {
2247    if (isNil(el.className.baseVal)) {
2248      el.className = name;
2249    } else {
2250      el.className.baseVal = name;
2251    }
2252
2253    return this;
2254  }
2255  function getClass(el) {
2256    return isNil(el.className.baseVal) ? el.className : el.className.baseVal;
2257  }
2258  function setOpacity(el, value) {
2259    el.style.opacity = value;
2260    return this;
2261  }
2262  function setTransform(el, offset) {
2263    var pos = offset || new Point(0, 0);
2264    el.style[TRANSFORM] = Browser$1.any3d ? 'translate3d(' + pos.x + 'px,' + pos.y + 'px,0px)' : 'translate(' + pos.x + 'px,' + pos.y + 'px)';
2265    return this;
2266  }
2267  function setTransformMatrix(el, m) {
2268    var text = 'matrix(' + (isString(m) ? m : m.join()) + ')';
2269
2270    if (el.style[TRANSFORM] !== text) {
2271      el.style[TRANSFORM] = text;
2272    }
2273
2274    return this;
2275  }
2276  function removeTransform(el) {
2277    if (el.style[TRANSFORM]) {
2278      el.style[TRANSFORM] = '';
2279    }
2280
2281    return this;
2282  }
2283  function isHTML(str) {
2284    return /<[a-z\][\s\S]*>/i.test(str);
2285  }
2286  function measureDom(parentTag, dom) {
2287    var ruler = getDomRuler(parentTag);
2288
2289    if (isString(dom)) {
2290      ruler.innerHTML = dom;
2291    } else {
2292      ruler.appendChild(dom);
2293    }
2294
2295    var result = new Size(ruler.clientWidth, ruler.clientHeight);
2296    removeDomNode(ruler);
2297    return result;
2298  }
2299  function getDomRuler(tag) {
2300    var span = document.createElement(tag);
2301    span.style.cssText = 'position:absolute;left:-10000px;top:-10000px;';
2302    document.body.appendChild(span);
2303    return span;
2304  }
2305  var on = addDomEvent;
2306  var off = removeDomEvent;
2307
2308  var dom = /*#__PURE__*/Object.freeze({
2309    TRANSFORM: TRANSFORM,
2310    TRANSFORMORIGIN: TRANSFORMORIGIN,
2311    TRANSITION: TRANSITION,
2312    CSSFILTER: CSSFILTER,
2313    createEl: createEl,
2314    createElOn: createElOn,
2315    removeDomNode: removeDomNode,
2316    addDomEvent: addDomEvent,
2317    removeDomEvent: removeDomEvent,
2318    listensDomEvent: listensDomEvent,
2319    preventDefault: preventDefault,
2320    stopPropagation: stopPropagation,
2321    preventSelection: preventSelection,
2322    offsetDom: offsetDom,
2323    computeDomPosition: computeDomPosition,
2324    getEventContainerPoint: getEventContainerPoint,
2325    setStyle: setStyle,
2326    hasClass: hasClass,
2327    addClass: addClass,
2328    setClass: setClass,
2329    getClass: getClass,
2330    setOpacity: setOpacity,
2331    setTransform: setTransform,
2332    setTransformMatrix: setTransformMatrix,
2333    removeTransform: removeTransform,
2334    isHTML: isHTML,
2335    measureDom: measureDom,
2336    getDomRuler: getDomRuler,
2337    on: on,
2338    off: off
2339  });
2340
2341  var Ajax = {
2342    jsonp: function jsonp(url, callback) {
2343      var name = '_maptalks_jsonp_' + UID();
2344      if (url.match(/\?/)) url += '&callback=' + name;else url += '?callback=' + name;
2345      var script = document.createElement('script');
2346      script.type = 'text/javascript';
2347      script.src = url;
2348
2349      window[name] = function (data) {
2350        callback(null, data);
2351        document.getElementsByTagName('head')[0].removeChild(script);
2352        script = null;
2353        delete window[name];
2354      };
2355
2356      document.getElementsByTagName('head')[0].appendChild(script);
2357      return this;
2358    },
2359    get: function get(url, options, cb) {
2360      if (isFunction(options)) {
2361        var t = cb;
2362        cb = options;
2363        options = t;
2364      }
2365
2366      if (IS_NODE && Ajax.get.node) {
2367        return Ajax.get.node(url, cb, options);
2368      }
2369
2370      var client = Ajax._getClient(cb);
2371
2372      client.open('GET', url, true);
2373
2374      if (options) {
2375        for (var k in options.headers) {
2376          client.setRequestHeader(k, options.headers[k]);
2377        }
2378
2379        client.withCredentials = options.credentials === 'include';
2380
2381        if (options['responseType']) {
2382          client.responseType = options['responseType'];
2383        }
2384      }
2385
2386      client.send(null);
2387      return client;
2388    },
2389    post: function post(url, options, cb) {
2390      var postData;
2391
2392      if (!isString(url)) {
2393        var t = cb;
2394        postData = options;
2395        options = url;
2396        url = options.url;
2397        cb = t;
2398      } else {
2399        if (isFunction(options)) {
2400          var _t = cb;
2401          cb = options;
2402          options = _t;
2403        }
2404
2405        options = options || {};
2406        postData = options.postData;
2407      }
2408
2409      if (IS_NODE && Ajax.post.node) {
2410        options.url = url;
2411        return Ajax.post.node(options, postData, cb);
2412      }
2413
2414      var client = Ajax._getClient(cb);
2415
2416      client.open('POST', options.url, true);
2417
2418      if (!options.headers) {
2419        options.headers = {};
2420      }
2421
2422      if (!options.headers['Content-Type']) {
2423        options.headers['Content-Type'] = 'application/x-www-form-urlencoded';
2424      }
2425
2426      if ('setRequestHeader' in client) {
2427        for (var p in options.headers) {
2428          if (options.headers.hasOwnProperty(p)) {
2429            client.setRequestHeader(p, options.headers[p]);
2430          }
2431        }
2432      }
2433
2434      if (!isString(postData)) {
2435        postData = JSON.stringify(postData);
2436      }
2437
2438      client.send(postData);
2439      return client;
2440    },
2441    _wrapCallback: function _wrapCallback(client, cb) {
2442      return function () {
2443        if (client.readyState === 4) {
2444          if (client.status === 200) {
2445            if (client.responseType === 'arraybuffer') {
2446              var response = client.response;
2447
2448              if (response.byteLength === 0) {
2449                cb(new Error('http status 200 returned without content.'));
2450              } else {
2451                cb(null, {
2452                  data: client.response,
2453                  cacheControl: client.getResponseHeader('Cache-Control'),
2454                  expires: client.getResponseHeader('Expires'),
2455                  contentType: client.getResponseHeader('Content-Type')
2456                });
2457              }
2458            } else {
2459              cb(null, client.responseText);
2460            }
2461          } else {
2462            cb(new Error(client.statusText + ',' + client.status));
2463          }
2464        }
2465      };
2466    },
2467    _getClient: function _getClient(cb) {
2468      var client;
2469
2470      try {
2471        client = new XMLHttpRequest();
2472      } catch (e) {
2473        try {
2474          client = new ActiveXObject('Msxml2.XMLHTTP');
2475        } catch (e) {
2476          try {
2477            client = new ActiveXObject('Microsoft.XMLHTTP');
2478          } catch (e) {}
2479        }
2480      }
2481
2482      client.onreadystatechange = Ajax._wrapCallback(client, cb);
2483      return client;
2484    },
2485    getArrayBuffer: function getArrayBuffer(url, options, cb) {
2486      if (isFunction(options)) {
2487        var t = cb;
2488        cb = options;
2489        options = t;
2490      }
2491
2492      if (!options) {
2493        options = {};
2494      }
2495
2496      options['responseType'] = 'arraybuffer';
2497      return Ajax.get(url, options, cb);
2498    },
2499    getImage: function getImage(img, url, options) {
2500      return Ajax.getArrayBuffer(url, options, function (err, imgData) {
2501        if (err) {
2502          if (img.onerror) {
2503            img.onerror(err);
2504          }
2505        } else if (imgData) {
2506          var URL = window.URL || window.webkitURL;
2507          var onload = img.onload;
2508
2509          img.onload = function () {
2510            if (onload) {
2511              onload();
2512            }
2513
2514            URL.revokeObjectURL(img.src);
2515          };
2516
2517          var blob = new Blob([new Uint8Array(imgData.data)], {
2518            type: imgData.contentType
2519          });
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
2528  Ajax.getJSON = function (url, options, cb) {
2529    if (isFunction(options)) {
2530      var t = cb;
2531      cb = options;
2532      options = t;
2533    }
2534
2535    var callback = function callback(err, resp) {
2536      var data = resp ? parseJSON(resp) : null;
2537      cb(err, data);
2538    };
2539
2540    if (options && options['jsonp']) {
2541      return Ajax.jsonp(url, callback);
2542    }
2543
2544    return Ajax.get(url, options, callback);
2545  };
2546
2547  var DEFAULT_STROKE_COLOR = '#000';
2548  var DEFAULT_FILL_COLOR = 'rgba(255,255,255,0)';
2549  var DEFAULT_TEXT_COLOR = '#000';
2550  var hitTesting = false;
2551  var TEMP_CANVAS = null;
2552  var Canvas = {
2553    setHitTesting: function setHitTesting(testing) {
2554      hitTesting = testing;
2555    },
2556    createCanvas: function createCanvas(width, height, canvasClass) {
2557      var canvas;
2558
2559      if (!IS_NODE) {
2560        canvas = createEl('canvas');
2561        canvas.width = width;
2562        canvas.height = height;
2563      } else {
2564        canvas = new canvasClass(width, height);
2565      }
2566
2567      return canvas;
2568    },
2569    prepareCanvasFont: function prepareCanvasFont(ctx, style) {
2570      ctx.textBaseline = 'top';
2571      ctx.font = getFont(style);
2572      var fill = style['textFill'];
2573
2574      if (!fill) {
2575        fill = DEFAULT_TEXT_COLOR;
2576      }
2577
2578      ctx.fillStyle = Canvas.getRgba(fill, style['textOpacity']);
2579    },
2580    prepareCanvas: function prepareCanvas(ctx, style, resources, testing) {
2581      if (!style) {
2582        return;
2583      }
2584
2585      var strokeWidth = style['lineWidth'];
2586
2587      if (!isNil(strokeWidth) && ctx.lineWidth !== strokeWidth) {
2588        ctx.lineWidth = strokeWidth;
2589      }
2590
2591      var strokeColor = style['linePatternFile'] || style['lineColor'] || DEFAULT_STROKE_COLOR;
2592
2593      if (testing) {
2594        ctx.strokeStyle = '#000';
2595      } else if (isImageUrl(strokeColor) && resources) {
2596        var patternOffset;
2597
2598        if (style['linePatternDx'] || style['linePatternDy']) {
2599          patternOffset = [style['linePatternDx'], style['linePatternDy']];
2600        }
2601
2602        Canvas._setStrokePattern(ctx, strokeColor, strokeWidth, patternOffset, resources);
2603
2604        style['lineDasharray'] = [];
2605      } else if (isGradient(strokeColor)) {
2606        if (style['lineGradientExtent']) {
2607          ctx.strokeStyle = Canvas._createGradient(ctx, strokeColor, style['lineGradientExtent']);
2608        } else {
2609          ctx.strokeStyle = DEFAULT_STROKE_COLOR;
2610        }
2611      } else {
2612          ctx.strokeStyle = strokeColor;
2613        }
2614
2615      if (style['lineJoin']) {
2616        ctx.lineJoin = style['lineJoin'];
2617      }
2618
2619      if (style['lineCap']) {
2620        ctx.lineCap = style['lineCap'];
2621      }
2622
2623      if (ctx.setLineDash && isArrayHasData(style['lineDasharray'])) {
2624        ctx.setLineDash(style['lineDasharray']);
2625      }
2626
2627      var fill = style['polygonPatternFile'] || style['polygonFill'] || DEFAULT_FILL_COLOR;
2628
2629      if (testing) {
2630        ctx.fillStyle = '#000';
2631      } else if (isImageUrl(fill) && resources) {
2632        var fillImgUrl = extractImageUrl(fill);
2633        var fillTexture = resources.getImage([fillImgUrl, null, null]);
2634
2635        if (!fillTexture) {
2636          fillTexture = resources.getImage([fillImgUrl + '-texture', null, strokeWidth]);
2637        }
2638
2639        if (isSVG(fillImgUrl) && fillTexture instanceof Image && (Browser$1.edge || Browser$1.ie)) {
2640          var w = fillTexture.width || 20,
2641              h = fillTexture.height || 20;
2642          var canvas = Canvas.createCanvas(w, h);
2643          Canvas.image(canvas.getContext('2d'), fillTexture, 0, 0, w, h);
2644          fillTexture = canvas;
2645        }
2646
2647        if (!fillTexture) {
2648          if (typeof console !== 'undefined') {
2649            console.warn('img not found for', fillImgUrl);
2650          }
2651        } else {
2652          ctx.fillStyle = ctx.createPattern(fillTexture, 'repeat');
2653
2654          if (style['polygonPatternDx'] || style['polygonPatternDy']) {
2655            ctx.fillStyle['polygonPatternOffset'] = [style['polygonPatternDx'], style['polygonPatternDy']];
2656          }
2657        }
2658      } else if (isGradient(fill)) {
2659        if (style['polygonGradientExtent']) {
2660          ctx.fillStyle = Canvas._createGradient(ctx, fill, style['polygonGradientExtent']);
2661        } else {
2662          ctx.fillStyle = 'rgba(255,255,255,0)';
2663        }
2664      } else {
2665          ctx.fillStyle = fill;
2666        }
2667    },
2668    _createGradient: function _createGradient(ctx, g, extent) {
2669      var gradient = null,
2670          places = g['places'];
2671      var min = extent.getMin(),
2672          max = extent.getMax(),
2673          width = extent.getWidth(),
2674          height = extent.getHeight();
2675
2676      if (!g['type'] || g['type'] === 'linear') {
2677        if (!places) {
2678          places = [min.x, min.y, max.x, min.y];
2679        } else {
2680          if (places.length !== 4) {
2681            throw new Error('A linear gradient\'s places should have 4 numbers.');
2682          }
2683
2684          places = [min.x + places[0] * width, min.y + places[1] * height, min.x + places[2] * width, min.y + places[3] * height];
2685        }
2686
2687        gradient = ctx.createLinearGradient.apply(ctx, places);
2688      } else if (g['type'] === 'radial') {
2689        if (!places) {
2690          var c = extent.getCenter()._round();
2691
2692          places = [c.x, c.y, Math.abs(c.x - min.x), c.x, c.y, 0];
2693        } else {
2694          if (places.length !== 6) {
2695            throw new Error('A radial gradient\'s places should have 6 numbers.');
2696          }
2697
2698          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]];
2699        }
2700
2701        gradient = ctx.createRadialGradient.apply(ctx, places);
2702      }
2703
2704      g['colorStops'].forEach(function (stop) {
2705        gradient.addColorStop.apply(gradient, stop);
2706      });
2707      return gradient;
2708    },
2709    _setStrokePattern: function _setStrokePattern(ctx, strokePattern, strokeWidth, linePatternOffset, resources) {
2710      var imgUrl = extractImageUrl(strokePattern);
2711      var imageTexture;
2712
2713      if (IS_NODE) {
2714        imageTexture = resources.getImage([imgUrl, null, strokeWidth]);
2715      } else {
2716        var key = imgUrl + '-texture-' + strokeWidth;
2717        imageTexture = resources.getImage(key);
2718
2719        if (!imageTexture) {
2720          var imageRes = resources.getImage([imgUrl, null, null]);
2721
2722          if (imageRes) {
2723            var w;
2724
2725            if (!imageRes.width || !imageRes.height) {
2726              w = strokeWidth;
2727            } else {
2728              w = Math.round(imageRes.width * strokeWidth / imageRes.height);
2729            }
2730
2731            var patternCanvas = Canvas.createCanvas(w, strokeWidth, ctx.canvas.constructor);
2732            Canvas.image(patternCanvas.getContext('2d'), imageRes, 0, 0, w, strokeWidth);
2733            resources.addResource([key, null, strokeWidth], patternCanvas);
2734            imageTexture = patternCanvas;
2735          }
2736        }
2737      }
2738
2739      if (imageTexture) {
2740        ctx.strokeStyle = ctx.createPattern(imageTexture, 'repeat');
2741        ctx.strokeStyle['linePatternOffset'] = linePatternOffset;
2742      } else if (typeof console !== 'undefined') {
2743        console.warn('img not found for', imgUrl);
2744      }
2745    },
2746    clearRect: function clearRect(ctx, x1, y1, x2, y2) {
2747      ctx.canvas._drawn = false;
2748      ctx.clearRect(x1, y1, x2, y2);
2749    },
2750    fillCanvas: function fillCanvas(ctx, fillOpacity, x, y) {
2751      if (hitTesting) {
2752        fillOpacity = 1;
2753      }
2754
2755      ctx.canvas._drawn = true;
2756
2757      if (fillOpacity === 0) {
2758        return;
2759      }
2760
2761      var isPattern = Canvas._isPattern(ctx.fillStyle);
2762
2763      var offset = ctx.fillStyle && ctx.fillStyle['polygonPatternOffset'];
2764      var dx = offset ? offset[0] : 0,
2765          dy = offset ? offset[1] : 0;
2766
2767      if (isNil(fillOpacity)) {
2768        fillOpacity = 1;
2769      }
2770
2771      var alpha;
2772
2773      if (fillOpacity < 1) {
2774        alpha = ctx.globalAlpha;
2775        ctx.globalAlpha *= fillOpacity;
2776      }
2777
2778      if (isPattern) {
2779        x = x || 0;
2780        y = y || 0;
2781        ctx.translate(x + dx, y + dy);
2782      }
2783
2784      ctx.fill();
2785
2786      if (isPattern) {
2787        ctx.translate(-x - dx, -y - dy);
2788      }
2789
2790      if (fillOpacity < 1) {
2791        ctx.globalAlpha = alpha;
2792      }
2793    },
2794    getRgba: function getRgba(color, op) {
2795      if (isNil(op)) {
2796        op = 1;
2797      }
2798
2799      if (color[0] !== '#') {
2800        return color;
2801      }
2802
2803      var r, g, b;
2804
2805      if (color.length === 7) {
2806        r = parseInt(color.substring(1, 3), 16);
2807        g = parseInt(color.substring(3, 5), 16);
2808        b = parseInt(color.substring(5, 7), 16);
2809      } else {
2810        r = parseInt(color.substring(1, 2), 16) * 17;
2811        g = parseInt(color.substring(2, 3), 16) * 17;
2812        b = parseInt(color.substring(3, 4), 16) * 17;
2813      }
2814
2815      return 'rgba(' + r + ',' + g + ',' + b + ',' + op + ')';
2816    },
2817    image: function image(ctx, img, x, y, width, height) {
2818      ctx.canvas._drawn = true;
2819
2820      try {
2821        if (isNumber(width) && isNumber(height)) {
2822          ctx.drawImage(img, x, y, width, height);
2823        } else {
2824          ctx.drawImage(img, x, y);
2825        }
2826      } catch (error) {
2827        if (console) {
2828          console.warn('error when drawing image on canvas:', error);
2829          console.warn(img);
2830        }
2831      }
2832    },
2833    text: function text(ctx, _text, pt, style, textDesc) {
2834      Canvas._textOnMultiRow(ctx, textDesc['rows'], style, pt, textDesc['size'], textDesc['rawSize']);
2835    },
2836    _textOnMultiRow: function _textOnMultiRow(ctx, texts, style, point, splitTextSize, textSize) {
2837      var ptAlign = getAlignPoint(splitTextSize, style['textHorizontalAlignment'], style['textVerticalAlignment']),
2838          lineHeight = textSize['height'] + style['textLineSpacing'],
2839          basePoint = point.add(0, ptAlign.y),
2840          maxHeight = style['textMaxHeight'];
2841      var text,
2842          rowAlign,
2843          height = 0;
2844
2845      for (var i = 0, len = texts.length; i < len; i++) {
2846        text = texts[i]['text'];
2847        rowAlign = getAlignPoint(texts[i]['size'], style['textHorizontalAlignment'], style['textVerticalAlignment']);
2848
2849        Canvas._textOnLine(ctx, text, basePoint.add(rowAlign.x, i * lineHeight), style['textHaloRadius'], style['textHaloFill'], style['textHaloOpacity']);
2850
2851        if (maxHeight > 0) {
2852          height += lineHeight;
2853
2854          if (height + textSize['height'] >= maxHeight) {
2855            break;
2856          }
2857        }
2858      }
2859    },
2860    _textOnLine: function _textOnLine(ctx, text, pt, textHaloRadius, textHaloFill, textHaloAlpha) {
2861      if (hitTesting) {
2862        textHaloAlpha = 1;
2863      }
2864
2865      var drawHalo = textHaloAlpha !== 0 && textHaloRadius !== 0;
2866      ctx.textBaseline = 'top';
2867      var gco, fill;
2868      var shadowBlur = ctx.shadowBlur,
2869          shadowOffsetX = ctx.shadowOffsetX,
2870          shadowOffsetY = ctx.shadowOffsetY;
2871
2872      if (drawHalo) {
2873        var alpha = ctx.globalAlpha;
2874        ctx.globalAlpha *= textHaloAlpha;
2875        ctx.miterLimit = 2;
2876        ctx.lineJoin = 'round';
2877        ctx.lineCap = 'round';
2878        ctx.lineWidth = textHaloRadius * 2;
2879        ctx.strokeStyle = textHaloFill;
2880        ctx.strokeText(text, Math.round(pt.x), Math.round(pt.y));
2881        ctx.miterLimit = 10;
2882        ctx.globalAlpha = alpha;
2883        gco = ctx.globalCompositeOperation;
2884        ctx.globalCompositeOperation = 'destination-out';
2885        fill = ctx.fillStyle;
2886        ctx.fillStyle = '#000';
2887      }
2888
2889      if (shadowBlur && drawHalo) {
2890        ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;
2891      }
2892
2893      Canvas.fillText(ctx, text, pt);
2894
2895      if (gco) {
2896        ctx.globalCompositeOperation = gco;
2897        Canvas.fillText(ctx, text, pt, fill);
2898
2899        if (shadowBlur) {
2900          ctx.shadowBlur = shadowBlur;
2901          ctx.shadowOffsetX = shadowOffsetX;
2902          ctx.shadowOffsetY = shadowOffsetY;
2903        }
2904      }
2905    },
2906    fillText: function fillText(ctx, text, pt, rgba) {
2907      ctx.canvas._drawn = true;
2908
2909      if (rgba) {
2910        ctx.fillStyle = rgba;
2911      }
2912
2913      ctx.fillText(text, Math.round(pt.x), Math.round(pt.y));
2914    },
2915    _stroke: function _stroke(ctx, strokeOpacity, x, y) {
2916      if (hitTesting) {
2917        strokeOpacity = 1;
2918      }
2919
2920      ctx.canvas._drawn = true;
2921
2922      if (strokeOpacity === 0) {
2923        return;
2924      }
2925
2926      var offset = ctx.strokeStyle && ctx.strokeStyle['linePatternOffset'];
2927      var dx = offset ? offset[0] : 0,
2928          dy = offset ? offset[1] : 0;
2929      var isPattern = Canvas._isPattern(ctx.strokeStyle) && (!isNil(x) && !isNil(y) || !isNil(dx) && !isNil(dy));
2930
2931      if (isNil(strokeOpacity)) {
2932        strokeOpacity = 1;
2933      }
2934
2935      var alpha;
2936
2937      if (strokeOpacity < 1) {
2938        alpha = ctx.globalAlpha;
2939        ctx.globalAlpha *= strokeOpacity;
2940      }
2941
2942      if (isPattern) {
2943        x = x || 0;
2944        y = y || 0;
2945        ctx.translate(x + dx, y + dy);
2946      }
2947
2948      ctx.stroke();
2949
2950      if (isPattern) {
2951        ctx.translate(-x - dx, -y - dy);
2952      }
2953
2954      if (strokeOpacity < 1) {
2955        ctx.globalAlpha = alpha;
2956      }
2957    },
2958    _path: function _path(ctx, points, lineDashArray, lineOpacity, ignoreStrokePattern) {
2959      if (!isArrayHasData(points)) {
2960        return;
2961      }
2962
2963      function fillWithPattern(p1, p2) {
2964        var degree = computeDegree(p1.x, p1.y, p2.x, p2.y);
2965        ctx.save();
2966        var cosd = Math.cos(degree);
2967
2968        if (Math.abs(cosd) < 1E-7) {
2969          ctx.translate(p1.x - ctx.lineWidth / 2, p1.y);
2970        } else {
2971          ctx.translate(p1.x, p1.y - ctx.lineWidth / 2 / cosd);
2972        }
2973
2974        ctx.rotate(degree);
2975
2976        Canvas._stroke(ctx, lineOpacity);
2977
2978        ctx.restore();
2979      }
2980
2981      var isDashed = isArrayHasData(lineDashArray);
2982      var isPatternLine = ignoreStrokePattern === true ? false : Canvas._isPattern(ctx.strokeStyle);
2983      var point, prePoint, nextPoint;
2984
2985      for (var i = 0, len = points.length; i < len; i++) {
2986        point = points[i];
2987
2988        if (!isDashed || ctx.setLineDash) {
2989          ctx.lineTo(point.x, point.y);
2990
2991          if (isPatternLine && i > 0) {
2992            prePoint = points[i - 1];
2993            fillWithPattern(prePoint, point);
2994            ctx.beginPath();
2995            ctx.moveTo(point.x, point.y);
2996          }
2997        } else if (isDashed) {
2998          if (i === len - 1) {
2999            break;
3000          }
3001
3002          nextPoint = points[i + 1];
3003          drawDashLine(ctx, point, nextPoint, lineDashArray, isPatternLine);
3004        }
3005      }
3006    },
3007    path: function path(ctx, points, lineOpacity, fillOpacity, lineDashArray) {
3008      if (!isArrayHasData(points)) {
3009        return;
3010      }
3011
3012      ctx.beginPath();
3013      ctx.moveTo(points[0].x, points[0].y);
3014
3015      Canvas._path(ctx, points, lineDashArray, lineOpacity);
3016
3017      Canvas._stroke(ctx, lineOpacity);
3018    },
3019    _multiClip: function _multiClip(ctx, points) {
3020      if (!points || points.length === 0) return;
3021      points = points[0];
3022
3023      for (var i = 0, len = points.length; i < len; i++) {
3024        var point = points[i];
3025        var x = point.x,
3026            y = point.y;
3027
3028        if (i === 0) {
3029          ctx.moveTo(x, y);
3030        } else {
3031          ctx.lineTo(x, y);
3032        }
3033
3034        if (i === len - 1) {
3035          x = points[0].x;
3036          y = points[0].y;
3037          ctx.lineTo(x, y);
3038        }
3039      }
3040    },
3041    polygon: function polygon(ctx, points, lineOpacity, fillOpacity, lineDashArray, smoothness) {
3042      if (ctx.isMultiClip) {
3043        Canvas._multiClip(ctx, points);
3044
3045        return;
3046      }
3047
3048      if (!isArrayHasData(points)) {
3049        return;
3050      }
3051
3052      var isPatternLine = Canvas._isPattern(ctx.strokeStyle),
3053          fillFirst = isArrayHasData(lineDashArray) && !ctx.setLineDash || isPatternLine && !smoothness;
3054
3055      if (!isArrayHasData(points[0])) {
3056        points = [points];
3057      }
3058
3059      var savedCtx = ctx;
3060
3061      if (points.length > 1 && !IS_NODE) {
3062        if (!TEMP_CANVAS) {
3063          TEMP_CANVAS = Canvas.createCanvas(1, 1);
3064        }
3065
3066        ctx.canvas._drawn = false;
3067        TEMP_CANVAS.width = ctx.canvas.width;
3068        TEMP_CANVAS.height = ctx.canvas.height;
3069        ctx = TEMP_CANVAS.getContext('2d');
3070        copyProperties(ctx, savedCtx);
3071      }
3072
3073      var op, i, len;
3074
3075      if (fillFirst) {
3076        ctx.save();
3077
3078        for (i = 0, len = points.length; i < len; i++) {
3079          if (!isArrayHasData(points[i])) {
3080            continue;
3081          }
3082
3083          Canvas._ring(ctx, points[i], null, 0, true);
3084
3085          op = fillOpacity;
3086
3087          if (i > 0) {
3088            ctx.globalCompositeOperation = 'destination-out';
3089            op = 1;
3090          }
3091
3092          Canvas.fillCanvas(ctx, op, points[i][0].x, points[i][0].y);
3093
3094          if (i > 0) {
3095            ctx.globalCompositeOperation = 'source-over';
3096          } else if (len > 1) {
3097            ctx.fillStyle = '#fff';
3098          }
3099
3100          Canvas._stroke(ctx, 0);
3101        }
3102
3103        ctx.restore();
3104      }
3105
3106      for (i = 0, len = points.length; i < len; i++) {
3107        if (!isArrayHasData(points[i])) {
3108          continue;
3109        }
3110
3111        if (smoothness) {
3112          Canvas.paintSmoothLine(ctx, points[i], lineOpacity, smoothness, true);
3113          ctx.closePath();
3114        } else {
3115          Canvas._ring(ctx, points[i], lineDashArray, lineOpacity);
3116        }
3117
3118        if (!fillFirst) {
3119          op = fillOpacity;
3120
3121          if (i > 0) {
3122            ctx.globalCompositeOperation = 'destination-out';
3123            op = 1;
3124          }
3125
3126          Canvas.fillCanvas(ctx, op, points[i][0].x, points[i][0].y);
3127
3128          if (i > 0) {
3129            ctx.globalCompositeOperation = 'source-over';
3130          } else if (len > 1) {
3131            ctx.fillStyle = '#fff';
3132          }
3133        }
3134
3135        Canvas._stroke(ctx, lineOpacity);
3136      }
3137
3138      if (points.length > 1 && !IS_NODE) {
3139        savedCtx.drawImage(TEMP_CANVAS, 0, 0);
3140        savedCtx.canvas._drawn = ctx.canvas._drawn;
3141        copyProperties(savedCtx, ctx);
3142      }
3143    },
3144    _ring: function _ring(ctx, ring, lineDashArray, lineOpacity, ignorePattern) {
3145      var isPattern = Canvas._isPattern(ctx.strokeStyle);
3146
3147      if (!ignorePattern && isPattern && !ring[0].equals(ring[ring.length - 1])) {
3148        ring = ring.concat([ring[0]]);
3149      }
3150
3151      ctx.beginPath();
3152      ctx.moveTo(ring[0].x, ring[0].y);
3153
3154      Canvas._path(ctx, ring, lineDashArray, lineOpacity, ignorePattern);
3155
3156      if (!isPattern) {
3157        ctx.closePath();
3158      }
3159    },
3160    paintSmoothLine: function paintSmoothLine(ctx, points, lineOpacity, smoothValue, close, tailIdx, tailRatio) {
3161      if (!points) {
3162        return;
3163      }
3164
3165      if (points.length <= 2 || !smoothValue) {
3166        Canvas.path(ctx, points, lineOpacity);
3167        return;
3168      }
3169
3170      function interpolate$$1(t0, t1, x1, y1, bx1, by1, bx2, by2, x2, y2) {
3171        var u0 = 1.0 - t0;
3172        var u1 = 1.0 - t1;
3173        var qxa = x1 * u0 * u0 + bx1 * 2 * t0 * u0 + bx2 * t0 * t0;
3174        var qxb = x1 * u1 * u1 + bx1 * 2 * t1 * u1 + bx2 * t1 * t1;
3175        var qxc = bx1 * u0 * u0 + bx2 * 2 * t0 * u0 + x2 * t0 * t0;
3176        var qxd = bx1 * u1 * u1 + bx2 * 2 * t1 * u1 + x2 * t1 * t1;
3177        var qya = y1 * u0 * u0 + by1 * 2 * t0 * u0 + by2 * t0 * t0;
3178        var qyb = y1 * u1 * u1 + by1 * 2 * t1 * u1 + by2 * t1 * t1;
3179        var qyc = by1 * u0 * u0 + by2 * 2 * t0 * u0 + y2 * t0 * t0;
3180        var qyd = by1 * u1 * u1 + by2 * 2 * t1 * u1 + y2 * t1 * t1;
3181        var xb = qxa * u1 + qxc * t1;
3182        var xc = qxb * u0 + qxd * t0;
3183        var xd = qxb * u1 + qxd * t1;
3184        var yb = qya * u1 + qyc * t1;
3185        var yc = qyb * u0 + qyd * t0;
3186        var yd = qyb * u1 + qyd * t1;
3187        return [xb, yb, xc, yc, xd, yd];
3188      }
3189
3190      function getCubicControlPoints(x0, y0, x1, y1, x2, y2, x3, y3, smoothValue, t) {
3191        var xc1 = (x0 + x1) / 2.0,
3192            yc1 = (y0 + y1) / 2.0;
3193        var xc2 = (x1 + x2) / 2.0,
3194            yc2 = (y1 + y2) / 2.0;
3195        var xc3 = (x2 + x3) / 2.0,
3196            yc3 = (y2 + y3) / 2.0;
3197        var len1 = Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
3198        var len2 = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
3199        var len3 = Math.sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
3200        var k1 = len1 / (len1 + len2);
3201        var k2 = len2 / (len2 + len3);
3202        var xm1 = xc1 + (xc2 - xc1) * k1,
3203            ym1 = yc1 + (yc2 - yc1) * k1;
3204        var xm2 = xc2 + (xc3 - xc2) * k2,
3205            ym2 = yc2 + (yc3 - yc2) * k2;
3206        var ctrl1X = xm1 + (xc2 - xm1) * smoothValue + x1 - xm1,
3207            ctrl1Y = ym1 + (yc2 - ym1) * smoothValue + y1 - ym1,
3208            ctrl2X = xm2 + (xc2 - xm2) * smoothValue + x2 - xm2,
3209            ctrl2Y = ym2 + (yc2 - ym2) * smoothValue + y2 - ym2;
3210        var ctrlPoints = [ctrl1X, ctrl1Y, ctrl2X, ctrl2Y];
3211
3212        if (t < 1) {
3213          return interpolate$$1(0, t, x1, y1, ctrl1X, ctrl1Y, ctrl2X, ctrl2Y, x2, y2);
3214        } else {
3215          return ctrlPoints;
3216        }
3217      }
3218
3219      var count = points.length;
3220      var l = close ? count : count - 1;
3221      ctx.beginPath();
3222      ctx.moveTo(points[0].x, points[0].y);
3223      if (tailRatio !== undefined) l -= Math.max(l - tailIdx - 1, 0);
3224      var preCtrlPoints;
3225
3226      for (var i = 0; i < l; i++) {
3227        var x1 = points[i].x,
3228            y1 = points[i].y;
3229        var x0 = void 0,
3230            y0 = void 0,
3231            x2 = void 0,
3232            y2 = void 0,
3233            x3 = void 0,
3234            y3 = void 0;
3235
3236        if (i - 1 < 0) {
3237          if (!close) {
3238            x0 = points[i + 1].x;
3239            y0 = points[i + 1].y;
3240          } else {
3241            x0 = points[l - 1].x;
3242            y0 = points[l - 1].y;
3243          }
3244        } else {
3245          x0 = points[i - 1].x;
3246          y0 = points[i - 1].y;
3247        }
3248
3249        if (i + 1 < count) {
3250          x2 = points[i + 1].x;
3251          y2 = points[i + 1].y;
3252        } else {
3253          x2 = points[i + 1 - count].x;
3254          y2 = points[i + 1 - count].y;
3255        }
3256
3257        if (i + 2 < count) {
3258          x3 = points[i + 2].x;
3259          y3 = points[i + 2].y;
3260        } else if (!close) {
3261          x3 = points[i].x;
3262          y3 = points[i].y;
3263        } else {
3264          x3 = points[i + 2 - count].x;
3265          y3 = points[i + 2 - count].y;
3266        }
3267
3268        var ctrlPoints = getCubicControlPoints(x0, y0, x1, y1, x2, y2, x3, y3, smoothValue, i === l - 1 ? tailRatio : 1);
3269
3270        if (i === l - 1 && tailRatio >= 0 && tailRatio < 1) {
3271          ctx.bezierCurveTo(ctrlPoints[0], ctrlPoints[1], ctrlPoints[2], ctrlPoints[3], ctrlPoints[4], ctrlPoints[5]);
3272          points.splice(l - 1, count - (l - 1) - 1);
3273          var lastPoint = new Point(ctrlPoints[4], ctrlPoints[5]);
3274          lastPoint.prevCtrlPoint = new Point(ctrlPoints[2], ctrlPoints[3]);
3275          points.push(lastPoint);
3276          count = points.length;
3277        } else {
3278          ctx.bezierCurveTo(ctrlPoints[0], ctrlPoints[1], ctrlPoints[2], ctrlPoints[3], x2, y2);
3279        }
3280
3281        points[i].nextCtrlPoint = ctrlPoints.slice(0, 2);
3282        points[i].prevCtrlPoint = preCtrlPoints ? preCtrlPoints.slice(2) : null;
3283        preCtrlPoints = ctrlPoints;
3284      }
3285
3286      if (!close && points[1].prevCtrlPoint) {
3287        points[0].nextCtrlPoint = points[1].prevCtrlPoint;
3288        delete points[0].prevCtrlPoint;
3289      }
3290
3291      if (!points[count - 1].prevCtrlPoint) {
3292        points[count - 1].prevCtrlPoint = points[count - 2].nextCtrlPoint;
3293      }
3294
3295      Canvas._stroke(ctx, lineOpacity);
3296    },
3297    _arcBetween: function _arcBetween(ctx, p1, p2, degree) {
3298      var a = degree,
3299          dist = p1.distanceTo(p2),
3300          r = dist / 2 / Math.sin(a / 2);
3301      var p1p2 = Math.asin((p2.y - p1.y) / dist);
3302
3303      if (p1.x > p2.x) {
3304        p1p2 = Math.PI - p1p2;
3305      }
3306
3307      var cp2 = 90 * Math.PI / 180 - a / 2,
3308          da = p1p2 - cp2;
3309      var dx = Math.cos(da) * r,
3310          dy = Math.sin(da) * r,
3311          cx = p1.x + dx,
3312          cy = p1.y + dy;
3313      var startAngle = Math.asin((p2.y - cy) / r);
3314
3315      if (cx > p2.x) {
3316        startAngle = Math.PI - startAngle;
3317      }
3318
3319      var endAngle = startAngle + a;
3320      ctx.beginPath();
3321      ctx.arc(cx, cy, r, startAngle, endAngle);
3322      return [cx, cy];
3323    },
3324    _lineTo: function _lineTo(ctx, p) {
3325      ctx.lineTo(p.x, p.y);
3326    },
3327    bezierCurveAndFill: function bezierCurveAndFill(ctx, points, lineOpacity, fillOpacity) {
3328      ctx.beginPath();
3329      var start = points[0];
3330      ctx.moveTo(start.x, start.y);
3331      var args = [ctx];
3332      args.push.apply(args, points.splice(1));
3333
3334      Canvas._bezierCurveTo.apply(Canvas, args);
3335
3336      Canvas.fillCanvas(ctx, fillOpacity);
3337
3338      Canvas._stroke(ctx, lineOpacity);
3339    },
3340    _bezierCurveTo: function _bezierCurveTo(ctx, p1, p2, p3) {
3341      ctx.bezierCurveTo(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);
3342    },
3343    ellipse: function ellipse(ctx, pt, width, height, lineOpacity, fillOpacity) {
3344      function bezierEllipse(x, y, a, b) {
3345        var k = 0.5522848,
3346            ox = a * k,
3347            oy = b * k;
3348        ctx.moveTo(x - a, y);
3349        ctx.bezierCurveTo(x - a, y - oy, x - ox, y - b, x, y - b);
3350        ctx.bezierCurveTo(x + ox, y - b, x + a, y - oy, x + a, y);
3351        ctx.bezierCurveTo(x + a, y + oy, x + ox, y + b, x, y + b);
3352        ctx.bezierCurveTo(x - ox, y + b, x - a, y + oy, x - a, y);
3353        ctx.closePath();
3354      }
3355
3356      ctx.beginPath();
3357
3358      if (width === height) {
3359        ctx.arc(pt.x, pt.y, width, 0, 2 * Math.PI);
3360      } else if (ctx.ellipse) {
3361        ctx.ellipse(pt.x, pt.y, width, height, 0, 0, Math.PI / 180 * 360);
3362      } else {
3363        bezierEllipse(pt.x, pt.y, width, height);
3364      }
3365
3366      Canvas.fillCanvas(ctx, fillOpacity, pt.x - width, pt.y - height);
3367
3368      Canvas._stroke(ctx, lineOpacity, pt.x - width, pt.y - height);
3369    },
3370    rectangle: function rectangle(ctx, pt, size, lineOpacity, fillOpacity) {
3371      var x = pt.x,
3372          y = pt.y;
3373      ctx.beginPath();
3374      ctx.rect(x, y, size['width'], size['height']);
3375      Canvas.fillCanvas(ctx, fillOpacity, x, y);
3376
3377      Canvas._stroke(ctx, lineOpacity, x, y);
3378    },
3379    sector: function sector(ctx, pt, size, angles, lineOpacity, fillOpacity) {
3380      var rad = Math.PI / 180;
3381      var startAngle = angles[0],
3382          endAngle = angles[1];
3383
3384      function sector(ctx, x, y, radius, startAngle, endAngle) {
3385        var sDeg = rad * -endAngle;
3386        var eDeg = rad * -startAngle;
3387        ctx.beginPath();
3388        ctx.moveTo(x, y);
3389        ctx.arc(x, y, radius, sDeg, eDeg);
3390        ctx.lineTo(x, y);
3391        Canvas.fillCanvas(ctx, fillOpacity, x - radius, y - radius);
3392
3393        Canvas._stroke(ctx, lineOpacity, x - radius, y - radius);
3394      }
3395
3396      sector(ctx, pt.x, pt.y, size, startAngle, endAngle);
3397    },
3398    _isPattern: function _isPattern(style) {
3399      return !isString(style) && !('addColorStop' in style);
3400    },
3401    drawCross: function drawCross(ctx, x, y, lineWidth, color) {
3402      ctx.canvas._drawn = true;
3403      ctx.strokeStyle = color;
3404      ctx.lineWidth = lineWidth;
3405      ctx.beginPath();
3406      ctx.moveTo(x - 5, y);
3407      ctx.lineTo(x + 5, y);
3408      ctx.moveTo(x, y - 5);
3409      ctx.lineTo(x, y + 5);
3410      ctx.stroke();
3411    },
3412    copy: function copy(canvas, c) {
3413      var target = c || createEl('canvas');
3414      target.width = canvas.width;
3415      target.height = canvas.height;
3416      target.getContext('2d').drawImage(canvas, 0, 0);
3417      return target;
3418    }
3419  };
3420
3421  function drawDashLine(ctx, startPoint, endPoint, dashArray) {
3422    var fromX = startPoint.x,
3423        fromY = startPoint.y,
3424        toX = endPoint.x,
3425        toY = endPoint.y;
3426    var pattern = dashArray;
3427
3428    var lt = function lt(a, b) {
3429      return a <= b;
3430    };
3431
3432    var gt = function gt(a, b) {
3433      return a >= b;
3434    };
3435
3436    var capmin = function capmin(a, b) {
3437      return Math.min(a, b);
3438    };
3439
3440    var capmax = function capmax(a, b) {
3441      return Math.max(a, b);
3442    };
3443
3444    var checkX = {
3445      thereYet: gt,
3446      cap: capmin
3447    };
3448    var checkY = {
3449      thereYet: gt,
3450      cap: capmin
3451    };
3452
3453    if (fromY - toY > 0) {
3454      checkY.thereYet = lt;
3455      checkY.cap = capmax;
3456    }
3457
3458    if (fromX - toX > 0) {
3459      checkX.thereYet = lt;
3460      checkX.cap = capmax;
3461    }
3462
3463    ctx.moveTo(fromX, fromY);
3464    var offsetX = fromX;
3465    var offsetY = fromY;
3466    var idx = 0,
3467        dash = true;
3468    var ang, len;
3469
3470    while (!(checkX.thereYet(offsetX, toX) && checkY.thereYet(offsetY, toY))) {
3471      ang = Math.atan2(toY - fromY, toX - fromX);
3472      len = pattern[idx];
3473      offsetX = checkX.cap(toX, offsetX + Math.cos(ang) * len);
3474      offsetY = checkY.cap(toY, offsetY + Math.sin(ang) * len);
3475
3476      if (dash) {
3477        ctx.lineTo(offsetX, offsetY);
3478      } else {
3479        ctx.moveTo(offsetX, offsetY);
3480      }
3481
3482      idx = (idx + 1) % pattern.length;
3483      dash = !dash;
3484    }
3485  }
3486
3487  var prefix = 'data:image/';
3488
3489  function isImageUrl(url) {
3490    return url.length > prefix.length && url.substring(0, prefix.length) === prefix || isCssUrl(url);
3491  }
3492
3493  function extractImageUrl(url) {
3494    if (url.substring(0, prefix.length) === prefix) {
3495      return url;
3496    }
3497
3498    return extractCssUrl(url);
3499  }
3500
3501  function copyProperties(ctx, savedCtx) {
3502    ctx.filter = savedCtx.filter;
3503    ctx.fillStyle = savedCtx.fillStyle;
3504    ctx.globalAlpha = savedCtx.globalAlpha;
3505    ctx.lineCap = savedCtx.lineCap;
3506    ctx.lineDashOffset = savedCtx.lineDashOffset;
3507    ctx.lineJoin = savedCtx.lineJoin;
3508    ctx.lineWidth = savedCtx.lineWidth;
3509    ctx.shadowBlur = savedCtx.shadowBlur;
3510    ctx.shadowColor = savedCtx.shadowColor;
3511    ctx.shadowOffsetX = savedCtx.shadowOffsetX;
3512    ctx.shadowOffsetY = savedCtx.shadowOffsetY;
3513    ctx.strokeStyle = savedCtx.strokeStyle;
3514  }
3515
3516  var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3517
3518  function createCommonjsModule(fn, module) {
3519  	return module = { exports: {} }, fn(module, module.exports), module.exports;
3520  }
3521
3522  var zousanMin = createCommonjsModule(function (module) {
3523    !function (t) {
3524
3525      function e(t) {
3526        if (t) {
3527          var e = this;
3528          t(function (t) {
3529            e.resolve(t);
3530          }, function (t) {
3531            e.reject(t);
3532          });
3533        }
3534      }
3535
3536      function n(t, e) {
3537        if ("function" == typeof t.y) try {
3538          var n = t.y.call(i, e);
3539          t.p.resolve(n);
3540        } catch (o) {
3541          t.p.reject(o);
3542        } else t.p.resolve(e);
3543      }
3544
3545      function o(t, e) {
3546        if ("function" == typeof t.n) try {
3547          var n = t.n.call(i, e);
3548          t.p.resolve(n);
3549        } catch (o) {
3550          t.p.reject(o);
3551        } else t.p.reject(e);
3552      }
3553
3554      var r,
3555          i,
3556          c = "fulfilled",
3557          u = "rejected",
3558          s = "undefined",
3559          f = function () {
3560        function e() {
3561          for (; n.length - o;) {
3562            try {
3563              n[o]();
3564            } catch (e) {
3565              t.console && t.console.error(e);
3566            }
3567
3568            n[o++] = i, o == r && (n.splice(0, r), o = 0);
3569          }
3570        }
3571
3572        var n = [],
3573            o = 0,
3574            r = 1024,
3575            c = function () {
3576          if (typeof MutationObserver !== s) {
3577            var t = document.createElement("div"),
3578                n = new MutationObserver(e);
3579            return n.observe(t, {
3580              attributes: !0
3581            }), function () {
3582              t.setAttribute("a", 0);
3583            };
3584          }
3585
3586          return typeof setImmediate !== s ? function () {
3587            setImmediate(e);
3588          } : function () {
3589            setTimeout(e, 0);
3590          };
3591        }();
3592
3593        return function (t) {
3594          n.push(t), n.length - o == 1 && c();
3595        };
3596      }();
3597
3598      e.prototype = {
3599        resolve: function resolve(t) {
3600          if (this.state === r) {
3601            if (t === this) return this.reject(new TypeError("Attempt to resolve promise with self"));
3602            var e = this;
3603            if (t && ("function" == typeof t || "object" == typeof t)) try {
3604              var o = !0,
3605                  i = t.then;
3606              if ("function" == typeof i) return void i.call(t, function (t) {
3607                o && (o = !1, e.resolve(t));
3608              }, function (t) {
3609                o && (o = !1, e.reject(t));
3610              });
3611            } catch (u) {
3612              return void (o && this.reject(u));
3613            }
3614            this.state = c, this.v = t, e.c && f(function () {
3615              for (var o = 0, r = e.c.length; r > o; o++) {
3616                n(e.c[o], t);
3617              }
3618            });
3619          }
3620        },
3621        reject: function reject(n) {
3622          if (this.state === r) {
3623            this.state = u, this.v = n;
3624            var i = this.c;
3625            i ? f(function () {
3626              for (var t = 0, e = i.length; e > t; t++) {
3627                o(i[t], n);
3628              }
3629            }) : !e.suppressUncaughtRejectionError && t.console && t.console.log("You upset Zousan. Please catch rejections: ", n, n ? n.stack : null);
3630          }
3631        },
3632        then: function then(t, i) {
3633          var u = new e(),
3634              s = {
3635            y: t,
3636            n: i,
3637            p: u
3638          };
3639          if (this.state === r) this.c ? this.c.push(s) : this.c = [s];else {
3640            var l = this.state,
3641                a = this.v;
3642            f(function () {
3643              l === c ? n(s, a) : o(s, a);
3644            });
3645          }
3646          return u;
3647        },
3648        "catch": function _catch(t) {
3649          return this.then(null, t);
3650        },
3651        "finally": function _finally(t) {
3652          return this.then(t, t);
3653        },
3654        timeout: function timeout(t, n) {
3655          n = n || "Timeout";
3656          var o = this;
3657          return new e(function (e, r) {
3658            setTimeout(function () {
3659              r(Error(n));
3660            }, t), o.then(function (t) {
3661              e(t);
3662            }, function (t) {
3663              r(t);
3664            });
3665          });
3666        }
3667      }, e.resolve = function (t) {
3668        var n = new e();
3669        return n.resolve(t), n;
3670      }, e.reject = function (t) {
3671        var n = new e();
3672        return n.reject(t), n;
3673      }, e.all = function (t) {
3674        function n(n, c) {
3675          n && "function" == typeof n.then || (n = e.resolve(n)), n.then(function (e) {
3676            o[c] = e, r++, r == t.length && i.resolve(o);
3677          }, function (t) {
3678            i.reject(t);
3679          });
3680        }
3681
3682        for (var o = [], r = 0, i = new e(), c = 0; c < t.length; c++) {
3683          n(t[c], c);
3684        }
3685
3686        return t.length || i.resolve(o), i;
3687      }, module.exports && (module.exports = e), t.define && t.define.amd && t.define([], function () {
3688        return e;
3689      }), t.Zousan = e, e.soon = f;
3690    }("undefined" != typeof commonjsGlobal ? commonjsGlobal : commonjsGlobal);
3691  });
3692
3693  var promise;
3694
3695  if (typeof Promise !== 'undefined') {
3696    promise = Promise;
3697  } else {
3698    promise = zousanMin;
3699  }
3700
3701  var Promise$1 = promise;
3702
3703  var Eventable = function Eventable(Base) {
3704    return function (_Base) {
3705      _inheritsLoose(_class, _Base);
3706
3707      function _class() {
3708        return _Base.apply(this, arguments) || this;
3709      }
3710
3711      var _proto = _class.prototype;
3712
3713      _proto.on = function on$$1(eventsOn, handler, context) {
3714        if (!eventsOn) {
3715          return this;
3716        }
3717
3718        if (!isString(eventsOn)) {
3719          return this._switch('on', eventsOn, handler);
3720        }
3721
3722        if (!handler) {
3723          return this;
3724        }
3725
3726        if (!this._eventMap) {
3727          this._eventMap = {};
3728        }
3729
3730        var eventTypes = eventsOn.toLowerCase().split(' ');
3731        var evtType;
3732
3733        if (!context) {
3734          context = this;
3735        }
3736
3737        var handlerChain;
3738
3739        for (var ii = 0, ll = eventTypes.length; ii < ll; ii++) {
3740          evtType = eventTypes[ii];
3741          handlerChain = this._eventMap[evtType];
3742
3743          if (!handlerChain) {
3744            handlerChain = [];
3745            this._eventMap[evtType] = handlerChain;
3746          }
3747
3748          var l = handlerChain.length;
3749
3750          if (l > 0) {
3751            for (var i = 0; i < l; i++) {
3752              if (handler === handlerChain[i].handler && handlerChain[i].context === context) {
3753                return this;
3754              }
3755            }
3756          }
3757
3758          handlerChain.push({
3759            handler: handler,
3760            context: context
3761          });
3762        }
3763
3764        return this;
3765      };
3766
3767      _proto.addEventListener = function addEventListener() {
3768        return this.on.apply(this, arguments);
3769      };
3770
3771      _proto.once = function once(eventTypes, handler, context) {
3772        if (!isString(eventTypes)) {
3773          var once = {};
3774
3775          for (var p in eventTypes) {
3776            if (eventTypes.hasOwnProperty(p)) {
3777              once[p] = this._wrapOnceHandler(p, eventTypes[p], context);
3778            }
3779          }
3780
3781          return this._switch('on', once);
3782        }
3783
3784        var evetTypes = eventTypes.split(' ');
3785
3786        for (var i = 0, l = evetTypes.length; i < l; i++) {
3787          this.on(evetTypes[i], this._wrapOnceHandler(evetTypes[i], handler, context));
3788        }
3789
3790        return this;
3791      };
3792
3793      _proto.off = function off$$1(eventsOff, handler, context) {
3794        if (!this._eventMap || !eventsOff) {
3795          return this;
3796        }
3797
3798        if (!isString(eventsOff)) {
3799          return this._switch('off', eventsOff, handler);
3800        }
3801
3802        if (!handler) {
3803          return this;
3804        }
3805
3806        var eventTypes = eventsOff.split(' ');
3807        var eventType, listeners, wrapKey;
3808
3809        if (!context) {
3810          context = this;
3811        }
3812
3813        for (var j = 0, jl = eventTypes.length; j < jl; j++) {
3814          eventType = eventTypes[j].toLowerCase();
3815          wrapKey = 'Z__' + eventType;
3816          listeners = this._eventMap[eventType];
3817
3818          if (!listeners) {
3819            return this;
3820          }
3821
3822          for (var i = listeners.length - 1; i >= 0; i--) {
3823            var listener = listeners[i];
3824
3825            if ((handler === listener.handler || handler === listener.handler[wrapKey]) && listener.context === context) {
3826              delete listener.handler[wrapKey];
3827              listeners.splice(i, 1);
3828            }
3829          }
3830
3831          if (!listeners.length) {
3832            delete this._eventMap[eventType];
3833          }
3834        }
3835
3836        return this;
3837      };
3838
3839      _proto.removeEventListener = function removeEventListener() {
3840        return this.off.apply(this, arguments);
3841      };
3842
3843      _proto.listens = function listens(eventType, handler, context) {
3844        if (!this._eventMap || !isString(eventType)) {
3845          return 0;
3846        }
3847
3848        var handlerChain = this._eventMap[eventType.toLowerCase()];
3849
3850        if (!handlerChain || !handlerChain.length) {
3851          return 0;
3852        }
3853
3854        if (!handler) {
3855          return handlerChain.length;
3856        }
3857
3858        for (var i = 0, len = handlerChain.length; i < len; i++) {
3859          if (handler === handlerChain[i].handler && (isNil(context) || handlerChain[i].context === context)) {
3860            return 1;
3861          }
3862        }
3863
3864        return 0;
3865      };
3866
3867      _proto.getListeningEvents = function getListeningEvents() {
3868        if (!this._eventMap) {
3869          return [];
3870        }
3871
3872        return Object.keys(this._eventMap);
3873      };
3874
3875      _proto.copyEventListeners = function copyEventListeners(target) {
3876        var eventMap = target._eventMap;
3877
3878        if (!eventMap) {
3879          return this;
3880        }
3881
3882        var handlerChain;
3883
3884        for (var eventType in eventMap) {
3885          handlerChain = eventMap[eventType];
3886
3887          for (var i = 0, len = handlerChain.length; i < len; i++) {
3888            this.on(eventType, handlerChain[i].handler, handlerChain[i].context);
3889          }
3890        }
3891
3892        return this;
3893      };
3894
3895      _proto.fire = function fire() {
3896        if (this._eventParent) {
3897          return this._eventParent.fire.apply(this._eventParent, arguments);
3898        }
3899
3900        return this._fire.apply(this, arguments);
3901      };
3902
3903      _proto._wrapOnceHandler = function _wrapOnceHandler(evtType, handler, context) {
3904        var me = this;
3905        var key = 'Z__' + evtType;
3906        var called = false;
vendor: 27,126 bytes, lines 3907-4980
3907
3908        var fn = function onceHandler() {
3909          if (called) {
3910            return;
3911          }
3912
3913          delete fn[key];
3914          called = true;
3915
3916          if (context) {
3917            handler.apply(context, arguments);
3918          } else {
3919            handler.apply(this, arguments);
3920          }
3921
3922          me.off(evtType, onceHandler, this);
3923        };
3924
3925        fn[key] = handler;
3926        return fn;
3927      };
3928
3929      _proto._switch = function _switch(to, eventKeys, context) {
3930        for (var p in eventKeys) {
3931          if (eventKeys.hasOwnProperty(p)) {
3932            this[to](p, eventKeys[p], context);
3933          }
3934        }
3935
3936        return this;
3937      };
3938
3939      _proto._clearListeners = function _clearListeners(eventType) {
3940        if (!this._eventMap || !isString(eventType)) {
3941          return;
3942        }
3943
3944        var handlerChain = this._eventMap[eventType.toLowerCase()];
3945
3946        if (!handlerChain) {
3947          return;
3948        }
3949
3950        this._eventMap[eventType] = null;
3951      };
3952
3953      _proto._clearAllListeners = function _clearAllListeners() {
3954        this._eventMap = null;
3955      };
3956
3957      _proto._setEventParent = function _setEventParent(parent) {
3958        this._eventParent = parent;
3959        return this;
3960      };
3961
3962      _proto._fire = function _fire(eventType, param) {
3963        if (!this._eventMap) {
3964          return this;
3965        }
3966
3967        var handlerChain = this._eventMap[eventType.toLowerCase()];
3968
3969        if (!handlerChain) {
3970          return this;
3971        }
3972
3973        if (!param) {
3974          param = {};
3975        }
3976
3977        param['type'] = eventType;
3978        param['target'] = this;
3979        var queue = handlerChain.slice(0);
3980        var context, bubble, passed;
3981
3982        for (var i = 0, len = queue.length; i < len; i++) {
3983          if (!queue[i]) {
3984            continue;
3985          }
3986
3987          context = queue[i].context;
3988          bubble = true;
3989          passed = extend({}, param);
3990
3991          if (context) {
3992            bubble = queue[i].handler.call(context, passed);
3993          } else {
3994            bubble = queue[i].handler(passed);
3995          }
3996
3997          if (bubble === false) {
3998            if (param['domEvent']) {
3999              stopPropagation(param['domEvent']);
4000            }
4001          }
4002        }
4003
4004        return this;
4005      };
4006
4007      return _class;
4008    }(Base);
4009  };
4010
4011  var Handler = function () {
4012    function Handler(target) {
4013      this.target = target;
4014    }
4015
4016    var _proto = Handler.prototype;
4017
4018    _proto.enable = function enable() {
4019      if (this._enabled) {
4020        return this;
4021      }
4022
4023      this._enabled = true;
4024      this.addHooks();
4025      return this;
4026    };
4027
4028    _proto.disable = function disable() {
4029      if (!this._enabled) {
4030        return this;
4031      }
4032
4033      this._enabled = false;
4034      this.removeHooks();
4035      return this;
4036    };
4037
4038    _proto.enabled = function enabled() {
4039      return !!this._enabled;
4040    };
4041
4042    _proto.remove = function remove() {
4043      this.disable();
4044      delete this.target;
4045      delete this.dom;
4046    };
4047
4048    return Handler;
4049  }();
4050
4051  var Handler$1 = Eventable(Handler);
4052
4053  var Class = function () {
4054    function Class(options) {
4055      if (!this || !this.setOptions) {
4056        throw new Error('Class instance is being created without "new" operator.');
4057      }
4058
4059      this.setOptions(options);
4060      this.callInitHooks();
4061    }
4062
4063    var _proto = Class.prototype;
4064
4065    _proto.callInitHooks = function callInitHooks() {
4066      var proto = Object.getPrototypeOf(this);
4067
4068      this._visitInitHooks(proto);
4069
4070      return this;
4071    };
4072
4073    _proto.setOptions = function setOptions(options) {
4074      if (!this.hasOwnProperty('options')) {
4075        this.options = this.options ? Object.create(this.options) : {};
4076      }
4077
4078      if (!options) {
4079        return this;
4080      }
4081
4082      for (var i in options) {
4083        this.options[i] = options[i];
4084      }
4085
4086      return this;
4087    };
4088
4089    _proto.config = function config(conf) {
4090      if (!conf) {
4091        var config = {};
4092
4093        for (var p in this.options) {
4094          if (this.options.hasOwnProperty(p)) {
4095            config[p] = this.options[p];
4096          }
4097        }
4098
4099        return config;
4100      } else {
4101        if (arguments.length === 2) {
4102          var t = {};
4103          t[conf] = arguments[1];
4104          conf = t;
4105        }
4106
4107        for (var i in conf) {
4108          this.options[i] = conf[i];
4109
4110          if (this[i] && this[i] instanceof Handler$1) {
4111            if (conf[i]) {
4112              this[i].enable();
4113            } else {
4114              this[i].disable();
4115            }
4116          }
4117        }
4118
4119        this.onConfig(conf);
4120      }
4121
4122      return this;
4123    };
4124
4125    _proto.onConfig = function onConfig() {};
4126
4127    _proto._visitInitHooks = function _visitInitHooks(proto) {
4128      if (this._initHooksCalled) {
4129        return;
4130      }
4131
4132      var parentProto = Object.getPrototypeOf(proto);
4133
4134      if (parentProto._visitInitHooks) {
4135        parentProto._visitInitHooks.call(this, parentProto);
4136      }
4137
4138      this._initHooksCalled = true;
4139      var hooks = proto._initHooks;
4140
4141      if (hooks && hooks !== parentProto._initHooks) {
4142        for (var i = 0; i < hooks.length; i++) {
4143          hooks[i].call(this);
4144        }
4145      }
4146    };
4147
4148    Class.addInitHook = function addInitHook(fn) {
4149      for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
4150        args[_key - 1] = arguments[_key];
4151      }
4152
4153      var init = typeof fn === 'function' ? fn : function () {
4154        this[fn].apply(this, args);
4155      };
4156      var proto = this.prototype;
4157      var parentProto = Object.getPrototypeOf(proto);
4158
4159      if (!proto._initHooks || proto._initHooks === parentProto._initHooks) {
4160        proto._initHooks = [];
4161      }
4162
4163      proto._initHooks.push(init);
4164
4165      return this;
4166    };
4167
4168    Class.include = function include() {
4169      for (var i = 0; i < arguments.length; i++) {
4170        extend(this.prototype, i < 0 || arguments.length <= i ? undefined : arguments[i]);
4171      }
4172
4173      return this;
4174    };
4175
4176    Class.mergeOptions = function mergeOptions(options) {
4177      var proto = this.prototype;
4178      var parentProto = Object.getPrototypeOf(proto);
4179
4180      if (!proto.options || proto.options === parentProto.options) {
4181        proto.options = proto.options ? Object.create(proto.options) : {};
4182      }
4183
4184      extend(proto.options, options);
4185      return this;
4186    };
4187
4188    return Class;
4189  }();
4190
4191  var registeredTypes = {};
4192  var JSONAble = (function (Base) {
4193    return function (_Base) {
4194      _inheritsLoose(_class, _Base);
4195
4196      function _class() {
4197        return _Base.apply(this, arguments) || this;
4198      }
4199
4200      _class.registerJSONType = function registerJSONType(type) {
4201        if (!type) {
4202          return this;
4203        }
4204
4205        registeredTypes[type] = this;
4206        return this;
4207      };
4208
4209      _class.getJSONClass = function getJSONClass(type) {
4210        if (!type) {
4211          return null;
4212        }
4213
4214        return registeredTypes[type];
4215      };
4216
4217      var _proto = _class.prototype;
4218
4219      _proto.getJSONType = function getJSONType() {
4220        if (this._jsonType === undefined) {
4221          var clazz = Object.getPrototypeOf(this).constructor;
4222
4223          for (var p in registeredTypes) {
4224            if (registeredTypes[p] === clazz) {
4225              this._jsonType = p;
4226              break;
4227            }
4228          }
4229        }
4230
4231        if (!this._jsonType) {
4232          throw new Error('Found an unregistered geometry class!');
4233        }
4234
4235        return this._jsonType;
4236      };
4237
4238      return _class;
4239    }(Base);
4240  });
4241
4242  function Handlerable (Base) {
4243    return function (_Base) {
4244      _inheritsLoose(_class, _Base);
4245
4246      function _class() {
4247        return _Base.apply(this, arguments) || this;
4248      }
4249
4250      var _proto = _class.prototype;
4251
4252      _proto.addHandler = function addHandler(name, handlerClass) {
4253        if (!handlerClass) {
4254          return this;
4255        }
4256
4257        if (!this._handlers) {
4258          this._handlers = [];
4259        }
4260
4261        if (this[name]) {
4262          this[name].enable();
4263          return this;
4264        }
4265
4266        var handler = this[name] = new handlerClass(this);
4267
4268        this._handlers.push(handler);
4269
4270        if (this.options[name]) {
4271          handler.enable();
4272        }
4273
4274        return this;
4275      };
4276
4277      _proto.removeHandler = function removeHandler(name) {
4278        if (!name) {
4279          return this;
4280        }
4281
4282        var handler = this[name];
4283
4284        if (handler) {
4285          var hit = this._handlers.indexOf(handler);
4286
4287          if (hit >= 0) {
4288            this._handlers.splice(hit, 1);
4289          }
4290
4291          this[name].remove();
4292          delete this[name];
4293        }
4294
4295        return this;
4296      };
4297
4298      _proto._clearHandlers = function _clearHandlers() {
4299        for (var i = 0, len = this._handlers.length; i < len; i++) {
4300          this._handlers[i].remove();
4301        }
4302
4303        this._handlers = [];
4304      };
4305
4306      return _class;
4307    }(Base);
4308  }
4309
4310  var START_EVENTS = 'touchstart mousedown';
4311  var MOVE_EVENTS = {
4312    mousedown: 'mousemove',
4313    touchstart: 'touchmove',
4314    pointerdown: 'touchmove',
4315    MSPointerDown: 'touchmove'
4316  };
4317  var END_EVENTS = {
4318    mousedown: 'mouseup',
4319    touchstart: 'touchend',
4320    pointerdown: 'touchend',
4321    MSPointerDown: 'touchend'
4322  };
4323
4324  var DragHandler = function (_Handler) {
4325    _inheritsLoose(DragHandler, _Handler);
4326
4327    function DragHandler(dom, options) {
4328      var _this;
4329
4330      if (options === void 0) {
4331        options = {};
4332      }
4333
4334      _this = _Handler.call(this, null) || this;
4335      _this.dom = dom;
4336      _this.options = options;
4337      return _this;
4338    }
4339
4340    var _proto = DragHandler.prototype;
4341
4342    _proto.enable = function enable() {
4343      if (!this.dom) {
4344        return this;
4345      }
4346
4347      this._onMouseDown = function (e) {
4348        return this.onMouseDown(e);
4349      };
4350
4351      on(this.dom, START_EVENTS, this._onMouseDown, this);
4352      return this;
4353    };
4354
4355    _proto.disable = function disable() {
4356      if (!this.dom) {
4357        return this;
4358      }
4359
4360      this._offEvents();
4361
4362      off(this.dom, START_EVENTS, this._onMouseDown);
4363      delete this._onMouseDown;
4364      return this;
4365    };
4366
4367    _proto.onMouseDown = function onMouseDown(event) {
4368      if (!this.options['rightclick'] && event.button === 2) {
4369        return;
4370      }
4371
4372      if (event.touches && event.touches.length > 1) {
4373        return;
4374      }
4375
4376      if (this.options['cancelOn'] && this.options['cancelOn'](event) === true) {
4377        return;
4378      }
4379
4380      var dom = this.dom;
4381
4382      if (dom.setCapture) {
4383        dom.setCapture();
4384      } else if (window.captureEvents) {
4385        window.captureEvents(window['Event'].MOUSEMOVE | window['Event'].MOUSEUP);
4386      }
4387
4388      dom['ondragstart'] = function () {
4389        return false;
4390      };
4391
4392      delete this.moved;
4393      var actual = event.touches ? event.touches[0] : event;
4394      this.startPos = new Point(actual.clientX, actual.clientY);
4395      on(document, MOVE_EVENTS[event.type], this.onMouseMove, this);
4396      on(document, END_EVENTS[event.type], this.onMouseUp, this);
4397
4398      if (!this.options['ignoreMouseleave']) {
4399        on(this.dom, 'mouseleave', this.onMouseUp, this);
4400      }
4401
4402      this.fire('mousedown', {
4403        'domEvent': event,
4404        'mousePos': new Point(actual.clientX, actual.clientY)
4405      });
4406    };
4407
4408    _proto.onMouseMove = function onMouseMove(event) {
4409      if (event.touches && event.touches.length > 1) {
4410        if (this.moved) {
4411          this.interupted = true;
4412          this.onMouseUp(event);
4413        }
4414
4415        return;
4416      }
4417
4418      var actual = event.touches ? event.touches[0] : event;
4419      var newPos = new Point(actual.clientX, actual.clientY),
4420          offset = newPos.sub(this.startPos);
4421
4422      if (!offset.x && !offset.y) {
4423        return;
4424      }
4425
4426      if (!this.moved) {
4427        this.fire('dragstart', {
4428          'domEvent': event,
4429          'mousePos': this.startPos.copy()
4430        });
4431        this.moved = true;
4432      } else {
4433        this.fire('dragging', {
4434          'domEvent': event,
4435          'mousePos': new Point(actual.clientX, actual.clientY)
4436        });
4437      }
4438    };
4439
4440    _proto.onMouseUp = function onMouseUp(event) {
4441      var actual = event.changedTouches ? event.changedTouches[0] : event;
4442
4443      this._offEvents();
4444
4445      var param = {
4446        'domEvent': event
4447      };
4448
4449      if (isNumber(actual.clientX)) {
4450        param['mousePos'] = new Point(parseInt(actual.clientX, 0), parseInt(actual.clientY, 0));
4451      }
4452
4453      if (this.moved) {
4454          param.interupted = this.interupted;
4455          this.fire('dragend', param);
4456          delete this.interupted;
4457          delete this.moved;
4458        }
4459
4460      this.fire('mouseup', param);
4461    };
4462
4463    _proto._offEvents = function _offEvents() {
4464      var dom = this.dom;
4465      off(dom, 'mouseleave', this.onMouseUp, this);
4466
4467      if (typeof document === 'undefined' || typeof window === 'undefined') {
4468        return;
4469      }
4470
4471      for (var i in MOVE_EVENTS) {
4472        off(document, MOVE_EVENTS[i], this.onMouseMove, this);
4473        off(document, END_EVENTS[i], this.onMouseUp, this);
4474      }
4475
4476      if (dom['releaseCapture']) {
4477        dom['releaseCapture']();
4478      } else if (window.captureEvents) {
4479        window.captureEvents(window['Event'].MOUSEMOVE | window['Event'].MOUSEUP);
4480      }
4481    };
4482
4483    return DragHandler;
4484  }(Handler$1);
4485
4486  var Coordinate = function (_Position) {
4487    _inheritsLoose(Coordinate, _Position);
4488
4489    function Coordinate() {
4490      return _Position.apply(this, arguments) || this;
4491    }
4492
4493    Coordinate.toNumberArrays = function toNumberArrays(coordinates) {
4494      if (!Array.isArray(coordinates)) {
4495        return [coordinates.x, coordinates.y];
4496      }
4497
4498      return forEachCoord(coordinates, function (coord) {
4499        return [coord.x, coord.y];
4500      });
4501    };
4502
4503    Coordinate.toCoordinates = function toCoordinates(coordinates) {
4504      if (isNumber(coordinates[0]) && isNumber(coordinates[1])) {
4505        return new Coordinate(coordinates);
4506      }
4507
4508      var result = [];
4509
4510      for (var i = 0, len = coordinates.length; i < len; i++) {
4511        var child = coordinates[i];
4512
4513        if (Array.isArray(child)) {
4514          if (isNumber(child[0])) {
4515            result.push(new Coordinate(child));
4516          } else {
4517            result.push(Coordinate.toCoordinates(child));
4518          }
4519        } else {
4520          result.push(new Coordinate(child));
4521        }
4522      }
4523
4524      return result;
4525    };
4526
4527    return Coordinate;
4528  }(Position);
4529
4530  var CRS = function () {
4531    function CRS(type, properties) {
4532      this.type = type;
4533      this.properties = properties;
4534    }
4535
4536    CRS.createProj4 = function createProj4(proj) {
4537      return new CRS('proj4', {
4538        'proj': proj
4539      });
4540    };
4541
4542    CRS.fromProjectionCode = function fromProjectionCode(code) {
4543      if (!code) {
4544        return null;
4545      }
4546
4547      code = code.toUpperCase().replace(':', '');
4548      return CRS[code] || null;
4549    };
4550
4551    return CRS;
4552  }();
4553
4554  CRS.WGS84 = CRS.createProj4('+proj=longlat +datum=WGS84 +no_defs');
4555  CRS.EPSG4326 = CRS.WGS84;
4556  CRS.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');
4557  CRS.IDENTITY = CRS.createProj4('+proj=identity +no_defs');
4558  CRS.CGCS2000 = CRS.createProj4('+proj=longlat +datum=CGCS2000');
4559  CRS.EPSG4490 = CRS.CGCS2000;
4560  CRS.BD09LL = CRS.createProj4('+proj=longlat +datum=BD09');
4561  CRS.GCJ02 = CRS.createProj4('+proj=longlat +datum=GCJ02');
4562
4563  var TEMP_POINT0 = new Point(0, 0);
4564  var TEMP_COORD0 = new Coordinate(0, 0);
4565  var TEMP_COORD1 = new Coordinate(0, 0);
4566  var TEMP_COORD2 = new Coordinate(0, 0);
4567  var TEMP_COORD3 = new Coordinate(0, 0);
4568  var TEMP_COORD4 = new Coordinate(0, 0);
4569  var TEMP_COORD5 = new Coordinate(0, 0);
4570  var TEMP_COORD6 = new Coordinate(0, 0);
4571  var TEMP_COORD7 = new Coordinate(0, 0);
4572  var MINMAX = [];
4573  var TEMP_EXTENT;
4574  var TEMP_COMBINE = [];
4575
4576  var Extent = function () {
4577    function Extent(p1, p2, p3, p4) {
4578      this._clazz = Coordinate;
4579      var l = arguments.length;
4580      var proj = l > 0 ? arguments[l - 1] : null;
4581
4582      if (proj && proj.unproject) {
4583        this.projection = arguments[l - 1];
4584      }
4585
4586      this._dirty = true;
4587
4588      this._initialize(p1, p2, p3, p4);
4589    }
4590
4591    var _proto = Extent.prototype;
4592
4593    _proto._initialize = function _initialize(p1, p2, p3, p4) {
4594      this.xmin = null;
4595      this.xmax = null;
4596      this.ymin = null;
4597      this.ymax = null;
4598
4599      if (isNil(p1)) {
4600        return;
4601      }
4602
4603      var projection = this.projection;
4604
4605      if (isNumber(p1) && isNumber(p2) && isNumber(p3) && isNumber(p4)) {
4606        if (projection) {
4607          this.set(p1, p2, p3, p4);
4608        } else {
4609          this.set(Math.min(p1, p3), Math.min(p2, p4), Math.max(p1, p3), Math.max(p2, p4));
4610        }
4611
4612        return;
4613      } else if (Array.isArray(p1)) {
4614        if (projection) {
4615          this.set(p1[0], p1[1], p1[2], p1[3]);
4616        } else {
4617          this.set(Math.min(p1[0], p1[2]), Math.min(p1[1], p1[3]), Math.max(p1[0], p1[2]), Math.max(p1[1], p1[3]));
4618        }
4619      } else if (isNumber(p1.x) && isNumber(p2.x) && isNumber(p1.y) && isNumber(p2.y)) {
4620        if (projection) {
4621          this.set(p1.x, p1.y, p2.x, p2.y);
4622        } else {
4623          if (p1.x > p2.x) {
4624            this['xmin'] = p2.x;
4625            this['xmax'] = p1.x;
4626          } else {
4627            this['xmin'] = p1.x;
4628            this['xmax'] = p2.x;
4629          }
4630
4631          if (p1.y > p2.y) {
4632            this['ymin'] = p2.y;
4633            this['ymax'] = p1.y;
4634          } else {
4635            this['ymin'] = p1.y;
4636            this['ymax'] = p2.y;
4637          }
4638        }
4639      } else if (isNumber(p1['xmin']) && isNumber(p1['xmax']) && isNumber(p1['ymin']) && isNumber(p1['ymax'])) {
4640        this.set(p1['xmin'], p1['ymin'], p1['xmax'], p1['ymax']);
4641      }
4642    };
4643
4644    _proto._add = function _add(p) {
4645      this._dirty = true;
4646
4647      if (!isNil(p.x)) {
4648        this['xmin'] += p.x;
4649        this['ymin'] += p.y;
4650        this['xmax'] += p.x;
4651        this['ymax'] += p.y;
4652      } else if (!isNil(p.xmin)) {
4653        this['xmin'] += p.xmin;
4654        this['ymin'] += p.ymin;
4655        this['xmax'] += p.xmax;
4656        this['ymax'] += p.ymax;
4657      } else if (!isNil(p[0])) {
4658        this['xmin'] += p[0];
4659        this['ymin'] += p[1];
4660        this['xmax'] += p[0];
4661        this['ymax'] += p[1];
4662      }
4663
4664      return this;
4665    };
4666
4667    _proto.add = function add() {
4668      var e = new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
4669      return e._add.apply(e, arguments);
4670    };
4671
4672    _proto._scale = function _scale(s) {
4673      this._dirty = true;
4674      this['xmin'] *= s;
4675      this['ymin'] *= s;
4676      this['xmax'] *= s;
4677      this['ymax'] *= s;
4678      return this;
4679    };
4680
4681    _proto._sub = function _sub(p) {
4682      this._dirty = true;
4683
4684      if (!isNil(p.x)) {
4685        this['xmin'] -= p.x;
4686        this['ymin'] -= p.y;
4687        this['xmax'] -= p.x;
4688        this['ymax'] -= p.y;
4689      } else if (!isNil(p.xmin)) {
4690        this['xmin'] -= p.xmin;
4691        this['ymin'] -= p.ymin;
4692        this['xmax'] -= p.xmax;
4693        this['ymax'] -= p.ymax;
4694      } else if (!isNil(p[0])) {
4695        this['xmin'] -= p[0];
4696        this['ymin'] -= p[1];
4697        this['xmax'] -= p[0];
4698        this['ymax'] -= p[1];
4699      }
4700
4701      return this;
4702    };
4703
4704    _proto._substract = function _substract() {
4705      return this._sub.apply(this, arguments);
4706    };
4707
4708    _proto.sub = function sub() {
4709      var e = new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
4710      return e._sub.apply(e, arguments);
4711    };
4712
4713    _proto.substract = function substract() {
4714      return this.sub.apply(this, arguments);
4715    };
4716
4717    _proto.round = function round() {
4718      return new this.constructor(Math.round(this['xmin']), Math.round(this['ymin']), Math.round(this['xmax']), Math.round(this['ymax']), this.projection);
4719    };
4720
4721    _proto._round = function _round() {
4722      this._dirty = true;
4723      this['xmin'] = Math.round(this['xmin']);
4724      this['ymin'] = Math.round(this['ymin']);
4725      this['xmax'] = Math.round(this['xmax']);
4726      this['ymax'] = Math.round(this['ymax']);
4727      return this;
4728    };
4729
4730    _proto.getMin = function getMin(out) {
4731      if (out) {
4732        out.set(this['xmin'], this['ymin']);
4733        return out;
4734      }
4735
4736      return new this._clazz(this['xmin'], this['ymin']);
4737    };
4738
4739    _proto.getMax = function getMax(out) {
4740      if (out) {
4741        out.set(this['xmax'], this['ymax']);
4742        return out;
4743      }
4744
4745      return new this._clazz(this['xmax'], this['ymax']);
4746    };
4747
4748    _proto.getCenter = function getCenter(out) {
4749      var x = (this['xmin'] + this['xmax']) / 2;
4750      var y = (this['ymin'] + this['ymax']) / 2;
4751
4752      if (out) {
4753        out.set(x, y);
4754        return out;
4755      }
4756
4757      return new this._clazz(x, y);
4758    };
4759
4760    _proto.isValid = function isValid() {
4761      return !isNil(this['xmin']) && !isNil(this['ymin']) && !isNil(this['xmax']) && !isNil(this['ymax']);
4762    };
4763
4764    _proto.equals = function equals(ext2) {
4765      return this['xmin'] === ext2['xmin'] && this['xmax'] === ext2['xmax'] && this['ymin'] === ext2['ymin'] && this['ymax'] === ext2['ymax'];
4766    };
4767
4768    _proto.intersects = function intersects(ext2) {
4769      this._project(this);
4770
4771      this._project(ext2);
4772
4773      var rxmin = Math.max(this['pxmin'], ext2['pxmin']);
4774      var rymin = Math.max(this['pymin'], ext2['pymin']);
4775      var rxmax = Math.min(this['pxmax'], ext2['pxmax']);
4776      var rymax = Math.min(this['pymax'], ext2['pymax']);
4777      var intersects = !(rxmin > rxmax || rymin > rymax);
4778      return intersects;
4779    };
4780
4781    _proto.within = function within(extent) {
4782      this._project(this);
4783
4784      this._project(extent);
4785
4786      return this.pxmin >= extent.pxmin && this.pxmax <= extent.pxmax && this.pymin >= extent.pymin && this.pymax <= extent.pymax;
4787    };
4788
4789    _proto.contains = function contains(c) {
4790      if (!c) {
4791        return false;
4792      }
4793
4794      this._project(this);
4795
4796      var proj = this.projection;
4797
4798      if (proj) {
4799        if (c.x !== undefined) {
4800          var coord = TEMP_COORD0;
4801
4802          if (Array.isArray(c)) {
4803            coord.x = c[0];
4804            coord.y = c[1];
4805          } else {
4806            coord.x = c.x;
4807            coord.y = c.y;
4808          }
4809
4810          c = proj.project(coord, coord);
4811        } else if (c.xmin !== undefined) {
4812          this._project(c);
4813        }
4814      }
4815
4816      return (c.x || c.pxmin || 0) >= this.pxmin && (c.x || c.pxmax || 0) <= this.pxmax && (c.y || c.pymin || 0) >= this.pymin && (c.y || c.pymax || 0) <= this.pymax;
4817    };
4818
4819    _proto.getWidth = function getWidth() {
4820      return Math.abs(this['xmax'] - this['xmin']);
4821    };
4822
4823    _proto.getHeight = function getHeight() {
4824      return Math.abs(this['ymax'] - this['ymin']);
4825    };
4826
4827    _proto.getSize = function getSize() {
4828      return new Size(this.getWidth(), this.getHeight());
4829    };
4830
4831    _proto.set = function set(xmin, ymin, xmax, ymax) {
4832      this.xmin = xmin;
4833      this.ymin = ymin;
4834      this.xmax = xmax;
4835      this.ymax = ymax;
4836      return this;
4837    };
4838
4839    _proto.__combine = function __combine(extent) {
4840      if (extent.x !== undefined) {
4841        TEMP_EXTENT.xmin = TEMP_EXTENT.xmax = extent.x;
4842        TEMP_EXTENT.ymin = TEMP_EXTENT.ymax = extent.y;
4843        extent = TEMP_EXTENT;
4844      }
4845
4846      this._project(extent);
4847
4848      this._project(this);
4849
4850      var inited = isNumber(this.pxmin);
4851      var xmin, ymin, xmax, ymax;
4852
4853      if (!inited) {
4854        xmin = extent['pxmin'];
4855        ymin = extent['pymin'];
4856        xmax = extent['pxmax'];
4857        ymax = extent['pymax'];
4858      } else {
4859        xmin = Math.min(this['pxmin'], extent['pxmin']);
4860        ymin = Math.min(this['pymin'], extent['pymin']);
4861        xmax = Math.max(this['pxmax'], extent['pxmax']);
4862        ymax = Math.max(this['pymax'], extent['pymax']);
4863      }
4864
4865      var proj = this.projection;
4866
4867      if (proj) {
4868        TEMP_COORD1.set(xmin, ymin);
4869        TEMP_COORD2.set(xmax, ymax);
4870        var min = proj.unproject(TEMP_COORD1, TEMP_COORD1),
4871            max = proj.unproject(TEMP_COORD2, TEMP_COORD2);
4872        xmin = min.x;
4873        ymin = min.y;
4874        xmax = max.x;
4875        ymax = max.y;
4876      }
4877
4878      TEMP_COMBINE[0] = xmin;
4879      TEMP_COMBINE[1] = ymin;
4880      TEMP_COMBINE[2] = xmax;
4881      TEMP_COMBINE[3] = ymax;
4882      return TEMP_COMBINE;
4883    };
4884
4885    _proto._combine = function _combine(extent) {
4886      if (!extent || extent.isValid && !extent.isValid()) {
4887        return this;
4888      }
4889
4890      var ext = this.__combine(extent);
4891
4892      this.set(ext[0], ext[1], ext[2], ext[3]);
4893      this._dirty = true;
4894      return this;
4895    };
4896
4897    _proto.combine = function combine(extent) {
4898      if (!extent || extent.isValid && !extent.isValid()) {
4899        return this;
4900      }
4901
4902      var ext = this.__combine(extent);
4903
4904      return new this.constructor(ext[0], ext[1], ext[2], ext[3], this.projection);
4905    };
4906
4907    _proto.intersection = function intersection(extent) {
4908      if (!this.intersects(extent)) {
4909        return null;
4910      }
4911
4912      TEMP_COORD3.x = Math.max(this['pxmin'], extent['pxmin']);
4913      TEMP_COORD3.y = Math.max(this['pymin'], extent['pymin']);
4914      TEMP_COORD4.x = Math.min(this['pxmax'], extent['pxmax']);
4915      TEMP_COORD4.y = Math.min(this['pymax'], extent['pymax']);
4916      var min = TEMP_COORD3,
4917          max = TEMP_COORD4;
4918      var proj = this.projection;
4919
4920      if (proj) {
4921        min = proj.unproject(min, min);
4922        max = proj.unproject(max, max);
4923      }
4924
4925      return new this.constructor(min, max, proj);
4926    };
4927
4928    _proto.expand = function expand(distance) {
4929      var w, h;
4930
4931      if (!isNumber(distance)) {
4932        w = distance['width'] || distance['x'] || distance[0] || 0;
4933        h = distance['height'] || distance['y'] || distance[1] || 0;
4934      } else {
4935        w = h = distance;
4936      }
4937
4938      return new this.constructor(this['xmin'] - w, this['ymin'] - h, this['xmax'] + w, this['ymax'] + h, this.projection);
4939    };
4940
4941    _proto._expand = function _expand(distance) {
4942      var w, h;
4943
4944      if (!isNumber(distance)) {
4945        w = distance['width'] || distance['x'] || distance[0] || 0;
4946        h = distance['height'] || distance['y'] || distance[1] || 0;
4947      } else {
4948        w = h = distance;
4949      }
4950
4951      this['xmin'] -= w;
4952      this['ymin'] -= h;
4953      this['xmax'] += w;
4954      this['ymax'] += h;
4955      this._dirty = true;
4956      return this;
4957    };
4958
4959    _proto.toJSON = function toJSON() {
4960      return {
4961        'xmin': this['xmin'],
4962        'ymin': this['ymin'],
4963        'xmax': this['xmax'],
4964        'ymax': this['ymax']
4965      };
4966    };
4967
4968    _proto.toArray = function toArray() {
4969      var xmin = this['xmin'],
4970          ymin = this['ymin'],
4971          xmax = this['xmax'],
4972          ymax = this['ymax'];
4973      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])];
4974    };
4975
4976    _proto.toString = function toString() {
4977      return this.xmin + "," + this.ymin + "," + this.xmax + "," + this.ymax;
4978    };
4979
4980    _proto.copy = function copy() {
4981      return new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
4982    };
4983
4984    _proto.convertTo = function convertTo(fn, out) {
4985      if (!this.isValid()) {
4986        return null;
4987      }
4988
4989      var e = out || new this.constructor();
4990
4991      if (out) {
4992        e.xmin = e.ymin = e.xmax = e.ymax = 0;
4993      }
4994
4995      var coord;
4996
4997      if (this._clazz === Coordinate) {
4998        coord = TEMP_COORD5;
4999      } else if (this._clazz === Point) {
5000        coord = TEMP_POINT0;
5001      }
5002
5003      coord.x = this.xmin;
5004      coord.y = this.ymax;
5005
5006      e._combine(fn(coord));
5007
5008      coord.x = this.xmax;
5009
5010      e._combine(fn(coord));
5011
5012      coord.y = this.ymin;
5013
5014      e._combine(fn(coord));
5015
5016      coord.x = this.xmin;
5017
5018      e._combine(fn(coord));
5019
5020      return e;
5021    };
5022
5023    _proto._project = function _project(ext) {
5024      if (!ext || !ext.isValid()) {
5025        return;
5026      }
5027
5028      var proj = this.projection;
5029
5030      if (proj) {
5031        if (ext._dirty) {
5032          TEMP_COORD6.set(ext.xmax, ext.ymin);
5033          TEMP_COORD7.set(ext.xmin, ext.ymax);
5034          MINMAX[0] = TEMP_COORD6;
5035          MINMAX[1] = TEMP_COORD7;
5036          var minmax = proj.projectCoords(MINMAX);
5037          var min = minmax[0],
5038              max = minmax[1];
5039          ext.pxmin = Math.min(min.x, max.x);
5040          ext.pymin = Math.min(min.y, max.y);
5041          ext.pxmax = Math.max(min.x, max.x);
5042          ext.pymax = Math.max(min.y, max.y);
5043        }
5044
5045        delete ext._dirty;
5046      } else {
5047        ext.pxmin = ext.xmin;
5048        ext.pxmax = ext.xmax;
5049        ext.pymin = ext.ymin;
5050        ext.pymax = ext.ymax;
5051      }
5052    };
5053
5054    return Extent;
5055  }();
5056
5057  TEMP_EXTENT = new Extent(0, 0, 0, 0);
5058
5059  var PointExtent = function (_Extent) {
5060    _inheritsLoose(PointExtent, _Extent);
5061
5062    function PointExtent(p1, p2, p3, p4) {
5063      var _this;
5064
5065      _this = _Extent.call(this, p1, p2, p3, p4) || this;
5066      _this._clazz = Point;
5067      return _this;
5068    }
5069
5070    return PointExtent;
5071  }(Extent);
5072
5073  var Transformation = function () {
5074    function Transformation(matrix) {
5075      this.matrix = matrix;
5076    }
5077
5078    var _proto = Transformation.prototype;
5079
5080    _proto.transform = function transform(coordinates, scale, out) {
5081      var x = this.matrix[0] * (coordinates.x - this.matrix[2]) / scale;
5082      var y = this.matrix[1] * (coordinates.y - this.matrix[3]) / scale;
5083
5084      if (out) {
5085        out.x = x;
5086        out.y = y;
5087        return out;
5088      }
5089
5090      return new Point(x, y);
5091    };
5092
5093    _proto.untransform = function untransform(point, scale, out) {
5094      var x = point.x * scale / this.matrix[0] + this.matrix[2];
5095      var y = point.y * scale / this.matrix[1] + this.matrix[3];
5096
5097      if (out) {
5098        out.x = x;
5099        out.y = y;
5100        return out;
5101      }
5102
5103      return new Coordinate(x, y);
5104    };
5105
5106    return Transformation;
5107  }();
5108
5109  var Common = {
5110    project: function project() {},
5111    unproject: function unproject() {},
5112    projectCoords: function projectCoords(coordinates) {
5113      var _this = this;
5114
5115      if (!coordinates) {
5116        return [];
5117      }
5118
5119      if (!Array.isArray(coordinates)) {
5120        return this.project(coordinates);
5121      }
5122
5123      if (coordinates.length === 0) {
5124        return [];
5125      }
5126
5127      if (!this.isSphere()) {
5128        return forEachCoord(coordinates, this.project, this);
5129      }
5130
5131      if (Array.isArray(coordinates[0])) {
5132        return coordinates.map(function (coords) {
5133          return _this.projectCoords(coords);
5134        });
5135      } else {
5136        var circum = this.getCircum();
5137        var extent = this.getSphereExtent(),
5138            sx = extent.sx,
5139            sy = extent.sy;
5140        var wrapX, wrapY;
5141        var pre = coordinates[0],
5142            current,
5143            dx,
5144            dy,
5145            p;
5146        var prj = [this.project(pre)];
5147
5148        for (var i = 1, l = coordinates.length; i < l; i++) {
5149          current = coordinates[i];
5150          dx = current.x - pre.x;
5151          dy = current.y - pre.y;
5152          p = this.project(current);
5153
5154          if (Math.abs(dx) > 180) {
5155            if (wrapX === undefined) {
5156              wrapX = current.x > pre.x;
5157            }
5158
5159            if (wrapX) {
5160              p._add(-circum.x * sign(dx) * sx, 0);
5161
5162              current._add(-360 * sign(dx), 0);
5163            }
5164          }
5165
5166          if (Math.abs(dy) > 90) {
5167            if (wrapY === undefined) {
5168              wrapY = current.y < pre.y;
5169            }
5170
5171            if (wrapY) {
5172              p._add(0, -circum.y * sign(dy) * sy);
5173
5174              current._add(0, -180 * sign(dy));
5175            }
5176          }
5177
5178          pre = current;
5179          prj.push(p);
5180        }
5181
5182        return prj;
5183      }
5184    },
5185    unprojectCoords: function unprojectCoords(projCoords) {
5186      if (!projCoords) {
5187        return [];
5188      }
5189
5190      if (!Array.isArray(projCoords)) {
5191        return this.unproject(projCoords);
5192      }
5193
5194      return forEachCoord(projCoords, this.unproject, this);
5195    },
5196    isSphere: function isSphere() {
5197      return !!this.sphere;
5198    },
5199    isOutSphere: function isOutSphere(pcoord) {
5200      if (!this.isSphere()) {
5201        return false;
vendor: 22,827 bytes, lines 5202-6034
5202      }
5203
5204      var extent = this.getSphereExtent();
5205      return !extent.contains(pcoord);
5206    },
5207    wrapCoord: function wrapCoord(pcoord) {
5208      if (!this.isSphere()) {
5209        return pcoord;
5210      }
5211
5212      var extent = this.getSphereExtent();
5213      var wrapped = new Coordinate(pcoord);
5214
5215      if (!extent.contains(wrapped)) {
5216        wrapped.x = wrap(pcoord.x, extent.xmin, extent.xmax);
5217        wrapped.y = wrap(pcoord.y, extent.ymin, extent.ymax);
5218      }
5219
5220      return wrapped;
5221    },
5222    getCircum: function getCircum() {
5223      if (!this.circum && this.isSphere()) {
5224        var extent = this.getSphereExtent();
5225        this.circum = {
5226          x: extent.getWidth(),
5227          y: extent.getHeight()
5228        };
5229      }
5230
5231      return this.circum;
5232    },
5233    getSphereExtent: function getSphereExtent() {
5234      if (!this.extent && this.isSphere()) {
5235        var max = this.project(new Coordinate(180, 90)),
5236            min = this.project(new Coordinate(-180, -90));
5237        this.extent = new Extent(min, max, this);
5238        this.extent.sx = max.x > min.x ? 1 : -1;
5239        this.extent.sy = max.y > min.y ? 1 : -1;
5240      }
5241
5242      return this.extent;
5243    }
5244  };
5245
5246  var Common$1 = {
5247    measureLength: function measureLength(c1, c2) {
5248      if (!Array.isArray(c1)) {
5249        return this.measureLenBetween(c1, c2);
5250      }
5251
5252      var len = 0;
5253
5254      for (var i = 0, l = c1.length; i < l - 1; i++) {
5255        len += this.measureLenBetween(c1[i], c1[i + 1]);
5256      }
5257
5258      return len;
5259    }
5260  };
5261
5262  var Identity = extend({
5263    'measure': 'IDENTITY',
5264    measureLenBetween: function measureLenBetween(c1, c2) {
5265      if (!c1 || !c2) {
5266        return 0;
5267      }
5268
5269      try {
5270        return Math.sqrt(Math.pow(c1.x - c2.x, 2) + Math.pow(c1.y - c2.y, 2));
5271      } catch (err) {
5272        return 0;
5273      }
5274    },
5275    measureArea: function measureArea(coordinates) {
5276      if (!Array.isArray(coordinates)) {
5277        return 0;
5278      }
5279
5280      var area = 0;
5281
5282      for (var i = 0, len = coordinates.length; i < len; i++) {
5283        var c1 = coordinates[i];
5284        var c2 = null;
5285
5286        if (i === len - 1) {
5287          c2 = coordinates[0];
5288        } else {
5289          c2 = coordinates[i + 1];
5290        }
5291
5292        area += c1.x * c2.y - c1.y * c2.x;
5293      }
5294
5295      return Math.abs(area / 2);
5296    },
5297    locate: function locate(c, xDist, yDist) {
5298      c = new Coordinate(c.x, c.y);
5299      return this._locate(c, xDist, yDist);
5300    },
5301    _locate: function _locate(c, xDist, yDist) {
5302      if (!c) {
5303        return null;
5304      }
5305
5306      if (!xDist) {
5307        xDist = 0;
5308      }
5309
5310      if (!yDist) {
5311        yDist = 0;
5312      }
5313
5314      if (!xDist && !yDist) {
5315        return c;
5316      }
5317
5318      c.x = c.x + xDist;
5319      c.y = c.y + yDist;
5320      return c;
5321    },
5322    rotate: function rotate(c, pivot, angle) {
5323      c = new Coordinate(c.x, c.y);
5324      return this._rotate(c, pivot, angle);
5325    },
5326    _rotate: function () {
5327      var tmp = new Point(0, 0);
5328      return function (c, pivot, angle) {
5329        tmp.x = c.x - pivot.x;
5330        tmp.y = c.y - pivot.y;
5331
5332        tmp._rotate(angle * Math.PI / 180);
5333
5334        c.x = pivot.x + tmp.x;
5335        c.y = pivot.y + tmp.y;
5336        return c;
5337      };
5338    }()
5339  }, Common$1);
5340
5341  var Sphere = function () {
5342    function Sphere(radius) {
5343      this.radius = radius;
5344    }
5345
5346    var _proto = Sphere.prototype;
5347
5348    _proto.measureLenBetween = function measureLenBetween(c1, c2) {
5349      if (!c1 || !c2) {
5350        return 0;
5351      }
5352
5353      var b = toRadian(c1.y);
5354      var d = toRadian(c2.y),
5355          e = b - d,
5356          f = toRadian(c1.x) - toRadian(c2.x);
5357      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)));
5358      b *= this.radius;
5359      return Math.round(b * 1E5) / 1E5;
5360    };
5361
5362    _proto.measureArea = function measureArea(coordinates) {
5363      var a = toRadian(this.radius);
5364      var b = 0,
5365          c = coordinates,
5366          d = c.length;
5367
5368      if (d < 3) {
5369        return 0;
5370      }
5371
5372      var i;
5373
5374      for (i = 0; i < d - 1; i++) {
5375        var e = c[i],
5376            f = c[i + 1];
5377        b += e.x * a * Math.cos(toRadian(e.y)) * f.y * a - f.x * a * Math.cos(toRadian(f.y)) * e.y * a;
5378      }
5379
5380      d = c[i];
5381      c = c[0];
5382      b += d.x * a * Math.cos(toRadian(d.y)) * c.y * a - c.x * a * Math.cos(toRadian(c.y)) * d.y * a;
5383      return 0.5 * Math.abs(b);
5384    };
5385
5386    _proto.locate = function locate(c, xDist, yDist) {
5387      c = new Coordinate(c.x, c.y);
5388      return this._locate(c, xDist, yDist);
5389    };
5390
5391    _proto._locate = function _locate(c, xDist, yDist) {
5392      if (!c) {
5393        return null;
5394      }
5395
5396      if (!xDist) {
5397        xDist = 0;
5398      }
5399
5400      if (!yDist) {
5401        yDist = 0;
5402      }
5403
5404      if (!xDist && !yDist) {
5405        return c;
5406      }
5407
5408      var x, y;
5409      var ry = toRadian(c.y);
5410
5411      if (yDist !== 0) {
5412        var dy = Math.abs(yDist);
5413        var sy = Math.sin(dy / (2 * this.radius)) * 2;
5414        ry = ry + sy * (yDist > 0 ? 1 : -1);
5415        y = wrap(ry * 180 / Math.PI, -90, 90);
5416      } else {
5417        y = c.y;
5418      }
5419
5420      if (xDist !== 0) {
5421        var dx = Math.abs(xDist);
5422        var rx = toRadian(c.x);
5423        var sx = 2 * Math.sqrt(Math.pow(Math.sin(dx / (2 * this.radius)), 2) / Math.pow(Math.cos(ry), 2));
5424        rx = rx + sx * (xDist > 0 ? 1 : -1);
5425        x = wrap(rx * 180 / Math.PI, -180, 180);
5426      } else {
5427        x = c.x;
5428      }
5429
5430      c.x = x;
5431      c.y = y;
5432      return c;
5433    };
5434
5435    _proto.rotate = function rotate(c, pivot, angle) {
5436      c = new Coordinate(c);
5437      return this._rotate(c, pivot, angle);
5438    };
5439
5440    _proto._rotate = function _rotate(c, pivot, angle) {
5441      var initialAngle = rhumbBearing(pivot, c);
5442      var finalAngle = initialAngle - angle;
5443      var distance = this.measureLenBetween(pivot, c);
5444      c.x = pivot.x;
5445      c.y = pivot.y;
5446      return calculateRhumbDestination(c, distance, finalAngle, this.radius);
5447    };
5448
5449    return Sphere;
5450  }();
5451
5452  function rhumbBearing(start, end, options) {
5453    if (options === void 0) {
5454      options = {};
5455    }
5456
5457    var bear360;
5458    if (options.final) bear360 = calculateRhumbBearing(end, start);else bear360 = calculateRhumbBearing(start, end);
5459    var bear180 = bear360 > 180 ? -(360 - bear360) : bear360;
5460    return bear180;
5461  }
5462
5463  function calculateRhumbBearing(from, to) {
5464    var phi1 = toRadian(from.y);
5465    var phi2 = toRadian(to.y);
5466    var deltaLambda = toRadian(to.x - from.x);
5467    if (deltaLambda > Math.PI) deltaLambda -= 2 * Math.PI;
5468    if (deltaLambda < -Math.PI) deltaLambda += 2 * Math.PI;
5469    var deltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
5470    var theta = Math.atan2(deltaLambda, deltaPsi);
5471    return (toDegree(theta) + 360) % 360;
5472  }
5473
5474  function calculateRhumbDestination(origin, distance, bearing, radius) {
5475    var delta = distance / radius;
5476    var lambda1 = origin.x * Math.PI / 180;
5477    var phi1 = toRadian(origin.y);
5478    var theta = toRadian(bearing);
5479    var DeltaPhi = delta * Math.cos(theta);
5480    var phi2 = phi1 + DeltaPhi;
5481    if (Math.abs(phi2) > Math.PI / 2) phi2 = phi2 > 0 ? Math.PI - phi2 : -Math.PI - phi2;
5482    var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
5483    var q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);
5484    var DeltaLambda = delta * Math.sin(theta) / q;
5485    var lambda2 = lambda1 + DeltaLambda;
5486    origin.x = (lambda2 * 180 / Math.PI + 540) % 360 - 180;
5487    origin.y = phi2 * 180 / Math.PI;
5488    return origin;
5489  }
5490
5491  var WGS84Sphere = extend({
5492    'measure': 'EPSG:4326',
5493    sphere: new Sphere(6378137),
5494    measureLenBetween: function measureLenBetween() {
5495      return this.sphere.measureLenBetween.apply(this.sphere, arguments);
5496    },
5497    measureArea: function measureArea() {
5498      return this.sphere.measureArea.apply(this.sphere, arguments);
5499    },
5500    _locate: function _locate() {
5501      return this.sphere._locate.apply(this.sphere, arguments);
5502    },
5503    locate: function locate() {
5504      return this.sphere.locate.apply(this.sphere, arguments);
5505    },
5506    _rotate: function _rotate() {
5507      return this.sphere._rotate.apply(this.sphere, arguments);
5508    },
5509    rotate: function rotate() {
5510      return this.sphere.rotate.apply(this.sphere, arguments);
5511    }
5512  }, Common$1);
5513  var BaiduSphere = extend({
5514    'measure': 'BAIDU',
5515    sphere: new Sphere(6370996.81),
5516    measureLenBetween: function measureLenBetween() {
5517      return this.sphere.measureLenBetween.apply(this.sphere, arguments);
5518    },
5519    measureArea: function measureArea() {
5520      return this.sphere.measureArea.apply(this.sphere, arguments);
5521    },
5522    _locate: function _locate() {
5523      return this.sphere._locate.apply(this.sphere, arguments);
5524    },
5525    locate: function locate() {
5526      return this.sphere.locate.apply(this.sphere, arguments);
5527    },
5528    _rotate: function _rotate() {
5529      return this.sphere._rotate.apply(this.sphere, arguments);
5530    },
5531    rotate: function rotate() {
5532      return this.sphere.rotate.apply(this.sphere, arguments);
5533    }
5534  }, Common$1);
5535
5536  var DEFAULT = WGS84Sphere;
5537  var measurers = {};
5538
5539  function registerMeasurer(m) {
5540    measurers[m.measure] = m;
5541  }
5542
5543  registerMeasurer(Identity);
5544  registerMeasurer(WGS84Sphere);
5545  registerMeasurer(BaiduSphere);
5546  var Measurer = {
5547    getInstance: function getInstance(name) {
5548      if (!name) {
5549        return DEFAULT;
5550      }
5551
5552      for (var p in measurers) {
5553        if (hasOwn(measurers, p)) {
5554          var mName = measurers[p]['measure'];
5555
5556          if (!mName) {
5557            continue;
5558          }
5559
5560          if (name.toLowerCase() === mName.toLowerCase()) {
5561            return measurers[p];
5562          }
5563        }
5564      }
5565
5566      return null;
5567    }
5568  };
5569
5570  var index$2 = /*#__PURE__*/Object.freeze({
5571    Identity: Identity,
5572    DEFAULT: DEFAULT,
5573    Measurer: Measurer,
5574    WGS84Sphere: WGS84Sphere,
5575    BaiduSphere: BaiduSphere
5576  });
5577
5578  var delta = 1E-7;
5579  var EPSG3857 = extend({}, Common, {
5580    code: 'EPSG:3857',
5581    rad: Math.PI / 180,
5582    metersPerDegree: 6378137 * Math.PI / 180,
5583    maxLatitude: 85.0511287798,
5584    project: function project(lnglat, out) {
5585      var rad = this.rad,
5586          metersPerDegree = this.metersPerDegree,
5587          max = this.maxLatitude;
5588      var lng = lnglat.x,
5589          lat = Math.max(Math.min(max, lnglat.y), -max);
5590      var c;
5591
5592      if (lat === 0) {
5593        c = 0;
5594      } else {
5595        c = Math.log(Math.tan((90 + lat) * rad / 2)) / rad;
5596      }
5597
5598      var x = lng * metersPerDegree;
5599      var y = c * metersPerDegree;
5600
5601      if (out) {
5602        out.x = x;
5603        out.y = y;
5604        return out;
5605      }
5606
5607      return new Coordinate(x, y);
5608    },
5609    unproject: function unproject(pLnglat, out) {
5610      var rad = this.rad;
5611      var metersPerDegree = this.metersPerDegree;
5612      var x = pLnglat.x / metersPerDegree;
5613      var y = pLnglat.y;
5614      var c;
5615
5616      if (y === 0) {
5617        c = 0;
5618      } else {
5619        c = y / metersPerDegree;
5620        c = (2 * Math.atan(Math.exp(c * rad)) - Math.PI / 2) / rad;
5621      }
5622
5623      if (Math.abs(Math.abs(x) - 180) < delta) {
5624        x = sign(x) * 180;
5625      }
5626
5627      if (Math.abs(Math.abs(c) - this.maxLatitude) < delta) {
5628        c = sign(c) * this.maxLatitude;
5629      }
5630
5631      var rx = wrap(x, -180, 180);
5632      var ry = wrap(c, -this.maxLatitude, this.maxLatitude);
5633
5634      if (out) {
5635        out.x = rx;
5636        out.y = ry;
5637        return out;
5638      }
5639
5640      return new Coordinate(rx, ry);
5641    }
5642  }, WGS84Sphere);
5643
5644  var PROJ4326 = extend({}, Common, {
5645    code: 'EPSG:4326',
5646    project: function project(p, out) {
5647      if (out) {
5648        out.x = p.x;
5649        out.y = p.y;
5650        return out;
5651      }
5652
5653      return new Coordinate(p);
5654    },
5655    unproject: function unproject(p, out) {
5656      if (out) {
5657        out.x = p.x;
5658        out.y = p.y;
5659        return out;
5660      }
5661
5662      return new Coordinate(p);
5663    }
5664  }, WGS84Sphere);
5665
5666  var Projection_EPSG4490 = extend({}, PROJ4326, {
5667    code: 'EPSG:4490'
5668  });
5669
5670  var Projection_Baidu = extend({}, Common, {
5671    code: 'BAIDU',
5672    project: function project(p, out) {
5673      return this.convertLL2MC(p, out);
5674    },
5675    unproject: function unproject(p, out) {
5676      return this.convertMC2LL(p, out);
5677    }
5678  }, BaiduSphere, {
5679    EARTHRADIUS: 6370996.81,
5680    MCBAND: [12890594.86, 8362377.87, 5591021, 3481989.83, 1678043.12, 0],
5681    LLBAND: [75, 60, 45, 30, 15, 0],
5682    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]],
5683    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]],
5684    convertMC2LL: function convertMC2LL(cB, out) {
5685      var cE;
5686
5687      for (var cD = 0, len = this.MCBAND.length; cD < len; cD++) {
5688        if (Math.abs(cB.y) >= this.MCBAND[cD]) {
5689          cE = this.MC2LL[cD];
5690          break;
5691        }
5692      }
5693
5694      var T = this.convertor(cB, cE, out);
5695      return T;
5696    },
5697    convertLL2MC: function convertLL2MC(T, out) {
5698      var cD, cC, len;
5699      T.x = this.getLoop(T.x, -180, 180);
5700      T.y = this.getRange(T.y, -74, 74);
5701      var cB = new Coordinate(T.x, T.y);
5702
5703      for (cC = 0, len = this.LLBAND.length; cC < len; cC++) {
5704        if (cB.y >= this.LLBAND[cC]) {
5705          cD = this.LL2MC[cC];
5706          break;
5707        }
5708      }
5709
5710      if (!cD) {
5711        for (cC = this.LLBAND.length - 1; cC >= 0; cC--) {
5712          if (cB.y <= -this.LLBAND[cC]) {
5713            cD = this.LL2MC[cC];
5714            break;
5715          }
5716        }
5717      }
5718
5719      var cE = this.convertor(T, cD, out);
5720      return cE;
5721    },
5722    convertor: function convertor(cC, cD, out) {
5723      if (!cC || !cD) {
5724        return null;
5725      }
5726
5727      var T = cD[0] + cD[1] * Math.abs(cC.x);
5728      var cB = Math.abs(cC.y) / cD[9];
5729      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;
5730      T *= cC.x < 0 ? -1 : 1;
5731      cE *= cC.y < 0 ? -1 : 1;
5732
5733      if (out) {
5734        out.x = T;
5735        out.y = cE;
5736        return out;
5737      }
5738
5739      return new Coordinate(T, cE);
5740    },
5741    toRadians: function toRadians(T) {
5742      return Math.PI * T / 180;
5743    },
5744    toDegrees: function toDegrees(T) {
5745      return 180 * T / Math.PI;
5746    },
5747    getRange: function getRange(cC, cB, T) {
5748      if (cB != null) {
5749        cC = Math.max(cC, cB);
5750      }
5751
5752      if (T != null) {
5753        cC = Math.min(cC, T);
5754      }
5755
5756      return cC;
5757    },
5758    getLoop: function getLoop(cC, cB, T) {
5759      if (cC === Infinity) {
5760        return T;
5761      } else if (cC === -Infinity) {
5762        return cB;
5763      }
5764
5765      while (cC > T) {
5766        cC -= T - cB;
5767      }
5768
5769      while (cC < cB) {
5770        cC += T - cB;
5771      }
5772
5773      return cC;
5774    }
5775  });
5776
5777  var Projection_IDENTITY = extend({}, Common, {
5778    code: 'IDENTITY',
5779    project: function project(p, out) {
5780      if (out) {
5781        out.x = p.x;
5782        out.y = p.y;
5783        return out;
5784      }
5785
5786      return p.copy();
5787    },
5788    unproject: function unproject(p, out) {
5789      if (out) {
5790        out.x = p.x;
5791        out.y = p.y;
5792        return out;
5793      }
5794
5795      return p.copy();
5796    }
5797  }, Identity);
5798
5799  var DEFAULT$1 = EPSG3857;
5800
5801  var projections = /*#__PURE__*/Object.freeze({
5802    EPSG3857: EPSG3857,
5803    DEFAULT: DEFAULT$1,
5804    EPSG4326: PROJ4326,
5805    EPSG4490: Projection_EPSG4490,
5806    BAIDU: Projection_Baidu,
5807    IDENTITY: Projection_IDENTITY,
5808    Common: Common
5809  });
5810
5811  var Renderable = (function (Base) {
5812    return function (_Base) {
5813      _inheritsLoose(_class, _Base);
5814
5815      function _class() {
5816        return _Base.apply(this, arguments) || this;
5817      }
5818
5819      _class.registerRenderer = function registerRenderer(name, clazz) {
5820        var proto = this.prototype;
5821        var parentProto = Object.getPrototypeOf(proto);
5822
5823        if (!proto._rendererClasses || proto._rendererClasses === parentProto._rendererClasses) {
5824          proto._rendererClasses = proto._rendererClasses ? Object.create(proto._rendererClasses) : {};
5825        }
5826
5827        proto._rendererClasses[name.toLowerCase()] = clazz;
5828        return this;
5829      };
5830
5831      _class.getRendererClass = function getRendererClass(name) {
5832        var proto = this.prototype;
5833
5834        if (!proto._rendererClasses) {
5835          return null;
5836        }
5837
5838        return proto._rendererClasses[name.toLowerCase()];
5839      };
5840
5841      return _class;
5842    }(Base);
5843  });
5844
5845  var CanvasRenderer = function (_Class) {
5846    _inheritsLoose(CanvasRenderer, _Class);
5847
5848    function CanvasRenderer(layer) {
5849      var _this;
5850
5851      _this = _Class.call(this) || this;
5852      _this.layer = layer;
5853      _this._painted = false;
5854      _this._drawTime = 0;
5855
5856      _this.setToRedraw();
5857
5858      return _this;
5859    }
5860
5861    var _proto = CanvasRenderer.prototype;
5862
5863    _proto.render = function render(framestamp) {
5864      var _this2 = this;
5865
5866      this.prepareRender();
5867
5868      if (!this.getMap() || !this.layer.isVisible()) {
5869        return;
5870      }
5871
5872      if (!this.resources) {
5873        this.resources = new ResourceCache();
5874      }
5875
5876      if (this.checkResources) {
5877        var resources = this.checkResources();
5878
5879        if (resources.length > 0) {
5880          this._loadingResource = true;
5881          this.loadResources(resources).then(function () {
5882            _this2._loadingResource = false;
5883
5884            if (_this2.layer) {
5885              _this2.layer.fire('resourceload');
5886
5887              _this2.setToRedraw();
5888            }
5889          });
5890        } else {
5891          this._tryToDraw(framestamp);
5892        }
5893      } else {
5894        this._tryToDraw(framestamp);
5895      }
5896    };
5897
5898    _proto.testIfNeedRedraw = function testIfNeedRedraw() {
5899      var map = this.getMap();
5900
5901      if (this._loadingResource) {
5902        return false;
5903      }
5904
5905      if (this._toRedraw) {
5906        return true;
5907      }
5908
5909      if (map.isInteracting() && !this.drawOnInteracting) {
5910        return false;
5911      }
5912
5913      if (this.needToRedraw()) {
5914        return true;
5915      }
5916
5917      return false;
5918    };
5919
5920    _proto.needToRedraw = function needToRedraw() {
5921      var map = this.getMap();
5922
5923      if (map.isInteracting()) {
5924        return !(!map.getPitch() && map.isMoving() && !map.isZooming() && !map.isRotating() && !this.layer.options['forceRenderOnMoving']);
5925      }
5926
5927      return false;
5928    };
5929
5930    _proto.onSkipDrawOnInteracting = function onSkipDrawOnInteracting() {};
5931
5932    _proto.isLoadingResource = function isLoadingResource() {
5933      return this._loadingResource;
5934    };
5935
5936    _proto.isRenderComplete = function isRenderComplete() {
5937      return !!this._renderComplete;
5938    };
5939
5940    _proto.mustRenderOnInteracting = function mustRenderOnInteracting() {
5941      return !this._painted || this.checkResources && this.checkResources().length > 0;
5942    };
5943
5944    _proto.setToRedraw = function setToRedraw() {
5945      this._toRedraw = true;
5946      return this;
5947    };
5948
5949    _proto.setCanvasUpdated = function setCanvasUpdated() {
5950      this._canvasUpdated = true;
5951      return this;
5952    };
5953
5954    _proto.isCanvasUpdated = function isCanvasUpdated() {
5955      return !!this._canvasUpdated;
5956    };
5957
5958    _proto.remove = function remove() {
5959      this.onRemove();
5960      delete this._loadingResource;
5961      delete this.southWest;
5962      delete this.canvas;
5963      delete this.context;
5964      delete this.canvasExtent2D;
5965      delete this._extent2D;
5966      delete this.resources;
5967      delete this.layer;
5968    };
5969
5970    _proto.onRemove = function onRemove() {};
5971
5972    _proto.onAdd = function onAdd() {};
5973
5974    _proto.getMap = function getMap() {
5975      if (!this.layer) {
5976        return null;
5977      }
5978
5979      return this.layer.getMap();
5980    };
5981
5982    _proto.getCanvasImage = function getCanvasImage() {
5983      var map = this.getMap();
5984      this._canvasUpdated = false;
5985
5986      if (this._renderZoom !== map.getZoom() || !this.canvas || !this._extent2D) {
5987        return null;
5988      }
5989
5990      if (this.isBlank()) {
5991        return null;
5992      }
5993
5994      if (this.layer.isEmpty && this.layer.isEmpty()) {
5995        return null;
5996      }
5997
5998      var containerPoint = map._pointToContainerPoint(this.southWest)._add(0, -map.height);
5999
6000      return {
6001        'image': this.canvas,
6002        'layer': this.layer,
6003        'point': containerPoint
6004      };
6005    };
6006
6007    _proto.clear = function clear() {
6008      this.clearCanvas();
6009    };
6010
6011    _proto.isBlank = function isBlank() {
6012      if (!this._painted) {
6013        return true;
6014      }
6015
6016      return false;
6017    };
6018
6019    _proto.show = function show() {
6020      this.setToRedraw();
6021    };
6022
6023    _proto.hide = function hide() {
6024      this.clear();
6025      this.setToRedraw();
6026    };
6027
6028    _proto.setZIndex = function setZIndex() {
6029      this.setToRedraw();
6030    };
6031
6032    _proto.hitDetect = function hitDetect(point) {
6033      if (!this.context || this.layer.isEmpty && this.layer.isEmpty() || this.isBlank() || this._errorThrown) {
6034        return false;
6035      }
6036
6037      var map = this.getMap();
6038      var r = map.getDevicePixelRatio();
6039      var size = map.getSize();
6040
6041      if (point.x < 0 || point.x > size['width'] * r || point.y < 0 || point.y > size['height'] * r) {
6042        return false;
6043      }
6044
6045      try {
6046        var imgData = this.context.getImageData(r * point.x, r * point.y, 1, 1).data;
6047
6048        if (imgData[3] > 0) {
6049          return true;
6050        }
6051      } catch (error) {
6052        if (!this._errorThrown) {
6053          if (console) {
6054            console.warn('hit detect failed with tainted canvas, some geometries have external resources in another domain:\n', error);
6055          }
6056
6057          this._errorThrown = true;
6058        }
6059
6060        return false;
6061      }
6062
6063      return false;
6064    };
6065
6066    _proto.loadResources = function loadResources(resourceUrls) {
6067      if (!this.resources) {
6068        this.resources = new ResourceCache();
6069      }
6070
6071      var resources = this.resources,
6072          promises = [];
6073
6074      if (isArrayHasData(resourceUrls)) {
6075        var cache = {};
6076
6077        for (var i = resourceUrls.length - 1; i >= 0; i--) {
6078          var url = resourceUrls[i];
6079
6080          if (!url || !url.length || cache[url.join('-')]) {
6081            continue;
6082          }
6083
6084          cache[url.join('-')] = 1;
6085
6086          if (!resources.isResourceLoaded(url, true)) {
6087            promises.push(new Promise$1(this._promiseResource(url)));
6088          }
6089        }
6090      }
6091
6092      return Promise$1.all(promises);
6093    };
6094
6095    _proto.prepareRender = function prepareRender() {
6096      delete this._renderComplete;
6097      var map = this.getMap();
6098      this._renderZoom = map.getZoom();
6099      this.canvasExtent2D = this._extent2D = map._get2DExtent();
6100      this.southWest = map._containerPointToPoint(new Point(0, map.height));
6101    };
6102
6103    _proto.createCanvas = function createCanvas() {
6104      if (this.canvas) {
6105        return;
6106      }
6107
6108      var map = this.getMap();
6109      var size = map.getSize();
6110      var r = map.getDevicePixelRatio(),
6111          w = r * size.width,
6112          h = r * size.height;
6113
6114      if (this.layer._canvas) {
6115        var canvas = this.layer._canvas;
6116        canvas.width = w;
6117        canvas.height = h;
6118
6119        if (canvas.style) {
6120          canvas.style.width = size.width + 'px';
6121          canvas.style.height = size.height + 'px';
6122        }
6123
6124        this.canvas = this.layer._canvas;
6125      } else {
6126        this.canvas = Canvas.createCanvas(w, h, map.CanvasClass);
6127      }
6128
6129      this.onCanvasCreate();
6130    };
6131
6132    _proto.onCanvasCreate = function onCanvasCreate() {};
6133
6134    _proto.createContext = function createContext() {
6135      if (this.gl && this.gl.canvas === this.canvas || this.context) {
6136        return;
6137      }
6138
6139      this.context = this.canvas.getContext('2d');
6140
6141      if (!this.context) {
6142        return;
6143      }
6144
6145      if (this.layer.options['globalCompositeOperation']) {
6146        this.context.globalCompositeOperation = this.layer.options['globalCompositeOperation'];
6147      }
6148
6149      var dpr = this.getMap().getDevicePixelRatio();
6150
6151      if (dpr !== 1) {
6152        this.context.scale(dpr, dpr);
6153      }
6154    };
6155
6156    _proto.resetCanvasTransform = function resetCanvasTransform() {
6157      if (!this.context) {
6158        return;
6159      }
6160
6161      var dpr = this.getMap().getDevicePixelRatio();
6162      this.context.setTransform(dpr, 0, 0, dpr, 0, 0);
6163    };
6164
6165    _proto.resizeCanvas = function resizeCanvas(canvasSize) {
6166      var canvas = this.canvas;
6167
6168      if (!canvas) {
6169        return;
6170      }
6171
6172      var size = canvasSize || this.getMap().getSize();
6173      var r = this.getMap().getDevicePixelRatio();
6174
6175      if (canvas.width === r * size.width && canvas.height === r * size.height) {
6176        return;
6177      }
6178
6179      canvas.height = r * size.height;
6180      canvas.width = r * size.width;
6181
6182      if (r !== 1 && this.context) {
6183        this.context.scale(r, r);
6184      }
6185
6186      if (this.layer._canvas && canvas.style) {
6187        canvas.style.width = size.width + 'px';
6188        canvas.style.height = size.height + 'px';
6189      }
6190    };
6191
6192    _proto.clearCanvas = function clearCanvas() {
6193      if (!this.context) {
6194        return;
6195      }
6196
6197      Canvas.clearRect(this.context, 0, 0, this.canvas.width, this.canvas.height);
6198    };
6199
6200    _proto.prepareCanvas = function prepareCanvas() {
6201      if (!this.canvas) {
6202        this.createCanvas();
6203        this.createContext();
6204        this.layer.onCanvasCreate();
6205        this.layer.fire('canvascreate', {
6206          'context': this.context,
6207          'gl': this.gl
6208        });
6209      } else {
6210        this.resetCanvasTransform();
6211        this.clearCanvas();
6212        this.resizeCanvas();
6213      }
6214
6215      delete this._maskExtent;
6216      var mask = this.layer.getMask();
6217
6218      if (!mask) {
6219        this.layer.fire('renderstart', {
6220          'context': this.context,
6221          'gl': this.gl
6222        });
6223        return null;
6224      }
6225
6226      var maskExtent2D = this._maskExtent = mask._getPainter().get2DExtent();
6227
6228      if (!maskExtent2D.intersects(this._extent2D)) {
6229        this.layer.fire('renderstart', {
6230          'context': this.context,
6231          'gl': this.gl
6232        });
6233        return maskExtent2D;
6234      }
6235
6236      this.layer.fire('renderstart', {
6237        'context': this.context,
6238        'gl': this.gl
6239      });
6240      return maskExtent2D;
6241    };
6242
6243    _proto.clipCanvas = function clipCanvas(context) {
6244      var mask = this.layer.getMask();
6245
6246      if (!mask) {
6247        return false;
vendor: 16,240 bytes, lines 6248-6969
6248      }
6249
6250      var old = this.southWest;
6251      var map = this.getMap();
6252      this.southWest = map._containerPointToPoint(new Point(0, map.height));
6253      context.save();
6254      var dpr = map.getDevicePixelRatio();
6255
6256      if (dpr !== 1) {
6257        context.save();
6258        context.scale(dpr, dpr);
6259      }
6260
6261      if (mask.getGeometries) {
6262        context.isMultiClip = true;
6263        var masks = mask.getGeometries() || [];
6264        context.beginPath();
6265        masks.forEach(function (_mask) {
6266          var painter = _mask._getPainter();
6267
6268          painter.paint(null, context);
6269        });
6270        context.stroke();
6271        delete context.isMultiClip;
6272      } else {
6273        var painter = mask._getPainter();
6274
6275        painter.paint(null, context);
6276      }
6277
6278      if (dpr !== 1) {
6279        context.restore();
6280      }
6281
6282      context.clip();
6283      this.southWest = old;
6284      return true;
6285    };
6286
6287    _proto.getViewExtent = function getViewExtent() {
6288      return {
6289        'extent': this._extent2D,
6290        'maskExtent': this._maskExtent,
6291        'zoom': this._renderZoom,
6292        'southWest': this.southWest
6293      };
6294    };
6295
6296    _proto.completeRender = function completeRender() {
6297      if (this.getMap()) {
6298        this._renderComplete = true;
6299        this.layer.fire('renderend', {
6300          'context': this.context,
6301          'gl': this.gl
6302        });
6303        this.setCanvasUpdated();
6304      }
6305    };
6306
6307    _proto.getEvents = function getEvents() {
6308      return {
6309        '_zoomstart': this.onZoomStart,
6310        '_zooming': this.onZooming,
6311        '_zoomend': this.onZoomEnd,
6312        '_resize': this.onResize,
6313        '_movestart': this.onMoveStart,
6314        '_moving': this.onMoving,
6315        '_moveend': this.onMoveEnd,
6316        '_dragrotatestart': this.onDragRotateStart,
6317        '_dragrotating': this.onDragRotating,
6318        '_dragrotateend': this.onDragRotateEnd,
6319        '_spatialreferencechange': this.onSpatialReferenceChange
6320      };
6321    };
6322
6323    _proto.onZoomStart = function onZoomStart() {};
6324
6325    _proto.onZoomEnd = function onZoomEnd() {
6326      this.setToRedraw();
6327    };
6328
6329    _proto.onZooming = function onZooming() {};
6330
6331    _proto.onMoveStart = function onMoveStart() {};
6332
6333    _proto.onMoving = function onMoving() {};
6334
6335    _proto.onMoveEnd = function onMoveEnd() {
6336      this.setToRedraw();
6337    };
6338
6339    _proto.onResize = function onResize() {
6340      delete this._extent2D;
6341      this.resizeCanvas();
6342      this.setToRedraw();
6343    };
6344
6345    _proto.onDragRotateStart = function onDragRotateStart() {};
6346
6347    _proto.onDragRotating = function onDragRotating() {};
6348
6349    _proto.onDragRotateEnd = function onDragRotateEnd() {
6350      this.setToRedraw();
6351    };
6352
6353    _proto.onSpatialReferenceChange = function onSpatialReferenceChange() {};
6354
6355    _proto.getDrawTime = function getDrawTime() {
6356      return this._drawTime;
6357    };
6358
6359    _proto._tryToDraw = function _tryToDraw(framestamp) {
6360      this._toRedraw = false;
6361
6362      if (!this.canvas && this.layer.isEmpty && this.layer.isEmpty()) {
6363        this._renderComplete = true;
6364        return;
6365      }
6366
6367      this._drawAndRecord(framestamp);
6368    };
6369
6370    _proto._drawAndRecord = function _drawAndRecord(framestamp) {
6371      if (!this.getMap()) {
6372        return;
6373      }
6374
6375      var painted = this._painted;
6376      this._painted = true;
6377      var t = now();
6378      this.draw(framestamp);
6379      t = now() - t;
6380      this._drawTime = painted ? t : t / 2;
6381
6382      if (painted && this.layer && this.layer.options['logDrawTime']) {
6383        console.log(this.layer.getId(), 'frameTimeStamp:', framestamp, 'drawTime:', this._drawTime);
6384      }
6385    };
6386
6387    _proto._promiseResource = function _promiseResource(url) {
6388      var me = this,
6389          resources = this.resources,
6390          crossOrigin = this.layer.options['crossOrigin'];
6391      return function (resolve) {
6392        if (resources.isResourceLoaded(url, true)) {
6393          resolve(url);
6394          return;
6395        }
6396
6397        var img = new Image();
6398
6399        if (!isNil(crossOrigin)) {
6400          img['crossOrigin'] = crossOrigin;
6401        }
6402
6403        if (isSVG(url[0]) && !IS_NODE) {
6404          if (url[1]) {
6405            url[1] *= 2;
6406          }
6407
6408          if (url[2]) {
6409            url[2] *= 2;
6410          }
6411        }
6412
6413        img.onload = function () {
6414          me._cacheResource(url, img);
6415
6416          resolve(url);
6417        };
6418
6419        img.onabort = function (err) {
6420          if (console) {
6421            console.warn('image loading aborted: ' + url[0]);
6422          }
6423
6424          if (err) {
6425            if (console) {
6426              console.warn(err);
6427            }
6428          }
6429
6430          resolve(url);
6431        };
6432
6433        img.onerror = function (err) {
6434          if (err && typeof console !== 'undefined') {
6435            console.warn(err);
6436          }
6437
6438          resources.markErrorResource(url);
6439          resolve(url);
6440        };
6441
6442        loadImage(img, url);
6443      };
6444    };
6445
6446    _proto._cacheResource = function _cacheResource(url, img) {
6447      if (!this.layer || !this.resources) {
6448        return;
6449      }
6450
6451      var w = url[1],
6452          h = url[2];
6453
6454      if (this.layer.options['cacheSvgOnCanvas'] && isSVG(url[0]) === 1 && (Browser$1.edge || Browser$1.ie)) {
6455        if (isNil(w)) {
6456          w = img.width || this.layer.options['defaultIconSize'][0];
6457        }
6458
6459        if (isNil(h)) {
6460          h = img.height || this.layer.options['defaultIconSize'][1];
6461        }
6462
6463        var canvas = Canvas.createCanvas(w, h);
6464        Canvas.image(canvas.getContext('2d'), img, 0, 0, w, h);
6465        img = canvas;
6466      }
6467
6468      this.resources.addResource(url, img);
6469    };
6470
6471    return CanvasRenderer;
6472  }(Class);
6473  var ResourceCache = function () {
6474    function ResourceCache() {
6475      this.resources = {};
6476      this._errors = {};
6477    }
6478
6479    var _proto2 = ResourceCache.prototype;
6480
6481    _proto2.addResource = function addResource(url, img) {
6482      this.resources[url[0]] = {
6483        image: img,
6484        width: +url[1],
6485        height: +url[2]
6486      };
6487    };
6488
6489    _proto2.isResourceLoaded = function isResourceLoaded(url, checkSVG) {
6490      if (!url) {
6491        return false;
6492      }
6493
6494      var imgUrl = this._getImgUrl(url);
6495
6496      if (this._errors[imgUrl]) {
6497        return true;
6498      }
6499
6500      var img = this.resources[imgUrl];
6501
6502      if (!img) {
6503        return false;
6504      }
6505
6506      if (checkSVG && isSVG(url[0]) && (+url[1] > img.width || +url[2] > img.height)) {
6507        return false;
6508      }
6509
6510      return true;
6511    };
6512
6513    _proto2.getImage = function getImage(url) {
6514      var imgUrl = this._getImgUrl(url);
6515
6516      if (!this.isResourceLoaded(url) || this._errors[imgUrl]) {
6517        return null;
6518      }
6519
6520      return this.resources[imgUrl].image;
6521    };
6522
6523    _proto2.markErrorResource = function markErrorResource(url) {
6524      this._errors[this._getImgUrl(url)] = 1;
6525    };
6526
6527    _proto2.merge = function merge(res) {
6528      if (!res) {
6529        return this;
6530      }
6531
6532      for (var p in res.resources) {
6533        var img = res.resources[p];
6534        this.addResource([p, img.width, img.height], img.image);
6535      }
6536
6537      return this;
6538    };
6539
6540    _proto2.forEach = function forEach(fn) {
6541      if (!this.resources) {
6542        return this;
6543      }
6544
6545      for (var p in this.resources) {
6546        if (hasOwn(this.resources, p)) {
6547          fn(p, this.resources[p]);
6548        }
6549      }
6550
6551      return this;
6552    };
6553
6554    _proto2._getImgUrl = function _getImgUrl(url) {
6555      if (!Array.isArray(url)) {
6556        return url;
6557      }
6558
6559      return url[0];
6560    };
6561
6562    return ResourceCache;
6563  }();
6564
6565  var options = {
6566    'attribution': null,
6567    'minZoom': null,
6568    'maxZoom': null,
6569    'visible': true,
6570    'opacity': 1,
6571    'globalCompositeOperation': null,
6572    'renderer': 'canvas',
6573    'debugOutline': '#0f0',
6574    'cssFilter': null,
6575    'forceRenderOnMoving': false,
6576    'forceRenderOnZooming': false,
6577    'forceRenderOnRotating': false
6578  };
6579
6580  var Layer = function (_JSONAble) {
6581    _inheritsLoose(Layer, _JSONAble);
6582
6583    function Layer(id, options) {
6584      var _this;
6585
6586      var canvas;
6587
6588      if (options) {
6589        canvas = options.canvas;
6590        delete options.canvas;
6591      }
6592
6593      _this = _JSONAble.call(this, options) || this;
6594      _this._canvas = canvas;
6595
6596      _this.setId(id);
6597
6598      if (options) {
6599        _this.setZIndex(options.zIndex);
6600      }
6601
6602      return _this;
6603    }
6604
6605    var _proto = Layer.prototype;
6606
6607    _proto.load = function load() {
6608      if (!this.getMap()) {
6609        return this;
6610      }
6611
6612      if (this.onLoad()) {
6613        this._initRenderer();
6614
6615        var zIndex = this.getZIndex();
6616
6617        if (!isNil(zIndex)) {
6618          this._renderer.setZIndex(zIndex);
6619
6620          if (!this.isCanvasRender()) {
6621            this._renderer.render();
6622          }
6623        }
6624
6625        this.onLoadEnd();
6626      }
6627
6628      return this;
6629    };
6630
6631    _proto.getId = function getId() {
6632      return this._id;
6633    };
6634
6635    _proto.setId = function setId(id) {
6636      var old = this._id;
6637
6638      if (!isNil(id)) {
6639        id = id + '';
6640      }
6641
6642      this._id = id;
6643      this.fire('idchange', {
6644        'old': old,
6645        'new': id
6646      });
6647      return this;
6648    };
6649
6650    _proto.addTo = function addTo(map) {
6651      map.addLayer(this);
6652      return this;
6653    };
6654
6655    _proto.setZIndex = function setZIndex(zIndex) {
6656      this._zIndex = zIndex;
6657
6658      if (isNil(zIndex)) {
6659        delete this.options['zIndex'];
6660      } else {
6661        this.options.zIndex = zIndex;
6662      }
6663
6664      if (this.map) {
6665        this.map._sortLayersByZIndex();
6666      }
6667
6668      if (this._renderer) {
6669        this._renderer.setZIndex(zIndex);
6670      }
6671
6672      return this;
6673    };
6674
6675    _proto.getZIndex = function getZIndex() {
6676      return this._zIndex || 0;
6677    };
6678
6679    _proto.getMinZoom = function getMinZoom() {
6680      var map = this.getMap();
6681      var minZoom = this.options['minZoom'];
6682      return map ? Math.max(map.getMinZoom(), minZoom || 0) : minZoom;
6683    };
6684
6685    _proto.getMaxZoom = function getMaxZoom() {
6686      var map = this.getMap();
6687      var maxZoom = this.options['maxZoom'];
6688      return map ? Math.min(map.getMaxZoom(), isNil(maxZoom) ? Infinity : maxZoom) : maxZoom;
6689    };
6690
6691    _proto.getOpacity = function getOpacity() {
6692      return this.options['opacity'];
6693    };
6694
6695    _proto.setOpacity = function setOpacity(op) {
6696      this.config('opacity', op);
6697      return this;
6698    };
6699
6700    _proto.isCanvasRender = function isCanvasRender() {
6701      var renderer = this._getRenderer();
6702
6703      return renderer && renderer instanceof CanvasRenderer;
6704    };
6705
6706    _proto.getMap = function getMap() {
6707      if (this.map) {
6708        return this.map;
6709      }
6710
6711      return null;
6712    };
6713
6714    _proto.getProjection = function getProjection() {
6715      var map = this.getMap();
6716      return map ? map.getProjection() : null;
6717    };
6718
6719    _proto.bringToFront = function bringToFront() {
6720      var layers = this._getLayerList();
6721
6722      if (!layers.length) {
6723        return this;
6724      }
6725
6726      var topLayer = layers[layers.length - 1];
6727
6728      if (layers.length === 1 || topLayer === this) {
6729        return this;
6730      }
6731
6732      var max = topLayer.getZIndex();
6733      this.setZIndex(max + 1);
6734      return this;
6735    };
6736
6737    _proto.bringToBack = function bringToBack() {
6738      var layers = this._getLayerList();
6739
6740      if (!layers.length) {
6741        return this;
6742      }
6743
6744      var bottomLayer = layers[0];
6745
6746      if (layers.length === 1 || bottomLayer === this) {
6747        return this;
6748      }
6749
6750      var min = bottomLayer.getZIndex();
6751      this.setZIndex(min - 1);
6752      return this;
6753    };
6754
6755    _proto.show = function show() {
6756      var _this2 = this;
6757
6758      if (!this.options['visible']) {
6759        this.options['visible'] = true;
6760        var renderer = this.getRenderer();
6761
6762        if (renderer) {
6763          renderer.show();
6764        }
6765
6766        var map = this.getMap();
6767
6768        if (renderer && map) {
6769          map.once('renderend', function () {
6770            _this2.fire('show');
6771          });
6772        } else {
6773          this.fire('show');
6774        }
6775      }
6776
6777      return this;
6778    };
6779
6780    _proto.hide = function hide() {
6781      var _this3 = this;
6782
6783      if (this.options['visible']) {
6784        this.options['visible'] = false;
6785        var renderer = this.getRenderer();
6786
6787        if (renderer) {
6788          renderer.hide();
6789        }
6790
6791        var map = this.getMap();
6792
6793        if (renderer && map) {
6794          map.once('renderend', function () {
6795            _this3.fire('hide');
6796          });
6797        } else {
6798          this.fire('hide');
6799        }
6800      }
6801
6802      return this;
6803    };
6804
6805    _proto.isVisible = function isVisible() {
6806      if (isNumber(this.options['opacity']) && this.options['opacity'] <= 0) {
6807        return false;
6808      }
6809
6810      var map = this.getMap();
6811
6812      if (map) {
6813        var zoom = map.getZoom();
6814
6815        if (!isNil(this.options['maxZoom']) && this.options['maxZoom'] < zoom || !isNil(this.options['minZoom']) && this.options['minZoom'] > zoom) {
6816          return false;
6817        }
6818      }
6819
6820      if (isNil(this.options['visible'])) {
6821        this.options['visible'] = true;
6822      }
6823
6824      return this.options['visible'];
6825    };
6826
6827    _proto.remove = function remove() {
6828      if (this.map) {
6829        this.map.removeLayer(this);
6830      }
6831
6832      return this;
6833    };
6834
6835    _proto.getMask = function getMask() {
6836      return this._mask;
6837    };
6838
6839    _proto.setMask = function setMask(mask) {
6840      if (!(mask.type === 'Point' && mask._isVectorMarker() || mask.type === 'Polygon' || mask.type === 'MultiPolygon')) {
6841        throw new Error('Mask for a layer must be a marker with vector marker symbol or a Polygon(MultiPolygon).');
6842      }
6843
6844      if (mask.type === 'Point') {
6845        mask.updateSymbol({
6846          'markerLineColor': 'rgba(0, 0, 0, 0)',
6847          'markerFillOpacity': 0
6848        });
6849      } else {
6850        mask.setSymbol({
6851          'lineColor': 'rgba(0, 0, 0, 0)',
6852          'polygonOpacity': 0
6853        });
6854      }
6855
6856      mask._bindLayer(this);
6857
6858      this._mask = mask;
6859
6860      if (!this.getMap() || this.getMap().isZooming()) {
6861        return this;
6862      }
6863
6864      var renderer = this._getRenderer();
6865
6866      if (renderer && renderer.setToRedraw) {
6867        this._getRenderer().setToRedraw();
6868      }
6869
6870      return this;
6871    };
6872
6873    _proto.removeMask = function removeMask() {
6874      delete this._mask;
6875
6876      if (!this.getMap() || this.getMap().isZooming()) {
6877        return this;
6878      }
6879
6880      var renderer = this._getRenderer();
6881
6882      if (renderer && renderer.setToRedraw) {
6883        this._getRenderer().setToRedraw();
6884      }
6885
6886      return this;
6887    };
6888
6889    _proto.onLoad = function onLoad() {
6890      return true;
6891    };
6892
6893    _proto.onLoadEnd = function onLoadEnd() {};
6894
6895    _proto.isLoaded = function isLoaded() {
6896      return !!this._loaded;
6897    };
6898
6899    _proto.getRenderer = function getRenderer() {
6900      return this._getRenderer();
6901    };
6902
6903    _proto.onConfig = function onConfig(conf) {
6904      if (isNumber(conf['opacity']) || conf['cssFilter']) {
6905        var renderer = this.getRenderer();
6906
6907        if (renderer) {
6908          renderer.setToRedraw();
6909        }
6910      }
6911    };
6912
6913    _proto.onAdd = function onAdd() {};
6914
6915    _proto.onRendererCreate = function onRendererCreate() {};
6916
6917    _proto.onCanvasCreate = function onCanvasCreate() {};
6918
6919    _proto.onRemove = function onRemove() {};
6920
6921    _proto._bindMap = function _bindMap(map, zIndex) {
6922      if (!map) {
6923        return;
6924      }
6925
6926      this.map = map;
6927
6928      if (!isNil(zIndex)) {
6929        this.setZIndex(zIndex);
6930      }
6931
6932      this._switchEvents('on', this);
6933
6934      this.onAdd();
6935      this.fire('add');
6936    };
6937
6938    _proto._initRenderer = function _initRenderer() {
6939      var renderer = this.options['renderer'];
6940
6941      if (!this.constructor.getRendererClass) {
6942        return;
6943      }
6944
6945      var clazz = this.constructor.getRendererClass(renderer);
6946
6947      if (!clazz) {
6948        throw new Error('Invalid renderer for Layer(' + this.getId() + '):' + renderer);
6949      }
6950
6951      this._renderer = new clazz(this);
6952      this._renderer.layer = this;
6953
6954      this._renderer.setZIndex(this.getZIndex());
6955
6956      this._switchEvents('on', this._renderer);
6957
6958      if (this._renderer.onAdd) {
6959        this._renderer.onAdd();
6960      }
6961
6962      this.onRendererCreate();
6963      this.fire('renderercreate', {
6964        'renderer': this._renderer
6965      });
6966    };
6967
6968    _proto._doRemove = function _doRemove() {
6969      this._loaded = false;
6970      this.onRemove();
6971
6972      this._switchEvents('off', this);
6973
6974      if (this._renderer) {
6975        this._switchEvents('off', this._renderer);
6976
6977        this._renderer.remove();
6978
6979        delete this._renderer;
6980      }
6981
6982      delete this.map;
6983    };
6984
6985    _proto._switchEvents = function _switchEvents(to, emitter) {
6986      if (emitter && emitter.getEvents) {
6987        this.getMap()[to](emitter.getEvents(), emitter);
6988      }
6989    };
6990
6991    _proto._getRenderer = function _getRenderer() {
6992      return this._renderer;
6993    };
6994
6995    _proto._getLayerList = function _getLayerList() {
6996      if (!this.map) {
6997        return [];
6998      }
6999
7000      return this.map._layers;
7001    };
7002
7003    _proto._getMask2DExtent = function _getMask2DExtent() {
7004      if (!this._mask || !this.getMap()) {
7005        return null;
7006      }
7007
7008      var painter = this._mask._getPainter();
7009
7010      if (!painter) {
7011        return null;
7012      }
7013
7014      return painter.get2DExtent();
7015    };
7016
7017    return Layer;
7018  }(JSONAble(Eventable(Renderable(Class))));
7019
7020  Layer.mergeOptions(options);
7021  var fire = Layer.prototype.fire;
7022
7023  Layer.prototype.fire = function (eventType, param) {
7024    if (eventType === 'layerload') {
7025      this._loaded = true;
7026    }
7027
7028    if (this.map) {
7029      if (!param) {
7030        param = {};
7031      }
7032
7033      param['type'] = eventType;
7034      param['target'] = this;
7035
7036      this.map._onLayerEvent(param);
7037    }
7038
7039    return fire.apply(this, arguments);
7040  };
7041
7042  var DefaultSpatialReference = {
7043    'EPSG:3857': {
7044      'resolutions': function () {
7045        var resolutions = [];
7046        var d = 2 * 6378137 * Math.PI;
7047
7048        for (var i = 0; i < 21; i++) {
7049          resolutions[i] = d / (256 * Math.pow(2, i));
7050        }
7051
7052        return resolutions;
7053      }(),
7054      'fullExtent': {
7055        'top': 6378137 * Math.PI,
7056        'left': -6378137 * Math.PI,
7057        'bottom': -6378137 * Math.PI,
7058        'right': 6378137 * Math.PI
7059      }
7060    },
7061    'EPSG:4326': {
7062      'fullExtent': {
7063        'top': 90,
7064        'left': -180,
7065        'bottom': -90,
7066        'right': 180
7067      },
7068      'resolutions': function () {
7069        var resolutions = [];
7070
7071        for (var i = 0; i < 20; i++) {
7072          resolutions[i] = 180 / (Math.pow(2, i) * 128);
7073        }
7074
7075        return resolutions;
7076      }()
7077    },
7078    'BAIDU': {
7079      'resolutions': function () {
7080        var res = Math.pow(2, 18);
7081        var resolutions = [];
7082
7083        for (var i = 0; i < 20; i++) {
7084          resolutions[i] = res;
7085          res *= 0.5;
7086        }
7087
7088        return resolutions;
7089      }(),
7090      'fullExtent': {
7091        'top': 33554432,
7092        'left': -33554432,
7093        'bottom': -33554432,
7094        'right': 33554432
7095      }
7096    },
7097    'IDENTITY': {
7098      'resolutions': function () {
7099        var res = Math.pow(2, 8);
7100        var resolutions = [];
7101
7102        for (var i = 0; i < 18; i++) {
7103          resolutions[i] = res;
7104          res *= 0.5;
7105        }
7106
7107        return resolutions;
7108      }(),
7109      'fullExtent': {
7110        'top': 200000,
7111        'left': -200000,
7112        'bottom': -200000,
7113        'right': 200000
7114      }
7115    }
7116  };
7117  DefaultSpatialReference['EPSG:4490'] = DefaultSpatialReference['EPSG:4326'];
7118
7119  var SpatialReference = function () {
7120    function SpatialReference(options) {
7121      if (options === void 0) {
7122        options = {};
7123      }
7124
7125      this.options = options;
7126
7127      this._initSpatialRef();
7128    }
7129
7130    SpatialReference.getProjectionInstance = function getProjectionInstance(prjName) {
7131      if (!prjName) {
7132        return null;
7133      }
7134
7135      if (isObject(prjName)) {
7136        return prjName;
7137      }
7138
7139      prjName = (prjName + '').toLowerCase();
7140
7141      for (var p in projections) {
7142        if (hasOwn(projections, p)) {
7143          var code = projections[p]['code'];
7144
7145          if (code && code.toLowerCase() === prjName) {
7146            return projections[p];
7147          }
7148        }
7149      }
7150
7151      return null;
7152    };
7153
7154    SpatialReference.equals = function equals(sp1, sp2) {
7155      if (!sp1 && !sp2) {
7156        return true;
7157      } else if (!sp1 || !sp2) {
7158        return false;
7159      }
7160
7161      if (sp1.projection !== sp2.projection) {
7162        return false;
vendor: 70,579 bytes, lines 7163-9843
7163      }
7164
7165      var f1 = sp1.fullExtent,
7166          f2 = sp2.fullExtent;
7167
7168      if (f1 && !f2 || !f1 && f2) {
7169        return false;
7170      }
7171
7172      if (f1 && f2) {
7173        if (f1.top !== f2.top || f1.bottom !== f2.bottom || f1.left !== f2.left || f1.right !== f2.right) {
7174          return false;
7175        }
7176      }
7177
7178      var r1 = sp1.resolutions,
7179          r2 = sp2.resolutions;
7180
7181      if (r1 && r2) {
7182        if (r1.length !== r2.length) {
7183          return false;
7184        }
7185
7186        for (var i = 0; i < r1.length; i++) {
7187          if (r1[i] !== r2[i]) {
7188            return false;
7189          }
7190        }
7191      }
7192
7193      return true;
7194    };
7195
7196    var _proto = SpatialReference.prototype;
7197
7198    _proto._initSpatialRef = function _initSpatialRef() {
7199      var projection = this.options['projection'];
7200
7201      if (projection) {
7202        projection = SpatialReference.getProjectionInstance(projection);
7203      } else {
7204        projection = DEFAULT$1;
7205      }
7206
7207      if (!projection) {
7208        throw new Error('must provide a valid projection in map\'s spatial reference.');
7209      }
7210
7211      projection = extend({}, Common, projection);
7212
7213      if (!projection.measureLength) {
7214        extend(projection, Measurer.DEFAULT);
7215      }
7216
7217      this._projection = projection;
7218      var defaultSpatialRef,
7219          resolutions = this.options['resolutions'];
7220
7221      if (!resolutions) {
7222        if (projection['code']) {
7223          defaultSpatialRef = DefaultSpatialReference[projection['code']];
7224
7225          if (defaultSpatialRef) {
7226            resolutions = defaultSpatialRef['resolutions'];
7227            this.isEPSG = projection['code'] !== 'IDENTITY';
7228          }
7229        }
7230
7231        if (!resolutions) {
7232          throw new Error('must provide valid resolutions in map\'s spatial reference.');
7233        }
7234      }
7235
7236      this._resolutions = resolutions;
7237      var fullExtent = this.options['fullExtent'];
7238
7239      if (!fullExtent) {
7240        if (projection['code']) {
7241          defaultSpatialRef = DefaultSpatialReference[projection['code']];
7242
7243          if (defaultSpatialRef) {
7244            fullExtent = defaultSpatialRef['fullExtent'];
7245          }
7246        }
7247
7248        if (!fullExtent) {
7249          throw new Error('must provide a valid fullExtent in map\'s spatial reference.');
7250        }
7251      }
7252
7253      if (!isNil(fullExtent['left'])) {
7254        this._fullExtent = new Extent(new Coordinate(fullExtent['left'], fullExtent['top']), new Coordinate(fullExtent['right'], fullExtent['bottom']));
7255      } else {
7256        this._fullExtent = new Extent(fullExtent);
7257        fullExtent['left'] = fullExtent['xmin'];
7258        fullExtent['right'] = fullExtent['xmax'];
7259        fullExtent['top'] = fullExtent['ymax'];
7260        fullExtent['bottom'] = fullExtent['ymin'];
7261      }
7262
7263      if (isNil(fullExtent['top']) || isNil(fullExtent['bottom']) || isNil(fullExtent['left']) || isNil(fullExtent['right'])) {
7264        throw new Error('must provide valid top/bottom/left/right in fullExtent.');
7265      }
7266
7267      extend(this._fullExtent, fullExtent);
7268      this._projection.fullExtent = fullExtent;
7269      var a = fullExtent['right'] >= fullExtent['left'] ? 1 : -1,
7270          b = fullExtent['top'] >= fullExtent['bottom'] ? -1 : 1;
7271      this._transformation = new Transformation([a, b, 0, 0]);
7272    };
7273
7274    _proto.getResolutions = function getResolutions() {
7275      return this._resolutions || [];
7276    };
7277
7278    _proto.getResolution = function getResolution(zoom) {
7279      var z = zoom | 0;
7280
7281      if (z < 0) {
7282        z = 0;
7283      } else if (z > this._resolutions.length - 1) {
7284        z = this._resolutions.length - 1;
7285      }
7286
7287      var res = this._resolutions[z];
7288
7289      if (z !== zoom && zoom > 0 && z < this._resolutions.length - 1) {
7290        var next = this._resolutions[z + 1];
7291        return res + (next - res) * (zoom - z);
7292      }
7293
7294      return res;
7295    };
7296
7297    _proto.getProjection = function getProjection() {
7298      return this._projection;
7299    };
7300
7301    _proto.getFullExtent = function getFullExtent() {
7302      return this._fullExtent;
7303    };
7304
7305    _proto.getTransformation = function getTransformation() {
7306      return this._transformation;
7307    };
7308
7309    _proto.getMinZoom = function getMinZoom() {
7310      for (var i = 0; i < this._resolutions.length; i++) {
7311        if (!isNil(this._resolutions[i])) {
7312          return i;
7313        }
7314      }
7315
7316      return 0;
7317    };
7318
7319    _proto.getMaxZoom = function getMaxZoom() {
7320      for (var i = this._resolutions.length - 1; i >= 0; i--) {
7321        if (!isNil(this._resolutions[i])) {
7322          return i;
7323        }
7324      }
7325
7326      return this._resolutions.length - 1;
7327    };
7328
7329    _proto.getZoomDirection = function getZoomDirection() {
7330      return sign(this._resolutions[this.getMinZoom()] - this._resolutions[this.getMaxZoom()]);
7331    };
7332
7333    _proto.toJSON = function toJSON() {
7334      if (!this.json) {
7335        this.json = {
7336          'resolutions': this._resolutions,
7337          'fullExtent': {
7338            'top': this._fullExtent.top,
7339            'left': this._fullExtent.left,
7340            'bottom': this._fullExtent.bottom,
7341            'right': this._fullExtent.right
7342          },
7343          'projection': this._projection.code
7344        };
7345      }
7346
7347      return this.json;
7348    };
7349
7350    return SpatialReference;
7351  }();
7352
7353  var options$1 = {
7354    'maxVisualPitch': 60,
7355    'maxPitch': 80,
7356    'centerCross': false,
7357    'zoomInCenter': false,
7358    'zoomOrigin': null,
7359    'zoomAnimation': function () {
7360      return !IS_NODE;
7361    }(),
7362    'zoomAnimationDuration': 330,
7363    'panAnimation': function () {
7364      return !IS_NODE;
7365    }(),
7366    'panAnimationDuration': 600,
7367    'zoomable': true,
7368    'enableInfoWindow': true,
7369    'hitDetect': function () {
7370      return !Browser$1.mobile;
7371    }(),
7372    'hitDetectLimit': 5,
7373    'fpsOnInteracting': 25,
7374    'layerCanvasLimitOnInteracting': -1,
7375    'maxZoom': null,
7376    'minZoom': null,
7377    'maxExtent': null,
7378    'fixCenterOnResize': false,
7379    'checkSize': true,
7380    'checkSizeInterval': 1000,
7381    'renderer': 'canvas'
7382  };
7383
7384  var Map$1 = function (_Handlerable) {
7385    _inheritsLoose(Map, _Handlerable);
7386
7387    function Map(container, options) {
7388      var _this;
7389
7390      if (!options) {
7391        throw new Error('Invalid options when creating map.');
7392      }
7393
7394      if (!options['center']) {
7395        throw new Error('Invalid center when creating map.');
7396      }
7397
7398      var opts = extend({}, options);
7399      var zoom = opts['zoom'];
7400      delete opts['zoom'];
7401      var center = new Coordinate(opts['center']);
7402      delete opts['center'];
7403      var baseLayer = opts['baseLayer'];
7404      delete opts['baseLayer'];
7405      var layers = opts['layers'];
7406      delete opts['layers'];
7407      _this = _Handlerable.call(this, opts) || this;
7408      _this.VERSION = Map.VERSION;
7409      Object.defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), 'id', {
7410        value: UID(),
7411        writable: false
7412      });
7413      _this._loaded = false;
7414
7415      _this._initContainer(container);
7416
7417      _this._panels = {};
7418      _this._baseLayer = null;
7419      _this._layers = [];
7420      _this._zoomLevel = zoom;
7421      _this._center = center;
7422
7423      _this.setSpatialReference(opts['spatialReference'] || opts['view']);
7424
7425      _this._mapViewPoint = new Point(0, 0);
7426
7427      _this._initRenderer();
7428
7429      _this._updateMapSize(_this._getContainerDomSize());
7430
7431      if (baseLayer) {
7432        _this.setBaseLayer(baseLayer);
7433      }
7434
7435      if (layers) {
7436        _this.addLayer(layers);
7437      }
7438
7439      _this._Load();
7440
7441      return _this;
7442    }
7443
7444    Map.addOnLoadHook = function addOnLoadHook(fn) {
7445      var args = Array.prototype.slice.call(arguments, 1);
7446      var onload = typeof fn === 'function' ? fn : function () {
7447        this[fn].apply(this, args);
7448      };
7449      this.prototype._onLoadHooks = this.prototype._onLoadHooks || [];
7450
7451      this.prototype._onLoadHooks.push(onload);
7452
7453      return this;
7454    };
7455
7456    var _proto = Map.prototype;
7457
7458    _proto.isLoaded = function isLoaded() {
7459      return !!this._loaded;
7460    };
7461
7462    _proto.getContainer = function getContainer() {
7463      return this._containerDOM;
7464    };
7465
7466    _proto.getSpatialReference = function getSpatialReference() {
7467      return this._spatialReference;
7468    };
7469
7470    _proto.setSpatialReference = function setSpatialReference(ref) {
7471      var oldRef = this.options['spatialReference'];
7472
7473      if (this._loaded && SpatialReference.equals(oldRef, ref)) {
7474        return this;
7475      }
7476
7477      this._updateSpatialReference(ref, oldRef);
7478
7479      return this;
7480    };
7481
7482    _proto._updateSpatialReference = function _updateSpatialReference(ref, oldRef) {
7483      ref = extend({}, ref);
7484      this._center = this.getCenter();
7485      this.options['spatialReference'] = ref;
7486      this._spatialReference = new SpatialReference(ref);
7487
7488      if (this.options['spatialReference'] && isFunction(this.options['spatialReference']['projection'])) {
7489        var projection = this._spatialReference.getProjection();
7490
7491        this.options['spatialReference']['projection'] = projection['code'];
7492      }
7493
7494      this._resetMapStatus();
7495
7496      this._fireEvent('spatialreferencechange', {
7497        'old': oldRef,
7498        'new': extend({}, this.options['spatialReference'])
7499      });
7500
7501      return this;
7502    };
7503
7504    _proto.onConfig = function onConfig(conf) {
7505      var ref = conf['spatialReference'] || conf['view'];
7506
7507      if (!isNil(ref)) {
7508        this._updateSpatialReference(ref, null);
7509      }
7510
7511      return this;
7512    };
7513
7514    _proto.getProjection = function getProjection() {
7515      if (!this._spatialReference) {
7516        return null;
7517      }
7518
7519      return this._spatialReference.getProjection();
7520    };
7521
7522    _proto.getFullExtent = function getFullExtent() {
7523      if (!this._spatialReference) {
7524        return null;
7525      }
7526
7527      return this._spatialReference.getFullExtent();
7528    };
7529
7530    _proto.setCursor = function setCursor(cursor) {
7531      delete this._cursor;
7532
7533      this._trySetCursor(cursor);
7534
7535      this._cursor = cursor;
7536      return this;
7537    };
7538
7539    _proto.resetCursor = function resetCursor() {
7540      return this.setCursor(null);
7541    };
7542
7543    _proto.getCenter = function getCenter() {
7544      if (!this._loaded || !this._prjCenter) {
7545        return this._center;
7546      }
7547
7548      var projection = this.getProjection();
7549      return projection.unproject(this._prjCenter);
7550    };
7551
7552    _proto.setCenter = function setCenter(center) {
7553      if (!center) {
7554        return this;
7555      }
7556
7557      center = new Coordinate(center);
7558      var projection = this.getProjection();
7559      var pcenter = projection.project(center);
7560
7561      if (!this._verifyExtent(pcenter)) {
7562        return this;
7563      }
7564
7565      if (!this._loaded) {
7566        this._center = center;
7567        return this;
7568      }
7569
7570      this.onMoveStart();
7571
7572      this._setPrjCenter(pcenter);
7573
7574      this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));
7575      return this;
7576    };
7577
7578    _proto.getSize = function getSize() {
7579      if (isNil(this.width) || isNil(this.height)) {
7580        return this._getContainerDomSize();
7581      }
7582
7583      return new Size(this.width, this.height);
7584    };
7585
7586    _proto.getContainerExtent = function getContainerExtent() {
7587      var visualHeight = this.height;
7588      var pitch = this.getPitch(),
7589          maxVisualPitch = this.options['maxVisualPitch'];
7590
7591      if (maxVisualPitch && pitch > maxVisualPitch) {
7592        visualHeight = this._getVisualHeight(maxVisualPitch);
7593      }
7594
7595      return new PointExtent(0, this.height - visualHeight, this.width, this.height);
7596    };
7597
7598    _proto._getVisualHeight = function _getVisualHeight(maxVisualPitch) {
7599      var pitch = this.getPitch();
7600      var visualDistance = this.height / 2 * Math.tan(maxVisualPitch * Math.PI / 180);
7601      return this.height / 2 + visualDistance * Math.tan((90 - pitch) * Math.PI / 180);
7602    };
7603
7604    _proto.getExtent = function getExtent() {
7605      return this._pointToExtent(this._get2DExtent());
7606    };
7607
7608    _proto.getProjExtent = function getProjExtent() {
7609      var extent2D = this._get2DExtent();
7610
7611      return new Extent(this._pointToPrj(extent2D.getMin()), this._pointToPrj(extent2D.getMax()));
7612    };
7613
7614    _proto.getPrjExtent = function getPrjExtent() {
7615      return this.getProjExtent();
7616    };
7617
7618    _proto.getMaxExtent = function getMaxExtent() {
7619      if (!this.options['maxExtent']) {
7620        return null;
7621      }
7622
7623      return new Extent(this.options['maxExtent'], this.getProjection());
7624    };
7625
7626    _proto.setMaxExtent = function setMaxExtent(extent) {
7627      if (extent) {
7628        var maxExt = new Extent(extent, this.getProjection());
7629        this.options['maxExtent'] = maxExt;
7630
7631        if (!this._verifyExtent(this._getPrjCenter())) {
7632          this._panTo(this._prjMaxExtent().getCenter());
7633        }
7634
7635        var projection = this.getProjection();
7636        this._prjMaxExtent = maxExt.convertTo(function (c) {
7637          return projection.project(c);
7638        });
7639      } else {
7640        delete this.options['maxExtent'];
7641        delete this._prjMaxExtent;
7642      }
7643
7644      return this;
7645    };
7646
7647    _proto.getZoom = function getZoom() {
7648      return this._zoomLevel;
7649    };
7650
7651    _proto.getZoomForScale = function getZoomForScale(scale, fromZoom, isFraction) {
7652      var zoom = this.getZoom();
7653
7654      if (isNil(fromZoom)) {
7655        fromZoom = zoom;
7656      }
7657
7658      if (scale === 1 && fromZoom === zoom) {
7659        return zoom;
7660      }
7661
7662      var res = this._getResolution(fromZoom),
7663          targetRes = res / scale;
7664
7665      var scaleZoom = this.getZoomFromRes(targetRes);
7666
7667      if (isFraction) {
7668        return scaleZoom;
7669      } else {
7670        var delta = 1E-6;
7671        return this.getSpatialReference().getZoomDirection() < 0 ? Math.ceil(scaleZoom - delta) : Math.floor(scaleZoom + delta);
7672      }
7673    };
7674
7675    _proto.getZoomFromRes = function getZoomFromRes(res) {
7676      var resolutions = this._getResolutions(),
7677          minRes = this._getResolution(this.getMinZoom()),
7678          maxRes = this._getResolution(this.getMaxZoom());
7679
7680      if (minRes <= maxRes) {
7681        if (res <= minRes) {
7682          return this.getMinZoom();
7683        } else if (res >= maxRes) {
7684          return this.getMaxZoom();
7685        }
7686      } else if (res >= minRes) {
7687        return this.getMinZoom();
7688      } else if (res <= maxRes) {
7689        return this.getMaxZoom();
7690      }
7691
7692      var l = resolutions.length;
7693
7694      for (var i = 0; i < l - 1; i++) {
7695        if (!resolutions[i]) {
7696          continue;
7697        }
7698
7699        var gap = resolutions[i + 1] - resolutions[i];
7700        var test = res - resolutions[i];
7701
7702        if (sign(gap) === sign(test) && Math.abs(gap) >= Math.abs(test)) {
7703          return i + test / gap;
7704        }
7705      }
7706
7707      return l - 1;
7708    };
7709
7710    _proto.setZoom = function setZoom(zoom, options) {
7711      if (options === void 0) {
7712        options = {
7713          'animation': true
7714        };
7715      }
7716
7717      if (isNaN(zoom) || isNil(zoom)) {
7718        return this;
7719      }
7720
7721      zoom = +zoom;
7722
7723      if (this._loaded && this.options['zoomAnimation'] && options['animation']) {
7724        this._zoomAnimation(zoom);
7725      } else {
7726        this._zoom(zoom);
7727      }
7728
7729      return this;
7730    };
7731
7732    _proto.getMaxZoom = function getMaxZoom() {
7733      if (!isNil(this.options['maxZoom'])) {
7734        return this.options['maxZoom'];
7735      }
7736
7737      return this.getMaxNativeZoom();
7738    };
7739
7740    _proto.setMaxZoom = function setMaxZoom(maxZoom) {
7741      var viewMaxZoom = this.getMaxNativeZoom();
7742
7743      if (maxZoom > viewMaxZoom) {
7744        maxZoom = viewMaxZoom;
7745      }
7746
7747      if (maxZoom !== null && maxZoom < this._zoomLevel) {
7748        this.setZoom(maxZoom);
7749        maxZoom = +maxZoom;
7750      }
7751
7752      this.options['maxZoom'] = maxZoom;
7753      return this;
7754    };
7755
7756    _proto.getMinZoom = function getMinZoom() {
7757      if (!isNil(this.options['minZoom'])) {
7758        return this.options['minZoom'];
7759      }
7760
7761      return this._spatialReference.getMinZoom();
7762    };
7763
7764    _proto.setMinZoom = function setMinZoom(minZoom) {
7765      if (minZoom !== null) {
7766        minZoom = +minZoom;
7767
7768        var viewMinZoom = this._spatialReference.getMinZoom();
7769
7770        if (minZoom < viewMinZoom) {
7771          minZoom = viewMinZoom;
7772        }
7773
7774        if (minZoom > this._zoomLevel) {
7775          this.setZoom(minZoom);
7776        }
7777      }
7778
7779      this.options['minZoom'] = minZoom;
7780      return this;
7781    };
7782
7783    _proto.getMaxNativeZoom = function getMaxNativeZoom() {
7784      var ref = this.getSpatialReference();
7785
7786      if (!ref) {
7787        return null;
7788      }
7789
7790      return ref.getMaxZoom();
7791    };
7792
7793    _proto.getGLZoom = function getGLZoom() {
7794      return this.getMaxNativeZoom() / 2;
7795    };
7796
7797    _proto.getGLScale = function getGLScale(zoom) {
7798      if (isNil(zoom)) {
7799        zoom = this.getZoom();
7800      }
7801
7802      return this._getResolution(zoom) / this._getResolution(this.getGLZoom());
7803    };
7804
7805    _proto.zoomIn = function zoomIn() {
7806      return this.setZoom(this.getZoom() + 1);
7807    };
7808
7809    _proto.zoomOut = function zoomOut() {
7810      return this.setZoom(this.getZoom() - 1);
7811    };
7812
7813    _proto.isZooming = function isZooming() {
7814      return !!this._zooming;
7815    };
7816
7817    _proto.isInteracting = function isInteracting() {
7818      return this.isZooming() || this.isMoving() || this.isRotating();
7819    };
7820
7821    _proto.setCenterAndZoom = function setCenterAndZoom(center, zoom) {
7822      if (!isNil(zoom) && this._zoomLevel !== zoom) {
7823        this.setCenter(center);
7824        this.setZoom(zoom, {
7825          animation: false
7826        });
7827      } else {
7828        this.setCenter(center);
7829      }
7830
7831      return this;
7832    };
7833
7834    _proto.getFitZoom = function getFitZoom(extent) {
7835      var _this2 = this;
7836
7837      if (!extent || !(extent instanceof Extent)) {
7838        return this._zoomLevel;
7839      }
7840
7841      if (extent['xmin'] === extent['xmax'] && extent['ymin'] === extent['ymax']) {
7842        return this.getMaxZoom();
7843      }
7844
7845      var size = this.getSize();
7846      var containerExtent = extent.convertTo(function (p) {
7847        return _this2.coordToContainerPoint(p);
7848      });
7849      var w = containerExtent.getWidth(),
7850          h = containerExtent.getHeight();
7851      var scaleX = size['width'] / w,
7852          scaleY = size['height'] / h;
7853      var scale = this.getSpatialReference().getZoomDirection() < 0 ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);
7854      var zoom = this.getZoomForScale(scale);
7855      return zoom;
7856    };
7857
7858    _proto.getView = function getView() {
7859      return {
7860        'center': this.getCenter().toArray(),
7861        'zoom': this.getZoom(),
7862        'pitch': this.getPitch(),
7863        'bearing': this.getBearing()
7864      };
7865    };
7866
7867    _proto.setView = function setView(view) {
7868      if (!view) {
7869        return this;
7870      }
7871
7872      if (view['center']) {
7873        this.setCenter(view['center']);
7874      }
7875
7876      if (view['zoom'] !== null && !isNaN(+view['zoom'])) {
7877        this.setZoom(+view['zoom'], {
7878          'animation': false
7879        });
7880      }
7881
7882      if (view['pitch'] !== null && !isNaN(+view['pitch'])) {
7883        this.setPitch(+view['pitch']);
7884      }
7885
7886      if (view['pitch'] !== null && !isNaN(+view['bearing'])) {
7887        this.setBearing(+view['bearing']);
7888      }
7889
7890      return this;
7891    };
7892
7893    _proto.getResolution = function getResolution(zoom) {
7894      return this._getResolution(zoom);
7895    };
7896
7897    _proto.getScale = function getScale(zoom) {
7898      var z = isNil(zoom) ? this.getZoom() : zoom;
7899
7900      var max = this._getResolution(this.getMaxNativeZoom()),
7901          res = this._getResolution(z);
7902
7903      return res / max;
7904    };
7905
7906    _proto.fitExtent = function fitExtent(extent, zoomOffset, options, step) {
7907      if (options === void 0) {
7908        options = {};
7909      }
7910
7911      if (!extent) {
7912        return this;
7913      }
7914
7915      extent = new Extent(extent, this.getProjection());
7916      var zoom = this.getFitZoom(extent) + (zoomOffset || 0);
7917      var center = extent.getCenter();
7918      if (typeof options['animation'] === 'undefined' || options['animation']) return this._animateTo({
7919        center: center,
7920        zoom: zoom
7921      }, {
7922        'duration': options['duration'] || this.options['zoomAnimationDuration'],
7923        'easing': options['easing'] || 'out'
7924      }, step);else return this.setCenterAndZoom(center, zoom);
7925    };
7926
7927    _proto.getBaseLayer = function getBaseLayer() {
7928      return this._baseLayer;
7929    };
7930
7931    _proto.setBaseLayer = function setBaseLayer(baseLayer) {
7932      var isChange = false;
7933
7934      if (this._baseLayer) {
7935        isChange = true;
7936
7937        this._fireEvent('baselayerchangestart');
7938
7939        this._baseLayer.remove();
7940      }
7941
7942      if (!baseLayer) {
7943        delete this._baseLayer;
7944
7945        this._fireEvent('baselayerchangeend');
7946
7947        this._fireEvent('setbaselayer');
7948
7949        return this;
7950      }
7951
7952      this._baseLayer = baseLayer;
7953
7954      baseLayer._bindMap(this, -1);
7955
7956      function onbaseLayerload() {
7957        this._fireEvent('baselayerload');
7958
7959        if (isChange) {
7960          isChange = false;
7961
7962          this._fireEvent('baselayerchangeend');
7963        }
7964      }
7965
7966      this._baseLayer.on('layerload', onbaseLayerload, this);
7967
7968      if (this._loaded) {
7969        this._baseLayer.load();
7970      }
7971
7972      this._fireEvent('setbaselayer');
7973
7974      return this;
7975    };
7976
7977    _proto.removeBaseLayer = function removeBaseLayer() {
7978      if (this._baseLayer) {
7979        this._baseLayer.remove();
7980
7981        delete this._baseLayer;
7982
7983        this._fireEvent('baselayerremove');
7984      }
7985
7986      return this;
7987    };
7988
7989    _proto.getLayers = function getLayers(filter) {
7990      return this._getLayers(function (layer) {
7991        if (layer === this._baseLayer || layer.getId().indexOf(INTERNAL_LAYER_PREFIX) >= 0) {
7992          return false;
7993        }
7994
7995        if (filter) {
7996          return filter(layer);
7997        }
7998
7999        return true;
8000      });
8001    };
8002
8003    _proto.getLayer = function getLayer(id) {
8004      if (!id) {
8005        return null;
8006      }
8007
8008      var layer = this._layerCache ? this._layerCache[id] : null;
8009
8010      if (layer) {
8011        return layer;
8012      }
8013
8014      var baseLayer = this.getBaseLayer();
8015
8016      if (baseLayer && baseLayer.getId() === id) {
8017        return baseLayer;
8018      }
8019
8020      return null;
8021    };
8022
8023    _proto.addLayer = function addLayer(layers) {
8024      if (!layers) {
8025        return this;
8026      }
8027
8028      if (!Array.isArray(layers)) {
8029        layers = Array.prototype.slice.call(arguments, 0);
8030        return this.addLayer(layers);
8031      }
8032
8033      if (!this._layerCache) {
8034        this._layerCache = {};
8035      }
8036
8037      var mapLayers = this._layers;
8038
8039      for (var i = 0, len = layers.length; i < len; i++) {
8040        var layer = layers[i];
8041        var id = layer.getId();
8042
8043        if (isNil(id)) {
8044          throw new Error('Invalid id for the layer: ' + id);
8045        }
8046
8047        if (layer.getMap() === this) {
8048          continue;
8049        }
8050
8051        if (this._layerCache[id]) {
8052          throw new Error('Duplicate layer id in the map: ' + id);
8053        }
8054
8055        this._layerCache[id] = layer;
8056
8057        layer._bindMap(this);
8058
8059        mapLayers.push(layer);
8060
8061        if (this._loaded) {
8062          layer.load();
8063        }
8064      }
8065
8066      this._sortLayersByZIndex();
8067
8068      this._fireEvent('addlayer', {
8069        'layers': layers
8070      });
8071
8072      return this;
8073    };
8074
8075    _proto.removeLayer = function removeLayer(layers) {
8076      if (!layers) {
8077        return this;
8078      }
8079
8080      if (!Array.isArray(layers)) {
8081        return this.removeLayer([layers]);
8082      }
8083
8084      var removed = [];
8085
8086      for (var i = 0, len = layers.length; i < len; i++) {
8087        var layer = layers[i];
8088
8089        if (!(layer instanceof Layer)) {
8090          layer = this.getLayer(layer);
8091        }
8092
8093        if (!layer) {
8094          continue;
8095        }
8096
8097        var map = layer.getMap();
8098
8099        if (!map || map !== this) {
8100          continue;
8101        }
8102
8103        removed.push(layer);
8104
8105        this._removeLayer(layer, this._layers);
8106
8107        if (this._loaded) {
8108          layer._doRemove();
8109        }
8110
8111        var id = layer.getId();
8112
8113        if (this._layerCache) {
8114          delete this._layerCache[id];
8115        }
8116      }
8117
8118      if (removed.length > 0) {
8119        var renderer = this.getRenderer();
8120
8121        if (renderer) {
8122          renderer.setLayerCanvasUpdated();
8123        }
8124
8125        this.once('frameend', function () {
8126          removed.forEach(function (layer) {
8127            layer.fire('remove');
8128          });
8129        });
8130      }
8131
8132      this._fireEvent('removelayer', {
8133        'layers': layers
8134      });
8135
8136      return this;
8137    };
8138
8139    _proto.sortLayers = function sortLayers(layers) {
8140      if (!layers || !Array.isArray(layers)) {
8141        return this;
8142      }
8143
8144      var layersToOrder = [];
8145      var minZ = Number.MAX_VALUE;
8146
8147      for (var i = 0, l = layers.length; i < l; i++) {
8148        var layer = layers[i];
8149
8150        if (isString(layers[i])) {
8151          layer = this.getLayer(layer);
8152        }
8153
8154        if (!(layer instanceof Layer) || !layer.getMap() || layer.getMap() !== this) {
8155          throw new Error('It must be a layer added to this map to order.');
8156        }
8157
8158        if (layer.getZIndex() < minZ) {
8159          minZ = layer.getZIndex();
8160        }
8161
8162        layersToOrder.push(layer);
8163      }
8164
8165      for (var _i = 0, _l = layersToOrder.length; _i < _l; _i++) {
8166        layersToOrder[_i].setZIndex(minZ + _i);
8167      }
8168
8169      return this;
8170    };
8171
8172    _proto.toDataURL = function toDataURL(options) {
8173      if (!options) {
8174        options = {};
8175      }
8176
8177      var mimeType = options['mimeType'];
8178
8179      if (!mimeType) {
8180        mimeType = 'image/png';
8181      }
8182
8183      var save = options['save'];
8184
8185      var renderer = this._getRenderer();
8186
8187      if (renderer && renderer.toDataURL) {
8188        var file = options['fileName'];
8189
8190        if (!file) {
8191          file = 'export';
8192        }
8193
8194        var dataURL = renderer.toDataURL(mimeType);
8195
8196        if (save && dataURL) {
8197          var imgURL;
8198
8199          if (typeof Blob !== 'undefined' && typeof atob !== 'undefined') {
8200            var blob = b64toBlob(dataURL.replace(/^data:image\/(png|jpeg|jpg);base64,/, ''), mimeType);
8201            imgURL = URL.createObjectURL(blob);
8202          } else {
8203            imgURL = dataURL;
8204          }
8205
8206          var dlLink = document.createElement('a');
8207          dlLink.download = file;
8208          dlLink.href = imgURL;
8209          document.body.appendChild(dlLink);
8210          dlLink.click();
8211          document.body.removeChild(dlLink);
8212        }
8213
8214        return dataURL;
8215      }
8216
8217      return null;
8218    };
8219
8220    _proto.coordToPoint = function coordToPoint(coordinate, zoom, out) {
8221      return this.coordinateToPoint(coordinate, zoom, out);
8222    };
8223
8224    _proto.pointToCoord = function pointToCoord(point, zoom, out) {
8225      return this.pointToCoordinate(point, zoom, out);
8226    };
8227
8228    _proto.coordToViewPoint = function coordToViewPoint(coordinate, out) {
8229      return this.coordinateToViewPoint(coordinate, out);
8230    };
8231
8232    _proto.viewPointToCoord = function viewPointToCoord(viewPoint, out) {
8233      return this.viewPointToCoordinate(viewPoint, out);
8234    };
8235
8236    _proto.coordToContainerPoint = function coordToContainerPoint(coordinate, zoom, out) {
8237      return this.coordinateToContainerPoint(coordinate, zoom, out);
8238    };
8239
8240    _proto.containerPointToCoord = function containerPointToCoord(containerPoint, out) {
8241      return this.containerPointToCoordinate(containerPoint, out);
8242    };
8243
8244    _proto.containerPointToViewPoint = function containerPointToViewPoint(containerPoint, out) {
8245      if (out) {
8246        out.set(containerPoint.x, containerPoint.y);
8247      } else {
8248        out = containerPoint.copy();
8249      }
8250
8251      return out._sub(this.getViewPoint());
8252    };
8253
8254    _proto.viewPointToContainerPoint = function viewPointToContainerPoint(viewPoint, out) {
8255      if (out) {
8256        out.set(viewPoint.x, viewPoint.y);
8257      } else {
8258        out = viewPoint.copy();
8259      }
8260
8261      return out._add(this.getViewPoint());
8262    };
8263
8264    _proto.checkSize = function checkSize() {
8265      var justStart = now() - this._initTime < 1500 && this.width === 0 || this.height === 0;
8266
8267      var watched = this._getContainerDomSize(),
8268          oldHeight = this.height,
8269          oldWidth = this.width;
8270
8271      if (watched['width'] === oldWidth && watched['height'] === oldHeight) {
8272        return this;
8273      }
8274
8275      var center = this.getCenter();
8276
8277      this._updateMapSize(watched);
8278
8279      if (!this.options['fixCenterOnResize']) {
8280        var resizeOffset = new Point((oldWidth - watched.width) / 2, (oldHeight - watched.height) / 2);
8281
8282        this._offsetCenterByPixel(resizeOffset);
8283
8284        this._mapViewCoord = this._getPrjCenter();
8285      }
8286
8287      var hided = watched['width'] === 0 || watched['height'] === 0 || oldWidth === 0 || oldHeight === 0;
8288
8289      if (justStart || hided) {
8290        this._noEvent = true;
8291        this.setCenter(center);
8292        delete this._noEvent;
8293      }
8294
8295      this._fireEvent('resize');
8296
8297      return this;
8298    };
8299
8300    _proto.locate = function locate(coordinate, dx, dy) {
8301      return this.getProjection()._locate(new Coordinate(coordinate), dx, dy);
8302    };
8303
8304    _proto.getMainPanel = function getMainPanel() {
8305      return this._getRenderer().getMainPanel();
8306    };
8307
8308    _proto.getPanels = function getPanels() {
8309      return this._panels;
8310    };
8311
8312    _proto.remove = function remove() {
8313      if (this.isRemoved()) {
8314        return this;
8315      }
8316
8317      this._fireEvent('removestart');
8318
8319      this._removeDomEvents();
8320
8321      this._clearHandlers();
8322
8323      this.removeBaseLayer();
8324      var layers = this.getLayers();
8325
8326      for (var i = 0; i < layers.length; i++) {
8327        layers[i].remove();
8328      }
8329
8330      if (this._getRenderer()) {
8331        this._getRenderer().remove();
8332      }
8333
8334      if (this._containerDOM.innerHTML) {
8335        this._containerDOM.innerHTML = '';
8336      }
8337
8338      delete this._panels;
8339      delete this._containerDOM;
8340      delete this.renderer;
8341
8342      this._fireEvent('removeend');
8343
8344      this._clearAllListeners();
8345
8346      return this;
8347    };
8348
8349    _proto.isRemoved = function isRemoved() {
8350      return !this._containerDOM;
8351    };
8352
8353    _proto.isMoving = function isMoving() {
8354      return !!this._moving;
8355    };
8356
8357    _proto.onMoveStart = function onMoveStart(param) {
8358      this._originCenter = this._getPrjCenter();
8359      this._moving = true;
8360
8361      this._trySetCursor('move');
8362
8363      this._fireEvent('movestart', this._parseEvent(param ? param['domEvent'] : null, 'movestart'));
8364    };
8365
8366    _proto.onMoving = function onMoving(param) {
8367      this._fireEvent('moving', this._parseEvent(param ? param['domEvent'] : null, 'moving'));
8368    };
8369
8370    _proto.onMoveEnd = function onMoveEnd(param) {
8371      this._moving = false;
8372
8373      this._trySetCursor('default');
8374
8375      this._fireEvent('moveend', param && param['domEvent'] ? this._parseEvent(param['domEvent'], 'moveend') : param);
8376
8377      if (!this._verifyExtent(this._getPrjCenter())) {
8378        var moveTo = this._originCenter;
8379
8380        if (!this._verifyExtent(moveTo)) {
8381          moveTo = this.getMaxExtent().getCenter();
8382        }
8383
8384        this._panTo(moveTo);
8385      }
8386    };
8387
8388    _proto.onDragRotateStart = function onDragRotateStart(param) {
8389      this._dragRotating = true;
8390
8391      this._fireEvent('dragrotatestart', this._parseEvent(param ? param['domEvent'] : null, 'dragrotatestart'));
8392    };
8393
8394    _proto.onDragRotating = function onDragRotating(param) {
8395      this._fireEvent('dragrotating', this._parseEvent(param ? param['domEvent'] : null, 'dragrotating'));
8396    };
8397
8398    _proto.onDragRotateEnd = function onDragRotateEnd(param) {
8399      this._dragRotating = false;
8400
8401      this._fireEvent('dragrotateend', this._parseEvent(param ? param['domEvent'] : null, 'dragrotateend'));
8402    };
8403
8404    _proto.isDragRotating = function isDragRotating() {
8405      return !!this._dragRotating;
8406    };
8407
8408    _proto.getRenderer = function getRenderer() {
8409      return this._getRenderer();
8410    };
8411
8412    _proto.getDevicePixelRatio = function getDevicePixelRatio() {
8413      return this.options['devicePixelRatio'] || Math.ceil(Browser$1.devicePixelRatio) || 1;
8414    };
8415
8416    _proto._initContainer = function _initContainer(container) {
8417      if (isString(container)) {
8418        this._containerDOM = document.getElementById(container);
8419
8420        if (!this._containerDOM) {
8421          throw new Error('Invalid container when creating map: \'' + container + '\'');
8422        }
8423      } else {
8424        this._containerDOM = container;
8425
8426        if (IS_NODE) {
8427          this.CanvasClass = this._containerDOM.constructor;
8428        }
8429      }
8430
8431      if (this._containerDOM.childNodes && this._containerDOM.childNodes.length > 0) {
8432        if (this._containerDOM.childNodes[0].className === 'maptalks-wrapper') {
8433          throw new Error('Container is already loaded with another map instance, use map.remove() to clear it.');
8434        }
8435      }
8436    };
8437
8438    _proto._trySetCursor = function _trySetCursor(cursor) {
8439      if (!this._cursor && !this._priorityCursor) {
8440        if (!cursor) {
8441          cursor = 'default';
8442        }
8443
8444        this._setCursorToPanel(cursor);
8445      }
8446
8447      return this;
8448    };
8449
8450    _proto._setPriorityCursor = function _setPriorityCursor(cursor) {
8451      if (!cursor) {
8452        var hasCursor = false;
8453
8454        if (this._priorityCursor) {
8455          hasCursor = true;
8456        }
8457
8458        delete this._priorityCursor;
8459
8460        if (hasCursor) {
8461          this.setCursor(this._cursor);
8462        }
8463      } else {
8464        this._priorityCursor = cursor;
8465
8466        this._setCursorToPanel(cursor);
8467      }
8468
8469      return this;
8470    };
8471
8472    _proto._setCursorToPanel = function _setCursorToPanel(cursor) {
8473      var panel = this.getMainPanel();
8474
8475      if (panel && panel.style && panel.style.cursor !== cursor) {
8476        panel.style.cursor = cursor;
8477      }
8478    };
8479
8480    _proto._removeLayer = function _removeLayer(layer, layerList) {
8481      if (!layer || !layerList) {
8482        return;
8483      }
8484
8485      var index = layerList.indexOf(layer);
8486
8487      if (index > -1) {
8488        layerList.splice(index, 1);
8489      }
8490    };
8491
8492    _proto._sortLayersByZIndex = function _sortLayersByZIndex() {
8493      if (!this._layers) {
8494        return;
8495      }
8496
8497      for (var i = 0, l = this._layers.length; i < l; i++) {
8498        this._layers[i]._order = i;
8499      }
8500
8501      this._layers.sort(function (a, b) {
8502        var c = a.getZIndex() - b.getZIndex();
8503
8504        if (c === 0) {
8505          return a._order - b._order;
8506        }
8507
8508        return c;
8509      });
8510    };
8511
8512    _proto._fireEvent = function _fireEvent(eventName, param) {
8513      if (this._noEvent) {
8514        return;
8515      }
8516
8517      this.fire('_' + eventName, param);
8518      this.fire(eventName, param);
8519    };
8520
8521    _proto._Load = function _Load() {
8522      this._resetMapStatus();
8523
8524      if (this.options['pitch']) {
8525        this.setPitch(this.options['pitch']);
8526        delete this.options['pitch'];
8527      }
8528
8529      if (this.options['bearing']) {
8530        this.setBearing(this.options['bearing']);
8531        delete this.options['bearing'];
8532      }
8533
8534      this._loadAllLayers();
8535
8536      this._getRenderer().onLoad();
8537
8538      this._loaded = true;
8539
8540      this._callOnLoadHooks();
8541
8542      this._initTime = now();
8543    };
8544
8545    _proto._initRenderer = function _initRenderer() {
8546      var renderer = this.options['renderer'];
8547      var clazz = Map.getRendererClass(renderer);
8548      this._renderer = new clazz(this);
8549
8550      this._renderer.load();
8551    };
8552
8553    _proto._getRenderer = function _getRenderer() {
8554      return this._renderer;
8555    };
8556
8557    _proto._loadAllLayers = function _loadAllLayers() {
8558      function loadLayer(layer) {
8559        if (layer) {
8560          layer.load();
8561        }
8562      }
8563
8564      if (this._baseLayer) {
8565        this._baseLayer.load();
8566      }
8567
8568      this._eachLayer(loadLayer, this.getLayers());
8569    };
8570
8571    _proto._getLayers = function _getLayers(filter) {
8572      var layers = this._baseLayer ? [this._baseLayer].concat(this._layers) : this._layers;
8573      var result = [];
8574
8575      for (var i = 0; i < layers.length; i++) {
8576        if (!filter || filter.call(this, layers[i])) {
8577          result.push(layers[i]);
8578        }
8579      }
8580
8581      return result;
8582    };
8583
8584    _proto._eachLayer = function _eachLayer(fn) {
8585      if (arguments.length < 2) {
8586        return;
8587      }
8588
8589      var layerLists = Array.prototype.slice.call(arguments, 1);
8590
8591      if (layerLists && !Array.isArray(layerLists)) {
8592        layerLists = [layerLists];
8593      }
8594
8595      var layers = [];
8596
8597      for (var i = 0, len = layerLists.length; i < len; i++) {
8598        layers = layers.concat(layerLists[i]);
8599      }
8600
8601      for (var j = 0, jlen = layers.length; j < jlen; j++) {
8602        fn.call(fn, layers[j]);
8603      }
8604    };
8605
8606    _proto._onLayerEvent = function _onLayerEvent(param) {
8607      if (!param) {
8608        return;
8609      }
8610
8611      if (param['type'] === 'idchange') {
8612        delete this._layerCache[param['old']];
8613        this._layerCache[param['new']] = param['target'];
8614      }
8615    };
8616
8617    _proto._resetMapStatus = function _resetMapStatus() {
8618      var maxZoom = this.getMaxZoom(),
8619          minZoom = this.getMinZoom();
8620
8621      var viewMaxZoom = this._spatialReference.getMaxZoom(),
8622          viewMinZoom = this._spatialReference.getMinZoom();
8623
8624      if (isNil(maxZoom) || maxZoom === -1 || maxZoom > viewMaxZoom) {
8625        this.setMaxZoom(viewMaxZoom);
8626      }
8627
8628      if (isNil(minZoom) || minZoom === -1 || minZoom < viewMinZoom) {
8629        this.setMinZoom(viewMinZoom);
8630      }
8631
8632      maxZoom = this.getMaxZoom();
8633      minZoom = this.getMinZoom();
8634
8635      if (maxZoom < minZoom) {
8636        this.setMaxZoom(minZoom);
8637      }
8638
8639      if (isNil(this._zoomLevel) || this._zoomLevel > maxZoom) {
8640        this._zoomLevel = maxZoom;
8641      }
8642
8643      if (this._zoomLevel < minZoom) {
8644        this._zoomLevel = minZoom;
8645      }
8646
8647      delete this._prjCenter;
8648      var projection = this.getProjection();
8649      this._prjCenter = projection.project(this._center);
8650
8651      this._calcMatrices();
8652
8653      var renderer = this._getRenderer();
8654
8655      if (renderer) {
8656        renderer.resetContainer();
8657      }
8658    };
8659
8660    _proto._getContainerDomSize = function _getContainerDomSize() {
8661      if (!this._containerDOM) {
8662        return null;
8663      }
8664
8665      var containerDOM = this._containerDOM;
8666      var width, height;
8667
8668      if (!isNil(containerDOM.width) && !isNil(containerDOM.height)) {
8669        width = containerDOM.width;
8670        height = containerDOM.height;
8671        var dpr = this.getDevicePixelRatio();
8672
8673        if (dpr !== 1 && containerDOM['layer']) {
8674          width /= dpr;
8675          height /= dpr;
8676        }
8677      } else if (!isNil(containerDOM.clientWidth) && !isNil(containerDOM.clientHeight)) {
8678        width = parseInt(containerDOM.clientWidth, 0);
8679        height = parseInt(containerDOM.clientHeight, 0);
8680      } else {
8681        throw new Error('can not get size of container');
8682      }
8683
8684      return new Size(width, height);
8685    };
8686
8687    _proto._updateMapSize = function _updateMapSize(mSize) {
8688      this.width = mSize['width'];
8689      this.height = mSize['height'];
8690
8691      this._getRenderer().updateMapSize(mSize);
8692
8693      this._calcMatrices();
8694
8695      return this;
8696    };
8697
8698    _proto._getPrjCenter = function _getPrjCenter() {
8699      return this._prjCenter;
8700    };
8701
8702    _proto._setPrjCenter = function _setPrjCenter(pcenter) {
8703      this._prjCenter = pcenter;
8704
8705      if (this.isInteracting() && !this.isMoving()) {
8706        this._mapViewCoord = pcenter;
8707      }
8708
8709      this._calcMatrices();
8710    };
8711
8712    _proto._setPrjCoordAtContainerPoint = function _setPrjCoordAtContainerPoint(coordinate, point) {
8713      if (point.x === this.width / 2 && point.y === this.height / 2) {
8714        return this;
8715      }
8716
8717      var t = this._containerPointToPoint(point)._sub(this._prjToPoint(this._getPrjCenter()));
8718
8719      var pcenter = this._pointToPrj(this._prjToPoint(coordinate).sub(t));
8720
8721      this._setPrjCenter(pcenter);
8722
8723      return this;
8724    };
8725
8726    _proto._verifyExtent = function _verifyExtent(prjCenter) {
8727      if (!prjCenter) {
8728        return false;
8729      }
8730
8731      var maxExt = this._prjMaxExtent;
8732
8733      if (!maxExt) {
8734        return true;
8735      }
8736
8737      return maxExt.contains(prjCenter);
8738    };
8739
8740    _proto._offsetCenterByPixel = function _offsetCenterByPixel(pixel) {
8741      var pos = new Point(this.width / 2 - pixel.x, this.height / 2 - pixel.y);
8742
8743      var pCenter = this._containerPointToPrj(pos);
8744
8745      this._setPrjCenter(pCenter);
8746
8747      return pCenter;
8748    };
8749
8750    _proto.offsetPlatform = function offsetPlatform(offset) {
8751      if (!offset) {
8752        return this._mapViewPoint;
8753      } else {
8754        this._getRenderer().offsetPlatform(offset);
8755
8756        this._mapViewCoord = this._getPrjCenter();
8757        this._mapViewPoint = this._mapViewPoint.add(offset);
8758        return this;
8759      }
8760    };
8761
8762    _proto.getViewPoint = function getViewPoint() {
8763      var offset = this._getViewPointFrameOffset();
8764
8765      var panelOffset = this.offsetPlatform();
8766
8767      if (offset) {
8768        panelOffset = panelOffset.add(offset);
8769      }
8770
8771      return panelOffset;
8772    };
8773
8774    _proto._resetMapViewPoint = function _resetMapViewPoint() {
8775      this._mapViewPoint = new Point(0, 0);
8776      this._mapViewCoord = this._getPrjCenter();
8777    };
8778
8779    _proto._getResolution = function _getResolution(zoom) {
8780      if ((zoom === undefined || zoom === this._zoomLevel) && this._mapRes !== undefined) {
8781        return this._mapRes;
8782      } else if (zoom === this.getGLZoom() && this._mapGlRes !== undefined) {
8783        return this._mapGlRes;
8784      }
8785
8786      if (isNil(zoom)) {
8787        zoom = this._zoomLevel;
8788      }
8789
8790      return this._spatialReference.getResolution(zoom);
8791    };
8792
8793    _proto._getResolutions = function _getResolutions() {
8794      return this._spatialReference.getResolutions();
8795    };
8796
8797    _proto._prjToPoint = function _prjToPoint(pCoord, zoom, out) {
8798      zoom = isNil(zoom) ? this.getZoom() : zoom;
8799      return this._spatialReference.getTransformation().transform(pCoord, this._getResolution(zoom), out);
8800    };
8801
8802    _proto._pointToPrj = function _pointToPrj(point, zoom, out) {
8803      zoom = isNil(zoom) ? this.getZoom() : zoom;
8804      return this._spatialReference.getTransformation().untransform(point, this._getResolution(zoom), out);
8805    };
8806
8807    _proto._pointToPoint = function _pointToPoint(point, zoom, out) {
8808      if (out) {
8809        out.x = point.x;
8810        out.y = point.y;
8811      } else {
8812        out = point.copy();
8813      }
8814
8815      if (!isNil(zoom)) {
8816        return out._multi(this._getResolution(zoom) / this._getResolution());
8817      }
8818
8819      return out;
8820    };
8821
8822    _proto._pointToPointAtZoom = function _pointToPointAtZoom(point, zoom, out) {
8823      if (out) {
8824        out.x = point.x;
8825        out.y = point.y;
8826      } else {
8827        out = point.copy();
8828      }
8829
8830      if (!isNil(zoom)) {
8831        return out._multi(this._getResolution() / this._getResolution(zoom));
8832      }
8833
8834      return out;
8835    };
8836
8837    _proto._containerPointToPrj = function _containerPointToPrj(containerPoint, out) {
8838      return this._pointToPrj(this._containerPointToPoint(containerPoint, undefined, out), undefined, out);
8839    };
8840
8841    _proto._callOnLoadHooks = function _callOnLoadHooks() {
8842      var proto = Map.prototype;
8843
8844      if (!proto._onLoadHooks) {
8845        return;
8846      }
8847
8848      for (var i = 0, l = proto._onLoadHooks.length; i < l; i++) {
8849        proto._onLoadHooks[i].call(this);
8850      }
8851    };
8852
8853    return Map;
8854  }(Handlerable(Eventable(Renderable(Class))));
8855
8856  Map$1.include({
8857    coordinateToPoint: function () {
8858      var COORD = new Coordinate(0, 0);
8859      return function (coordinate, zoom, out) {
8860        var prjCoord = this.getProjection().project(coordinate, COORD);
8861        return this._prjToPoint(prjCoord, zoom, out);
8862      };
8863    }(),
8864    pointToCoordinate: function () {
8865      var COORD = new Coordinate(0, 0);
8866      return function (point, zoom, out) {
8867        var prjCoord = this._pointToPrj(point, zoom, COORD);
8868
8869        return this.getProjection().unproject(prjCoord, out);
8870      };
8871    }(),
8872    coordinateToViewPoint: function () {
8873      var COORD = new Coordinate(0, 0);
8874      return function (coordinate, out) {
8875        return this._prjToViewPoint(this.getProjection().project(coordinate, COORD), out);
8876      };
8877    }(),
8878    viewPointToCoordinate: function () {
8879      var COORD = new Coordinate(0, 0);
8880      return function (viewPoint, out) {
8881        return this.getProjection().unproject(this._viewPointToPrj(viewPoint, COORD), out);
8882      };
8883    }(),
8884    coordinateToContainerPoint: function () {
8885      var COORD = new Coordinate(0, 0);
8886      return function (coordinate, zoom, out) {
8887        var pCoordinate = this.getProjection().project(coordinate, COORD);
8888        return this._prjToContainerPoint(pCoordinate, zoom, out);
8889      };
8890    }(),
8891    containerPointToCoordinate: function () {
8892      var COORD = new Coordinate(0, 0);
8893      return function (containerPoint, out) {
8894        var pCoordinate = this._containerPointToPrj(containerPoint, COORD);
8895
8896        return this.getProjection().unproject(pCoordinate, out);
8897      };
8898    }(),
8899    containerToExtent: function () {
8900      var POINT0 = new Point(0, 0);
8901      var POINT1 = new Point(0, 0);
8902      return function (containerExtent) {
8903        var extent2D = new PointExtent(this._containerPointToPoint(containerExtent.getMin(POINT0), undefined, POINT0), this._containerPointToPoint(containerExtent.getMax(POINT1), undefined, POINT1));
8904        return this._pointToExtent(extent2D);
8905      };
8906    }(),
8907    distanceToPixel: function () {
8908      var POINT0 = new Point(0, 0);
8909      var POINT1 = new Point(0, 0);
8910      return function (xDist, yDist, zoom) {
8911        var projection = this.getProjection();
8912
8913        if (!projection) {
8914          return null;
8915        }
8916
8917        var scale = this.getScale() / this.getScale(zoom);
8918        var center = this.getCenter(),
8919            target = projection.locate(center, xDist, yDist);
8920        var p0 = this.coordToContainerPoint(center, undefined, POINT0),
8921            p1 = this.coordToContainerPoint(target, undefined, POINT1);
8922
8923        p1._sub(p0)._multi(scale)._abs();
8924
8925        return new Size(p1.x, p1.y);
8926      };
8927    }(),
8928    distanceToPoint: function () {
8929      var POINT = new Point(0, 0);
8930      return function (xDist, yDist, zoom) {
8931        var projection = this.getProjection();
8932
8933        if (!projection) {
8934          return null;
8935        }
8936
8937        var center = this.getCenter(),
8938            target = projection.locate(center, xDist, yDist);
8939        var p0 = this.coordToPoint(center, zoom, POINT),
8940            p1 = this.coordToPoint(target, zoom);
8941
8942        p1._sub(p0)._abs();
8943
8944        return p1;
8945      };
8946    }(),
8947    pixelToDistance: function () {
8948      var COORD0 = new Coordinate(0, 0);
8949      var COORD1 = new Coordinate(0, 0);
8950      return function (width, height) {
8951        var projection = this.getProjection();
8952
8953        if (!projection) {
8954          return null;
8955        }
8956
8957        var fullExt = this.getFullExtent();
8958        var d = fullExt['top'] > fullExt['bottom'] ? -1 : 1;
8959        var target = COORD0.set(this.width / 2 + width, this.height / 2 + d * height);
8960        var coord = this.containerPointToCoord(target, COORD1);
8961        return projection.measureLength(this.getCenter(), coord);
8962      };
8963    }(),
8964    pointToDistance: function () {
8965      var POINT = new Point(0, 0);
8966      var COORD = new Coordinate(0, 0);
8967      return function (dx, dy, zoom) {
8968        var projection = this.getProjection();
8969
8970        if (!projection) {
8971          return null;
8972        }
8973
8974        var c = this._prjToPoint(this._getPrjCenter(), zoom, POINT);
8975
8976        c._add(dx, dy);
8977
8978        var target = this.pointToCoord(c, zoom, COORD);
8979        return projection.measureLength(this.getCenter(), target);
8980      };
8981    }(),
8982    locateByPoint: function () {
8983      var POINT = new Point(0, 0);
8984      return function (coordinate, px, py) {
8985        var point = this.coordToContainerPoint(coordinate, undefined, POINT);
8986        return this.containerPointToCoord(point._add(px, py));
8987      };
8988    }(),
8989    _get2DExtent: function () {
8990      var POINT = new Point(0, 0);
8991      return function (zoom, out) {
8992        var _this3 = this;
8993
8994        var cached;
8995
8996        if ((zoom === undefined || zoom === this._zoomLevel) && this._mapExtent2D) {
8997          cached = this._mapExtent2D;
8998        } else if (zoom === this.getGLZoom() && this._mapGlExtent2D) {
8999          cached = this._mapGlExtent2D;
9000        }
9001
9002        if (cached) {
9003          if (out) {
9004            out.set(cached['xmin'], cached['ymin'], cached['xmax'], cached['ymax']);
9005            return out;
9006          }
9007
9008          return cached.copy();
9009        }
9010
9011        var cExtent = this.getContainerExtent();
9012        return cExtent.convertTo(function (c) {
9013          return _this3._containerPointToPoint(c, zoom, POINT);
9014        }, out);
9015      };
9016    }(),
9017    _pointToExtent: function () {
9018      var COORD0 = new Coordinate(0, 0);
9019      var COORD1 = new Coordinate(0, 0);
9020      return function (extent2D) {
9021        var min2d = extent2D.getMin(),
9022            max2d = extent2D.getMax();
9023        var fullExtent = this.getFullExtent();
9024
9025        var _ref = !fullExtent || fullExtent.left <= fullExtent.right ? [min2d.x, max2d.x] : [max2d.x, min2d.x],
9026            minx = _ref[0],
9027            maxx = _ref[1];
9028
9029        var _ref2 = !fullExtent || fullExtent.top > fullExtent.bottom ? [max2d.y, min2d.y] : [min2d.y, max2d.y],
9030            miny = _ref2[0],
9031            maxy = _ref2[1];
9032
9033        var min = min2d.set(minx, miny);
9034        var max = max2d.set(maxx, maxy);
9035        return new Extent(this.pointToCoord(min, undefined, COORD0), this.pointToCoord(max, undefined, COORD1), this.getProjection());
9036      };
9037    }(),
9038    _getViewPointFrameOffset: function () {
9039      var POINT = new Point(0, 0);
9040      return function () {
9041        if (this.isZooming()) {
9042          return null;
9043        }
9044
9045        var pcenter = this._getPrjCenter();
9046
9047        if (this._mapViewCoord && !this._mapViewCoord.equals(pcenter)) {
9048          return this._prjToContainerPoint(this._mapViewCoord)._sub(this._prjToContainerPoint(pcenter, undefined, POINT));
9049        }
9050
9051        return null;
9052      };
9053    }(),
9054    _viewPointToPrj: function () {
9055      var POINT = new Point(0, 0);
9056      return function (viewPoint, out) {
9057        return this._containerPointToPrj(this.viewPointToContainerPoint(viewPoint, POINT), out);
9058      };
9059    }(),
9060    _prjToContainerPoint: function () {
9061      var POINT = new Point(0, 0);
9062      return function (pCoordinate, zoom, out) {
9063        return this._pointToContainerPoint(this._prjToPoint(pCoordinate, zoom, POINT), zoom, 0, out);
9064      };
9065    }(),
9066    _prjToViewPoint: function () {
9067      var POINT = new Point(0, 0);
9068      return function (pCoordinate, out) {
9069        var containerPoint = this._prjToContainerPoint(pCoordinate, undefined, POINT);
9070
9071        return this.containerPointToViewPoint(containerPoint, out);
9072      };
9073    }(),
9074    _viewPointToPoint: function () {
9075      var POINT = new Point(0, 0);
9076      return function (viewPoint, zoom, out) {
9077        return this._containerPointToPoint(this.viewPointToContainerPoint(viewPoint, POINT), zoom, out);
9078      };
9079    }(),
9080    _pointToViewPoint: function () {
9081      var COORD = new Coordinate(0, 0);
9082      return function (point, zoom, out) {
9083        return this._prjToViewPoint(this._pointToPrj(point, zoom, COORD), out);
9084      };
9085    }()
9086  });
9087  Map$1.mergeOptions(options$1);
9088
9089  var MapDoubleClickZoomHandler = function (_Handler) {
9090    _inheritsLoose(MapDoubleClickZoomHandler, _Handler);
9091
9092    function MapDoubleClickZoomHandler() {
9093      return _Handler.apply(this, arguments) || this;
9094    }
9095
9096    var _proto = MapDoubleClickZoomHandler.prototype;
9097
9098    _proto.addHooks = function addHooks() {
9099      if (!this.target) {
9100        return;
9101      }
9102
9103      this.target.on('_dblclick', this._onDoubleClick, this);
9104    };
9105
9106    _proto.removeHooks = function removeHooks() {
9107      if (!this.target) {
9108        return;
9109      }
9110
9111      this.target.off('_dblclick', this._onDoubleClick, this);
9112    };
9113
9114    _proto._onDoubleClick = function _onDoubleClick(param) {
9115      var map = this.target;
9116
9117      if (map.options['doubleClickZoom']) {
9118        var oldZoom = map.getZoom(),
9119            zoom = param['domEvent']['shiftKey'] ? Math.ceil(oldZoom) - 1 : Math.floor(oldZoom) + 1;
9120
9121        map._zoomAnimation(zoom, param['containerPoint']);
9122      }
9123    };
9124
9125    return MapDoubleClickZoomHandler;
9126  }(Handler$1);
9127
9128  Map$1.mergeOptions({
9129    'doubleClickZoom': true
9130  });
9131  Map$1.addOnLoadHook('addHandler', 'doubleClickZoom', MapDoubleClickZoomHandler);
9132
9133  var MapDragHandler = function (_Handler) {
9134    _inheritsLoose(MapDragHandler, _Handler);
9135
9136    function MapDragHandler() {
9137      return _Handler.apply(this, arguments) || this;
9138    }
9139
9140    var _proto = MapDragHandler.prototype;
9141
9142    _proto.addHooks = function addHooks() {
9143      var map = this.target;
9144
9145      if (!map) {
9146        return;
9147      }
9148
9149      var dom = map._panels.mapWrapper || map._containerDOM;
9150      this._dragHandler = new DragHandler(dom, {
9151        'cancelOn': this._cancelOn.bind(this),
9152        'rightclick': true
9153      });
9154
9155      this._dragHandler.on('mousedown', this._onMouseDown, this).on('dragstart', this._onDragStart, this).on('dragging', this._onDragging, this).on('dragend', this._onDragEnd, this).enable();
9156    };
9157
9158    _proto.removeHooks = function removeHooks() {
9159      this._dragHandler.off('mousedown', this._onMouseDown, this).off('dragstart', this._onDragStart, this).off('dragging', this._onDragging, this).off('dragend', this._onDragEnd, this);
9160
9161      this._dragHandler.remove();
9162
9163      delete this._dragHandler;
9164    };
9165
9166    _proto._cancelOn = function _cancelOn(domEvent) {
9167      if (this.target.isZooming() || this._ignore(domEvent)) {
9168        return true;
9169      }
9170
9171      return false;
9172    };
9173
9174    _proto._ignore = function _ignore(param) {
9175      if (!param) {
9176        return false;
9177      }
9178
9179      if (param.domEvent) {
9180        param = param.domEvent;
9181      }
9182
9183      return this.target._ignoreEvent(param);
9184    };
9185
9186    _proto._onMouseDown = function _onMouseDown(param) {
9187      delete this.startDragTime;
9188      delete this._mode;
9189
9190      if (param.domEvent.button === 2 || param.domEvent.ctrlKey) {
9191        if (this.target.options['dragRotate'] || this.target.options['dragPitch']) {
9192          this._mode = 'rotatePitch';
9193        }
9194      } else if (this.target.options['dragPan']) {
9195        this._mode = 'move';
9196      }
9197
9198      this.target._stopAnim(this.target._mapAnimPlayer);
9199
9200      preventDefault(param['domEvent']);
9201    };
9202
9203    _proto._onDragStart = function _onDragStart(param) {
9204      this.startDragTime = now();
9205
9206      if (this._mode === 'move') {
9207        this._moveStart(param);
9208      } else if (this._mode === 'rotatePitch') {
9209        this._rotateStart(param);
9210      }
9211    };
9212
9213    _proto._onDragging = function _onDragging(param) {
9214      var map = this.target;
9215
9216      if (map._isEventOutMap(param['domEvent'])) {
9217        return;
9218      }
9219
9220      if (this._mode === 'move') {
9221        this._moving(param);
9222      } else if (this._mode === 'rotatePitch') {
9223        this._rotating(param);
9224      }
9225    };
9226
9227    _proto._onDragEnd = function _onDragEnd(param) {
9228      if (this._mode === 'move') {
9229        this._moveEnd(param);
9230      } else if (this._mode === 'rotatePitch') {
9231        this._rotateEnd(param);
9232      }
9233
9234      delete this.startDragTime;
9235      delete this.startBearing;
9236    };
9237
9238    _proto._start = function _start(param) {
9239      this.preX = param['mousePos'].x;
9240      this.preY = param['mousePos'].y;
9241      this.startX = this.preX;
9242      this.startY = this.preY;
9243    };
9244
9245    _proto._moveStart = function _moveStart(param) {
9246      this._start(param);
9247
9248      var map = this.target;
9249      map.onMoveStart(param);
9250      var p = getEventContainerPoint(map._getActualEvent(param.domEvent), map.getContainer());
9251      this.startPrjCoord = map._containerPointToPrj(p);
9252    };
9253
9254    _proto._moving = function _moving(param) {
9255      if (!this.startDragTime) {
9256        return;
9257      }
9258
9259      var map = this.target;
9260      var p = getEventContainerPoint(map._getActualEvent(param.domEvent), map.getContainer());
9261
9262      map._setPrjCoordAtContainerPoint(this.startPrjCoord, p);
9263
9264      map.onMoving(param);
9265    };
9266
9267    _proto._moveEnd = function _moveEnd(param) {
9268      if (!this.startDragTime) {
9269        return;
9270      }
9271
9272      var map = this.target;
9273      var t = now() - this.startDragTime;
9274      var mx = param['mousePos'].x,
9275          my = param['mousePos'].y;
9276      var dx = mx - this.startX;
9277      var dy = my - this.startY;
9278
9279      this._clear();
9280
9281      if (map.options['panAnimation'] && !param.interupted && map._verifyExtent(map._getPrjCenter()) && t < 280 && Math.abs(dy) + Math.abs(dx) > 5) {
9282        t = 5 * t * (Math.abs(dx) + Math.abs(dy)) / 500;
9283        map.panBy(new Point(dx, dy), {
9284          'duration': t
9285        });
9286      } else {
9287        map.onMoveEnd(param);
9288      }
9289    };
9290
9291    _proto._rotateStart = function _rotateStart(param) {
9292      this._start(param);
9293
9294      delete this._rotateMode;
9295      this.startBearing = this.target.getBearing();
9296      this.target.onDragRotateStart(param);
9297      this._db = 0;
9298    };
9299
9300    _proto._rotating = function _rotating(param) {
9301      var map = this.target;
9302      var mx = param['mousePos'].x,
9303          my = param['mousePos'].y;
9304      var prePitch = map.getPitch(),
9305          preBearing = map.getBearing();
9306      var dx = Math.abs(mx - this.preX),
9307          dy = Math.abs(my - this.preY);
9308
9309      if (!this._rotateMode) {
9310        if (map.options['dragRotatePitch']) {
9311          this._rotateMode = 'rotate_pitch';
9312        } else if (dx > dy) {
9313          this._rotateMode = 'rotate';
9314        } else if (dx < dy) {
9315          this._rotateMode = 'pitch';
9316        } else {
9317          this._rotateMode = 'rotate';
9318        }
9319      }
9320
9321      if (this._rotateMode === 'pitch' && prePitch === 0 && dy < 10) {
9322        return;
9323      }
9324
9325      if (this._rotateMode.indexOf('rotate') >= 0 && map.options['dragRotate']) {
9326        var db = 0;
9327
9328        if (map.options['dragPitch'] || dx > dy) {
9329          db = -0.6 * (this.preX - mx);
9330        } else if (mx > map.width / 2) {
9331          db = 0.6 * (this.preY - my);
9332        } else {
9333          db = -0.6 * (this.preY - my);
9334        }
9335
9336        var bearing = map.getBearing() + db;
9337        this._db = this._db || 0;
9338        this._db += db;
9339        map.setBearing(bearing);
9340      }
9341
9342      if (this._rotateMode.indexOf('pitch') >= 0 && map.options['dragPitch']) {
9343        map.setPitch(map.getPitch() + (this.preY - my) * 0.4);
9344      }
9345
9346      this.preX = mx;
9347      this.preY = my;
9348
9349      if (map.getBearing() !== preBearing || map.getPitch() !== prePitch) {
9350        map.onDragRotating(param);
9351      }
9352    };
9353
9354    _proto._rotateEnd = function _rotateEnd(param) {
9355      var map = this.target;
9356      var bearing = map.getBearing();
9357
9358      this._clear();
9359
9360      var t = now() - this.startDragTime;
9361      map.onDragRotateEnd(param);
9362
9363      if (Math.abs(bearing - this.startBearing) > 20 && (this._rotateMode === 'rotate' || this._rotateMode === 'rotate_pitch') && !param.interupted && t < 400) {
9364        var _bearing = map.getBearing();
9365
9366        map._animateTo({
9367          'bearing': _bearing + this._db / 2
9368        }, {
9369          'easing': 'out',
9370          'duration': 800
9371        });
9372      }
9373    };
9374
9375    _proto._clear = function _clear() {
9376      delete this.startPrjCoord;
9377      delete this.preX;
9378      delete this.preY;
9379      delete this.startX;
9380      delete this.startY;
9381    };
9382
9383    return MapDragHandler;
9384  }(Handler$1);
9385
9386  Map$1.mergeOptions({
9387    'draggable': true,
9388    'dragPan': true,
9389    'dragRotatePitch': true,
9390    'dragRotate': true,
9391    'dragPitch': true
9392  });
9393  Map$1.addOnLoadHook('addHandler', 'draggable', MapDragHandler);
9394
9395  function clipLine(points, bounds, round, noCut) {
9396    var parts = [];
9397    var k = 0,
9398        segment;
9399
9400    for (var j = 0, l = points.length; j < l - 1; j++) {
9401      segment = clipSegment(points[j], points[j + 1], bounds, j, round, noCut);
9402
9403      if (!segment) {
9404        continue;
9405      }
9406
9407      parts[k] = parts[k] || [];
9408      parts[k].push({
9409        'point': segment[0],
9410        'index': j
9411      });
9412
9413      if (segment[1] !== points[j + 1] || j === l - 2) {
9414        parts[k].push({
9415          'point': segment[1],
9416          'index': j + 1
9417        });
9418        k++;
9419      }
9420    }
9421
9422    return parts;
9423  }
9424
9425  var _lastCode;
9426
9427  function clipSegment(a, b, bounds, useLastCode, round, noCut) {
9428    var codeA = useLastCode ? _lastCode : _getBitCode(a, bounds),
9429        codeB = _getBitCode(b, bounds),
9430        codeOut,
9431        p,
9432        newCode;
9433
9434    _lastCode = codeB;
9435
9436    while (true) {
9437      if (!(codeA | codeB)) {
9438        return [a, b];
9439      }
9440
9441      if (codeA & codeB) {
9442        return false;
9443      }
9444
9445      if (noCut) {
9446        return [a, b];
9447      }
9448
9449      codeOut = codeA || codeB;
9450      p = _getEdgeIntersection(a, b, codeOut, bounds, round);
9451      newCode = _getBitCode(p, bounds);
9452
9453      if (codeOut === codeA) {
9454        a = p;
9455        codeA = newCode;
9456      } else {
9457        b = p;
9458        codeB = newCode;
9459      }
9460    }
9461  }
9462  function clipPolygon(points, bounds, round) {
9463    var edges = [1, 4, 2, 8];
9464    var clippedPoints, i, j, k, a, b, len, edge, p;
9465
9466    for (i = 0, len = points.length; i < len; i++) {
9467      points[i]._code = _getBitCode(points[i], bounds);
9468    }
9469
9470    for (k = 0; k < 4; k++) {
9471      edge = edges[k];
9472      clippedPoints = [];
9473
9474      for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {
9475        a = points[i];
9476        b = points[j];
9477
9478        if (!(a._code & edge)) {
9479          if (b._code & edge) {
9480            p = _getEdgeIntersection(b, a, edge, bounds, round);
9481            p._code = _getBitCode(p, bounds);
9482            clippedPoints.push(p);
9483          }
9484
9485          clippedPoints.push(a);
9486        } else if (!(b._code & edge)) {
9487          p = _getEdgeIntersection(b, a, edge, bounds, round);
9488          p._code = _getBitCode(p, bounds);
9489          clippedPoints.push(p);
9490        }
9491      }
9492
9493      points = clippedPoints;
9494    }
9495
9496    return points;
9497  }
9498
9499  function _getEdgeIntersection(a, b, code, bounds, round) {
9500    var dx = b.x - a.x,
9501        dy = b.y - a.y,
9502        min = bounds.getMin(),
9503        max = bounds.getMax();
9504    var x, y;
9505
9506    if (code & 8) {
9507      x = a.x + dx * (max.y - a.y) / dy;
9508      y = max.y;
9509    } else if (code & 4) {
9510      x = a.x + dx * (min.y - a.y) / dy;
9511      y = min.y;
9512    } else if (code & 2) {
9513      x = max.x;
9514      y = a.y + dy * (max.x - a.x) / dx;
9515    } else if (code & 1) {
9516      x = min.x;
9517      y = a.y + dy * (min.x - a.x) / dx;
9518    }
9519
9520    var p = new Point(x, y);
9521
9522    if (round) {
9523      p._round();
9524    }
9525
9526    return p;
9527  }
9528
9529  function _getBitCode(p, bounds) {
9530    var code = 0;
9531
9532    if (p.x < bounds.getMin().x) {
9533      code |= 1;
9534    } else if (p.x > bounds.getMax().x) {
9535      code |= 2;
9536    }
9537
9538    if (p.y < bounds.getMin().y) {
9539      code |= 4;
9540    } else if (p.y > bounds.getMax().y) {
9541      code |= 8;
9542    }
9543
9544    return code;
9545  }
9546
9547  function withInEllipse(point, center, southeast, tolerance) {
9548    point = new Point(point);
9549    var a = Math.abs(southeast.x - center.x),
9550        b = Math.abs(southeast.y - center.y),
9551        c = Math.sqrt(Math.abs(a * a - b * b)),
9552        xfocus = a >= b;
9553    var f1, f2, d;
9554
9555    if (xfocus) {
9556      f1 = new Point(center.x - c, center.y);
9557      f2 = new Point(center.x + c, center.y);
9558      d = a * 2;
9559    } else {
9560      f1 = new Point(center.x, center.y - c);
9561      f2 = new Point(center.x, center.y + c);
9562      d = b * 2;
9563    }
9564
9565    return point.distanceTo(f1) + point.distanceTo(f2) <= d + 2 * tolerance;
9566  }
9567
9568  var Symbolizer = function () {
9569    function Symbolizer() {}
9570
9571    var _proto = Symbolizer.prototype;
9572
9573    _proto.getMap = function getMap() {
9574      return this.geometry.getMap();
9575    };
9576
9577    _proto.getPainter = function getPainter() {
9578      return this.painter;
9579    };
9580
9581    Symbolizer.testColor = function testColor(prop) {
9582      if (!prop || !isString(prop)) {
9583        return false;
9584      }
9585
9586      if (COLOR_PROPERTIES.indexOf(prop) >= 0) {
9587        return true;
9588      }
9589
9590      return false;
9591    };
9592
9593    return Symbolizer;
9594  }();
9595
9596  var CanvasSymbolizer = function (_Symbolizer) {
9597    _inheritsLoose(CanvasSymbolizer, _Symbolizer);
9598
9599    function CanvasSymbolizer() {
9600      return _Symbolizer.apply(this, arguments) || this;
9601    }
9602
9603    var _proto = CanvasSymbolizer.prototype;
9604
9605    _proto._prepareContext = function _prepareContext(ctx) {
9606      if (isNumber(this.symbol['opacity'])) {
9607        if (ctx.globalAlpha !== this.symbol['opacity']) {
9608          ctx.globalAlpha = this.symbol['opacity'];
9609        }
9610      } else if (ctx.globalAlpha !== 1) {
9611        ctx.globalAlpha = 1;
9612      }
9613    };
9614
9615    _proto.prepareCanvas = function prepareCanvas(ctx, style, resources) {
9616      Canvas.prepareCanvas(ctx, style, resources, this.getPainter().isHitTesting());
9617    };
9618
9619    _proto.remove = function remove() {};
9620
9621    _proto.setZIndex = function setZIndex() {};
9622
9623    _proto.show = function show() {};
9624
9625    _proto.hide = function hide() {};
9626
9627    _proto._defineStyle = function _defineStyle(style) {
9628      return function () {
9629        var _this = this;
9630
9631        var arr = [],
9632            prop = {};
9633        return loadFunctionTypes(style, function () {
9634          var map = _this.getMap();
9635
9636          return set$1(arr, map.getZoom(), extend({}, _this.geometry.getProperties(), setProp(prop, map.getBearing(), map.getPitch(), map.getZoom())));
9637        });
9638      }.bind(this)();
9639    };
9640
9641    return CanvasSymbolizer;
9642  }(Symbolizer);
9643
9644  function set$1(arr, a0, a1) {
9645    arr[0] = a0;
9646    arr[1] = a1;
9647    return arr;
9648  }
9649
9650  function setProp(prop, b, p, z) {
9651    prop['{bearing}'] = b;
9652    prop['{pitch}'] = p;
9653    prop['{zoom}'] = z;
9654    return prop;
9655  }
9656
9657  var TEMP_POINT0$1 = new Point(0, 0);
9658  var TEMP_POINT1 = new Point(0, 0);
9659
9660  var PointSymbolizer = function (_CanvasSymbolizer) {
9661    _inheritsLoose(PointSymbolizer, _CanvasSymbolizer);
9662
9663    function PointSymbolizer(symbol, geometry, painter) {
9664      var _this;
9665
9666      _this = _CanvasSymbolizer.call(this) || this;
9667      _this.symbol = symbol;
9668      _this.geometry = geometry;
9669      _this.painter = painter;
9670      return _this;
9671    }
9672
9673    var _proto = PointSymbolizer.prototype;
9674
9675    _proto.get2DExtent = function get2DExtent() {
9676      var map = this.getMap();
9677      var glZoom = map.getGLZoom();
9678      var extent = new PointExtent();
9679
9680      var renderPoints = this._getRenderPoints()[0];
9681
9682      for (var i = renderPoints.length - 1; i >= 0; i--) {
9683        if (renderPoints[i]) {
9684          extent._combine(map._pointToPoint(renderPoints[i], glZoom));
9685        }
9686      }
9687
9688      return extent;
9689    };
9690
9691    _proto._rotateExtent = function _rotateExtent(fixedExtent, angle) {
9692      return fixedExtent.convertTo(function (p) {
9693        return p._rotate(angle);
9694      });
9695    };
9696
9697    _proto._getRenderPoints = function _getRenderPoints() {
9698      var painter = this.getPainter();
9699      var placement = painter.isSpriting() ? 'center' : this.getPlacement();
9700      return this.getPainter().getRenderPoints(placement);
9701    };
9702
9703    _proto._getRenderContainerPoints = function _getRenderContainerPoints(ignoreAltitude) {
9704      var painter = this.getPainter(),
9705          points = this._getRenderPoints()[0];
9706
9707      if (painter.isSpriting()) {
9708        return points;
9709      }
9710
9711      var dxdy = this.getDxDy();
9712
9713      var cpoints = this.painter._pointContainerPoints(points, dxdy.x, dxdy.y, ignoreAltitude, true, this.getPlacement());
9714
9715      if (!cpoints || !Array.isArray(cpoints[0])) {
9716        return cpoints;
9717      }
9718
9719      var flat = [];
9720
9721      for (var i = 0, l = cpoints.length; i < l; i++) {
9722        for (var ii = 0, ll = cpoints[i].length; ii < ll; ii++) {
9723          flat.push(cpoints[i][ii]);
9724        }
9725      }
9726
9727      return flat;
9728    };
9729
9730    _proto._getRotationAt = function _getRotationAt(i) {
9731      var r = this.getRotation();
9732
9733      if (!r) {
9734        r = 0;
9735      }
9736
9737      var rotations = this._getRenderPoints()[1];
9738
9739      if (!rotations || !rotations[i]) {
9740        return r;
9741      }
9742
9743      var map = this.getMap();
9744      var p0 = rotations[i][0],
9745          p1 = rotations[i][1];
9746
9747      if (map.isTransforming()) {
9748        var maxZoom = map.getGLZoom();
9749        p0 = map._pointToContainerPoint(rotations[i][0], maxZoom, 0, TEMP_POINT0$1);
9750        p1 = map._pointToContainerPoint(rotations[i][1], maxZoom, 0, TEMP_POINT1);
9751      }
9752
9753      return r + computeDegree(p0.x, p0.y, p1.x, p1.y);
9754    };
9755
9756    _proto._rotate = function _rotate(ctx, origin, rotation) {
9757      if (rotation) {
9758        var dxdy = this.getDxDy();
9759        var p = origin.sub(dxdy);
9760        ctx.save();
9761        ctx.translate(p.x, p.y);
9762        ctx.rotate(rotation);
9763        return this.getDxDy();
9764      }
9765
9766      return null;
9767    };
9768
9769    return PointSymbolizer;
9770  }(CanvasSymbolizer);
9771
9772  var VectorMarkerSymbolizer = function (_PointSymbolizer) {
9773    _inheritsLoose(VectorMarkerSymbolizer, _PointSymbolizer);
9774
9775    VectorMarkerSymbolizer.test = function test(symbol) {
9776      if (!symbol) {
9777        return false;
9778      }
9779
9780      if (isNil(symbol['markerFile']) && !isNil(symbol['markerType']) && symbol['markerType'] !== 'path') {
9781        return true;
9782      }
9783
9784      return false;
9785    };
9786
9787    function VectorMarkerSymbolizer(symbol, geometry, painter) {
9788      var _this;
9789
9790      _this = _PointSymbolizer.call(this, symbol, geometry, painter) || this;
9791      _this._dynamic = hasFunctionDefinition(symbol);
9792      _this.style = _this._defineStyle(_this.translate());
9793      _this.strokeAndFill = _this._defineStyle(VectorMarkerSymbolizer.translateLineAndFill(_this.style));
9794      var lineWidth = _this.strokeAndFill['lineWidth'];
9795
9796      if (lineWidth % 2 === 0) {
9797        _this.padding = 2;
9798      } else {
9799        _this.padding = 1.5;
9800      }
9801
9802      return _this;
9803    }
9804
9805    var _proto = VectorMarkerSymbolizer.prototype;
9806
9807    _proto.symbolize = function symbolize(ctx, resources) {
9808      var style = this.style;
9809
9810      if (!this.painter.isHitTesting() && (style['markerWidth'] === 0 || style['markerHeight'] === 0 || style['polygonOpacity'] === 0 && style['lineOpacity'] === 0)) {
9811        return;
9812      }
9813
9814      var cookedPoints = this._getRenderContainerPoints();
9815
9816      if (!isArrayHasData(cookedPoints)) {
9817        return;
9818      }
9819
9820      this._prepareContext(ctx);
9821
9822      if (this.getPainter().isSpriting() || this.geometry.getLayer().getMask() === this.geometry || this._dynamic || this.geometry.getLayer().options['cacheVectorOnCanvas'] === false) {
9823        this._drawMarkers(ctx, cookedPoints, resources);
9824      } else {
9825        this._drawMarkersWithCache(ctx, cookedPoints, resources);
9826      }
9827    };
9828
9829    _proto.getDxDy = function getDxDy() {
9830      var s = this.style;
9831      var dx = s['markerDx'],
9832          dy = s['markerDy'];
9833      return new Point(dx, dy);
9834    };
9835
9836    _proto._drawMarkers = function _drawMarkers(ctx, cookedPoints, resources) {
9837      var strokeAndFill = this.strokeAndFill;
9838      var gradient = isGradient(strokeAndFill['lineColor']) || isGradient(strokeAndFill['polygonFill']);
9839
9840      if (!gradient) {
9841        this.prepareCanvas(ctx, strokeAndFill, resources);
9842      }
9843
9844      for (var i = cookedPoints.length - 1; i >= 0; i--) {
9845        var point = cookedPoints[i];
9846
9847        var origin = this._rotate(ctx, point, this._getRotationAt(i));
9848
9849        if (origin) {
9850          point = origin;
9851        }
9852
9853        this._drawVectorMarker(ctx, point, resources);
9854
9855        if (origin) {
9856          ctx.restore();
9857        }
9858      }
9859    };
9860
9861    _proto._drawMarkersWithCache = function _drawMarkersWithCache(ctx, cookedPoints, resources) {
9862      var stamp = this._stampSymbol();
9863
9864      var image = resources.getImage(stamp);
9865
9866      if (!image) {
9867        image = this._createMarkerImage(ctx, resources);
9868        resources.addResource([stamp, image.width, image.height], image);
9869      }
9870
9871      var anchor = this._getAnchor(image.width, image.height);
9872
9873      for (var i = cookedPoints.length - 1; i >= 0; i--) {
9874        var point = cookedPoints[i];
9875
9876        var origin = this._rotate(ctx, point, this._getRotationAt(i));
9877
9878        if (origin) {
9879          point = origin;
9880        }
9881
9882        Canvas.image(ctx, image, point.x + anchor.x, point.y + anchor.y);
9883
9884        if (origin) {
9885          ctx.restore();
9886        }
9887      }
9888    };
9889
9890    _proto._calMarkerSize = function _calMarkerSize() {
9891      if (!this._size) {
9892        var lineWidth = this.strokeAndFill['lineWidth'],
9893            shadow = 2 * (this.symbol['shadowBlur'] || 0),
9894            w = Math.round(this.style['markerWidth'] + lineWidth + 2 * shadow + this.padding * 2),
9895            h = Math.round(this.style['markerHeight'] + lineWidth + 2 * shadow + this.padding * 2);
9896        this._size = [w, h];
9897      }
9898
9899      return this._size;
9900    };
9901
9902    _proto._createMarkerImage = function _createMarkerImage(ctx, resources) {
9903      var canvasClass = ctx.canvas.constructor,
9904          size = this._calMarkerSize(),
9905          canvas = Canvas.createCanvas(size[0], size[1], canvasClass),
9906          point = this._getCacheImageAnchor(size[0], size[1]);
9907
9908      var context = canvas.getContext('2d');
9909      var gradient = isGradient(this.strokeAndFill['lineColor']) || isGradient(this.strokeAndFill['polygonFill']);
9910
9911      if (!gradient) {
9912        this.prepareCanvas(context, this.strokeAndFill, resources);
9913      }
9914
9915      this._drawVectorMarker(context, point, resources);
9916
9917      return canvas;
9918    };
9919
9920    _proto._stampSymbol = function _stampSymbol() {
9921      if (!this._stamp) {
9922        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('_');
9923      }
9924
9925      return this._stamp;
9926    };
9927
9928    _proto._getAnchor = function _getAnchor(w, h) {
9929      var shadow = 2 * (this.symbol['shadowBlur'] || 0),
9930          margin = shadow + this.padding;
9931      var p = getAlignPoint(new Size(w, h), this.style['markerHorizontalAlignment'], this.style['markerVerticalAlignment']);
9932
9933      if (p.x !== -w / 2) {
9934        p.x -= sign(p.x + w / 2) * margin;
9935      }
9936
9937      if (p.y !== -h / 2) {
9938        p.y -= sign(p.y + h / 2) * margin;
9939      }
9940
9941      return p;
9942    };
9943
9944    _proto._getCacheImageAnchor = function _getCacheImageAnchor(w, h) {
9945      var shadow = 2 * (this.symbol['shadowBlur'] || 0),
9946          margin = shadow + this.padding;
9947      var markerType = this.style['markerType'];
9948
9949      if (markerType === 'bar' || markerType === 'pie' || markerType === 'pin') {
9950        return new Point(w / 2, h - margin);
9951      } else if (markerType === 'rectangle') {
9952        return new Point(margin, margin);
9953      } else {
9954        return new Point(w / 2, h / 2);
9955      }
9956    };
9957
9958    _proto._getGraidentExtent = function _getGraidentExtent(points) {
9959      var e = new PointExtent(),
9960          dxdy = this.getDxDy(),
9961          m = this.getFixedExtent();
9962
9963      if (Array.isArray(points)) {
9964        for (var i = points.length - 1; i >= 0; i--) {
9965          e._combine(points[i]);
9966        }
9967      } else {
9968        e._combine(points);
9969      }
9970
9971      e['xmin'] += m['xmin'] - dxdy.x;
9972      e['ymin'] += m['ymin'] - dxdy.y;
9973      e['xmax'] += m['xmax'] - dxdy.x;
9974      e['ymax'] += m['ymax'] - dxdy.y;
9975      return e;
9976    };
9977
9978    _proto._drawVectorMarker = function _drawVectorMarker(ctx, point, resources) {
9979      var style = this.style,
9980          strokeAndFill = this.strokeAndFill,
9981          markerType = style['markerType'].toLowerCase(),
9982          vectorArray = VectorMarkerSymbolizer._getVectorPoints(markerType, style['markerWidth'], style['markerHeight']),
9983          lineOpacity = strokeAndFill['lineOpacity'],
9984          fillOpacity = strokeAndFill['polygonOpacity'];
9985
9986      var gradient = isGradient(strokeAndFill['lineColor']) || isGradient(strokeAndFill['polygonFill']);
9987
9988      if (gradient) {
9989        var gradientExtent;
9990
9991        if (isGradient(strokeAndFill['lineColor'])) {
9992          gradientExtent = this._getGraidentExtent(point);
9993          strokeAndFill['lineGradientExtent'] = gradientExtent.expand(strokeAndFill['lineWidth']);
9994        }
9995
9996        if (isGradient(strokeAndFill['polygonFill'])) {
9997          if (!gradientExtent) {
9998            gradientExtent = this._getGraidentExtent(point);
9999          }
10000
10001          strokeAndFill['polygonGradientExtent'] = gradientExtent;
10002        }
10003
10004        this.prepareCanvas(ctx, strokeAndFill, resources);
10005      }
10006
10007      var width = style['markerWidth'],
10008          height = style['markerHeight'],
vendor: 11,410 bytes, lines 10009-10366
10009          hLineWidth = style['markerLineWidth'] / 2;
10010
10011      if (markerType === 'ellipse') {
10012        Canvas.ellipse(ctx, point, width / 2, height / 2, lineOpacity, fillOpacity);
10013      } else if (markerType === 'cross' || markerType === 'x') {
10014        for (var j = vectorArray.length - 1; j >= 0; j--) {
10015          vectorArray[j]._add(point);
10016        }
10017
10018        Canvas.path(ctx, vectorArray.slice(0, 2), lineOpacity);
10019        Canvas.path(ctx, vectorArray.slice(2, 4), lineOpacity);
10020      } else if (markerType === 'diamond' || markerType === 'bar' || markerType === 'square' || markerType === 'rectangle' || markerType === 'triangle') {
10021        if (markerType === 'bar') {
10022          point = point.add(0, -hLineWidth);
10023        } else if (markerType === 'rectangle') {
10024          point = point.add(hLineWidth, hLineWidth);
10025        }
10026
10027        for (var _j = vectorArray.length - 1; _j >= 0; _j--) {
10028          vectorArray[_j]._add(point);
10029        }
10030
10031        Canvas.polygon(ctx, vectorArray, lineOpacity, fillOpacity);
10032      } else if (markerType === 'pin') {
10033        point = point.add(0, -hLineWidth);
10034
10035        for (var _j2 = vectorArray.length - 1; _j2 >= 0; _j2--) {
10036          vectorArray[_j2]._add(point);
10037        }
10038
10039        var lineCap = ctx.lineCap;
10040        ctx.lineCap = 'round';
10041        Canvas.bezierCurveAndFill(ctx, vectorArray, lineOpacity, fillOpacity);
10042        ctx.lineCap = lineCap;
10043      } else if (markerType === 'pie') {
10044        point = point.add(0, hLineWidth);
10045        var angle = Math.atan(width / 2 / height) * 180 / Math.PI;
10046        var _lineCap = ctx.lineCap;
10047        ctx.lineCap = 'round';
10048        Canvas.sector(ctx, point, height, [90 - angle, 90 + angle], lineOpacity, fillOpacity);
10049        ctx.lineCap = _lineCap;
10050      } else {
10051        throw new Error('unsupported markerType: ' + markerType);
10052      }
10053    };
10054
10055    _proto.getPlacement = function getPlacement() {
10056      return this.symbol['markerPlacement'];
10057    };
10058
10059    _proto.getRotation = function getRotation() {
10060      var r = this.style['markerRotation'];
10061
10062      if (!isNumber(r)) {
10063        return null;
10064      }
10065
10066      return -r * Math.PI / 180;
10067    };
10068
10069    _proto.getFixedExtent = function getFixedExtent() {
10070      var dxdy = this.getDxDy(),
10071          padding = this.padding * 2;
10072
10073      var size = this._calMarkerSize().map(function (d) {
10074        return d - padding;
10075      });
10076
10077      var alignPoint = this._getAnchor(size[0], size[1]);
10078
10079      var result = new PointExtent(dxdy.add(0, 0), dxdy.add(size[0], size[1]));
10080
10081      result._add(alignPoint);
10082
10083      var rotation = this.getRotation();
10084
10085      if (rotation) {
10086        result = this._rotateExtent(result, rotation);
10087      }
10088
10089      return result;
10090    };
10091
10092    _proto.translate = function translate() {
10093      var s = this.symbol;
10094      var result = {
10095        'markerType': getValueOrDefault(s['markerType'], 'ellipse'),
10096        'markerFill': getValueOrDefault(s['markerFill'], '#00f'),
10097        'markerFillOpacity': getValueOrDefault(s['markerFillOpacity'], 1),
10098        'markerFillPatternFile': getValueOrDefault(s['markerFillPatternFile'], null),
10099        'markerLineColor': getValueOrDefault(s['markerLineColor'], '#000'),
10100        'markerLineWidth': getValueOrDefault(s['markerLineWidth'], 1),
10101        'markerLineOpacity': getValueOrDefault(s['markerLineOpacity'], 1),
10102        'markerLineDasharray': getValueOrDefault(s['markerLineDasharray'], []),
10103        'markerLinePatternFile': getValueOrDefault(s['markerLinePatternFile'], null),
10104        'markerDx': getValueOrDefault(s['markerDx'], 0),
10105        'markerDy': getValueOrDefault(s['markerDy'], 0),
10106        'markerWidth': getValueOrDefault(s['markerWidth'], 10),
10107        'markerHeight': getValueOrDefault(s['markerHeight'], 10),
10108        'markerRotation': getValueOrDefault(s['markerRotation'], 0)
10109      };
10110      var markerType = result['markerType'];
10111      var ha, va;
10112
10113      if (markerType === 'bar' || markerType === 'pie' || markerType === 'pin') {
10114        ha = 'middle';
10115        va = 'top';
10116      } else if (markerType === 'rectangle') {
10117        ha = 'right';
10118        va = 'bottom';
10119      } else {
10120        ha = 'middle';
10121        va = 'middle';
10122      }
10123
10124      result['markerHorizontalAlignment'] = getValueOrDefault(s['markerHorizontalAlignment'], ha);
10125      result['markerVerticalAlignment'] = getValueOrDefault(s['markerVerticalAlignment'], va);
10126
10127      if (isNumber(s['markerOpacity'])) {
10128        if (isNumber(s['markerFillOpacity'])) {
10129          result['markerFillOpacity'] *= s['markerOpacity'];
10130        }
10131
10132        if (isNumber(s['markerLineOpacity'])) {
10133          result['markerLineOpacity'] *= s['markerOpacity'];
10134        }
10135      }
10136
10137      return result;
10138    };
10139
10140    VectorMarkerSymbolizer.translateLineAndFill = function translateLineAndFill(s) {
10141      var result = {
10142        'lineColor': s['markerLineColor'],
10143        'linePatternFile': s['markerLinePatternFile'],
10144        'lineWidth': s['markerLineWidth'],
10145        'lineOpacity': s['markerLineOpacity'],
10146        'lineDasharray': s['markerLineDasharray'],
10147        'lineCap': 'butt',
10148        'lineJoin': 'round',
10149        'polygonFill': s['markerFill'],
10150        'polygonPatternFile': s['markerFillPatternFile'],
10151        'polygonOpacity': s['markerFillOpacity']
10152      };
10153
10154      if (result['lineWidth'] === 0) {
10155        result['lineOpacity'] = 0;
10156      }
10157
10158      return result;
10159    };
10160
10161    VectorMarkerSymbolizer._getVectorPoints = function _getVectorPoints(markerType, width, height) {
10162      var hh = height / 2,
10163          hw = width / 2;
10164      var left = 0,
10165          top = 0;
10166      var v0, v1, v2, v3;
10167
10168      if (markerType === 'triangle') {
10169        v0 = new Point(left, top - hh);
10170        v1 = new Point(left - hw, top + hh);
10171        v2 = new Point(left + hw, top + hh);
10172        return [v0, v1, v2];
10173      } else if (markerType === 'cross') {
10174        v0 = new Point(left - hw, top);
10175        v1 = new Point(left + hw, top);
10176        v2 = new Point(left, top - hh);
10177        v3 = new Point(left, top + hh);
10178        return [v0, v1, v2, v3];
10179      } else if (markerType === 'diamond') {
10180        v0 = new Point(left - hw, top);
10181        v1 = new Point(left, top - hh);
10182        v2 = new Point(left + hw, top);
10183        v3 = new Point(left, top + hh);
10184        return [v0, v1, v2, v3];
10185      } else if (markerType === 'square') {
10186        v0 = new Point(left - hw, top + hh);
10187        v1 = new Point(left + hw, top + hh);
10188        v2 = new Point(left + hw, top - hh);
10189        v3 = new Point(left - hw, top - hh);
10190        return [v0, v1, v2, v3];
10191      } else if (markerType === 'rectangle') {
10192        v0 = new Point(left, top);
10193        v1 = v0.add(width, 0);
10194        v2 = v0.add(width, height);
10195        v3 = v0.add(0, height);
10196        return [v0, v1, v2, v3];
10197      } else if (markerType === 'x') {
10198        v0 = new Point(left - hw, top + hh);
10199        v1 = new Point(left + hw, top - hh);
10200        v2 = new Point(left + hw, top + hh);
10201        v3 = new Point(left - hw, top - hh);
10202        return [v0, v1, v2, v3];
10203      } else if (markerType === 'bar') {
10204        v0 = new Point(left - hw, top - height);
10205        v1 = new Point(left + hw, top - height);
10206        v2 = new Point(left + hw, top);
10207        v3 = new Point(left - hw, top);
10208        return [v0, v1, v2, v3];
10209      } else if (markerType === 'pin') {
10210        var extWidth = height * Math.atan(hw / hh);
10211        v0 = new Point(left, top);
10212        v1 = new Point(left - extWidth, top - height);
10213        v2 = new Point(left + extWidth, top - height);
10214        v3 = new Point(left, top);
10215        return [v0, v1, v2, v3];
10216      }
10217
10218      return [];
10219    };
10220
10221    return VectorMarkerSymbolizer;
10222  }(PointSymbolizer);
10223
10224  var DebugSymbolizer = function (_PointSymbolizer) {
10225    _inheritsLoose(DebugSymbolizer, _PointSymbolizer);
10226
10227    function DebugSymbolizer() {
10228      return _PointSymbolizer.apply(this, arguments) || this;
10229    }
10230
10231    var _proto = DebugSymbolizer.prototype;
10232
10233    _proto.getPlacement = function getPlacement() {
10234      return 'point';
10235    };
10236
10237    _proto.getDxDy = function getDxDy() {
10238      return new Point(0, 0);
10239    };
10240
10241    _proto.symbolize = function symbolize(ctx) {
10242      var geometry = this.geometry,
10243          layer = geometry.getLayer();
10244
10245      if (!geometry.options['debug'] && layer && !layer.options['debug']) {
10246        return;
10247      }
10248
10249      var map = this.getMap();
10250
10251      if (!map || map.isZooming()) {
10252        return;
10253      }
10254
10255      var color = layer.options['debugOutline'],
10256          op = 1;
10257      ctx.strokeStyle = color;
10258      ctx.fillStyle = color;
10259      var outline = this.getPainter().getContainerExtent().toArray();
10260      Canvas.polygon(ctx, [outline], op, 0);
10261
10262      var points = this._getRenderContainerPoints(),
10263          id = this.geometry.getId(),
10264          cross = VectorMarkerSymbolizer._getVectorPoints('cross', 10, 10);
10265
10266      for (var i = 0; i < points.length; i++) {
10267        var p = points[i];
10268
10269        if (!isNil(id)) {
10270          Canvas.fillText(ctx, id, p.add(8, -4), color);
10271        }
10272
10273        var c = [];
10274
10275        for (var ii = 0; ii < cross.length; ii++) {
10276          c.push(cross[ii].add(p));
10277        }
10278
10279        Canvas.path(ctx, c.slice(0, 2), op);
10280        Canvas.path(ctx, c.slice(2, 4), op);
10281      }
10282    };
10283
10284    return DebugSymbolizer;
10285  }(PointSymbolizer);
10286
10287  var ImageMarkerSymbolizer = function (_PointSymbolizer) {
10288    _inheritsLoose(ImageMarkerSymbolizer, _PointSymbolizer);
10289
10290    ImageMarkerSymbolizer.test = function test(symbol) {
10291      if (!symbol) {
10292        return false;
10293      }
10294
10295      if (!isNil(symbol['markerFile'])) {
10296        return true;
10297      }
10298
10299      return false;
10300    };
10301
10302    function ImageMarkerSymbolizer(symbol, geometry, painter) {
10303      var _this;
10304
10305      _this = _PointSymbolizer.call(this, symbol, geometry, painter) || this;
10306      _this.style = _this._defineStyle(_this.translate());
10307      return _this;
10308    }
10309
10310    var _proto = ImageMarkerSymbolizer.prototype;
10311
10312    _proto.symbolize = function symbolize(ctx, resources) {
10313      var style = this.style;
10314
10315      if (!this.painter.isHitTesting() && (style['markerWidth'] === 0 || style['markerHeight'] === 0 || style['markerOpacity'] === 0)) {
10316        return;
10317      }
10318
10319      var cookedPoints = this._getRenderContainerPoints();
10320
10321      if (!isArrayHasData(cookedPoints)) {
10322        return;
10323      }
10324
10325      var img = this._getImage(resources);
10326
10327      if (!img) {
10328        if (typeof console !== 'undefined') {
10329          console.warn('no img found for ' + (this.style['markerFile'] || this._url[0]));
10330        }
10331
10332        return;
10333      }
10334
10335      this._prepareContext(ctx);
10336
10337      var width = style['markerWidth'];
10338      var height = style['markerHeight'];
10339
10340      if (!isNumber(width) || !isNumber(height)) {
10341        width = img.width;
10342        height = img.height;
10343        style['markerWidth'] = width;
10344        style['markerHeight'] = height;
10345        var imgURL = [style['markerFile'], style['markerWidth'], style['markerHeight']];
10346
10347        if (!resources.isResourceLoaded(imgURL)) {
10348          resources.addResource(imgURL, img);
10349        }
10350
10351        var painter = this.getPainter();
10352
10353        if (!painter.isSpriting()) {
10354          painter.removeCache();
10355        }
10356      }
10357
10358      var alpha;
10359
10360      if (this.symbol['markerType'] !== 'path' && isNumber(style['markerOpacity']) && style['markerOpacity'] < 1) {
10361        alpha = ctx.globalAlpha;
10362        ctx.globalAlpha *= style['markerOpacity'];
10363      }
10364
10365      var alignPoint = getAlignPoint(new Size(width, height), style['markerHorizontalAlignment'], style['markerVerticalAlignment']);
10366
10367      for (var i = 0, len = cookedPoints.length; i < len; i++) {
10368        var p = cookedPoints[i];
10369
10370        var origin = this._rotate(ctx, p, this._getRotationAt(i));
10371
10372        if (origin) {
10373          p = origin;
10374        }
10375
10376        Canvas.image(ctx, img, p.x + alignPoint.x, p.y + alignPoint.y, width, height);
10377
10378        if (origin) {
10379          ctx.restore();
10380        }
10381      }
10382
10383      if (alpha !== undefined) {
10384        ctx.globalAlpha = alpha;
10385      }
10386    };
10387
10388    _proto._getImage = function _getImage(resources) {
10389      var img = !resources ? null : resources.getImage([this.style['markerFile'], this.style['markerWidth'], this.style['markerHeight']]);
10390      return img;
10391    };
10392
10393    _proto.getPlacement = function getPlacement() {
10394      return this.symbol['markerPlacement'];
10395    };
10396
10397    _proto.getRotation = function getRotation() {
10398      var r = this.style['markerRotation'];
10399
10400      if (!isNumber(r)) {
10401        return null;
10402      }
10403
10404      return -r * Math.PI / 180;
10405    };
10406
10407    _proto.getDxDy = function getDxDy() {
10408      var s = this.style;
10409      var dx = s['markerDx'],
10410          dy = s['markerDy'];
10411      return new Point(dx, dy);
10412    };
10413
10414    _proto.getFixedExtent = function getFixedExtent(resources) {
10415      var style = this.style;
10416      var url = style['markerFile'],
10417          img = resources ? resources.getImage(url) : null;
10418      var width = style['markerWidth'] || (img ? img.width : 0),
10419          height = style['markerHeight'] || (img ? img.height : 0);
10420      var dxdy = this.getDxDy();
10421      var alignPoint = getAlignPoint(new Size(width, height), style['markerHorizontalAlignment'], style['markerVerticalAlignment']);
10422      var result = new PointExtent(dxdy.add(0, 0), dxdy.add(width, height));
10423
10424      result._add(alignPoint);
10425
10426      var rotation = this.getRotation();
10427
10428      if (rotation) {
10429        result = this._rotateExtent(result, rotation);
10430      }
10431
10432      return result;
10433    };
10434
10435    _proto.translate = function translate() {
10436      var s = this.symbol;
10437      return {
10438        'markerFile': s['markerFile'],
10439        'markerOpacity': getValueOrDefault(s['markerOpacity'], 1),
10440        'markerWidth': getValueOrDefault(s['markerWidth'], null),
10441        'markerHeight': getValueOrDefault(s['markerHeight'], null),
10442        'markerRotation': getValueOrDefault(s['markerRotation'], 0),
10443        'markerDx': getValueOrDefault(s['markerDx'], 0),
10444        'markerDy': getValueOrDefault(s['markerDy'], 0),
10445        'markerHorizontalAlignment': getValueOrDefault(s['markerHorizontalAlignment'], 'middle'),
10446        'markerVerticalAlignment': getValueOrDefault(s['markerVerticalAlignment'], 'top')
10447      };
10448    };
10449
10450    return ImageMarkerSymbolizer;
10451  }(PointSymbolizer);
10452
10453  var TEMP_COORD0$1 = new Coordinate(0, 0);
10454  var TEMP_COORD1$1 = new Coordinate(0, 0);
10455
10456  var StrokeAndFillSymbolizer = function (_CanvasSymbolizer) {
10457    _inheritsLoose(StrokeAndFillSymbolizer, _CanvasSymbolizer);
10458
10459    StrokeAndFillSymbolizer.test = function test(symbol, geometry) {
10460      if (!symbol) {
10461        return false;
10462      }
10463
10464      if (geometry && geometry.type === 'Point') {
10465        return false;
10466      }
10467
10468      for (var p in symbol) {
10469        var f = p.slice(0, 4);
10470
10471        if (f === 'line' || f === 'poly') {
10472          return true;
10473        }
10474      }
10475
10476      return false;
10477    };
10478
10479    function StrokeAndFillSymbolizer(symbol, geometry, painter) {
10480      var _this;
10481
10482      _this = _CanvasSymbolizer.call(this) || this;
10483      _this.symbol = symbol;
10484      _this.geometry = geometry;
10485      _this.painter = painter;
10486
10487      if (geometry.type === 'Point') {
10488        return _assertThisInitialized(_this);
10489      }
10490
10491      _this.style = _this._defineStyle(_this.translate());
10492      return _this;
10493    }
10494
10495    var _proto = StrokeAndFillSymbolizer.prototype;
10496
10497    _proto.symbolize = function symbolize(ctx, resources) {
10498      var style = this.style;
10499
10500      if (style['polygonOpacity'] === 0 && style['lineOpacity'] === 0 && !this.painter.isHitTesting()) {
10501        return;
10502      }
10503
10504      var paintParams = this._getPaintParams();
10505
10506      if (!paintParams) {
10507        return;
10508      }
10509
10510      this._prepareContext(ctx);
10511
10512      var isGradient$$1 = isGradient(style['lineColor']),
10513          isPath = this.geometry.getJSONType() === 'Polygon' || this.geometry.type === 'LineString';
10514
10515      if (isGradient$$1 && (style['lineColor']['places'] || !isPath)) {
10516        style['lineGradientExtent'] = this.getPainter().getContainerExtent()._expand(style['lineWidth']);
10517      }
10518
10519      if (isGradient(style['polygonFill'])) {
10520        style['polygonGradientExtent'] = this.getPainter().getContainerExtent();
10521      }
10522
10523      var points = paintParams[0],
10524          isSplitted = this.geometry.getJSONType() === 'Polygon' && points.length > 0 && Array.isArray(points[0][0]) || this.geometry.type === 'LineString' && points.length > 0 && Array.isArray(points[0]);
10525
10526      if (isSplitted) {
10527        for (var i = 0; i < points.length; i++) {
10528          this.prepareCanvas(ctx, style, resources);
10529
10530          if (isGradient$$1 && isPath && !style['lineColor']['places']) {
10531            this._createGradient(ctx, points[i], style['lineColor']);
10532          }
10533
10534          var params = [ctx, points[i]];
10535
10536          if (paintParams.length > 1) {
vendor: 4,195 bytes, lines 10537-10660
10537            params.push.apply(params, paintParams.slice(1));
10538          }
10539
10540          params.push(style['lineOpacity'], style['polygonOpacity'], style['lineDasharray']);
10541
10542          this.geometry._paintOn.apply(this.geometry, params);
10543        }
10544      } else {
10545        this.prepareCanvas(ctx, style, resources);
10546
10547        if (isGradient$$1 && isPath && !style['lineColor']['places']) {
10548          this._createGradient(ctx, points, style['lineColor']);
10549        }
10550
10551        var _params = [ctx];
10552
10553        _params.push.apply(_params, paintParams);
10554
10555        _params.push(style['lineOpacity'], style['polygonOpacity'], style['lineDasharray']);
10556
10557        this.geometry._paintOn.apply(this.geometry, _params);
10558      }
10559
10560      if (ctx.setLineDash && Array.isArray(style['lineDasharray'])) {
10561        ctx.setLineDash([]);
10562      }
10563    };
10564
10565    _proto.get2DExtent = function get2DExtent() {
10566      var map = this.getMap();
10567
10568      var extent = this.geometry._getPrjExtent();
10569
10570      if (!extent) {
10571        return null;
10572      }
10573
10574      if (!this._extMin || !this._extMax) {
10575        this._extMin = new Coordinate(0, 0);
10576        this._extMax = new Coordinate(0, 0);
10577      }
10578
10579      this._extMin.x = extent['xmin'];
10580      this._extMin.y = extent['ymin'];
10581      this._extMax.x = extent['xmax'];
10582      this._extMax.y = extent['ymax'];
10583
10584      var min = map._prjToPoint(this._extMin, undefined, TEMP_COORD0$1),
10585          max = map._prjToPoint(this._extMax, undefined, TEMP_COORD1$1);
10586
10587      if (!this._pxExtent) {
10588        this._pxExtent = new PointExtent(min, max);
10589      } else {
10590        this._pxExtent.set(Math.min(min.x, max.x), Math.min(min.y, max.y), Math.max(min.x, max.x), Math.max(min.y, max.y));
10591      }
10592
10593      return this._pxExtent;
10594    };
10595
10596    _proto.getFixedExtent = function getFixedExtent() {
10597      var t = this.style['lineWidth'] / 2;
10598      return new PointExtent(-t, -t, t, t);
10599    };
10600
10601    _proto._getPaintParams = function _getPaintParams() {
10602      return this.getPainter().getPaintParams(this.style['lineDx'], this.style['lineDy']);
10603    };
10604
10605    _proto.translate = function translate() {
10606      var s = this.symbol;
10607      var result = {
10608        'lineColor': getValueOrDefault(s['lineColor'], '#000'),
10609        'lineWidth': getValueOrDefault(s['lineWidth'], 2),
10610        'lineOpacity': getValueOrDefault(s['lineOpacity'], 1),
10611        'lineDasharray': getValueOrDefault(s['lineDasharray'], []),
10612        'lineCap': getValueOrDefault(s['lineCap'], 'butt'),
10613        'lineJoin': getValueOrDefault(s['lineJoin'], 'miter'),
10614        'linePatternFile': getValueOrDefault(s['linePatternFile'], null),
10615        'lineDx': getValueOrDefault(s['lineDx'], 0),
10616        'lineDy': getValueOrDefault(s['lineDy'], 0),
10617        'polygonFill': getValueOrDefault(s['polygonFill'], null),
10618        'polygonOpacity': getValueOrDefault(s['polygonOpacity'], 1),
10619        'polygonPatternFile': getValueOrDefault(s['polygonPatternFile'], null),
10620        'polygonPatternDx': getValueOrDefault(s['polygonPatternDx'], 0),
10621        'polygonPatternDy': getValueOrDefault(s['polygonPatternDy'], 0),
10622        'linePatternDx': getValueOrDefault(s['linePatternDx'], 0),
10623        'linePatternDy': getValueOrDefault(s['linePatternDy'], 0)
10624      };
10625
10626      if (result['lineWidth'] === 0) {
10627        result['lineOpacity'] = 0;
10628      }
10629
10630      if (this.geometry.type === 'LineString' && !result['polygonFill']) {
10631        result['polygonFill'] = result['lineColor'];
10632      }
10633
10634      return result;
10635    };
10636
10637    _proto._createGradient = function _createGradient(ctx, points, lineColor) {
10638      if (!Array.isArray(points) || !points.length) {
10639        return;
10640      }
10641
10642      var len = points.length;
10643      var grad = ctx.createLinearGradient(points[0].x, points[0].y, points[len - 1].x, points[len - 1].y);
10644      lineColor['colorStops'].forEach(function (stop) {
10645        grad.addColorStop.apply(grad, stop);
10646      });
10647      ctx.strokeStyle = grad;
10648    };
10649
10650    return StrokeAndFillSymbolizer;
10651  }(CanvasSymbolizer);
10652
10653  var CACHE_KEY = '___text_symbol_cache';
10654
10655  var TextMarkerSymbolizer = function (_PointSymbolizer) {
10656    _inheritsLoose(TextMarkerSymbolizer, _PointSymbolizer);
10657
10658    TextMarkerSymbolizer.test = function test(symbol) {
10659      if (!symbol) {
10660        return false;
10661      }
10662
10663      if (!isNil(symbol['textName'])) {
10664        return true;
10665      }
10666
10667      return false;
10668    };
10669
10670    function TextMarkerSymbolizer(symbol, geometry, painter) {
10671      var _this;
10672
10673      _this = _PointSymbolizer.call(this, symbol, geometry, painter) || this;
10674      _this._dynamic = hasFunctionDefinition(symbol);
10675      _this.style = _this._defineStyle(_this.translate());
10676
10677      if (_this.style['textWrapWidth'] === 0) {
10678        return _assertThisInitialized(_this);
10679      }
10680
10681      _this.strokeAndFill = _this._defineStyle(_this.translateLineAndFill(_this.style));
10682      var textContent = replaceVariable(_this.style['textName'], _this.geometry.getProperties());
10683
10684      if (!_this._dynamic) {
10685        _this._cacheKey = genCacheKey(textContent, _this.style);
10686      }
10687
10688      _this._descText(textContent);
10689
10690      return _this;
10691    }
10692
10693    var _proto = TextMarkerSymbolizer.prototype;
10694
10695    _proto.symbolize = function symbolize(ctx, resources) {
10696      if (!this.painter.isHitTesting() && (this.style['textSize'] === 0 || !this.style['textOpacity'] && (!this.style['textHaloRadius'] || !this.style['textHaloOpacity']) || this.style['textWrapWidth'] === 0)) {
10697        return;
10698      }
10699
10700      var cookedPoints = this._getRenderContainerPoints();
10701
10702      if (!isArrayHasData(cookedPoints)) {
10703        return;
10704      }
10705
10706      var style = this.style,
10707          strokeAndFill = this.strokeAndFill;
10708      var textContent = replaceVariable(this.style['textName'], this.geometry.getProperties());
10709
10710      this._descText(textContent);
10711
10712      this._prepareContext(ctx);
10713
10714      this.prepareCanvas(ctx, strokeAndFill, resources);
10715      Canvas.prepareCanvasFont(ctx, style);
10716
10717      for (var i = 0, len = cookedPoints.length; i < len; i++) {
10718        var p = cookedPoints[i];
10719
10720        var origin = this._rotate(ctx, p, this._getRotationAt(i));
10721
10722        if (origin) {
10723          p = origin;
10724        }
10725
10726        Canvas.text(ctx, textContent, p, style, this.textDesc);
10727
10728        if (origin) {
10729          ctx.restore();
10730        }
10731      }
10732    };
10733
10734    _proto.getPlacement = function getPlacement() {
10735      return this.symbol['textPlacement'];
10736    };
10737
10738    _proto.getRotation = function getRotation() {
10739      var r = this.style['textRotation'];
10740
10741      if (!isNumber(r)) {
10742        return null;
10743      }
10744
10745      return -r * Math.PI / 180;
10746    };
10747
10748    _proto.getDxDy = function getDxDy() {
10749      var s = this.style;
10750      return new Point(s['textDx'], s['textDy']);
10751    };
10752
10753    _proto.getFixedExtent = function getFixedExtent() {
10754      var dxdy = this.getDxDy(),
10755          style = this.style;
10756      var size = this.textDesc['size'];
10757      var alignPoint = getAlignPoint(size, style['textHorizontalAlignment'], style['textVerticalAlignment']);
10758      var alignW = alignPoint.x,
10759          alignH = alignPoint.y;
10760
10761      if (style['textHaloRadius']) {
10762        var r = style['textHaloRadius'];
10763        size = size.add(r * 2, r * 2);
10764      }
10765
10766      var result = new PointExtent(dxdy.add(alignW, alignH), dxdy.add(alignW + size['width'], alignH + size['height']));
10767      var rotation = this.getRotation();
10768
10769      if (rotation) {
10770        result = this._rotateExtent(result, rotation);
10771      }
10772
10773      return result;
10774    };
10775
10776    _proto.translate = function translate() {
10777      var s = this.symbol;
10778      var result = {
10779        'textName': s['textName'],
10780        'textFaceName': getValueOrDefault(s['textFaceName'], 'monospace'),
10781        'textWeight': getValueOrDefault(s['textWeight'], 'normal'),
10782        'textStyle': getValueOrDefault(s['textStyle'], 'normal'),
10783        'textSize': getValueOrDefault(s['textSize'], 10),
10784        'textFont': getValueOrDefault(s['textFont'], null),
10785        'textFill': getValueOrDefault(s['textFill'], '#000'),
10786        'textOpacity': getValueOrDefault(s['textOpacity'], 1),
10787        'textHaloFill': getValueOrDefault(s['textHaloFill'], '#ffffff'),
10788        'textHaloRadius': getValueOrDefault(s['textHaloRadius'], 0),
10789        'textHaloOpacity': getValueOrDefault(s['textHaloOpacity'], 1),
10790        'textWrapWidth': getValueOrDefault(s['textWrapWidth'], null),
10791        'textWrapCharacter': getValueOrDefault(s['textWrapCharacter'], '\n'),
10792        'textLineSpacing': getValueOrDefault(s['textLineSpacing'], 0),
10793        'textDx': getValueOrDefault(s['textDx'], 0),
10794        'textDy': getValueOrDefault(s['textDy'], 0),
10795        'textHorizontalAlignment': getValueOrDefault(s['textHorizontalAlignment'], 'middle'),
10796        'textVerticalAlignment': getValueOrDefault(s['textVerticalAlignment'], 'middle'),
10797        'textAlign': getValueOrDefault(s['textAlign'], 'center'),
10798        'textRotation': getValueOrDefault(s['textRotation'], 0),
10799        'textMaxWidth': getValueOrDefault(s['textMaxWidth'], 0),
10800        'textMaxHeight': getValueOrDefault(s['textMaxHeight'], 0)
10801      };
10802
10803      if (result['textMaxWidth'] > 0 && (!result['textWrapWidth'] || result['textWrapWidth'] > result['textMaxWidth'])) {
10804        if (!result['textWrapWidth']) {
10805          result['textMaxHeight'] = 1;
10806        }
10807
10808        result['textWrapWidth'] = result['textMaxWidth'];
10809      }
10810
10811      return result;
10812    };
10813
10814    _proto.translateLineAndFill = function translateLineAndFill(s) {
10815      return {
10816        'lineColor': s['textHaloRadius'] ? s['textHaloFill'] : s['textFill'],
10817        'lineWidth': s['textHaloRadius'],
10818        'lineOpacity': s['textOpacity'],
10819        'lineDasharray': null,
10820        'lineCap': 'butt',
10821        'lineJoin': 'round',
10822        'polygonFill': s['textFill'],
10823        'polygonOpacity': s['textOpacity']
10824      };
10825    };
10826
10827    _proto._descText = function _descText(textContent) {
10828      if (this._dynamic) {
10829        this.textDesc = this._measureText(textContent);
10830        return;
10831      }
10832
10833      this.textDesc = this._loadFromCache();
10834
10835      if (!this.textDesc) {
10836        this.textDesc = this._measureText(textContent);
10837
10838        this._storeToCache(this.textDesc);
10839      }
10840    };
10841
10842    _proto._measureText = function _measureText(textContent) {
10843      var maxHeight = this.style['textMaxHeight'];
10844      var textDesc = splitTextToRow(textContent, this.style);
10845
10846      if (maxHeight && maxHeight < textDesc.size.height) {
10847        textDesc.size.height = maxHeight;
10848      }
10849
10850      return textDesc;
10851    };
10852
10853    _proto._storeToCache = function _storeToCache(textDesc) {
10854      if (IS_NODE) {
10855        return;
10856      }
10857
10858      if (!this.geometry[CACHE_KEY]) {
10859        this.geometry[CACHE_KEY] = {};
10860      }
10861
10862      this.geometry[CACHE_KEY][this._cacheKey] = {
10863        'desc': textDesc,
10864        'active': true
10865      };
10866    };
10867
10868    _proto._loadFromCache = function _loadFromCache() {
10869      if (!this.geometry[CACHE_KEY]) {
10870        return null;
10871      }
10872
10873      var cache = this.geometry[CACHE_KEY][this._cacheKey];
10874
10875      if (!cache) {
10876        return null;
10877      }
10878
10879      cache.active = true;
10880      return cache.desc;
10881    };
10882
10883    return TextMarkerSymbolizer;
10884  }(PointSymbolizer);
10885  TextMarkerSymbolizer.CACHE_KEY = CACHE_KEY;
10886
10887  function genCacheKey(textContent, style) {
10888    var key = [textContent];
10889
10890    for (var p in style) {
10891      if (style.hasOwnProperty(p) && p.length > 4 && p.substring(0, 4) === 'text') {
10892        key.push(p + '=' + style[p]);
10893      }
10894    }
10895
10896    return key.join('-');
10897  }
10898
10899  var VectorPathMarkerSymbolizer = function (_ImageMarkerSymbolize) {
10900    _inheritsLoose(VectorPathMarkerSymbolizer, _ImageMarkerSymbolize);
10901
10902    VectorPathMarkerSymbolizer.test = function test(symbol) {
10903      if (!symbol) {
10904        return false;
vendor: 13,873 bytes, lines 10905-11399
10905      }
10906
10907      if (isNil(symbol['markerFile']) && symbol['markerType'] === 'path') {
10908        return true;
10909      }
10910
10911      return false;
10912    };
10913
10914    function VectorPathMarkerSymbolizer(symbol, geometry, painter) {
10915      var _this;
10916
10917      if (isNil(symbol['markerWidth'])) {
10918        symbol['markerWidth'] = 80;
10919      }
10920
10921      if (isNil(symbol['markerHeight'])) {
10922        symbol['markerHeight'] = 80;
10923      }
10924
10925      _this = _ImageMarkerSymbolize.call(this, symbol, geometry, painter) || this;
10926      symbol = extend(symbol, _this.translate());
10927
10928      var style = _this.style = _this._defineStyle(symbol);
10929
10930      if (Browser$1.gecko) {
10931        _this._url = [getMarkerPathBase64(style, style['markerWidth'], style['markerHeight']), style['markerWidth'], style['markerHeight']];
10932      } else {
10933        _this._url = [getMarkerPathBase64(style), style['markerWidth'], style['markerHeight']];
10934      }
10935
10936      return _this;
10937    }
10938
10939    var _proto = VectorPathMarkerSymbolizer.prototype;
10940
10941    _proto._prepareContext = function _prepareContext() {};
10942
10943    _proto._getImage = function _getImage(resources) {
10944      var _this2 = this;
10945
10946      if (resources && resources.isResourceLoaded(this._url)) {
10947        return resources.getImage(this._url);
10948      }
10949
10950      var painter = this.painter;
10951      var image = new Image();
10952
10953      image.onload = function () {
10954        var renderer = painter.getLayer() && painter.getLayer().getRenderer();
10955
10956        if (renderer) {
10957          renderer.setToRedraw();
10958        }
10959      };
10960
10961      image.onerror = function (err) {
10962        if (err && typeof console !== 'undefined') {
10963          console.warn(err);
10964        }
10965
10966        resources.markErrorResource(_this2._url);
10967      };
10968
10969      image.src = this._url[0];
10970
10971      if (resources) {
10972        resources.addResource(this._url, image);
10973      }
10974
10975      return image;
10976    };
10977
10978    return VectorPathMarkerSymbolizer;
10979  }(ImageMarkerSymbolizer);
10980
10981  var defaultSymbol = {
10982    lineWidth: 1,
10983    polygonFill: '#fff',
10984    polygonOpacity: 0.5
10985  };
10986
10987  var DrawAltitudeSymbolizer = function (_PointSymbolizer) {
10988    _inheritsLoose(DrawAltitudeSymbolizer, _PointSymbolizer);
10989
10990    DrawAltitudeSymbolizer.test = function test(symbol, geometry) {
10991      var layer = geometry.getLayer();
10992
10993      if (!layer) {
10994        return false;
10995      }
10996
10997      var type = geometry.getJSONType();
10998      return type === 'Marker' || type === 'LineString';
10999    };
11000
11001    function DrawAltitudeSymbolizer(symbol, geometry, painter) {
11002      var _this;
11003
11004      _this = _PointSymbolizer.call(this, symbol, geometry, painter) || this;
11005      _this.style = geometry.getLayer().options['drawAltitude'];
11006
11007      if (!_this.style || !isObject(_this.style)) {
11008        _this.style = {
11009          'lineWidth': 2
11010        };
11011      }
11012
11013      if (!_this.style['lineWidth']) {
11014        _this.style['lineWidth'] = 0;
11015      }
11016
11017      _this.dxdy = _this._defineStyle({
11018        'dx': symbol['textDx'] || symbol['markerDx'],
11019        'dy': symbol['textDy'] || symbol['markerDy']
11020      });
11021      return _this;
11022    }
11023
11024    var _proto = DrawAltitudeSymbolizer.prototype;
11025
11026    _proto.symbolize = function symbolize(ctx) {
11027      var layer = this.geometry.getLayer();
11028
11029      if (!layer.options['drawAltitude']) {
11030        return;
11031      }
11032
11033      var properties = this.geometry.getProperties();
11034
11035      if (!properties || !properties[layer.options['altitudeProperty']]) {
11036        return;
11037      }
11038
11039      var style = this._getStyle();
11040
11041      this._prepareContext(ctx);
11042
11043      if (this.geometry.type === 'LineString') {
11044        var paintParams = this._getPaintParams(style['lineDx'], style['lineDy']);
11045
11046        if (!paintParams) {
11047          return;
11048        }
11049
11050        var groundPoints = this.getPainter().getPaintParams(style['lineDx'], style['lineDy'], true)[0];
11051
11052        this._drawLineAltitude(ctx, paintParams[0], groundPoints);
11053      } else {
11054        var point = this._getRenderContainerPoints(),
11055            groundPoint = this._getRenderContainerPoints(true);
11056
11057        if (!point || point.length === 0) {
11058          return;
11059        }
11060
11061        this._drawMarkerAltitude(ctx, point[0], groundPoint[0]);
11062      }
11063    };
11064
11065    _proto.getDxDy = function getDxDy() {
11066      var s = this.dxdy;
11067      return new Point(s['dx'] || 0, s['dy'] || 0);
11068    };
11069
11070    _proto.get2DExtent = function get2DExtent() {
11071      if (this.geometry.type === 'LineString') {
11072        return StrokeAndFillSymbolizer.prototype.get2DExtent.apply(this);
11073      } else {
11074        return _PointSymbolizer.prototype.get2DExtent.call(this);
11075      }
11076    };
11077
11078    _proto.getPlacement = function getPlacement() {
11079      return 'point';
11080    };
11081
11082    _proto._getPaintParams = function _getPaintParams(dx, dy) {
11083      return this.getPainter().getPaintParams(dx || 0, dy || 0);
11084    };
11085
11086    _proto._drawMarkerAltitude = function _drawMarkerAltitude(ctx, point, groundPoint) {
11087      var style = this._getStyle();
11088
11089      this.prepareCanvas(ctx, style);
11090      Canvas.path(ctx, [point, groundPoint], style['lineOpacity'], null, style['lineDasharray']);
11091    };
11092
11093    _proto._drawLineAltitude = function _drawLineAltitude(ctx, points, groundPoints) {
11094      var style = this._getStyle();
11095
11096      var isSplitted = points.length > 0 && Array.isArray(points[0]);
11097
11098      if (isSplitted) {
11099        for (var i = 0; i < points.length; i++) {
11100          this._drawLine(ctx, points[i], groundPoints[i]);
11101        }
11102      } else {
11103        this._drawLine(ctx, points, groundPoints);
11104      }
11105
11106      if (ctx.setLineDash && Array.isArray(style['lineDasharray'])) {
11107        ctx.setLineDash([]);
11108      }
11109    };
11110
11111    _proto._drawLine = function _drawLine(ctx, points, groundPoints) {
11112      var style = this._getStyle();
11113
11114      this.prepareCanvas(ctx, style);
11115
11116      for (var i = 0, l = points.length - 1; i < l; i++) {
11117        Canvas.polygon(ctx, [points[i], points[i + 1], groundPoints[i + 1], groundPoints[i]], style['lineOpacity'], style['polygonOpacity'], style['lineDasharray']);
11118      }
11119    };
11120
11121    _proto._getStyle = function _getStyle() {
11122      var style = this.geometry.getLayer().options['drawAltitude'];
11123
11124      if (!isObject(style)) {
11125        style = defaultSymbol;
11126      }
11127
11128      if (!style['lineWidth']) {
11129        style['lineWidth'] = 0;
11130        style['lineOpacity'] = 0;
11131      }
11132
11133      return style;
11134    };
11135
11136    return DrawAltitudeSymbolizer;
11137  }(PointSymbolizer);
11138
11139
11140
11141  var index$3 = /*#__PURE__*/Object.freeze({
11142    Symbolizer: Symbolizer,
11143    CanvasSymbolizer: CanvasSymbolizer,
11144    DebugSymbolizer: DebugSymbolizer,
11145    ImageMarkerSymbolizer: ImageMarkerSymbolizer,
11146    PointSymbolizer: PointSymbolizer,
11147    StrokeAndFillSymbolizer: StrokeAndFillSymbolizer,
11148    TextMarkerSymbolizer: TextMarkerSymbolizer,
11149    VectorMarkerSymbolizer: VectorMarkerSymbolizer,
11150    VectorPathMarkerSymbolizer: VectorPathMarkerSymbolizer,
11151    DrawAltitudeSymbolizer: DrawAltitudeSymbolizer
11152  });
11153
11154  var registerSymbolizers = [DrawAltitudeSymbolizer, StrokeAndFillSymbolizer, ImageMarkerSymbolizer, VectorPathMarkerSymbolizer, VectorMarkerSymbolizer, TextMarkerSymbolizer];
11155  var testCanvas;
11156  var TEMP_POINT0$2 = new Point(0, 0);
11157  var TEMP_POINT1$1 = new Point(0, 0);
11158  var TEMP_POINT2 = new Point(0, 0);
11159  var TEMP_PAINT_EXTENT = new PointExtent();
11160  var TEMP_EXTENT$1 = new PointExtent();
11161  var TEMP_FIXED_EXTENT = new PointExtent();
11162  var TEMP_CLIP_EXTENT0 = new PointExtent();
11163  var TEMP_CLIP_EXTENT1 = new PointExtent();
11164
11165  var Painter = function (_Class) {
11166    _inheritsLoose(Painter, _Class);
11167
11168    function Painter(geometry) {
11169      var _this;
11170
11171      _this = _Class.call(this) || this;
11172      _this.geometry = geometry;
11173      _this.symbolizers = _this._createSymbolizers();
11174      _this._altAtGLZoom = _this._getGeometryAltitude();
11175      return _this;
11176    }
11177
11178    var _proto = Painter.prototype;
11179
11180    _proto.getMap = function getMap() {
11181      return this.geometry.getMap();
11182    };
11183
11184    _proto.getLayer = function getLayer() {
11185      return this.geometry.getLayer();
11186    };
11187
11188    _proto._createSymbolizers = function _createSymbolizers() {
11189      var geoSymbol = this.getSymbol(),
11190          symbolizers = [],
11191          regSymbolizers = registerSymbolizers;
11192      var symbols = geoSymbol;
11193
11194      if (!Array.isArray(geoSymbol)) {
11195        symbols = [geoSymbol];
11196      }
11197
11198      for (var ii = symbols.length - 1; ii >= 0; ii--) {
11199        var symbol = symbols[ii];
11200
11201        for (var i = regSymbolizers.length - 1; i >= 0; i--) {
11202          if (regSymbolizers[i].test(symbol, this.geometry)) {
11203            var symbolizer = new regSymbolizers[i](symbol, this.geometry, this);
11204            symbolizers.push(symbolizer);
11205
11206            if (symbolizer instanceof PointSymbolizer) {
11207              this._hasPoint = true;
11208            }
11209          }
11210        }
11211      }
11212
11213      if (!symbolizers.length) {
11214        if (console) {
11215          var id = this.geometry.getId();
11216          console.warn('invalid symbol for geometry(' + (this.geometry ? this.geometry.getType() + (id ? ':' + id : '') : '') + ') to draw : ' + JSON.stringify(geoSymbol));
11217        }
11218      }
11219
11220      this._debugSymbolizer = new DebugSymbolizer(geoSymbol, this.geometry, this);
11221      return symbolizers;
11222    };
11223
11224    _proto.hasPoint = function hasPoint() {
11225      return !!this._hasPoint;
11226    };
11227
11228    _proto.getRenderPoints = function getRenderPoints(placement) {
11229      if (!this._renderPoints) {
11230        this._renderPoints = {};
11231      }
11232
11233      if (!placement) {
11234        placement = 'center';
11235      }
11236
11237      if (!this._renderPoints[placement]) {
11238        this._renderPoints[placement] = this.geometry._getRenderPoints(placement);
11239      }
11240
11241      return this._renderPoints[placement];
11242    };
11243
11244    _proto.getPaintParams = function getPaintParams(dx, dy, ignoreAltitude) {
11245      var map = this.getMap(),
11246          geometry = this.geometry,
11247          res = map.getResolution(),
11248          pitched = map.getPitch() !== 0,
11249          rotated = map.getBearing() !== 0;
11250      var params = this._cachedParams;
11251
11252      var paintAsPath = geometry._paintAsPath && geometry._paintAsPath();
11253
11254      if (paintAsPath && this._unsimpledParams && res <= this._unsimpledParams._res) {
11255        params = this._unsimpledParams;
11256      } else if (!params || params._res !== map.getResolution() || this._pitched !== pitched && geometry._redrawWhenPitch() || this._rotated !== rotated && geometry._redrawWhenRotate()) {
11257        params = geometry._getPaintParams();
11258
11259        if (!params) {
11260          return null;
11261        }
11262
11263        params._res = res;
11264
11265        if (!geometry._simplified && paintAsPath) {
11266          if (!this._unsimpledParams) {
11267            this._unsimpledParams = params;
11268          }
11269
11270          if (res > this._unsimpledParams._res) {
11271            this._unsimpledParams._res = res;
11272          }
11273        }
11274
11275        this._cachedParams = params;
11276      }
11277
11278      if (!params) {
11279        return null;
11280      }
11281
11282      this._pitched = pitched;
11283      this._rotated = rotated;
11284      var zoomScale = map.getGLScale(),
11285          tr = [],
11286          points = params[0];
11287      var mapExtent = map.getContainerExtent();
11288
11289      var cPoints = this._pointContainerPoints(points, dx, dy, ignoreAltitude, this._hitPoint && !mapExtent.contains(this._hitPoint));
11290
11291      if (!cPoints) {
11292        return null;
11293      }
11294
11295      tr.push(cPoints);
11296
11297      for (var i = 1, l = params.length; i < l; i++) {
11298        if (isNumber(params[i]) || params[i] instanceof Size) {
11299          if (isNumber(params[i])) {
11300            tr.push(params[i] / zoomScale);
11301          } else {
11302            tr.push(params[i].multi(1 / zoomScale));
11303          }
11304        } else {
11305          tr.push(params[i]);
11306        }
11307      }
11308
11309      return tr;
11310    };
11311
11312    _proto._pointContainerPoints = function _pointContainerPoints(points, dx, dy, ignoreAltitude, disableClip, pointPlacement) {
11313      if (this._aboveCamera()) {
11314        return null;
11315      }
11316
11317      var map = this.getMap(),
11318          glZoom = map.getGLZoom(),
11319          containerOffset = this.containerOffset;
11320      var cPoints;
11321
11322      function pointContainerPoint(point, alt) {
11323        var p = map._pointToContainerPoint(point, glZoom, alt)._sub(containerOffset);
11324
11325        if (dx || dy) {
11326          p._add(dx || 0, dy || 0);
11327        }
11328
11329        return p;
11330      }
11331
11332      var altitude = this.getAltitude();
11333
11334      if (Array.isArray(points)) {
11335        var geometry = this.geometry;
11336        var clipped;
11337
11338        if (!disableClip && geometry.options['enableClip']) {
11339          clipped = this._clip(points, altitude);
11340        } else {
11341          clipped = {
11342            points: points,
11343            altitude: altitude
11344          };
11345        }
11346
11347        var clipPoints = clipped.points;
11348        altitude = clipped.altitude;
11349
11350        if (ignoreAltitude) {
11351          altitude = 0;
11352        }
11353
11354        var alt = altitude;
11355        cPoints = [];
11356
11357        for (var i = 0, l = clipPoints.length; i < l; i++) {
11358          var c = clipPoints[i];
11359
11360          if (Array.isArray(c)) {
11361            var cring = [];
11362
11363            for (var ii = 0, ll = c.length; ii < ll; ii++) {
11364              var cc = c[ii];
11365
11366              if (Array.isArray(altitude)) {
11367                if (altitude[i]) {
11368                  alt = altitude[i][ii];
11369                } else {
11370                  alt = 0;
11371                }
11372              }
11373
11374              cring.push(pointContainerPoint(cc, alt));
11375            }
11376
11377            cPoints.push(cring);
11378          } else {
11379            if (Array.isArray(altitude)) {
11380              if (pointPlacement === 'vertex-last') {
11381                alt = altitude[altitude.length - 1 - i];
11382              } else if (pointPlacement === 'line') {
11383                alt = (altitude[i] + altitude[i + 1]) / 2;
11384              } else {
11385                alt = altitude[i];
11386              }
11387            }
11388
11389            cPoints.push(pointContainerPoint(c, alt));
11390          }
11391        }
11392      } else if (points instanceof Point) {
11393        if (ignoreAltitude) {
11394          altitude = 0;
11395        }
11396
11397        cPoints = map._pointToContainerPoint(points, glZoom, altitude)._sub(containerOffset);
11398
11399        if (dx || dy) {
11400          cPoints._add(dx, dy);
11401        }
11402      }
11403
11404      return cPoints;
11405    };
11406
11407    _proto._clip = function _clip(points, altitude) {
11408      var map = this.getMap(),
11409          geometry = this.geometry;
11410      var lineWidth = this.getSymbol()['lineWidth'];
11411
11412      if (!isNumber(lineWidth)) {
11413        lineWidth = 4;
11414      }
11415
11416      var extent2D = map._get2DExtent(undefined, TEMP_CLIP_EXTENT0)._expand(lineWidth);
11417
11418      if (map.getPitch() > 0 && altitude) {
11419        var c = map.cameraLookAt;
11420        var pos = map.cameraPosition;
11421        TEMP_POINT0$2.set(pos.x, pos.y);
11422        extent2D = extent2D._combine(TEMP_POINT0$2._add(sign(c[0] - pos[0]), sign(c[1] - pos[1])));
11423      }
11424
11425      var e = this.get2DExtent(null, TEMP_CLIP_EXTENT1);
11426      var clipPoints = points;
11427
11428      if (e.within(extent2D)) {
11429        return {
11430          points: clipPoints,
11431          altitude: altitude
11432        };
11433      }
11434
11435      var glExtent2D = map._get2DExtent(map.getGLZoom(), TEMP_CLIP_EXTENT0)._expand(lineWidth / map._glScale);
11436
11437      var smoothness = geometry.options['smoothness'];
11438
11439      if (geometry.getShell && this.geometry.getHoles && !smoothness) {
11440        if (!Array.isArray(points[0])) {
11441          clipPoints = clipPolygon(points, glExtent2D);
11442        } else {
11443          clipPoints = [];
11444
11445          for (var i = 0; i < points.length; i++) {
11446            var part = clipPolygon(points[i], glExtent2D);
11447
11448            if (part.length) {
11449              clipPoints.push(part);
11450            }
11451          }
11452        }
11453      } else if (geometry.getJSONType() === 'LineString') {
11454        if (!Array.isArray(points[0])) {
11455          clipPoints = clipLine(points, glExtent2D, false, !!smoothness);
11456        } else {
11457          clipPoints = [];
11458
11459          for (var _i = 0; _i < points.length; _i++) {
11460            pushIn(clipPoints, clipLine(points[_i], glExtent2D, false, !!smoothness));
11461          }
11462        }
11463
11464        return this._interpolateSegAlt(clipPoints, points, altitude);
11465      }
11466
11467      return {
11468        points: clipPoints,
11469        altitude: altitude
11470      };
11471    };
11472
11473    _proto._interpolateSegAlt = function _interpolateSegAlt(clipSegs, orig, altitude) {
11474      if (!Array.isArray(altitude)) {
11475        var fn = function fn(cc) {
11476          return cc.point;
11477        };
11478
11479        return {
11480          points: clipSegs.map(function (c) {
11481            if (Array.isArray(c)) {
11482              return c.map(fn);
11483            }
11484
11485            return c.point;
11486          }),
11487          altitude: altitude
11488        };
11489      }
11490
11491      var segsWithAlt = interpolateAlt(clipSegs, orig, altitude);
11492      altitude = [];
11493      var points = segsWithAlt.map(function (p) {
11494        if (Array.isArray(p)) {
11495          var alt = [];
11496          var cp = p.map(function (pp) {
11497            alt.push(pp.altitude);
11498            return pp.point;
11499          });
11500          altitude.push(alt);
11501          return cp;
11502        }
11503
11504        altitude.push(p.altitude);
11505        return p.point;
11506      });
11507      return {
11508        points: points,
11509        altitude: altitude
11510      };
11511    };
11512
11513    _proto.getSymbol = function getSymbol() {
11514      return this.geometry._getInternalSymbol();
11515    };
11516
11517    _proto.paint = function paint(extent, context, offset) {
11518      if (!this.symbolizers) {
11519        return;
11520      }
11521
11522      var renderer = this.getLayer()._getRenderer();
11523
11524      if (!renderer || !renderer.context && !context) {
11525        return;
11526      }
11527
11528      if (extent && !extent.intersects(this.get2DExtent(renderer.resources, TEMP_PAINT_EXTENT))) {
11529        return;
11530      }
11531
11532      var map = this.getMap();
11533      var minAltitude = this.getMinAltitude();
11534      var frustumAlt = map.getFrustumAltitude();
11535
11536      if (minAltitude && frustumAlt && frustumAlt < minAltitude) {
11537        return;
11538      }
11539
11540      this.containerOffset = offset || map._pointToContainerPoint(renderer.southWest)._add(0, -map.height);
11541
11542      this._beforePaint();
11543
11544      var ctx = context || renderer.context;
11545      var contexts = [ctx, renderer.resources];
11546
11547      for (var i = this.symbolizers.length - 1; i >= 0; i--) {
11548        this._prepareShadow(ctx, this.symbolizers[i].symbol);
11549
11550        this.symbolizers[i].symbolize.apply(this.symbolizers[i], contexts);
11551      }
11552
11553      this._afterPaint();
11554
11555      this._painted = true;
11556
11557      this._debugSymbolizer.symbolize.apply(this._debugSymbolizer, contexts);
11558    };
11559
11560    _proto.getSprite = function getSprite(resources, canvasClass) {
11561      if (this.geometry.type !== 'Point') {
11562        return null;
11563      }
11564
11565      this._spriting = true;
11566
11567      if (!this._sprite && this.symbolizers.length > 0) {
11568        var extent = new PointExtent();
11569        this.symbolizers.forEach(function (s) {
11570          var markerExtent = s.getFixedExtent(resources);
11571
11572          extent._combine(markerExtent);
11573        });
11574        var origin = extent.getMin().multi(-1);
11575        var clazz = canvasClass || (this.getMap() ? this.getMap().CanvasClass : null);
11576        var canvas = Canvas.createCanvas(extent.getWidth(), extent.getHeight(), clazz);
11577        var bak;
11578
11579        if (this._renderPoints) {
11580          bak = this._renderPoints;
11581        }
11582
11583        var ctx = canvas.getContext('2d');
11584        var contexts = [ctx, resources];
11585
11586        for (var i = this.symbolizers.length - 1; i >= 0; i--) {
11587          var dxdy = this.symbolizers[i].getDxDy();
11588          this._renderPoints = {
11589            'center': [[origin.add(dxdy)]]
11590          };
11591
11592          this._prepareShadow(ctx, this.symbolizers[i].symbol);
11593
11594          this.symbolizers[i].symbolize.apply(this.symbolizers[i], contexts);
11595        }
11596
11597        if (bak) {
11598          this._renderPoints = bak;
11599        }
11600
11601        this._sprite = {
11602          'canvas': canvas,
11603          'offset': extent.getCenter()
11604        };
11605      }
11606
11607      this._spriting = false;
11608      return this._sprite;
11609    };
11610
11611    _proto.isSpriting = function isSpriting() {
11612      return !!this._spriting;
11613    };
11614
11615    _proto.hitTest = function hitTest(cp, tolerance) {
11616      if (!tolerance || tolerance < 0.5) {
11617        tolerance = 0.5;
11618      }
11619
11620      if (!testCanvas) {
11621        testCanvas = Canvas.createCanvas(1, 1);
11622      }
11623
11624      Canvas.setHitTesting(true);
11625      testCanvas.width = testCanvas.height = 2 * tolerance;
11626      var ctx = testCanvas.getContext('2d');
11627      this._hitPoint = cp.sub(tolerance, tolerance);
11628
11629      try {
11630        this.paint(null, ctx, this._hitPoint);
11631      } catch (e) {
11632        throw e;
11633      } finally {
11634        Canvas.setHitTesting(false);
11635      }
11636
11637      delete this._hitPoint;
11638      var imgData = ctx.getImageData(0, 0, testCanvas.width, testCanvas.height).data;
11639
11640      for (var i = 3, l = imgData.length; i < l; i += 4) {
11641        if (imgData[i] > 0) {
11642          return true;
11643        }
11644      }
11645
11646      return false;
11647    };
11648
11649    _proto.isHitTesting = function isHitTesting() {
11650      return !!this._hitPoint;
11651    };
11652
11653    _proto._prepareShadow = function _prepareShadow(ctx, symbol) {
11654      if (symbol['shadowBlur']) {
11655        ctx.shadowBlur = this.isHitTesting() ? 0 : symbol['shadowBlur'];
11656        ctx.shadowColor = symbol['shadowColor'] || '#000';
11657        ctx.shadowOffsetX = symbol['shadowOffsetX'] || 0;
11658        ctx.shadowOffsetY = symbol['shadowOffsetY'] || 0;
11659      } else if (ctx.shadowBlur) {
11660        ctx.shadowBlur = null;
11661        ctx.shadowColor = null;
11662        ctx.shadowOffsetX = null;
11663        ctx.shadowOffsetY = null;
11664      }
11665    };
11666
11667    _proto._eachSymbolizer = function _eachSymbolizer(fn, context) {
11668      if (!this.symbolizers) {
11669        return;
11670      }
11671
11672      if (!context) {
11673        context = this;
11674      }
11675
11676      for (var i = this.symbolizers.length - 1; i >= 0; i--) {
11677        fn.apply(context, [this.symbolizers[i]]);
11678      }
11679    };
11680
11681    _proto.get2DExtent = function get2DExtent(resources, out) {
11682      this._verifyProjection();
11683
11684      var map = this.getMap();
11685      resources = resources || this.getLayer()._getRenderer().resources;
11686      var zoom = map.getZoom();
11687
11688      if (!this._extent2D || this._extent2D._zoom !== zoom) {
11689        delete this._extent2D;
11690        delete this._fixedExtent;
11691
11692        if (this.symbolizers) {
11693          var extent = this._extent2D = new PointExtent();
11694          var fixedExt = this._fixedExtent = new PointExtent();
11695
11696          for (var i = this.symbolizers.length - 1; i >= 0; i--) {
11697            var symbolizer = this.symbolizers[i];
11698
11699            extent._combine(symbolizer.get2DExtent());
11700
11701            if (symbolizer.getFixedExtent) {
11702              fixedExt._combine(symbolizer.getFixedExtent(resources));
11703            }
11704          }
11705
11706          extent._zoom = zoom;
11707        }
11708      }
11709
11710      if (!this._extent2D) {
11711        return null;
11712      }
11713
11714      if (out) {
11715        out.set(this._extent2D['xmin'], this._extent2D['ymin'], this._extent2D['xmax'], this._extent2D['ymax']);
11716
11717        out._add(this._fixedExtent);
11718
11719        return out;
11720      }
11721
11722      return this._extent2D.add(this._fixedExtent);
11723    };
11724
11725    _proto.getContainerExtent = function getContainerExtent(out) {
11726      if (this._aboveCamera()) {
11727        return null;
11728      }
11729
11730      this._verifyProjection();
11731
11732      var map = this.getMap();
11733      var zoom = map.getZoom();
11734      var glScale = map._glScale;
11735
11736      if (!this._extent2D || this._extent2D._zoom !== zoom) {
11737        this.get2DExtent(null, TEMP_EXTENT$1);
11738      }
11739
11740      var altitude = this.getMinAltitude();
11741
11742      var extent = this._extent2D.convertTo(function (c) {
11743        return map._pointToContainerPoint(c, zoom, altitude / glScale, TEMP_POINT0$2);
11744      }, out);
11745
11746      var maxAltitude = this.getMaxAltitude();
11747
11748      if (maxAltitude !== altitude) {
11749        var extent2 = this._extent2D.convertTo(function (c) {
11750          return map._pointToContainerPoint(c, zoom, maxAltitude / glScale, TEMP_POINT0$2);
11751        }, TEMP_EXTENT$1);
11752
11753        extent._combine(extent2);
11754      }
11755
11756      var layer = this.geometry.getLayer();
11757
11758      if (this.geometry.type === 'LineString' && maxAltitude && layer.options['drawAltitude']) {
11759        var groundExtent = this._extent2D.convertTo(function (c) {
vendor: 32,313 bytes, lines 11760-13152
11760          return map._pointToContainerPoint(c, zoom, 0, TEMP_POINT0$2);
11761        }, TEMP_EXTENT$1);
11762
11763        extent._combine(groundExtent);
11764      }
11765
11766      if (extent) {
11767        extent._add(this._fixedExtent);
11768      }
11769
11770      var smoothness = this.geometry.options['smoothness'];
11771
11772      if (smoothness) {
11773        extent._expand(extent.getWidth() * 0.15);
11774      }
11775
11776      return extent;
11777    };
11778
11779    _proto._aboveCamera = function _aboveCamera() {
11780      var altitude = this.getMinAltitude();
11781      var map = this.getMap();
11782      var frustumAlt = map.getFrustumAltitude();
11783      return altitude && frustumAlt && frustumAlt < altitude;
11784    };
11785
11786    _proto.getFixedExtent = function getFixedExtent() {
11787      var map = this.getMap();
11788      var zoom = map.getZoom();
11789
11790      if (!this._extent2D || this._extent2D._zoom !== zoom) {
11791        this.get2DExtent(null, TEMP_FIXED_EXTENT);
11792      }
11793
11794      return this._fixedExtent;
11795    };
11796
11797    _proto.setZIndex = function setZIndex(change) {
11798      this._eachSymbolizer(function (symbolizer) {
11799        symbolizer.setZIndex(change);
11800      });
11801    };
11802
11803    _proto.show = function show() {
11804      if (!this._painted) {
11805        var layer = this.getLayer();
11806
11807        if (!layer.isCanvasRender()) {
11808          this.paint();
11809        }
11810      } else {
11811        this.removeCache();
11812
11813        this._eachSymbolizer(function (symbolizer) {
11814          symbolizer.show();
11815        });
11816      }
11817    };
11818
11819    _proto.hide = function hide() {
11820      this._eachSymbolizer(function (symbolizer) {
11821        symbolizer.hide();
11822      });
11823    };
11824
11825    _proto.repaint = function repaint() {
11826      this._altAtGLZoom = this._getGeometryAltitude();
11827      this.removeCache();
11828      var layer = this.getLayer();
11829
11830      if (!layer) {
11831        return;
11832      }
11833
11834      var renderer = layer.getRenderer();
11835
11836      if (!renderer || !renderer.setToRedraw()) {
11837        return;
11838      }
11839
11840      renderer.setToRedraw();
11841    };
11842
11843    _proto.refreshSymbol = function refreshSymbol() {
11844      this.removeCache();
11845
11846      this._removeSymbolizers();
11847
11848      this.symbolizers = this._createSymbolizers();
11849    };
11850
11851    _proto.remove = function remove() {
11852      this.removeCache();
11853
11854      this._removeSymbolizers();
11855    };
11856
11857    _proto._removeSymbolizers = function _removeSymbolizers() {
11858      this._eachSymbolizer(function (symbolizer) {
11859        delete symbolizer.painter;
11860        symbolizer.remove();
11861      });
11862
11863      delete this.symbolizers;
11864    };
11865
11866    _proto.removeCache = function removeCache() {
11867      delete this._renderPoints;
11868      delete this._paintParams;
11869      delete this._sprite;
11870      delete this._extent2D;
11871      delete this._fixedExtent;
11872      delete this._cachedParams;
11873      delete this._unsimpledParams;
11874
11875      if (this.geometry) {
11876        delete this.geometry[TextMarkerSymbolizer.CACHE_KEY];
11877      }
11878    };
11879
11880    _proto.getAltitude = function getAltitude() {
11881      var propAlt = this._getAltitudeProperty();
11882
11883      if (propAlt !== this._propAlt) {
11884        this._altAtGLZoom = this._getGeometryAltitude();
11885      }
11886
11887      if (!this._altAtGLZoom) {
11888        return 0;
11889      }
11890
11891      return this._altAtGLZoom;
11892    };
11893
11894    _proto.getMinAltitude = function getMinAltitude() {
11895      if (!this.minAltitude) {
11896        return 0;
11897      }
11898
11899      return this.minAltitude;
11900    };
11901
11902    _proto.getMaxAltitude = function getMaxAltitude() {
11903      if (!this.maxAltitude) {
11904        return 0;
11905      }
11906
11907      return this.maxAltitude;
11908    };
11909
11910    _proto._getGeometryAltitude = function _getGeometryAltitude() {
11911      var _this2 = this;
11912
11913      var map = this.getMap();
11914
11915      if (!map) {
11916        return 0;
11917      }
11918
11919      var altitude = this._getAltitudeProperty();
11920
11921      this._propAlt = altitude;
11922
11923      if (!altitude) {
11924        this.minAltitude = this.maxAltitude = 0;
11925        return 0;
11926      }
11927
11928      var center = this.geometry.getCenter();
11929
11930      if (!center) {
11931        return 0;
11932      }
11933
11934      if (Array.isArray(altitude)) {
11935        this.minAltitude = Number.MAX_VALUE;
11936        this.maxAltitude = Number.MIN_VALUE;
11937        return altitude.map(function (alt) {
11938          var a = _this2._meterToPoint(center, alt);
11939
11940          if (a < _this2.minAltitude) {
11941            _this2.minAltitude = a;
11942          }
11943
11944          if (a > _this2.maxAltitude) {
11945            _this2.maxAltitude = a;
11946          }
11947
11948          return a;
11949        });
11950      } else {
11951        this.minAltitude = this.maxAltitude = this._meterToPoint(center, altitude);
11952        return this.minAltitude;
11953      }
11954    };
11955
11956    _proto._meterToPoint = function _meterToPoint(center, altitude) {
11957      var map = this.getMap();
11958      var z = map.getGLZoom();
11959      var target = map.locate(center, altitude, 0);
11960      var p0 = map.coordToPoint(center, z, TEMP_POINT1$1),
11961          p1 = map.coordToPoint(target, z, TEMP_POINT2);
11962      return Math.abs(p1.x - p0.x) * sign(altitude);
11963    };
11964
11965    _proto._getAltitudeProperty = function _getAltitudeProperty() {
11966      var geometry = this.geometry,
11967          layerOpts = geometry.getLayer().options,
11968          properties = geometry.getProperties();
11969      var altitude = layerOpts['enableAltitude'] ? properties ? properties[layerOpts['altitudeProperty']] : 0 : 0;
11970      return altitude;
11971    };
11972
11973    _proto._verifyProjection = function _verifyProjection() {
11974      var projection = this.geometry._getProjection();
11975
11976      if (this._projCode && this._projCode !== projection.code) {
11977        this.removeCache();
11978      }
11979
11980      this._projCode = projection.code;
11981    };
11982
11983    _proto._beforePaint = function _beforePaint() {
11984      var textcache = this.geometry[TextMarkerSymbolizer.CACHE_KEY];
11985
11986      if (!textcache) {
11987        return;
11988      }
11989
11990      for (var p in textcache) {
11991        if (hasOwn(textcache, p)) {
11992          textcache[p].active = false;
11993        }
11994      }
11995    };
11996
11997    _proto._afterPaint = function _afterPaint() {
11998      var textcache = this.geometry[TextMarkerSymbolizer.CACHE_KEY];
11999
12000      if (!textcache) {
12001        return;
12002      }
12003
12004      for (var p in textcache) {
12005        if (hasOwn(textcache, p)) {
12006          if (!textcache[p].active) {
12007            delete textcache[p];
12008          }
12009        }
12010      }
12011    };
12012
12013    return Painter;
12014  }(Class);
12015
12016  function interpolateAlt(points, orig, altitude) {
12017    if (!Array.isArray(altitude)) {
12018      return points;
12019    }
12020
12021    var parts = [];
12022
12023    for (var i = 0, l = points.length; i < l; i++) {
12024      if (Array.isArray(points[i])) {
12025        parts.push(interpolateAlt(points[i], orig, altitude));
12026      } else {
12027        var p = points[i];
12028
12029        if (!p.point.equals(orig[p.index])) {
12030          var w0 = void 0,
12031              w1 = void 0;
12032
12033          if (p.index === 0) {
12034            w0 = p.index;
12035            w1 = p.index + 1;
12036          } else {
12037            w0 = p.index - 1;
12038            w1 = p.index;
12039          }
12040
12041          var t0 = p.point.distanceTo(orig[w1]);
12042          var t = t0 / (t0 + orig[w0].distanceTo(p.point));
12043          var alt = interpolate(altitude[w0], altitude[w1], 1 - t);
12044          p.altitude = alt;
12045          parts.push(p);
12046        } else {
12047          p.altitude = altitude[p.index];
12048          parts.push(p);
12049        }
12050      }
12051    }
12052
12053    return parts;
12054  }
12055
12056  var TEMP_EXTENT$2 = new PointExtent();
12057
12058  var CollectionPainter = function (_Class) {
12059    _inheritsLoose(CollectionPainter, _Class);
12060
12061    function CollectionPainter(geometry) {
12062      var _this;
12063
12064      _this = _Class.call(this) || this;
12065      _this.geometry = geometry;
12066      return _this;
12067    }
12068
12069    var _proto = CollectionPainter.prototype;
12070
12071    _proto._eachPainter = function _eachPainter(fn) {
12072      var geometries = this.geometry.getGeometries();
12073      var painter;
12074
12075      for (var i = 0, len = geometries.length; i < len; i++) {
12076        painter = geometries[i]._getPainter();
12077
12078        if (!painter) {
12079          continue;
12080        }
12081
12082        if (painter) {
12083          if (fn.call(this, painter) === false) {
12084            break;
12085          }
12086        }
12087      }
12088    };
12089
12090    _proto.paint = function paint(extent) {
12091      if (!this.geometry) {
12092        return;
12093      }
12094
12095      this._eachPainter(function (painter) {
12096        painter.paint(extent);
12097      });
12098    };
12099
12100    _proto.get2DExtent = function get2DExtent(resources, out) {
12101      if (out) {
12102        out.set(null, null, null, null);
12103      }
12104
12105      var extent = out || new PointExtent();
12106
12107      this._eachPainter(function (painter) {
12108        extent = extent._combine(painter.get2DExtent(resources, TEMP_EXTENT$2));
12109      });
12110
12111      return extent;
12112    };
12113
12114    _proto.getContainerExtent = function getContainerExtent() {
12115      var extent = new PointExtent();
12116
12117      this._eachPainter(function (painter) {
12118        extent = extent.combine(painter.getContainerExtent());
12119      });
12120
12121      return extent;
12122    };
12123
12124    _proto.remove = function remove() {
12125      var args = arguments;
12126
12127      this._eachPainter(function (painter) {
12128        painter.remove.apply(painter, args);
12129      });
12130    };
12131
12132    _proto.setZIndex = function setZIndex() {
12133      var args = arguments;
12134
12135      this._eachPainter(function (painter) {
12136        painter.setZIndex.apply(painter, args);
12137      });
12138    };
12139
12140    _proto.show = function show() {
12141      var args = arguments;
12142
12143      this._eachPainter(function (painter) {
12144        painter.show.apply(painter, args);
12145      });
12146    };
12147
12148    _proto.hide = function hide() {
12149      var args = arguments;
12150
12151      this._eachPainter(function (painter) {
12152        painter.hide.apply(painter, args);
12153      });
12154    };
12155
12156    _proto.repaint = function repaint() {
12157      var args = arguments;
12158
12159      this._eachPainter(function (painter) {
12160        painter.repaint.apply(painter, args);
12161      });
12162    };
12163
12164    _proto.refreshSymbol = function refreshSymbol() {
12165      var args = arguments;
12166
12167      this._eachPainter(function (painter) {
12168        painter.refreshSymbol.apply(painter, args);
12169      });
12170    };
12171
12172    _proto.hasPoint = function hasPoint() {
12173      var result = false;
12174
12175      this._eachPainter(function (painter) {
12176        if (painter.hasPoint()) {
12177          result = true;
12178          return false;
12179        }
12180
12181        return true;
12182      });
12183
12184      return result;
12185    };
12186
12187    _proto.getMinAltitude = function getMinAltitude() {
12188      var first = true;
12189      var result = 0;
12190
12191      this._eachPainter(function (painter) {
12192        var alt = painter.getMinAltitude();
12193
12194        if (first || alt < result) {
12195          first = false;
12196          result = alt;
12197        }
12198      });
12199
12200      return result;
12201    };
12202
12203    _proto.getMaxAltitude = function getMaxAltitude() {
12204      var result = 0;
12205
12206      this._eachPainter(function (painter) {
12207        var alt = painter.getMaxAltitude();
12208
12209        if (alt > result) {
12210          result = alt;
12211        }
12212      });
12213
12214      return result;
12215    };
12216
12217    return CollectionPainter;
12218  }(Class);
12219
12220  var options$2 = {
12221    'id': null,
12222    'visible': true,
12223    'interactive': true,
12224    'editable': true,
12225    'cursor': null,
12226    'defaultProjection': 'EPSG:4326'
12227  };
12228
12229  var Geometry = function (_JSONAble) {
12230    _inheritsLoose(Geometry, _JSONAble);
12231
12232    function Geometry(options) {
12233      var _this;
12234
12235      var opts = extend({}, options);
12236      var symbol = opts['symbol'];
12237      var properties = opts['properties'];
12238      var id = opts['id'];
12239      delete opts['symbol'];
12240      delete opts['id'];
12241      delete opts['properties'];
12242      _this = _JSONAble.call(this, opts) || this;
12243
12244      if (symbol) {
12245        _this.setSymbol(symbol);
12246      }
12247
12248      if (properties) {
12249        _this.setProperties(properties);
12250      }
12251
12252      if (!isNil(id)) {
12253        _this.setId(id);
12254      }
12255
12256      return _this;
12257    }
12258
12259    var _proto = Geometry.prototype;
12260
12261    _proto.getFirstCoordinate = function getFirstCoordinate() {
12262      if (this.type === 'GeometryCollection') {
12263        var geometries = this.getGeometries();
12264
12265        if (!geometries.length) {
12266          return null;
12267        }
12268
12269        return geometries[0].getFirstCoordinate();
12270      }
12271
12272      var coordinates = this.getCoordinates();
12273
12274      if (!Array.isArray(coordinates)) {
12275        return coordinates;
12276      }
12277
12278      do {
12279        coordinates = coordinates[0];
12280      } while (Array.isArray(coordinates) && coordinates.length > 0);
12281
12282      return coordinates;
12283    };
12284
12285    _proto.getLastCoordinate = function getLastCoordinate() {
12286      if (this.type === 'GeometryCollection') {
12287        var geometries = this.getGeometries();
12288
12289        if (!geometries.length) {
12290          return null;
12291        }
12292
12293        return geometries[geometries.length - 1].getLastCoordinate();
12294      }
12295
12296      var coordinates = this.getCoordinates();
12297
12298      if (!Array.isArray(coordinates)) {
12299        return coordinates;
12300      }
12301
12302      do {
12303        coordinates = coordinates[coordinates.length - 1];
12304      } while (Array.isArray(coordinates) && coordinates.length > 0);
12305
12306      return coordinates;
12307    };
12308
12309    _proto.addTo = function addTo(layer, fitview) {
12310      layer.addGeometry(this, fitview);
12311      return this;
12312    };
12313
12314    _proto.getLayer = function getLayer() {
12315      if (!this._layer) {
12316        return null;
12317      }
12318
12319      return this._layer;
12320    };
12321
12322    _proto.getMap = function getMap() {
12323      if (!this._layer) {
12324        return null;
12325      }
12326
12327      return this._layer.getMap();
12328    };
12329
12330    _proto.getId = function getId() {
12331      return this._id;
12332    };
12333
12334    _proto.setId = function setId(id) {
12335      var oldId = this.getId();
12336      this._id = id;
12337
12338      this._fireEvent('idchange', {
12339        'old': oldId,
12340        'new': id
12341      });
12342
12343      return this;
12344    };
12345
12346    _proto.getProperties = function getProperties() {
12347      if (!this.properties) {
12348        if (this._getParent()) {
12349          return this._getParent().getProperties();
12350        }
12351
12352        return null;
12353      }
12354
12355      return this.properties;
12356    };
12357
12358    _proto.setProperties = function setProperties(properties) {
12359      var old = this.properties;
12360      this.properties = isObject(properties) ? extend({}, properties) : properties;
12361
12362      this._repaint();
12363
12364      this._fireEvent('propertieschange', {
12365        'old': old,
12366        'new': properties
12367      });
12368
12369      return this;
12370    };
12371
12372    _proto.getType = function getType() {
12373      return this.type;
12374    };
12375
12376    _proto.getSymbol = function getSymbol() {
12377      var s = this._symbol;
12378
12379      if (s) {
12380        if (!Array.isArray(s)) {
12381          return extend({}, s);
12382        } else {
12383          return extendSymbol(s);
12384        }
12385      }
12386
12387      return null;
12388    };
12389
12390    _proto.setSymbol = function setSymbol(symbol) {
12391      this._symbol = this._prepareSymbol(symbol);
12392      this.onSymbolChanged();
12393      return this;
12394    };
12395
12396    _proto.updateSymbol = function updateSymbol(props) {
12397      if (!props) {
12398        return this;
12399      }
12400
12401      var s = this._getSymbol();
12402
12403      if (s) {
12404        s = extendSymbol(s, props);
12405      } else {
12406        s = extendSymbol(this._getInternalSymbol(), props);
12407      }
12408
12409      return this.setSymbol(s);
12410    };
12411
12412    _proto.getCenter = function getCenter() {
12413      return this._computeCenter(this._getMeasurer());
12414    };
12415
12416    _proto.getExtent = function getExtent() {
12417      var prjExt = this._getPrjExtent();
12418
12419      if (prjExt) {
12420        var p = this._getProjection();
12421
12422        var min = p.unproject(new Coordinate(prjExt['xmin'], prjExt['ymin'])),
12423            max = p.unproject(new Coordinate(prjExt['xmax'], prjExt['ymax']));
12424        return new Extent(min, max, this._getProjection());
12425      } else {
12426        return this._computeExtent(this._getMeasurer());
12427      }
12428    };
12429
12430    _proto.getContainerExtent = function getContainerExtent(out) {
12431      var painter = this._getPainter();
12432
12433      return painter ? painter.getContainerExtent(out) : null;
12434    };
12435
12436    _proto.getSize = function getSize() {
12437      var extent = this.getContainerExtent();
12438      return extent ? extent.getSize() : null;
12439    };
12440
12441    _proto.containsPoint = function containsPoint(containerPoint, t) {
12442      if (!this.getMap()) {
12443        throw new Error('The geometry is required to be added on a map to perform "containsPoint".');
12444      }
12445
12446      if (containerPoint instanceof Coordinate) {
12447        containerPoint = this.getMap().coordToContainerPoint(containerPoint);
12448      }
12449
12450      return this._containsPoint(containerPoint, t);
12451    };
12452
12453    _proto._containsPoint = function _containsPoint(containerPoint, t) {
12454      var painter = this._getPainter();
12455
12456      if (!painter) {
12457        return false;
12458      }
12459
12460      if (isNil(t) && this._hitTestTolerance) {
12461        t = this._hitTestTolerance();
12462      }
12463
12464      return painter.hitTest(containerPoint, t);
12465    };
12466
12467    _proto.show = function show() {
12468      this.options['visible'] = true;
12469
12470      if (this.getMap()) {
12471        var painter = this._getPainter();
12472
12473        if (painter) {
12474          painter.show();
12475        }
12476
12477        this._fireEvent('show');
12478      }
12479
12480      return this;
12481    };
12482
12483    _proto.hide = function hide() {
12484      this.options['visible'] = false;
12485
12486      if (this.getMap()) {
12487        this.onHide();
12488
12489        var painter = this._getPainter();
12490
12491        if (painter) {
12492          painter.hide();
12493        }
12494
12495        this._fireEvent('hide');
12496      }
12497
12498      return this;
12499    };
12500
12501    _proto.isVisible = function isVisible() {
12502      if (!this.options['visible']) {
12503        return false;
12504      }
12505
12506      var symbol = this._getInternalSymbol();
12507
12508      if (!symbol) {
12509        return true;
12510      }
12511
12512      if (Array.isArray(symbol)) {
12513        if (!symbol.length) {
12514          return true;
12515        }
12516
12517        for (var i = 0, l = symbol.length; i < l; i++) {
12518          if (isNil(symbol[i]['opacity']) || symbol[i]['opacity'] > 0) {
12519            return true;
12520          }
12521        }
12522
12523        return false;
12524      } else {
12525        return isNil(symbol['opacity']) || isNumber(symbol['opacity']) && symbol['opacity'] > 0;
12526      }
12527    };
12528
12529    _proto.getZIndex = function getZIndex() {
12530      return this.options['zIndex'] || 0;
12531    };
12532
12533    _proto.setZIndex = function setZIndex(zIndex) {
12534      var old = this.options['zIndex'];
12535      this.options['zIndex'] = zIndex;
12536
12537      this._fireEvent('zindexchange', {
12538        'old': old,
12539        'new': zIndex
12540      });
12541
12542      return this;
12543    };
12544
12545    _proto.setZIndexSilently = function setZIndexSilently(zIndex) {
12546      this.options['zIndex'] = zIndex;
12547      return this;
12548    };
12549
12550    _proto.bringToFront = function bringToFront() {
12551      var layer = this.getLayer();
12552
12553      if (!layer || !layer.getGeoMaxZIndex) {
12554        return this;
12555      }
12556
12557      var topZ = layer.getGeoMaxZIndex();
12558      this.setZIndex(topZ + 1);
12559      return this;
12560    };
12561
12562    _proto.bringToBack = function bringToBack() {
12563      var layer = this.getLayer();
12564
12565      if (!layer || !layer.getGeoMinZIndex) {
12566        return this;
12567      }
12568
12569      var bottomZ = layer.getGeoMinZIndex();
12570      this.setZIndex(bottomZ - 1);
12571      return this;
12572    };
12573
12574    _proto.translate = function translate(x, y) {
12575      if (isNil(x)) {
12576        return this;
12577      }
12578
12579      var offset = new Coordinate(x, y);
12580
12581      if (offset.x === 0 && offset.y === 0) {
12582        return this;
12583      }
12584
12585      var coordinates = this.getCoordinates();
12586
12587      if (coordinates) {
12588        if (Array.isArray(coordinates)) {
12589          var translated = forEachCoord(coordinates, function (coord) {
12590            return coord.add(offset);
12591          });
12592          this.setCoordinates(translated);
12593        } else {
12594          this.setCoordinates(coordinates.add(offset));
12595        }
12596      }
12597
12598      return this;
12599    };
12600
12601    _proto.flash = function flash$$1(interval, count, cb, context) {
12602      return flash.call(this, interval, count, cb, context);
12603    };
12604
12605    _proto.copy = function copy() {
12606      var json = this.toJSON();
12607      var ret = Geometry.fromJSON(json);
12608      ret.options['visible'] = true;
12609      return ret;
12610    };
12611
12612    _proto.remove = function remove() {
12613      var layer = this.getLayer();
12614
12615      if (!layer) {
12616        return this;
12617      }
12618
12619      this._fireEvent('removestart');
12620
12621      this._unbind();
12622
12623      this._fireEvent('removeend');
12624
12625      this._fireEvent('remove');
12626
12627      return this;
12628    };
12629
12630    _proto.toGeoJSONGeometry = function toGeoJSONGeometry() {
12631      var gJson = this._exportGeoJSONGeometry();
12632
12633      return gJson;
12634    };
12635
12636    _proto.toGeoJSON = function toGeoJSON(opts) {
12637      if (!opts) {
12638        opts = {};
12639      }
12640
12641      var feature = {
12642        'type': 'Feature',
12643        'geometry': null
12644      };
12645
12646      if (isNil(opts['geometry']) || opts['geometry']) {
12647        var geoJSON = this._exportGeoJSONGeometry();
12648
12649        feature['geometry'] = geoJSON;
12650      }
12651
12652      var id = this.getId();
12653
12654      if (!isNil(id)) {
12655        feature['id'] = id;
12656      }
12657
12658      var properties;
12659
12660      if (isNil(opts['properties']) || opts['properties']) {
12661        properties = this._exportProperties();
12662      }
12663
12664      feature['properties'] = properties;
12665      return feature;
12666    };
12667
12668    _proto.toJSON = function toJSON(options) {
12669      if (!options) {
12670        options = {};
12671      }
12672
12673      var json = this._toJSON(options);
12674
12675      var other = this._exportGraphicOptions(options);
12676
12677      extend(json, other);
12678      return json;
12679    };
12680
12681    _proto.getLength = function getLength() {
12682      return this._computeGeodesicLength(this._getMeasurer());
12683    };
12684
12685    _proto.getArea = function getArea() {
12686      return this._computeGeodesicArea(this._getMeasurer());
12687    };
12688
12689    _proto.rotate = function rotate(angle, pivot) {
12690      if (this.type === 'GeometryCollection') {
12691        var geometries = this.getGeometries();
12692        geometries.forEach(function (g) {
12693          return g.rotate(angle, pivot);
12694        });
12695        return this;
12696      }
12697
12698      if (!pivot) {
12699        pivot = this.getCenter();
12700      } else {
12701        pivot = new Coordinate(pivot);
12702      }
12703
12704      var measurer = this._getMeasurer();
12705
12706      var coordinates = this.getCoordinates();
12707
12708      if (!Array.isArray(coordinates)) {
12709        if (pivot.x !== coordinates.x || pivot.y !== coordinates.y) {
12710          var c = measurer._rotate(coordinates, pivot, angle);
12711
12712          this.setCoordinates(c);
12713        }
12714
12715        return this;
12716      }
12717
12718      forEachCoord(coordinates, function (c) {
12719        return measurer._rotate(c, pivot, angle);
12720      });
12721      this.setCoordinates(coordinates);
12722      return this;
12723    };
12724
12725    _proto._getConnectPoints = function _getConnectPoints() {
12726      return [this.getCenter()];
12727    };
12728
12729    _proto._initOptions = function _initOptions(options) {
12730      var opts = extend({}, options);
12731      var symbol = opts['symbol'];
12732      var properties = opts['properties'];
12733      var id = opts['id'];
12734      delete opts['symbol'];
12735      delete opts['id'];
12736      delete opts['properties'];
12737      this.setOptions(opts);
12738
12739      if (symbol) {
12740        this.setSymbol(symbol);
12741      }
12742
12743      if (properties) {
12744        this.setProperties(properties);
12745      }
12746
12747      if (!isNil(id)) {
12748        this.setId(id);
12749      }
12750    };
12751
12752    _proto._bindLayer = function _bindLayer(layer) {
12753      if (this.getLayer()) {
12754        throw new Error('Geometry cannot be added to two or more layers at the same time.');
12755      }
12756
12757      this._layer = layer;
12758
12759      this._clearCache();
12760
12761      this._clearProjection();
12762    };
12763
12764    _proto._prepareSymbol = function _prepareSymbol(symbol) {
12765      if (Array.isArray(symbol)) {
12766        var cookedSymbols = [];
12767
12768        for (var i = 0; i < symbol.length; i++) {
12769          cookedSymbols.push(convertResourceUrl(this._checkAndCopySymbol(symbol[i])));
12770        }
12771
12772        return cookedSymbols;
12773      } else if (symbol) {
12774        symbol = this._checkAndCopySymbol(symbol);
12775        return convertResourceUrl(symbol);
12776      }
12777
12778      return null;
12779    };
12780
12781    _proto._checkAndCopySymbol = function _checkAndCopySymbol(symbol) {
12782      var s = {};
12783
12784      for (var i in symbol) {
12785        if (NUMERICAL_PROPERTIES[i] && isString(symbol[i])) {
12786          s[i] = +symbol[i];
12787        } else {
12788          s[i] = symbol[i];
12789        }
12790      }
12791
12792      return s;
12793    };
12794
12795    _proto._getSymbol = function _getSymbol() {
12796      return this._symbol;
12797    };
12798
12799    _proto._setExternSymbol = function _setExternSymbol(symbol) {
12800      this._externSymbol = this._prepareSymbol(symbol);
12801      this.onSymbolChanged();
12802      return this;
12803    };
12804
12805    _proto._getInternalSymbol = function _getInternalSymbol() {
12806      if (this._symbol) {
12807        return this._symbol;
12808      } else if (this._externSymbol) {
12809        return this._externSymbol;
12810      } else if (this.options['symbol']) {
12811        return this.options['symbol'];
12812      }
12813
12814      return null;
12815    };
12816
12817    _proto._getPrjExtent = function _getPrjExtent() {
12818      var p = this._getProjection();
12819
12820      this._verifyProjection();
12821
12822      if (!this._extent && p) {
12823        this._extent = this._computePrjExtent(p);
12824      }
12825
12826      return this._extent;
12827    };
12828
12829    _proto._unbind = function _unbind() {
12830      var layer = this.getLayer();
12831
12832      if (!layer) {
12833        return;
12834      }
12835
12836      if (this._animPlayer) {
12837        this._animPlayer.finish();
12838      }
12839
12840      this._clearHandlers();
12841
12842      this._unbindMenu();
12843
12844      this._unbindInfoWindow();
12845
12846      if (this.isEditing()) {
12847        this.endEdit();
12848      }
12849
12850      this._removePainter();
12851
12852      if (this.onRemove) {
12853        this.onRemove();
12854      }
12855
12856      if (layer.onRemoveGeometry) {
12857        layer.onRemoveGeometry(this);
12858      }
12859
12860      delete this._layer;
12861      delete this._internalId;
12862      delete this._extent;
12863    };
12864
12865    _proto._getInternalId = function _getInternalId() {
12866      return this._internalId;
12867    };
12868
12869    _proto._setInternalId = function _setInternalId(id) {
12870      this._internalId = id;
12871    };
12872
12873    _proto._getMeasurer = function _getMeasurer() {
12874      if (this._getProjection()) {
12875        return this._getProjection();
12876      }
12877
12878      return SpatialReference.getProjectionInstance(this.options['defaultProjection']);
12879    };
12880
12881    _proto._getProjection = function _getProjection() {
12882      var map = this.getMap();
12883
12884      if (map) {
12885        return map.getProjection();
12886      }
12887
12888      return null;
12889    };
12890
12891    _proto._verifyProjection = function _verifyProjection() {
12892      var projection = this._getProjection();
12893
12894      if (this._projCode && (!projection || this._projCode !== projection.code)) {
12895        this._clearProjection();
12896      }
12897
12898      this._projCode = projection ? projection.code : null;
12899    };
12900
12901    _proto._getExternalResources = function _getExternalResources() {
12902      var symbol = this._getInternalSymbol();
12903
12904      return getExternalResources(symbol);
12905    };
12906
12907    _proto._getPainter = function _getPainter() {
12908      if (!this._painter && this.getMap()) {
12909        if (GEOMETRY_COLLECTION_TYPES.indexOf(this.type) !== -1) {
12910          this._painter = new CollectionPainter(this);
12911        } else {
12912          this._painter = new Painter(this);
12913        }
12914      }
12915
12916      return this._painter;
12917    };
12918
12919    _proto._removePainter = function _removePainter() {
12920      if (this._painter) {
12921        this._painter.remove();
12922      }
12923
12924      delete this._painter;
12925    };
12926
12927    _proto._paint = function _paint(extent) {
12928      if (this._painter) {
12929        this._painter.paint(extent);
12930      }
12931    };
12932
12933    _proto._clearCache = function _clearCache() {
12934      delete this._extent;
12935    };
12936
12937    _proto._clearProjection = function _clearProjection() {
12938      delete this._extent;
12939    };
12940
12941    _proto._repaint = function _repaint() {
12942      if (this._painter) {
12943        this._painter.repaint();
12944      }
12945    };
12946
12947    _proto.onHide = function onHide() {
12948      this.closeMenu();
12949      this.closeInfoWindow();
12950    };
12951
12952    _proto.onShapeChanged = function onShapeChanged() {
12953      this._clearCache();
12954
12955      this._repaint();
12956
12957      this._fireEvent('shapechange');
12958    };
12959
12960    _proto.onPositionChanged = function onPositionChanged() {
12961      this._clearCache();
12962
12963      this._repaint();
12964
12965      this._fireEvent('positionchange');
12966    };
12967
12968    _proto.onSymbolChanged = function onSymbolChanged() {
12969      if (this._painter) {
12970        this._painter.refreshSymbol();
12971      }
12972
12973      this._fireEvent('symbolchange');
12974    };
12975
12976    _proto.onConfig = function onConfig(conf) {
12977      var properties;
12978
12979      if (conf['properties']) {
12980        properties = conf['properties'];
12981        delete conf['properties'];
12982      }
12983
12984      var needRepaint = false;
12985
12986      for (var p in conf) {
12987        if (conf.hasOwnProperty(p)) {
12988          var prefix = p.slice(0, 5);
12989
12990          if (prefix === 'arrow' || prefix === 'smoot') {
12991            needRepaint = true;
12992            break;
12993          }
12994        }
12995      }
12996
12997      if (properties) {
12998        this.setProperties(properties);
12999
13000        this._repaint();
13001      } else if (needRepaint) {
13002        this._repaint();
13003      }
13004    };
13005
13006    _proto._setParent = function _setParent(geometry) {
13007      if (geometry) {
13008        this._parent = geometry;
13009      }
13010    };
13011
13012    _proto._getParent = function _getParent() {
13013      return this._parent;
13014    };
13015
13016    _proto._fireEvent = function _fireEvent(eventName, param) {
13017      if (this.getLayer() && this.getLayer()._onGeometryEvent) {
13018        if (!param) {
13019          param = {};
13020        }
13021
13022        param['type'] = eventName;
13023        param['target'] = this;
13024
13025        this.getLayer()._onGeometryEvent(param);
13026      }
13027
13028      this.fire(eventName, param);
13029    };
13030
13031    _proto._toJSON = function _toJSON(options) {
13032      return {
13033        'feature': this.toGeoJSON(options)
13034      };
13035    };
13036
13037    _proto._exportGraphicOptions = function _exportGraphicOptions(options) {
13038      var json = {};
13039
13040      if (isNil(options['options']) || options['options']) {
13041        json['options'] = this.config();
13042      }
13043
13044      if (isNil(options['symbol']) || options['symbol']) {
13045        json['symbol'] = this.getSymbol();
13046      }
13047
13048      if (isNil(options['infoWindow']) || options['infoWindow']) {
13049        if (this._infoWinOptions) {
13050          json['infoWindow'] = this._infoWinOptions;
13051        }
13052      }
13053
13054      return json;
13055    };
13056
13057    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
13058      var points = this.getCoordinates();
13059      var coordinates = Coordinate.toNumberArrays(points);
13060      return {
13061        'type': this.getType(),
13062        'coordinates': coordinates
13063      };
13064    };
13065
13066    _proto._exportProperties = function _exportProperties() {
13067      var properties = null;
13068      var geoProperties = this.getProperties();
13069
13070      if (!isNil(geoProperties)) {
13071        if (isObject(geoProperties)) {
13072          properties = extend({}, geoProperties);
13073        } else {
13074          properties = geoProperties;
13075        }
13076      }
13077
13078      return properties;
13079    };
13080
13081    return Geometry;
13082  }(JSONAble(Eventable(Handlerable(Class))));
13083
13084  Geometry.mergeOptions(options$2);
13085
13086  var EVENTS = 'mousedown ' + 'mouseup ' + 'mousemove ' + 'click ' + 'dblclick ' + 'contextmenu ' + 'touchstart ' + 'touchmove ' + 'touchend';
13087
13088  var MapGeometryEventsHandler = function (_Handler) {
13089    _inheritsLoose(MapGeometryEventsHandler, _Handler);
13090
13091    function MapGeometryEventsHandler() {
13092      return _Handler.apply(this, arguments) || this;
13093    }
13094
13095    var _proto = MapGeometryEventsHandler.prototype;
13096
13097    _proto.addHooks = function addHooks() {
13098      var map = this.target;
13099      var dom = map._panels.allLayers || map._containerDOM;
13100      on(dom, EVENTS, this._identifyGeometryEvents, this);
13101    };
13102
13103    _proto.removeHooks = function removeHooks() {
13104      var map = this.target;
13105      var dom = map._panels.allLayers || map._containerDOM;
13106      off(dom, EVENTS, this._identifyGeometryEvents, this);
13107    };
13108
13109    _proto._identifyGeometryEvents = function _identifyGeometryEvents(domEvent, type) {
13110      var map = this.target;
13111
13112      if (map.isInteracting() || map._ignoreEvent(domEvent)) {
13113        return;
13114      }
13115
13116      var layers = map._getLayers(function (layer) {
13117        if (layer.identify && layer.options['geometryEvents']) {
13118          return true;
13119        }
13120
13121        return false;
13122      });
13123
13124      if (!layers.length) {
13125        return;
13126      }
13127
13128      var oneMoreEvent = null;
13129      var eventType = type || domEvent.type;
13130
13131      if (eventType === 'mousedown' || eventType === 'touchstart' && domEvent.touches.length === 1) {
13132        this._mouseDownTime = now();
13133      } else if ((eventType === 'click' || eventType === 'touchend') && this._mouseDownTime) {
13134        var downTime = this._mouseDownTime;
13135        delete this._mouseDownTime;
13136        var time = now();
13137
13138        if (time - downTime > 300) {
13139          if (eventType === 'click') {
13140            return;
13141          }
13142        } else if (eventType === 'touchend') {
13143          oneMoreEvent = 'click';
13144        }
13145      }
13146
13147      var actual = domEvent.touches && domEvent.touches.length > 0 ? domEvent.touches[0] : domEvent.changedTouches && domEvent.changedTouches.length > 0 ? domEvent.changedTouches[0] : domEvent;
13148
13149      if (!actual) {
13150        return;
13151      }
13152
13153      var containerPoint = getEventContainerPoint(actual, map._containerDOM),
13154          coordinate = map.containerPointToCoordinate(containerPoint);
13155
13156      if (eventType === 'touchstart') {
13157        preventDefault(domEvent);
13158      }
13159
13160      var geometryCursorStyle = null;
13161      var identifyOptions = {
13162        'includeInternals': true,
13163        'filter': function filter(geometry) {
13164          if (!(geometry instanceof Geometry)) {
13165            return false;
13166          }
13167
13168          var eventToFire = geometry._getEventTypeToFire(domEvent);
13169
13170          if (eventType === 'mousemove') {
13171            if (!geometryCursorStyle && geometry.options['cursor']) {
13172              geometryCursorStyle = geometry.options['cursor'];
13173            }
13174
13175            if (!geometry.listens('mousemove') && !geometry.listens('mouseover') && !geometry.listens('mouseenter')) {
13176              return false;
13177            }
13178          } else if (!geometry.listens(eventToFire) && !geometry.listens(oneMoreEvent)) {
13179            return false;
13180          }
13181
13182          return true;
13183        },
13184        'count': 1,
13185        'coordinate': coordinate,
13186        'onlyVisible': map.options['onlyVisibleGeometryEvents'],
13187        'layers': layers
13188      };
13189      var callback = fireGeometryEvent.bind(this);
13190
13191      if (eventType === 'mousemove' || eventType === 'touchmove') {
13192        this._queryIdentifyTimeout = map.getRenderer().callInNextFrame(function () {
13193          if (map.isInteracting()) {
13194            return;
13195          }
13196
13197          map.identify(identifyOptions, callback);
13198        });
13199      } else {
13200        map.identify(identifyOptions, callback);
13201      }
13202
13203      function fireGeometryEvent(geometries) {
13204        var propagation = true;
13205
13206        if (eventType === 'mousemove') {
13207          var geoMap = {};
13208
13209          if (geometries.length > 0) {
13210            for (var i = geometries.length - 1; i >= 0; i--) {
13211              var geo = geometries[i];
13212
13213              if (!(geo instanceof Geometry)) {
13214                continue;
13215              }
13216
13217              var iid = geo._getInternalId();
13218
13219              geoMap[iid] = geo;
13220
13221              geo._onEvent(domEvent);
13222
13223              if (!this._prevOverGeos || !this._prevOverGeos.geomap[iid]) {
13224                geo._onEvent(domEvent, 'mouseenter');
13225              }
13226
13227              propagation = geo._onEvent(domEvent, 'mouseover');
13228            }
13229          }
13230
13231          map._setPriorityCursor(geometryCursorStyle);
13232
13233          var oldTargets = this._prevOverGeos && this._prevOverGeos.geos;
13234          this._prevOverGeos = {
13235            'geos': geometries,
13236            'geomap': geoMap
13237          };
13238
13239          if (oldTargets && oldTargets.length > 0) {
13240            for (var _i = oldTargets.length - 1; _i >= 0; _i--) {
13241              var oldTarget = oldTargets[_i];
13242
13243              if (!(oldTarget instanceof Geometry)) {
13244                continue;
13245              }
13246
13247              var oldTargetId = oldTargets[_i]._getInternalId();
13248
13249              if (!geoMap[oldTargetId]) {
13250                propagation = oldTarget._onEvent(domEvent, 'mouseout');
13251              }
13252            }
13253          }
13254        } else {
13255          if (!geometries || !geometries.length) {
13256            return;
13257          }
13258
13259          for (var _i2 = geometries.length - 1; _i2 >= 0; _i2--) {
13260            if (!(geometries[_i2] instanceof Geometry)) {
13261              continue;
13262            }
13263
13264            propagation = geometries[_i2]._onEvent(domEvent);
13265
13266            if (oneMoreEvent) {
13267              geometries[_i2]._onEvent(domEvent, oneMoreEvent);
13268            }
13269
13270            break;
13271          }
13272        }
13273
13274        if (propagation === false) {
13275          stopPropagation(domEvent);
13276        }
13277      }
13278    };
13279
13280    return MapGeometryEventsHandler;
13281  }(Handler$1);
13282
13283  Map$1.mergeOptions({
13284    'geometryEvents': true,
13285    'onlyVisibleGeometryEvents': true
13286  });
13287  Map$1.addOnLoadHook('addHandler', 'geometryEvents', MapGeometryEventsHandler);
13288
13289  var wheelZoomDelta = 4.000244140625;
13290  var defaultZoomRate = 1 / 100;
13291  var wheelZoomRate = 1 / 450;
13292  var maxScalePerFrame = 2;
13293
13294  var MapScrollWheelZoomHandler = function (_Handler) {
13295    _inheritsLoose(MapScrollWheelZoomHandler, _Handler);
13296
13297    function MapScrollWheelZoomHandler(target) {
13298      var _this;
13299
13300      _this = _Handler.call(this, target) || this;
13301      _this._thisScrollZoom = _this._scrollZoom.bind(_assertThisInitialized(_assertThisInitialized(_this)));
13302      _this._wheelZoomRate = wheelZoomRate;
13303      _this._defaultZoomRate = defaultZoomRate;
13304      _this._delta = 0;
13305      return _this;
13306    }
13307
13308    var _proto = MapScrollWheelZoomHandler.prototype;
13309
13310    _proto.addHooks = function addHooks() {
13311      addDomEvent(this.target._containerDOM, 'mousewheel', this._onWheelScroll, this);
13312    };
13313
13314    _proto.removeHooks = function removeHooks() {
13315      removeDomEvent(this.target._containerDOM, 'mousewheel', this._onWheelScroll);
13316    };
13317
13318    _proto._onWheelScroll = function _onWheelScroll(evt) {
13319      preventDefault(evt);
13320      stopPropagation(evt);
13321      var map = this.target;
13322
13323      if (map._ignoreEvent(evt) || !map.options['zoomable']) {
13324        return false;
vendor: 83,014 bytes, lines 13325-16625
13325      }
13326
13327      var container = map._containerDOM;
13328
13329      var origin = map._checkZoomOrigin(getEventContainerPoint(evt, container));
13330
13331      if (map.options['seamlessZoom']) {
13332        if (!this._zooming) {
13333          this._trackPadSuspect = 0;
13334          this._ensureTrackpad = false;
13335        }
13336
13337        return this._seamless(evt, origin);
13338      } else {
13339        return this._interval(evt, origin);
13340      }
13341    };
13342
13343    _proto._seamless = function _seamless(evt, origin) {
13344      var value = evt.deltaMode === window.WheelEvent.DOM_DELTA_LINE ? evt.deltaY * 60 : evt.deltaY;
13345
13346      if (value % wheelZoomDelta !== 0) {
13347        if (!this._ensureTrackpad) {
13348          if (Math.abs(value) < 60) {
13349            this._trackPadSuspect++;
13350          } else {
13351            this._trackPadSuspect = 0;
13352          }
13353
13354          if (this._trackPadSuspect >= 2) {
13355            this._ensureTrackpad = true;
13356          }
13357        }
13358
13359        if (this._ensureTrackpad) {
13360          value *= 14;
13361        }
13362      }
13363
13364      if (evt.shiftKey && value) value = value / 4;
13365      this._lastWheelEvent = evt;
13366      this._delta -= value;
13367
13368      if (!this._zooming && this._delta) {
13369        var map = this.target;
13370        this._zoomOrigin = origin;
13371        map.onZoomStart(null, origin);
13372      }
13373
13374      this._start();
13375    };
13376
13377    _proto._start = function _start() {
13378      if (!this._delta) return;
13379      this._zooming = true;
13380      var map = this.target;
13381
13382      if (!this._active) {
13383        map.getRenderer().callInNextFrame(this._thisScrollZoom);
13384        this._active = true;
13385      }
13386    };
13387
13388    _proto._scrollZoom = function _scrollZoom() {
13389      var _this2 = this;
13390
13391      this._active = false;
13392
13393      if (!this._delta) {
13394        return;
13395      }
13396
13397      var zoomRate = Math.abs(this._delta) > wheelZoomDelta ? this._wheelZoomRate : this._defaultZoomRate;
13398      var scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(this._delta * zoomRate)));
13399
13400      if (this._delta < 0 && scale !== 0) {
13401        scale = 1 / scale;
13402      }
13403
13404      var map = this.target;
13405      var zoom = map.getZoom();
13406      var targetZoom = map.getZoomForScale(scale, zoom, true);
13407      this._delta = 0;
13408      map.onZooming(targetZoom, this._zoomOrigin);
13409
13410      if (this._timeout) {
13411        clearTimeout(this._timeout);
13412      }
13413
13414      this._timeout = setTimeout(function () {
13415        _this2._zooming = false;
13416        delete _this2._timeout;
13417        map.onZoomEnd(map.getZoom(), _this2._zoomOrigin);
13418      }, 320);
13419    };
13420
13421    _proto._interval = function _interval(evt, origin) {
13422      var _this3 = this;
13423
13424      var map = this.target;
13425
13426      if (this._zooming) {
13427        this._requesting++;
13428        return false;
13429      }
13430
13431      this._requesting = 0;
13432      var levelValue = (evt.wheelDelta ? evt.wheelDelta : evt.detail) > 0 ? 1 : -1;
13433
13434      if (evt.detail) {
13435        levelValue *= -1;
13436      }
13437
13438      var zoom = map.getZoom();
13439      var nextZoom = zoom + levelValue;
13440      nextZoom = map._checkZoom(levelValue > 0 ? Math.ceil(nextZoom) : Math.floor(nextZoom));
13441
13442      if (nextZoom === zoom) {
13443        return false;
13444      }
13445
13446      this._zooming = true;
13447
13448      if (!this._delta) {
13449        map.onZoomStart(null, origin);
13450        this._origin = origin;
13451        this._delta = levelValue;
13452        this._startZoom = map.getZoom();
13453      }
13454
13455      var duration = 90;
13456
13457      map._animateTo({
13458        'zoom': nextZoom - this._delta * 1 / 2,
13459        'around': this._origin
13460      }, {
13461        'continueOnViewChanged': true,
13462        'easing': 'linear',
13463        'duration': duration,
13464        'wheelZoom': true
13465      }, function (frame) {
13466        if (frame.state.playState !== 'finished') {
13467          return;
13468        }
13469
13470        if (_this3._requesting < 1 || Math.abs(nextZoom - _this3._startZoom) > 2 || nextZoom === map.getMaxZoom() || nextZoom === map.getMinZoom()) {
13471          map._animateTo({
13472            'zoom': nextZoom,
13473            'around': _this3._origin
13474          }, {
13475            'continueOnViewChanged': true,
13476            'duration': 100
13477          }, function (frame) {
13478            if (frame.state.playState === 'finished') {
13479              setTimeout(function () {
13480                delete _this3._zooming;
13481                delete _this3._requesting;
13482              }, 200);
13483            }
13484          });
13485
13486          delete _this3._startZoom;
13487          delete _this3._origin;
13488          delete _this3._delta;
13489          _this3._requesting = 0;
13490        } else if (!isNil(_this3._requesting)) {
13491          delete _this3._zooming;
13492
13493          _this3._onWheelScroll(evt);
13494        }
13495      });
13496
13497      return false;
13498    };
13499
13500    return MapScrollWheelZoomHandler;
13501  }(Handler$1);
13502
13503  Map$1.mergeOptions({
13504    'scrollWheelZoom': true,
13505    'seamlessZoom': false
13506  });
13507  Map$1.addOnLoadHook('addHandler', 'scrollWheelZoom', MapScrollWheelZoomHandler);
13508
13509  var MapTouchZoomHandler = function (_Handler) {
13510    _inheritsLoose(MapTouchZoomHandler, _Handler);
13511
13512    function MapTouchZoomHandler() {
13513      return _Handler.apply(this, arguments) || this;
13514    }
13515
13516    var _proto = MapTouchZoomHandler.prototype;
13517
13518    _proto.addHooks = function addHooks() {
13519      addDomEvent(this.target.getContainer(), 'touchstart', this._onTouchStart, this);
13520    };
13521
13522    _proto.removeHooks = function removeHooks() {
13523      removeDomEvent(this.target.getContainer(), 'touchstart', this._onTouchStart);
13524    };
13525
13526    _proto._onTouchStart = function _onTouchStart(event) {
13527      var map = this.target;
13528
13529      if (!event.touches || event.touches.length !== 2 || map.isInteracting()) {
13530        return;
13531      }
13532
13533      var container = map.getContainer();
13534      var p1 = getEventContainerPoint(event.touches[0], container),
13535          p2 = getEventContainerPoint(event.touches[1], container);
13536      this.preY = p1.y;
13537      this._startP1 = p1;
13538      this._startP2 = p2;
13539      this._startDist = p1.distanceTo(p2);
13540      this._startVector = p1.sub(p2);
13541      this._startZoom = map.getZoom();
13542      this._startBearing = map.getBearing();
13543      addDomEvent(document, 'touchmove', this._onTouchMove, this);
13544      addDomEvent(document, 'touchend', this._onTouchEnd, this);
13545      preventDefault(event);
13546
13547      map._fireEvent('touchactstart');
13548    };
13549
13550    _proto._onTouchMove = function _onTouchMove(event) {
13551      var map = this.target;
13552
13553      if (!event.touches || event.touches.length !== 2) {
13554        return;
13555      }
13556
13557      var container = map.getContainer(),
13558          p1 = getEventContainerPoint(event.touches[0], container),
13559          p2 = getEventContainerPoint(event.touches[1], container),
13560          d1 = p1.sub(this._startP1),
13561          d2 = p2.sub(this._startP2),
13562          vector = p1.sub(p2),
13563          scale = p1.distanceTo(p2) / this._startDist,
13564          bearing = vector.angleWith(this._startVector) * 180 / Math.PI,
13565          preY = this.preY || p1.y,
13566          pitch = (preY - p1.y) * 0.4;
13567
13568      this.preY = p1.y;
13569      var param = {
13570        'domEvent': event,
13571        'mousePos': [p1, p2]
13572      };
13573
13574      if (!this.mode) {
13575        if (map.options['touchRotate'] && Math.abs(bearing) > 8) {
13576          this.mode = map.options['touchZoomRotate'] ? 'rotate_zoom' : 'rotate';
13577        } else if (map.options['touchPitch'] && d1.y * d2.y > 0 && Math.abs(d1.y) > 10 && Math.abs(d2.y) > 10) {
13578          this.mode = 'pitch';
13579        } else if (map.options['zoomable'] && map.options['touchZoom'] && Math.abs(1 - scale) > 0.15) {
13580          this.mode = map.options['touchZoomRotate'] && map.options['touchRotate'] ? 'rotate_zoom' : 'zoom';
13581        }
13582
13583        this._startTouching(param);
13584      }
13585
13586      if (this.mode === 'zoom' || this.mode === 'rotate_zoom') {
13587        this._scale = scale;
13588        var res = map._getResolution(this._startZoom) / scale;
13589        var zoom = map.getZoomFromRes(res);
13590        map.onZooming(zoom, this._Origin);
13591      }
13592
13593      if (this.mode === 'rotate' || this.mode === 'rotate_zoom') {
13594        map.setBearing(this._startBearing + bearing);
13595        map.onDragRotating(param);
13596      } else if (this.mode === 'pitch') {
13597        map.setPitch(map.getPitch() + pitch);
13598        map.onDragRotating(param);
13599      }
13600
13601      map._fireEvent('touchactinging');
13602    };
13603
13604    _proto._startTouching = function _startTouching(param) {
13605      var map = this.target;
13606
13607      if (this.mode === 'zoom' || this.mode === 'rotate_zoom') {
13608        var size = map.getSize();
13609        this._Origin = new Point(size['width'] / 2, size['height'] / 2);
13610        map.onZoomStart(null, this._Origin);
13611      }
13612
13613      if (this.mode === 'rotate' || this.mode === 'pitch' || this.mode === 'rotate_zoom') {
13614        map.onDragRotateStart(param);
13615      }
13616    };
13617
13618    _proto._onTouchEnd = function _onTouchEnd(event) {
13619      delete this.preY;
13620      var map = this.target;
13621      off(document, 'touchmove', this._onTouchMove, this);
13622      off(document, 'touchend', this._onTouchEnd, this);
13623
13624      if (this.mode === 'zoom' || this.mode === 'rotate_zoom') {
13625        var scale = this._scale;
13626        var res = map._getResolution(this._startZoom) / scale;
13627        var zoom = map.getZoomFromRes(res);
13628        map.onZoomEnd(zoom, this._Origin);
13629      }
13630
13631      if (this.mode === 'pitch' || this.mode === 'rotate' || this.mode === 'rotate_zoom') {
13632        map.onDragRotateEnd({
13633          'domEvent': event
13634        });
13635      }
13636
13637      delete this.mode;
13638
13639      map._fireEvent('touchactend');
13640    };
13641
13642    return MapTouchZoomHandler;
13643  }(Handler$1);
13644
13645  Map$1.mergeOptions({
13646    'touchGesture': true,
13647    'touchZoom': true,
13648    'touchPitch': true,
13649    'touchRotate': true,
13650    'touchZoomRotate': false
13651  });
13652  Map$1.addOnLoadHook('addHandler', 'touchGesture', MapTouchZoomHandler);
13653
13654  var Easing = {
13655    in: function _in(t) {
13656      return Math.pow(t, 2);
13657    },
13658    out: function out(t) {
13659      return 1 - Easing.in(1 - t);
13660    },
13661    inAndOut: function inAndOut(t) {
13662      return 3 * t * t - 2 * t * t * t;
13663    },
13664    linear: function linear(t) {
13665      return t;
13666    },
13667    upAndDown: function upAndDown(t) {
13668      if (t < 0.5) {
13669        return Easing.inAndOut(2 * t);
13670      } else {
13671        return 1 - Easing.inAndOut(2 * (t - 0.5));
13672      }
13673    }
13674  };
13675
13676  var Frame = function Frame(state, styles) {
13677    this.state = state;
13678    this.styles = styles;
13679  };
13680
13681  var Player = function Player(animation, options, onFrame) {
13682    this._animation = animation;
13683    this.options = options;
13684    this._onFrame = onFrame;
13685    this.playState = 'idle';
13686    this.ready = true;
13687    this.finished = false;
13688  };
13689
13690  var Animation = {
13691    speed: {
13692      'slow': 2000,
13693      'normal': 1000,
13694      'fast': 500
13695    },
13696    _resolveStyles: function _resolveStyles(styles) {
13697      if (!styles) {
13698        return null;
13699      }
13700
13701      function resolveChild(child) {
13702        if (!Array.isArray(child)) {
13703          return Animation._resolveStyles(child);
13704        }
13705
13706        var start = [],
13707            d = [],
13708            dest = [];
13709
13710        for (var i = 0; i < child.length; i++) {
13711          var _styles = Animation._resolveStyles(child[i]);
13712
13713          if (_styles) {
13714            start.push(_styles[0]);
13715            d.push(_styles[1]);
13716            dest.push(_styles[2]);
13717          }
13718        }
13719
13720        if (!start.length) {
13721          return null;
13722        } else {
13723          return [start, d, dest];
13724        }
13725      }
13726
13727      function resolveVal(val) {
13728        var values = val;
13729        var clazz;
13730
13731        if (!Array.isArray(val)) {
13732          if (isNumber(val)) {
13733            values = [0, val];
13734          } else if (val instanceof Point || val instanceof Coordinate) {
13735            clazz = val.constructor;
13736            values = [new clazz(0, 0), val];
13737          } else {
13738            values = [val, val];
13739          }
13740        }
13741
13742        var v1 = values[0],
13743            v2 = values[1];
13744
13745        if (isNumber(v1) && isNumber(v2)) {
13746          if (v1 === v2) {
13747            return null;
13748          }
13749
13750          return [v1, v2 - v1, v2];
13751        } else if (Array.isArray(v1) || v1 instanceof Coordinate || v1 instanceof Point) {
13752          if (Array.isArray(v1)) {
13753            v1 = new Coordinate(v1);
13754            v2 = new Coordinate(v2);
13755          } else {
13756            clazz = v1.constructor;
13757            v1 = new clazz(v1);
13758            v2 = new clazz(v2);
13759          }
13760
13761          if (v1.equals(v2)) {
13762            return null;
13763          }
13764
13765          return [v1, v2.sub(v1), v2];
13766        } else {
13767          return [v1, 0, v2];
13768        }
13769      }
13770
13771      function isChild(val) {
13772        if (!Array.isArray(val) && val.constructor === Object) {
13773          return true;
13774        } else if (Array.isArray(val) && val[0].constructor === Object) {
13775          return true;
13776        }
13777
13778        return false;
13779      }
13780
13781      var d = {},
13782          start = {},
13783          dest = {};
13784
13785      for (var p in styles) {
13786        if (styles.hasOwnProperty(p)) {
13787          var values = styles[p];
13788
13789          if (!values) {
13790            continue;
13791          } else if (Array.isArray(values)) {
13792            if (isNil(values[0]) || isNil(values[1])) {
13793              continue;
13794            }
13795          }
13796
13797          var childStyles = void 0;
13798
13799          if (isChild(values)) {
13800            childStyles = resolveChild(values);
13801          } else {
13802            childStyles = resolveVal(values);
13803          }
13804
13805          if (childStyles) {
13806            start[p] = childStyles[0];
13807            d[p] = childStyles[1];
13808            dest[p] = childStyles[2];
13809          }
13810        }
13811      }
13812
13813      return [start, d, dest];
13814    },
13815    framing: function framing(styles, options) {
13816      if (!options) {
13817        options = {};
13818      }
13819
13820      var easing = options['easing'] ? Easing[options['easing']] : Easing.linear;
13821
13822      if (!easing) {
13823        easing = Easing.linear;
13824      }
13825
13826      var dStyles, startStyles, destStyles;
13827      styles = Animation._resolveStyles(styles);
13828
13829      if (styles) {
13830        startStyles = styles[0];
13831        dStyles = styles[1];
13832        destStyles = styles[2];
13833      }
13834
13835      var deltaStyles = function deltaStyles(delta, _startStyles, _dStyles) {
13836        if (!_startStyles || !_dStyles) {
13837          return null;
13838        }
13839
13840        var result = {};
13841
13842        for (var p in _dStyles) {
13843          if (_dStyles.hasOwnProperty(p)) {
13844            if (_startStyles[p] === destStyles[p]) {
13845              result[p] = _startStyles[p];
13846              continue;
13847            }
13848
13849            var s = _startStyles[p],
13850                d = _dStyles[p];
13851
13852            if (isNumber(d)) {
13853              result[p] = s + delta * d;
13854            } else if (Array.isArray(d)) {
13855              var children = [];
13856
13857              for (var i = 0; i < d.length; i++) {
13858                children.push(deltaStyles(delta, s[i], d[i]));
13859              }
13860
13861              result[p] = children;
13862            } else {
13863              var clazz = d.constructor;
13864
13865              if (clazz === Object) {
13866                result[p] = deltaStyles(delta, s, d);
13867              } else if (s instanceof Point || s instanceof Coordinate) {
13868                result[p] = s.add(d.multi(delta));
13869              }
13870            }
13871          }
13872        }
13873
13874        return result;
13875      };
13876
13877      return function (elapsed, duration) {
13878        var state, d;
13879
13880        if (elapsed < 0) {
13881          state = {
13882            'playState': 'idle',
13883            'delta': 0
13884          };
13885          d = startStyles;
13886        } else if (elapsed < duration) {
13887          var delta = easing(elapsed / duration);
13888          state = {
13889            'playState': 'running',
13890            'delta': delta
13891          };
13892          d = deltaStyles(delta, startStyles, dStyles);
13893        } else {
13894          state = {
13895            'playState': 'finished',
13896            'delta': 1
13897          };
13898          d = destStyles;
13899        }
13900
13901        state['startStyles'] = startStyles;
13902        state['destStyles'] = destStyles;
13903        state['progress'] = elapsed;
13904        state['remainingMs'] = duration - elapsed;
13905        return new Frame(state, d);
13906      };
13907    },
13908    _requestAnimFrame: function _requestAnimFrame(fn) {
13909      if (!this._frameQueue) {
13910        this._frameQueue = [];
13911      }
13912
13913      this._frameQueue.push(fn);
13914
13915      this._a();
13916    },
13917    _a: function _a() {
13918      if (!this._animationFrameId) {
13919        this._animationFrameId = requestAnimFrame(Animation._frameFn);
13920      }
13921    },
13922    _run: function _run() {
13923      if (this._frameQueue.length) {
13924        var running = this._frameQueue;
13925        this._frameQueue = [];
13926
13927        for (var i = 0, len = running.length; i < len; i++) {
13928          running[i]();
13929        }
13930
13931        if (this._frameQueue.length) {
13932          this._animationFrameId = requestAnimFrame(Animation._frameFn);
13933        } else {
13934          delete this._animationFrameId;
13935        }
13936      }
13937    },
13938    animate: function animate(styles, options, step) {
13939      if (!options) {
13940        options = {};
13941      }
13942
13943      var animation = Animation.framing(styles, options);
13944      return new Player(animation, options, step);
13945    }
13946  };
13947  Animation._frameFn = Animation._run.bind(Animation);
13948  extend(Player.prototype, {
13949    _prepare: function _prepare() {
13950      var options = this.options;
13951      var duration = options['speed'] || options['duration'];
13952
13953      if (isString(duration)) {
13954        duration = Animation.speed[duration];
13955
13956        if (!duration) {
13957          duration = +duration;
13958        }
13959      }
13960
13961      if (!duration) {
13962        duration = Animation.speed['normal'];
13963      }
13964
13965      this.duration = duration;
13966      this._framer = options['framer'] || Animation._requestAnimFrame.bind(Animation);
13967    },
13968    play: function play() {
13969      if (this.playState !== 'idle' && this.playState !== 'paused') {
13970        return this;
13971      }
13972
13973      if (this.playState === 'idle') {
13974        this.currentTime = 0;
13975
13976        this._prepare();
13977      }
13978
13979      var t = now();
13980
13981      if (!this.startTime) {
13982        var options = this.options;
13983        this.startTime = options['startTime'] ? options['startTime'] : t;
13984      }
13985
13986      this._playStartTime = Math.max(t, this.startTime);
13987
13988      if (this.playState === 'paused') {
13989        this._playStartTime -= this.currentTime;
13990      }
13991
13992      this.playState = 'running';
13993
13994      this._run();
13995
13996      return this;
13997    },
13998    pause: function pause() {
13999      if (this.playState === 'paused') {
14000        return this;
14001      }
14002
14003      this.playState = 'paused';
14004
14005      this._run();
14006
14007      return this;
14008    },
14009    cancel: function cancel() {
14010      if (this.playState === 'idle') {
14011        return this;
14012      }
14013
14014      this.playState = 'idle';
14015      this.finished = false;
14016
14017      this._run();
14018
14019      return this;
14020    },
14021    finish: function finish() {
14022      if (this.playState === 'finished') {
14023        return this;
14024      }
14025
14026      this.playState = 'finished';
14027      this.finished = true;
14028
14029      this._run();
14030
14031      return this;
14032    },
14033    reverse: function reverse() {},
14034    _run: function _run() {
14035      var _this = this;
14036
14037      var onFrame = this._onFrame;
14038      var t = now();
14039      var elapsed = t - this._playStartTime;
14040
14041      if (this.options['repeat'] && elapsed >= this.duration) {
14042        this._playStartTime = t;
14043        elapsed = 0;
14044      }
14045
14046      if (this.playState !== 'running') {
14047        if (onFrame) {
14048          if (this.playState === 'finished') {
14049            elapsed = this.duration;
14050          } else if (this.playState === 'idle') {
14051            elapsed = 0;
14052          }
14053
14054          var _frame = this._animation(elapsed, this.duration);
14055
14056          _frame.state.playState = this.playState;
14057          onFrame(_frame);
14058        }
14059
14060        return;
14061      }
14062
14063      var frame = this._animation(elapsed, this.duration);
14064
14065      this.playState = frame.state['playState'];
14066
14067      if (this.playState === 'idle') {
14068        if (this.startTime > t) {
14069          setTimeout(this._run.bind(this), this.startTime - t);
14070        }
14071      } else if (this.playState === 'running') {
14072        this._framer(function () {
14073          if (_this.playState !== 'running') {
14074            return;
14075          }
14076
14077          _this.currentTime = elapsed;
14078
14079          if (onFrame) {
14080            onFrame(frame);
14081          }
14082
14083          _this._run();
14084        });
14085      } else if (this.playState === 'finished') {
14086        this.finished = true;
14087
14088        if (onFrame) {
14089          onFrame(frame);
14090        }
14091      }
14092    }
14093  });
14094
14095  var Animation$1 = /*#__PURE__*/Object.freeze({
14096    Animation: Animation,
14097    Easing: Easing,
14098    Player: Player,
14099    Frame: Frame
14100  });
14101
14102  var simplify = createCommonjsModule(function (module) {
14103    (function () {
14104
14105      function getSqDist(p1, p2) {
14106        var dx = p1.x - p2.x,
14107            dy = p1.y - p2.y;
14108        return dx * dx + dy * dy;
14109      }
14110
14111      function getSqSegDist(p, p1, p2) {
14112        var x = p1.x,
14113            y = p1.y,
14114            dx = p2.x - x,
14115            dy = p2.y - y;
14116
14117        if (dx !== 0 || dy !== 0) {
14118          var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy);
14119
14120          if (t > 1) {
14121            x = p2.x;
14122            y = p2.y;
14123          } else if (t > 0) {
14124            x += dx * t;
14125            y += dy * t;
14126          }
14127        }
14128
14129        dx = p.x - x;
14130        dy = p.y - y;
14131        return dx * dx + dy * dy;
14132      }
14133
14134      function simplifyRadialDist(points, sqTolerance) {
14135        var prevPoint = points[0],
14136            newPoints = [prevPoint],
14137            point;
14138
14139        for (var i = 1, len = points.length; i < len; i++) {
14140          point = points[i];
14141
14142          if (getSqDist(point, prevPoint) > sqTolerance) {
14143            newPoints.push(point);
14144            prevPoint = point;
14145          }
14146        }
14147
14148        if (prevPoint !== point) newPoints.push(point);
14149        return newPoints;
14150      }
14151
14152      function simplifyDPStep(points, first, last, sqTolerance, simplified) {
14153        var maxSqDist = sqTolerance,
14154            index;
14155
14156        for (var i = first + 1; i < last; i++) {
14157          var sqDist = getSqSegDist(points[i], points[first], points[last]);
14158
14159          if (sqDist > maxSqDist) {
14160            index = i;
14161            maxSqDist = sqDist;
14162          }
14163        }
14164
14165        if (maxSqDist > sqTolerance) {
14166          if (index - first > 1) simplifyDPStep(points, first, index, sqTolerance, simplified);
14167          simplified.push(points[index]);
14168          if (last - index > 1) simplifyDPStep(points, index, last, sqTolerance, simplified);
14169        }
14170      }
14171
14172      function simplifyDouglasPeucker(points, sqTolerance) {
14173        var last = points.length - 1;
14174        var simplified = [points[0]];
14175        simplifyDPStep(points, 0, last, sqTolerance, simplified);
14176        simplified.push(points[last]);
14177        return simplified;
14178      }
14179
14180      function simplify(points, tolerance, highestQuality) {
14181        if (points.length <= 2) return points;
14182        var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1;
14183        points = highestQuality ? points : simplifyRadialDist(points, sqTolerance);
14184        points = simplifyDouglasPeucker(points, sqTolerance);
14185        return points;
14186      }
14187
14188      {
14189        module.exports = simplify;
14190        module.exports.default = simplify;
14191      }
14192    })();
14193  });
14194
14195  var options$3 = {
14196    'smoothness': 0,
14197    'enableClip': true,
14198    'enableSimplify': true,
14199    'simplifyTolerance': 2,
14200    'symbol': {
14201      'lineColor': '#000',
14202      'lineWidth': 2,
14203      'lineOpacity': 1,
14204      'polygonFill': '#fff',
14205      'polygonOpacity': 1,
14206      'opacity': 1
14207    }
14208  };
14209
14210  var Path = function (_Geometry) {
14211    _inheritsLoose(Path, _Geometry);
14212
14213    function Path() {
14214      return _Geometry.apply(this, arguments) || this;
14215    }
14216
14217    var _proto = Path.prototype;
14218
14219    _proto.getOutline = function getOutline() {
14220      var painter = this._getPainter();
14221
14222      if (!painter) {
14223        return null;
14224      }
14225
14226      var map = this.getMap();
14227      var extent = painter.getContainerExtent().convertTo(function (c) {
14228        return map.containerPointToCoord(c);
14229      });
14230      return new Polygon(extent.toArray(), {
14231        symbol: {
14232          'lineWidth': 1,
14233          'lineColor': '6b707b'
14234        }
14235      });
14236    };
14237
14238    _proto.animateShow = function animateShow(options, cb) {
14239      var _this = this;
14240
14241      if (options === void 0) {
14242        options = {};
14243      }
14244
14245      if (this._showPlayer) {
14246        this._showPlayer.finish();
14247      }
14248
14249      if (isFunction(options)) {
14250        options = {};
14251        cb = options;
14252      }
14253
14254      var coordinates = this.getCoordinates();
14255
14256      if (coordinates.length === 0) {
14257        return this;
14258      }
14259
14260      this._animIdx = 0;
14261      this._animLenSoFar = 0;
14262      this.show();
14263      var isPolygon = !!this.getShell;
14264      var animCoords = isPolygon ? this.getShell().concat(this.getShell()[0]) : this.getCoordinates();
14265
14266      var projection = this._getProjection();
14267
14268      this._aniShowCenter = projection.unproject(this._getPrjExtent().getCenter());
14269      var duration = options['duration'] || 1000,
14270          length = this.getLength(),
14271          easing = options['easing'] || 'out';
14272      this.setCoordinates([]);
14273      var player = this._showPlayer = Animation.animate({
14274        't': duration
14275      }, {
14276        'duration': duration,
14277        'easing': easing
14278      }, function (frame) {
14279        if (!_this.getMap()) {
14280          if (player.playState !== 'finished') {
14281            player.finish();
14282
14283            if (cb) {
14284              var _coordinates = _this.getCoordinates();
14285
14286              cb(frame, _coordinates[_coordinates.length - 1]);
14287            }
14288          }
14289
14290          return;
14291        }
14292
14293        var currentCoord = _this._drawAnimShowFrame(frame.styles.t, duration, length, animCoords);
14294
14295        if (frame.state.playState === 'finished') {
14296          delete _this._showPlayer;
14297          delete _this._aniShowCenter;
14298          delete _this._animIdx;
14299          delete _this._animLenSoFar;
14300          delete _this._animTailRatio;
14301
14302          _this.setCoordinates(coordinates);
14303        }
14304
14305        if (cb) {
14306          cb(frame, currentCoord);
14307        }
14308      });
14309      player.play();
14310      return player;
14311    };
14312
14313    _proto._drawAnimShowFrame = function _drawAnimShowFrame(t, duration, length, coordinates) {
14314      if (t === 0) {
14315        return coordinates[0];
14316      }
14317
14318      var map = this.getMap();
14319      var targetLength = t / duration * length;
14320      var segLen = 0;
14321      var i, l;
14322
14323      for (i = this._animIdx, l = coordinates.length; i < l - 1; i++) {
14324        segLen = map.computeLength(coordinates[i], coordinates[i + 1]);
14325
14326        if (this._animLenSoFar + segLen > targetLength) {
14327          break;
14328        }
14329
14330        this._animLenSoFar += segLen;
14331      }
14332
14333      this._animIdx = i;
14334
14335      if (this._animIdx >= l - 1) {
14336        this.setCoordinates(coordinates);
14337        return coordinates[coordinates.length - 1];
14338      }
14339
14340      var idx = this._animIdx;
14341      var p1 = coordinates[idx],
14342          p2 = coordinates[idx + 1],
14343          span = targetLength - this._animLenSoFar,
14344          r = span / segLen;
14345      this._animTailRatio = r;
14346      var x = p1.x + (p2.x - p1.x) * r,
14347          y = p1.y + (p2.y - p1.y) * r,
14348          targetCoord = new Coordinate(x, y);
14349      var isPolygon = !!this.getShell;
14350
14351      if (!isPolygon && this.options['smoothness'] > 0) {
14352        var animCoords = coordinates.slice(0, this._animIdx + 3);
14353        this.setCoordinates(animCoords);
14354      } else {
14355        var _animCoords = coordinates.slice(0, this._animIdx + 1);
14356
14357        _animCoords.push(targetCoord);
14358
14359        if (isPolygon) {
14360          this.setCoordinates([this._aniShowCenter].concat(_animCoords));
14361        } else {
14362          this.setCoordinates(_animCoords);
14363        }
14364      }
14365
14366      return targetCoord;
14367    };
14368
14369    _proto._getCenterInExtent = function _getCenterInExtent(extent, coordinates, clipFn) {
14370      var meExtent = this.getExtent();
14371
14372      if (!extent.intersects(meExtent)) {
14373        return null;
14374      }
14375
14376      var clipped = clipFn(coordinates, extent);
14377
14378      if (clipped.length === 0) {
14379        return null;
14380      }
14381
14382      var sumx = 0,
14383          sumy = 0,
14384          counter = 0;
14385      clipped.forEach(function (part) {
14386        if (Array.isArray(part)) {
14387          part.forEach(function (c) {
14388            if (c.point) {
14389              c = c.point;
14390            }
14391
14392            sumx += c.x;
14393            sumy += c.y;
14394            counter++;
14395          });
14396        } else {
14397          if (part.point) {
14398            part = part.point;
14399          }
14400
14401          sumx += part.x;
14402          sumy += part.y;
14403          counter++;
14404        }
14405      });
14406
14407      var c = new Coordinate(sumx, sumy)._multi(1 / counter);
14408
14409      c.count = counter;
14410      return c;
14411    };
14412
14413    _proto._getPath2DPoints = function _getPath2DPoints(prjCoords, disableSimplify, zoom) {
14414      if (!isArrayHasData(prjCoords)) {
14415        return [];
14416      }
14417
14418      var map = this.getMap(),
14419          isSimplify = !disableSimplify && this._shouldSimplify(),
14420          tolerance = this.options['simplifyTolerance'] * map._getResolution(),
14421          isMulti = Array.isArray(prjCoords[0]);
14422
14423      delete this._simplified;
14424
14425      if (isSimplify && !isMulti) {
14426        var count = prjCoords.length;
14427        prjCoords = simplify(prjCoords, tolerance, false);
14428        this._simplified = prjCoords.length < count;
14429      }
14430
14431      if (isNil(zoom)) {
14432        zoom = map.getZoom();
14433      }
14434
14435      return forEachCoord(prjCoords, function (c) {
14436        return map._prjToPoint(c, zoom);
14437      });
14438    };
14439
14440    _proto._shouldSimplify = function _shouldSimplify() {
14441      var layer = this.getLayer(),
14442          properties = this.getProperties();
14443      var hasAltitude = properties && layer.options['enableAltitude'] && !isNil(properties[layer.options['altitudeProperty']]);
14444      return layer && layer.options['enableSimplify'] && !hasAltitude && this.options['enableSimplify'] && !this._showPlayer;
14445    };
14446
14447    _proto._setPrjCoordinates = function _setPrjCoordinates(prjPoints) {
14448      this._prjCoords = prjPoints;
14449      this.onShapeChanged();
14450    };
14451
14452    _proto._getPrjCoordinates = function _getPrjCoordinates() {
14453      var projection = this._getProjection();
14454
14455      if (!projection) {
14456        return null;
14457      }
14458
14459      this._verifyProjection();
14460
14461      if (!this._prjCoords) {
14462        this._prjCoords = this._projectCoords(this._coordinates);
14463      }
14464
14465      return this._prjCoords;
14466    };
14467
14468    _proto._updateCache = function _updateCache() {
14469      this._clearCache();
14470
14471      var projection = this._getProjection();
14472
14473      if (!projection) {
14474        return;
14475      }
14476
14477      if (this._prjCoords) {
14478        this._coordinates = this._unprojectCoords(this._getPrjCoordinates());
14479      }
14480    };
14481
14482    _proto._clearProjection = function _clearProjection() {
14483      this._prjCoords = null;
14484
14485      _Geometry.prototype._clearProjection.call(this);
14486    };
14487
14488    _proto._projectCoords = function _projectCoords(points) {
14489      var projection = this._getProjection();
14490
14491      if (projection) {
14492        return projection.projectCoords(points);
14493      }
14494
14495      return [];
14496    };
14497
14498    _proto._unprojectCoords = function _unprojectCoords(prjPoints) {
14499      var projection = this._getProjection();
14500
14501      if (projection) {
14502        return projection.unprojectCoords(prjPoints);
14503      }
14504
14505      return [];
14506    };
14507
14508    _proto._computeCenter = function _computeCenter() {
14509      var ring = this._coordinates;
14510
14511      if (!isArrayHasData(ring)) {
14512        return null;
14513      }
14514
14515      var sumx = 0,
14516          sumy = 0,
14517          counter = 0;
14518      var size = ring.length;
14519
14520      for (var i = 0; i < size; i++) {
14521        if (ring[i]) {
14522          if (isNumber(ring[i].x) && isNumber(ring[i].y)) {
14523            sumx += ring[i].x;
14524            sumy += ring[i].y;
14525            counter++;
14526          }
14527        }
14528      }
14529
14530      return new Coordinate(sumx / counter, sumy / counter);
14531    };
14532
14533    _proto._computeExtent = function _computeExtent() {
14534      var shell = this._coordinates;
14535
14536      if (!isArrayHasData(shell)) {
14537        return null;
14538      }
14539
14540      var rings = [shell];
14541
14542      if (this.hasHoles && this.hasHoles()) {
14543        rings.push.apply(rings, this.getHoles());
14544      }
14545
14546      return this._coords2Extent(rings, this._getProjection());
14547    };
14548
14549    _proto._computePrjExtent = function _computePrjExtent() {
14550      var coords = [this._getPrjCoordinates()];
14551
14552      if (this.hasHoles && this.hasHoles()) {
14553        coords.push.apply(coords, this._getPrjHoles());
14554      }
14555
14556      return this._coords2Extent(coords);
14557    };
14558
14559    _proto._get2DLength = function _get2DLength() {
14560      var vertexes = this._getPath2DPoints(this._getPrjCoordinates(), true);
14561
14562      var len = 0;
14563
14564      for (var i = 1, l = vertexes.length; i < l; i++) {
14565        len += vertexes[i].distanceTo(vertexes[i - 1]);
14566      }
14567
14568      return len;
14569    };
14570
14571    _proto._hitTestTolerance = function _hitTestTolerance() {
14572      var symbol = this._getInternalSymbol();
14573
14574      var w;
14575
14576      if (Array.isArray(symbol)) {
14577        w = 0;
14578
14579        for (var i = 0; i < symbol.length; i++) {
14580          if (isNumber(symbol[i]['lineWidth'])) {
14581            if (symbol[i]['lineWidth'] > w) {
14582              w = symbol[i]['lineWidth'];
14583            }
14584          }
14585        }
14586      } else {
14587        w = symbol['lineWidth'];
14588      }
14589
14590      return isNumber(w) ? w / 2 : 1.5;
14591    };
14592
14593    _proto._coords2Extent = function _coords2Extent(coords, proj) {
14594      var result = new Extent(proj);
14595
14596      for (var i = 0, l = coords.length; i < l; i++) {
14597        for (var j = 0, ll = coords[i].length; j < ll; j++) {
14598          result._combine(coords[i][j]);
14599        }
14600      }
14601
14602      return result;
14603    };
14604
14605    return Path;
14606  }(Geometry);
14607
14608  Path.mergeOptions(options$3);
14609
14610  var JSON_TYPE = 'Polygon';
14611
14612  var Polygon = function (_Path) {
14613    _inheritsLoose(Polygon, _Path);
14614
14615    function Polygon(coordinates, opts) {
14616      var _this;
14617
14618      _this = _Path.call(this, opts) || this;
14619      _this.type = 'Polygon';
14620
14621      if (coordinates) {
14622        _this.setCoordinates(coordinates);
14623      }
14624
14625      return _this;
14626    }
14627
14628    var _proto = Polygon.prototype;
14629
14630    _proto.setCoordinates = function setCoordinates(coordinates) {
14631      if (!coordinates) {
14632        this._coordinates = null;
14633        this._holes = null;
14634
14635        this._projectRings();
14636
14637        return this;
14638      }
14639
14640      var rings = Coordinate.toCoordinates(coordinates);
14641      var len = rings.length;
14642
14643      if (!Array.isArray(rings[0])) {
14644        this._coordinates = this._trimRing(rings);
14645      } else {
14646        this._coordinates = this._trimRing(rings[0]);
14647
14648        if (len > 1) {
14649          var holes = [];
14650
14651          for (var i = 1; i < len; i++) {
14652            if (!rings[i]) {
14653              continue;
14654            }
14655
14656            holes.push(this._trimRing(rings[i]));
14657          }
14658
14659          this._holes = holes;
14660        }
14661      }
14662
14663      this._projectRings();
14664
14665      return this;
14666    };
14667
14668    _proto.getCoordinates = function getCoordinates() {
14669      if (!this._coordinates) {
14670        return [];
14671      }
14672
14673      var holes = this.getHoles();
14674      var rings = [this._copyAndCloseRing(this._coordinates)];
14675
14676      for (var i = 0, l = holes.length; i < l; i++) {
14677        rings.push(this._copyAndCloseRing(holes[i]));
14678      }
14679
14680      return rings;
14681    };
14682
14683    _proto.getCenterInExtent = function getCenterInExtent(extent) {
14684      return this._getCenterInExtent(extent, this.getShell(), clipPolygon);
14685    };
14686
14687    _proto.getShell = function getShell() {
14688      return this._coordinates || [];
14689    };
14690
14691    _proto.getHoles = function getHoles() {
14692      return this._holes || [];
14693    };
14694
14695    _proto.hasHoles = function hasHoles() {
14696      return this.getHoles().length > 0;
14697    };
14698
14699    _proto._projectRings = function _projectRings() {
14700      if (!this.getMap()) {
14701        this.onShapeChanged();
14702        return;
14703      }
14704
14705      this._prjCoords = this._projectCoords(this._coordinates);
14706      this._prjHoles = this._projectCoords(this._holes);
14707      this.onShapeChanged();
14708    };
14709
14710    _proto._cleanRing = function _cleanRing(ring) {
14711      for (var i = ring.length - 1; i >= 0; i--) {
14712        if (!ring[i]) {
14713          ring.splice(i, 1);
14714        }
14715      }
14716    };
14717
14718    _proto._checkRing = function _checkRing(ring) {
14719      this._cleanRing(ring);
14720
14721      if (!ring || !isArrayHasData(ring)) {
14722        return false;
14723      }
14724
14725      var lastPoint = ring[ring.length - 1];
14726      var isClose = true;
14727
14728      if (ring[0].x !== lastPoint.x || ring[0].y !== lastPoint.y) {
14729        isClose = false;
14730      }
14731
14732      return isClose;
14733    };
14734
14735    _proto._trimRing = function _trimRing(ring) {
14736      var isClose = this._checkRing(ring);
14737
14738      if (isArrayHasData(ring) && isClose) {
14739        ring.splice(ring.length - 1, 1);
14740      }
14741
14742      return ring;
14743    };
14744
14745    _proto._copyAndCloseRing = function _copyAndCloseRing(ring) {
14746      ring = ring.slice(0);
14747
14748      var isClose = this._checkRing(ring);
14749
14750      if (isArrayHasData(ring) && !isClose) {
14751        ring.push(ring[0].copy());
14752        return ring;
14753      } else {
14754        return ring;
14755      }
14756    };
14757
14758    _proto._getPrjShell = function _getPrjShell() {
14759      if (this.getJSONType() === JSON_TYPE) {
14760        return this._getPrjCoordinates();
14761      }
14762
14763      var projection = this._getProjection();
14764
14765      if (!projection) {
14766        return null;
14767      }
14768
14769      this._verifyProjection();
14770
14771      if (!this._prjShell) {
14772        this._prjShell = this._projectCoords(this.getShell());
14773      }
14774
14775      return this._prjShell;
14776    };
14777
14778    _proto._getPrjHoles = function _getPrjHoles() {
14779      var projection = this._getProjection();
14780
14781      if (!projection) {
14782        return null;
14783      }
14784
14785      this._verifyProjection();
14786
14787      if (!this._prjHoles) {
14788        this._prjHoles = this._projectCoords(this.getHoles());
14789      }
14790
14791      return this._prjHoles;
14792    };
14793
14794    _proto._computeGeodesicLength = function _computeGeodesicLength(measurer) {
14795      var rings = this.getCoordinates();
14796
14797      if (!isArrayHasData(rings)) {
14798        return 0;
14799      }
14800
14801      var result = 0;
14802
14803      for (var i = 0, len = rings.length; i < len; i++) {
14804        result += measurer.measureLength(rings[i]);
14805      }
14806
14807      return result;
14808    };
14809
14810    _proto._computeGeodesicArea = function _computeGeodesicArea(measurer) {
14811      var rings = this.getCoordinates();
14812
14813      if (!isArrayHasData(rings)) {
14814        return 0;
14815      }
14816
14817      var result = measurer.measureArea(rings[0]);
14818
14819      for (var i = 1, len = rings.length; i < len; i++) {
14820        result -= measurer.measureArea(rings[i]);
14821      }
14822
14823      return result;
14824    };
14825
14826    _proto._updateCache = function _updateCache() {
14827      _Path.prototype._updateCache.call(this);
14828
14829      if (this._prjHoles) {
14830        this._holes = this._unprojectCoords(this._getPrjHoles());
14831      }
14832    };
14833
14834    _proto._clearCache = function _clearCache() {
14835      delete this._prjShell;
14836      return _Path.prototype._clearCache.call(this);
14837    };
14838
14839    _proto._clearProjection = function _clearProjection() {
14840      if (this._prjHoles) {
14841        this._prjHoles = null;
14842      }
14843
14844      if (this._prjShell) {
14845        this._prjShell = null;
14846      }
14847
14848      _Path.prototype._clearProjection.call(this);
14849    };
14850
14851    return Polygon;
14852  }(Path);
14853
14854  Polygon.registerJSONType(JSON_TYPE);
14855
14856  function CenterMixin (Base) {
14857    return function (_Base) {
14858      _inheritsLoose(_class, _Base);
14859
14860      function _class() {
14861        return _Base.apply(this, arguments) || this;
14862      }
14863
14864      var _proto = _class.prototype;
14865
14866      _proto.getCoordinates = function getCoordinates() {
14867        return this._coordinates;
14868      };
14869
14870      _proto.setCoordinates = function setCoordinates(coordinates) {
14871        var center = coordinates instanceof Coordinate ? coordinates : new Coordinate(coordinates);
14872
14873        if (center.equals(this._coordinates)) {
14874          return this;
14875        }
14876
14877        this._coordinates = center;
14878
14879        if (!this.getMap()) {
14880          this.onPositionChanged();
14881          return this;
14882        }
14883
14884        var projection = this._getProjection();
14885
14886        this._setPrjCoordinates(projection.project(this._coordinates));
14887
14888        return this;
14889      };
14890
14891      _proto._getCenter2DPoint = function _getCenter2DPoint(zoom) {
14892        var map = this.getMap();
14893
14894        if (!map) {
14895          return null;
14896        }
14897
14898        var z = isNil(zoom) ? map.getZoom() : map.getGLZoom();
14899
14900        var pcenter = this._getPrjCoordinates();
14901
14902        if (!pcenter) {
14903          return null;
14904        }
14905
14906        return map._prjToPoint(pcenter, z);
14907      };
14908
14909      _proto._getPrjCoordinates = function _getPrjCoordinates() {
14910        var projection = this._getProjection();
14911
14912        if (!projection) {
14913          return null;
14914        }
14915
14916        this._verifyProjection();
14917
14918        if (!this._pcenter) {
14919          if (this._coordinates) {
14920            this._pcenter = projection.project(this._coordinates);
14921          }
14922        }
14923
14924        return this._pcenter;
14925      };
14926
14927      _proto._setPrjCoordinates = function _setPrjCoordinates(pcenter) {
14928        this._pcenter = pcenter;
14929        this.onPositionChanged();
14930      };
14931
14932      _proto._updateCache = function _updateCache() {
14933        this._clearCache();
14934
14935        var projection = this._getProjection();
14936
14937        if (this._pcenter && projection) {
14938          this._coordinates = projection.unproject(this._pcenter);
14939        }
14940      };
14941
14942      _proto._clearProjection = function _clearProjection() {
14943        this._pcenter = null;
14944
14945        _Base.prototype._clearProjection.call(this);
14946      };
14947
14948      _proto._computeCenter = function _computeCenter() {
14949        return this._coordinates ? this._coordinates.copy() : null;
14950      };
14951
14952      return _class;
14953    }(Base);
14954  }
14955
14956  var options$4 = {
14957    'symbol': {
14958      'markerType': 'path',
14959      'markerPath': [{
14960        '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',
14961        'fill': '#DE3333'
14962      }],
14963      'markerPathWidth': 16,
14964      'markerPathHeight': 23,
14965      'markerWidth': 24,
14966      'markerHeight': 34
14967    },
14968    'hitTestForEvent': false
14969  };
14970
14971  var Marker = function (_CenterMixin) {
14972    _inheritsLoose(Marker, _CenterMixin);
14973
14974    function Marker(coordinates, opts) {
14975      var _this;
14976
14977      _this = _CenterMixin.call(this, opts) || this;
14978      _this.type = 'Point';
14979
14980      if (coordinates) {
14981        _this.setCoordinates(coordinates);
14982      }
14983
14984      return _this;
14985    }
14986
14987    var _proto = Marker.prototype;
14988
14989    _proto.getOutline = function getOutline() {
14990      var painter = this._getPainter();
14991
14992      if (!painter) {
14993        return null;
14994      }
14995
14996      var coord = this.getCoordinates();
14997      var extent = painter.getContainerExtent();
14998      var anchor = this.getMap().coordToContainerPoint(coord);
14999      return new Marker(coord, {
15000        'symbol': {
15001          'markerType': 'square',
15002          'markerWidth': extent.getWidth(),
15003          'markerHeight': extent.getHeight(),
15004          'markerLineWidth': 1,
15005          'markerLineColor': '6b707b',
15006          'markerFill': 'rgba(0, 0, 0, 0)',
15007          'markerDx': extent.xmin - (anchor.x - extent.getWidth() / 2),
15008          'markerDy': extent.ymin - (anchor.y - extent.getHeight() / 2)
15009        }
15010      });
15011    };
15012
15013    _proto._isVectorMarker = function _isVectorMarker() {
15014      var symbol = this._getInternalSymbol();
15015
15016      if (Array.isArray(symbol)) {
15017        return false;
15018      }
15019
15020      return VectorMarkerSymbolizer.test(symbol);
15021    };
15022
15023    _proto._canEdit = function _canEdit() {
15024      var symbol = this._getInternalSymbol();
15025
15026      if (Array.isArray(symbol)) {
15027        return false;
15028      }
15029
15030      return VectorMarkerSymbolizer.test(symbol) || VectorPathMarkerSymbolizer.test(symbol) || ImageMarkerSymbolizer.test(symbol);
15031    };
15032
15033    _proto._containsPoint = function _containsPoint(point, t) {
15034      var extent = this.getContainerExtent();
15035
15036      if (t) {
15037        extent = extent.expand(t);
15038      }
15039
15040      if (extent.contains(point)) {
15041        if (this.options['hitTestForEvent']) {
15042          return _CenterMixin.prototype._containsPoint.call(this, point, t);
15043        } else {
15044          return true;
15045        }
15046      } else {
15047        return false;
15048      }
15049    };
15050
15051    _proto._computeExtent = function _computeExtent() {
15052      return computeExtent.call(this, 'getCenter');
15053    };
15054
15055    _proto._computePrjExtent = function _computePrjExtent() {
15056      return computeExtent.call(this, '_getPrjCoordinates');
15057    };
15058
15059    _proto._computeGeodesicLength = function _computeGeodesicLength() {
15060      return 0;
15061    };
15062
15063    _proto._computeGeodesicArea = function _computeGeodesicArea() {
15064      return 0;
15065    };
15066
15067    _proto._getSprite = function _getSprite(resources, canvasClass) {
15068      if (this._getPainter()) {
15069        return this._getPainter().getSprite(resources, canvasClass);
15070      }
15071
15072      return new Painter(this).getSprite(resources, canvasClass);
15073    };
15074
15075    return Marker;
15076  }(CenterMixin(Geometry));
15077
15078  Marker.mergeOptions(options$4);
15079  Marker.registerJSONType('Marker');
15080
15081  function computeExtent(fn) {
15082    var coordinates = this[fn]();
15083
15084    if (!coordinates) {
15085      return null;
15086    }
15087
15088    return new Extent(coordinates, coordinates, this._getProjection());
15089  }
15090
15091  var options$5 = {
15092    'arrowStyle': null,
15093    'arrowPlacement': 'vertex-last'
15094  };
15095
15096  var LineString = function (_Path) {
15097    _inheritsLoose(LineString, _Path);
15098
15099    function LineString(coordinates, options) {
15100      var _this;
15101
15102      _this = _Path.call(this, options) || this;
15103      _this.type = 'LineString';
15104
15105      if (coordinates) {
15106        _this.setCoordinates(coordinates);
15107      }
15108
15109      return _this;
15110    }
15111
15112    var _proto = LineString.prototype;
15113
15114    _proto.setCoordinates = function setCoordinates(coordinates) {
15115      if (!coordinates) {
15116        this._coordinates = null;
15117
15118        this._setPrjCoordinates(null);
15119
15120        return this;
15121      }
15122
15123      this._coordinates = Coordinate.toCoordinates(coordinates);
15124
15125      if (this.getMap()) {
15126        this._setPrjCoordinates(this._projectCoords(this._coordinates));
15127      } else {
15128        this.onShapeChanged();
15129      }
15130
15131      return this;
15132    };
15133
15134    _proto.getCoordinates = function getCoordinates() {
15135      return this._coordinates || [];
15136    };
15137
15138    _proto.getCenterInExtent = function getCenterInExtent(extent) {
15139      return this._getCenterInExtent(extent, this.getCoordinates(), clipLine);
15140    };
15141
15142    _proto._computeGeodesicLength = function _computeGeodesicLength(measurer) {
15143      return measurer.measureLength(this.getCoordinates());
15144    };
15145
15146    _proto._computeGeodesicArea = function _computeGeodesicArea() {
15147      return 0;
15148    };
15149
15150    return LineString;
15151  }(Path);
15152
15153  LineString.mergeOptions(options$5);
15154  LineString.registerJSONType('LineString');
15155
15156  var GeometryCollection = function (_Geometry) {
15157    _inheritsLoose(GeometryCollection, _Geometry);
15158
15159    function GeometryCollection(geometries, opts) {
15160      var _this;
15161
15162      _this = _Geometry.call(this, opts) || this;
15163      _this.type = 'GeometryCollection';
15164
15165      _this.setGeometries(geometries);
15166
15167      return _this;
15168    }
15169
15170    var _proto = GeometryCollection.prototype;
15171
15172    _proto.setGeometries = function setGeometries(_geometries) {
15173      var geometries = this._checkGeometries(_geometries || []);
15174
15175      var symbol = this._getSymbol();
15176
15177      var options = this.config();
15178
15179      for (var i = geometries.length - 1; i >= 0; i--) {
15180        geometries[i]._initOptions(options);
15181
15182        geometries[i]._setParent(this);
15183
15184        geometries[i]._setEventParent(this);
15185
15186        if (symbol) {
15187          geometries[i].setSymbol(symbol);
15188        }
15189      }
15190
15191      this._geometries = geometries;
15192
15193      if (this.getLayer()) {
15194        this._bindGeometriesToLayer();
15195
15196        this.onShapeChanged();
15197      }
15198
15199      return this;
15200    };
15201
15202    _proto.getGeometries = function getGeometries() {
15203      return this._geometries || [];
15204    };
15205
15206    _proto.forEach = function forEach(fn, context) {
15207      var geometries = this.getGeometries();
15208
15209      for (var i = 0, l = geometries.length; i < l; i++) {
15210        if (!geometries[i]) {
15211          continue;
15212        }
15213
15214        if (!context) {
15215          fn(geometries[i], i);
15216        } else {
15217          fn.call(context, geometries[i], i);
15218        }
15219      }
15220
15221      return this;
15222    };
15223
15224    _proto.filter = function filter(fn, context) {
15225      if (!fn) {
15226        return new GeometryCollection();
15227      }
15228
15229      var selected = [];
15230      var isFn = isFunction(fn);
15231      var filter = isFn ? fn : createFilter(fn);
15232      this.forEach(function (geometry) {
15233        var g = isFn ? geometry : getFilterFeature(geometry);
15234
15235        if (context ? filter.call(context, g) : filter(g)) {
15236          selected.push(geometry);
15237        }
15238      }, this);
15239      return new GeometryCollection(selected);
15240    };
15241
15242    _proto.translate = function translate(offset) {
15243      if (!offset) {
15244        return this;
15245      }
15246
15247      if (this.isEmpty()) {
15248        return this;
15249      }
15250
15251      var args = arguments;
15252      this.forEach(function (geometry) {
15253        if (geometry && geometry.translate) {
15254          geometry.translate.apply(geometry, args);
15255        }
15256      });
15257      return this;
15258    };
15259
15260    _proto.isEmpty = function isEmpty() {
15261      return !isArrayHasData(this.getGeometries());
15262    };
15263
15264    _proto.remove = function remove() {
15265      this.forEach(function (geometry) {
15266        geometry._unbind();
15267      });
15268      return Geometry.prototype.remove.apply(this, arguments);
15269    };
15270
15271    _proto.show = function show() {
15272      this.options['visible'] = true;
15273      this.forEach(function (geometry) {
15274        geometry.show();
15275      });
15276      return this;
15277    };
15278
15279    _proto.hide = function hide() {
15280      this.options['visible'] = false;
15281      this.forEach(function (geometry) {
15282        geometry.hide();
15283      });
15284      return this;
15285    };
15286
15287    _proto.onConfig = function onConfig(config) {
15288      this.forEach(function (geometry) {
15289        geometry.config(config);
15290      });
15291    };
15292
15293    _proto.getSymbol = function getSymbol() {
15294      var s = _Geometry.prototype.getSymbol.call(this);
15295
15296      if (!s) {
15297        var symbols = [];
15298        var is = false;
15299        this.forEach(function (g) {
15300          var symbol = g.getSymbol();
15301
15302          if (symbol && !is) {
15303            is = true;
15304          }
15305
15306          symbols.push(g.getSymbol());
15307        });
15308
15309        if (is) {
15310          s = {
15311            'children': symbols
15312          };
15313        }
15314      }
15315
15316      return s;
15317    };
15318
15319    _proto.setSymbol = function setSymbol(s) {
15320      if (s && s['children']) {
15321        this._symbol = null;
15322        this.forEach(function (g, i) {
15323          g.setSymbol(s['children'][i]);
15324        });
15325      } else {
15326        var symbol = this._prepareSymbol(s);
15327
15328        this._symbol = symbol;
15329        this.forEach(function (g) {
15330          g.setSymbol(symbol);
15331        });
15332      }
15333
15334      this.onSymbolChanged();
15335      return this;
15336    };
15337
15338    _proto._setExternSymbol = function _setExternSymbol(symbol) {
15339      symbol = this._prepareSymbol(symbol);
15340      this._externSymbol = symbol;
15341      this.forEach(function (geometry) {
15342        geometry._setExternSymbol(symbol);
15343      });
15344      this.onSymbolChanged();
15345      return this;
15346    };
15347
15348    _proto._bindLayer = function _bindLayer() {
15349      _Geometry.prototype._bindLayer.apply(this, arguments);
15350
15351      this._bindGeometriesToLayer();
15352    };
15353
15354    _proto._bindGeometriesToLayer = function _bindGeometriesToLayer() {
15355      var layer = this.getLayer();
15356      this.forEach(function (geometry) {
15357        geometry._bindLayer(layer);
15358      });
15359    };
15360
15361    _proto._checkGeometries = function _checkGeometries(geometries) {
15362      var invalidGeoError = 'The geometry added to collection is invalid.';
15363
15364      if (geometries && !Array.isArray(geometries)) {
15365        if (geometries instanceof Geometry) {
15366          return [geometries];
15367        } else {
15368          throw new Error(invalidGeoError);
15369        }
15370      } else {
15371        for (var i = 0, l = geometries.length; i < l; i++) {
15372          if (!this._checkGeo(geometries[i])) {
15373            throw new Error(invalidGeoError + ' Index: ' + i);
15374          }
15375        }
15376
15377        return geometries;
15378      }
15379    };
15380
15381    _proto._checkGeo = function _checkGeo(geo) {
15382      return geo instanceof Geometry;
15383    };
15384
15385    _proto._updateCache = function _updateCache() {
15386      this._clearCache();
15387
15388      if (this.isEmpty()) {
15389        return;
15390      }
15391
15392      this.forEach(function (geometry) {
15393        if (geometry && geometry._updateCache) {
15394          geometry._updateCache();
15395        }
15396      });
15397    };
15398
15399    _proto._removePainter = function _removePainter() {
15400      if (this._painter) {
15401        this._painter.remove();
15402      }
15403
15404      delete this._painter;
15405      this.forEach(function (geometry) {
15406        geometry._removePainter();
15407      });
15408    };
15409
15410    _proto._computeCenter = function _computeCenter(projection) {
15411      if (!projection || this.isEmpty()) {
15412        return null;
15413      }
15414
15415      var sumX = 0,
15416          sumY = 0,
15417          counter = 0;
15418      var geometries = this.getGeometries();
15419
15420      for (var i = 0, l = geometries.length; i < l; i++) {
15421        if (!geometries[i]) {
15422          continue;
15423        }
15424
15425        var center = geometries[i]._computeCenter(projection);
15426
15427        if (center) {
15428          sumX += center.x;
15429          sumY += center.y;
15430          counter++;
15431        }
15432      }
15433
15434      if (counter === 0) {
15435        return null;
15436      }
15437
15438      return new Coordinate(sumX / counter, sumY / counter);
15439    };
15440
15441    _proto._containsPoint = function _containsPoint(point, t) {
15442      if (this.isEmpty()) {
15443        return false;
15444      }
15445
15446      var geometries = this.getGeometries();
15447
15448      for (var i = 0, l = geometries.length; i < l; i++) {
15449        if (geometries[i]._containsPoint(point, t)) {
15450          return true;
15451        }
15452      }
15453
15454      return false;
15455    };
15456
15457    _proto._computeExtent = function _computeExtent(projection) {
15458      return computeExtent$1.call(this, projection, '_computeExtent');
15459    };
15460
15461    _proto._computePrjExtent = function _computePrjExtent(projection) {
15462      return computeExtent$1.call(this, projection, '_computePrjExtent');
15463    };
15464
15465    _proto._computeGeodesicLength = function _computeGeodesicLength(projection) {
15466      if (!projection || this.isEmpty()) {
15467        return 0;
15468      }
15469
15470      var geometries = this.getGeometries();
15471      var result = 0;
15472
15473      for (var i = 0, l = geometries.length; i < l; i++) {
15474        if (!geometries[i]) {
15475          continue;
15476        }
15477
15478        result += geometries[i]._computeGeodesicLength(projection);
15479      }
15480
15481      return result;
15482    };
15483
15484    _proto._computeGeodesicArea = function _computeGeodesicArea(projection) {
15485      if (!projection || this.isEmpty()) {
15486        return 0;
15487      }
15488
15489      var geometries = this.getGeometries();
15490      var result = 0;
15491
15492      for (var i = 0, l = geometries.length; i < l; i++) {
15493        if (!geometries[i]) {
15494          continue;
15495        }
15496
15497        result += geometries[i]._computeGeodesicArea(projection);
15498      }
15499
15500      return result;
15501    };
15502
15503    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
15504      var children = [];
15505
15506      if (!this.isEmpty()) {
15507        var geometries = this.getGeometries();
15508
15509        for (var i = 0, l = geometries.length; i < l; i++) {
15510          if (!geometries[i]) {
15511            continue;
15512          }
15513
15514          children.push(geometries[i]._exportGeoJSONGeometry());
15515        }
15516      }
15517
15518      return {
15519        'type': 'GeometryCollection',
15520        'geometries': children
15521      };
15522    };
15523
15524    _proto._clearProjection = function _clearProjection() {
15525      if (this.isEmpty()) {
15526        return;
15527      }
15528
15529      var geometries = this.getGeometries();
15530
15531      for (var i = 0, l = geometries.length; i < l; i++) {
15532        if (!geometries[i]) {
15533          continue;
15534        }
15535
15536        geometries[i]._clearProjection();
15537      }
15538    };
15539
15540    _proto._getConnectPoints = function _getConnectPoints() {
15541      var extent = this.getExtent();
15542      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)];
15543      return anchors;
15544    };
15545
15546    _proto._getExternalResources = function _getExternalResources() {
15547      if (this.isEmpty()) {
15548        return [];
15549      }
15550
15551      var geometries = this.getGeometries(),
15552          resources = [];
15553      var cache = {};
15554      var symbol, res, key;
15555
15556      for (var i = 0, l = geometries.length; i < l; i++) {
15557        if (!geometries[i]) {
15558          continue;
15559        }
15560
15561        symbol = geometries[i]._getInternalSymbol();
15562        res = getExternalResources(symbol);
15563
15564        for (var ii = 0, ll = res.length; ii < ll; ii++) {
15565          key = res[ii].join();
15566
15567          if (!cache[key]) {
15568            resources.push(res[ii]);
15569            cache[key] = 1;
15570          }
15571        }
15572      }
15573
15574      return resources;
15575    };
15576
15577    _proto.startEdit = function startEdit(opts) {
15578      var _this2 = this;
15579
15580      if (this.isEmpty()) {
15581        return this;
15582      }
15583
15584      if (!opts) {
15585        opts = {};
15586      }
15587
15588      if (opts['symbol']) {
15589        this._originalSymbol = this.getSymbol();
15590        this.setSymbol(opts['symbol']);
15591      }
15592
15593      this._draggbleBeforeEdit = this.options['draggable'];
15594      this.config('draggable', false);
15595      var geometries = this.getGeometries();
15596
15597      for (var i = 0, l = geometries.length; i < l; i++) {
15598        geometries[i].startEdit(opts);
15599      }
15600
15601      this._editing = true;
15602      this.hide();
15603      setTimeout(function () {
15604        _this2.fire('editstart');
15605      }, 1);
15606      return this;
15607    };
15608
15609    _proto.endEdit = function endEdit() {
15610      if (this.isEmpty()) {
15611        return this;
15612      }
15613
15614      var geometries = this.getGeometries();
15615
15616      for (var i = 0, l = geometries.length; i < l; i++) {
15617        geometries[i].endEdit();
15618      }
15619
15620      if (this._originalSymbol) {
15621        this.setSymbol(this._originalSymbol);
15622        delete this._originalSymbol;
15623      }
15624
15625      this._editing = false;
15626      this.show();
15627      this.config('draggable', this._draggbleBeforeEdit);
15628      this.fire('editend');
15629      return this;
15630    };
15631
15632    _proto.isEditing = function isEditing() {
15633      if (!this._editing) {
15634        return false;
15635      }
15636
15637      return true;
15638    };
15639
15640    return GeometryCollection;
15641  }(Geometry);
15642
15643  GeometryCollection.registerJSONType('GeometryCollection');
15644
15645  function computeExtent$1(projection, fn) {
15646    if (this.isEmpty()) {
15647      return null;
15648    }
15649
15650    var geometries = this.getGeometries();
15651    var result = null;
15652
15653    for (var i = 0, l = geometries.length; i < l; i++) {
15654      var geo = geometries[i];
15655
15656      if (!geo) {
15657        continue;
15658      }
15659
15660      var geoExtent = geo[fn](projection);
15661
15662      if (geoExtent) {
15663        result = geoExtent.combine(result);
15664      }
15665    }
15666
15667    return result;
15668  }
15669
15670  var MultiGeometry = function (_GeometryCollection) {
15671    _inheritsLoose(MultiGeometry, _GeometryCollection);
15672
15673    function MultiGeometry(geoType, type, data, options) {
15674      var _this;
15675
15676      _this = _GeometryCollection.call(this, null, options) || this;
15677      _this.GeometryType = geoType;
15678      _this.type = type;
15679
15680      _this._initData(data);
15681
15682      return _this;
15683    }
15684
15685    var _proto = MultiGeometry.prototype;
15686
15687    _proto.getCoordinates = function getCoordinates() {
15688      var coordinates = [];
15689      var geometries = this.getGeometries();
15690
15691      for (var i = 0, l = geometries.length; i < l; i++) {
15692        var child = geometries[i];
15693        coordinates.push(child.getShell && child.getJSONType() !== 'Polygon' ? [child.getShell()] : child.getCoordinates());
15694      }
15695
15696      return coordinates;
15697    };
15698
15699    _proto.setCoordinates = function setCoordinates(coordinates) {
15700      coordinates = coordinates || [];
15701      var geometries = [];
15702
15703      for (var i = 0, l = coordinates.length; i < l; i++) {
15704        var g = new this.GeometryType(coordinates[i], this.config());
15705        geometries.push(g);
15706      }
15707
15708      this.setGeometries(geometries);
15709      return this;
15710    };
15711
15712    _proto._initData = function _initData(data) {
15713      data = data || [];
15714
15715      if (data.length) {
15716        if (data[0] instanceof this.GeometryType) {
15717          this.setGeometries(data);
15718        } else {
15719          this.setCoordinates(data);
15720        }
15721      }
15722    };
15723
15724    _proto._checkGeo = function _checkGeo(geo) {
15725      return geo instanceof this.GeometryType;
15726    };
15727
15728    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
15729      var points = this.getCoordinates();
15730      var coordinates = Coordinate.toNumberArrays(points);
15731      return {
15732        'type': this.getType(),
15733        'coordinates': coordinates
15734      };
15735    };
15736
15737    return MultiGeometry;
15738  }(GeometryCollection);
15739
15740  var MultiPoint = function (_MultiGeometry) {
15741    _inheritsLoose(MultiPoint, _MultiGeometry);
15742
15743    function MultiPoint(data, opts) {
15744      return _MultiGeometry.call(this, Marker, 'MultiPoint', data, opts) || this;
15745    }
15746
15747    var _proto = MultiPoint.prototype;
15748
15749    _proto.findClosest = function findClosest(coordinate) {
15750      if (!coordinate) {
15751        return null;
15752      }
15753
15754      var coords = this.getCoordinates();
15755      var hit = null;
15756      var max = Infinity;
15757      coords.forEach(function (c) {
15758        var dist = distanceTo(c, coordinate);
15759
15760        if (dist < max) {
15761          hit = c;
15762          max = dist;
15763        }
15764      });
15765      return hit;
15766    };
15767
15768    return MultiPoint;
15769  }(MultiGeometry);
15770
15771  MultiPoint.registerJSONType('MultiPoint');
15772
15773  function distanceTo(p0, p1) {
15774    var x = p1.x - p0.x,
15775        y = p1.y - p0.y;
15776    return Math.sqrt(x * x + y * y);
15777  }
15778
15779  var MultiPath = function (_MultiGeometry) {
15780    _inheritsLoose(MultiPath, _MultiGeometry);
15781
15782    function MultiPath() {
15783      return _MultiGeometry.apply(this, arguments) || this;
15784    }
15785
15786    var _proto = MultiPath.prototype;
15787
15788    _proto.getCenterInExtent = function getCenterInExtent(extent) {
15789      var children = this.getGeometries();
15790      var sumx = 0,
15791          sumy = 0,
15792          counter = 0;
15793      children.forEach(function (l) {
15794        var c = l.getCenterInExtent(extent);
15795
15796        if (c) {
15797          sumx += c.x * c.count;
15798          sumy += c.y * c.count;
15799          counter += c.count;
15800        }
15801      });
15802
15803      if (counter === 0) {
15804        return null;
15805      }
15806
15807      return new Coordinate(sumx, sumy)._multi(1 / counter);
15808    };
15809
15810    return MultiPath;
15811  }(MultiGeometry);
15812
15813  var MultiLineString = function (_MultiPath) {
15814    _inheritsLoose(MultiLineString, _MultiPath);
15815
15816    function MultiLineString(data, options) {
15817      return _MultiPath.call(this, LineString, 'MultiLineString', data, options) || this;
15818    }
15819
15820    return MultiLineString;
15821  }(MultiPath);
15822
15823  MultiLineString.registerJSONType('MultiLineString');
15824
15825  var MultiPolygon = function (_MultiPath) {
15826    _inheritsLoose(MultiPolygon, _MultiPath);
15827
15828    function MultiPolygon(data, opts) {
15829      return _MultiPath.call(this, Polygon, 'MultiPolygon', data, opts) || this;
15830    }
15831
15832    return MultiPolygon;
15833  }(MultiPath);
15834
15835  MultiPolygon.registerJSONType('MultiPolygon');
15836
15837  var types$1 = {
15838    'Marker': Marker,
15839    'LineString': LineString,
15840    'Polygon': Polygon,
15841    'MultiPoint': MultiPoint,
15842    'MultiLineString': MultiLineString,
15843    'MultiPolygon': MultiPolygon
15844  };
15845  var GeoJSON = {
15846    toGeometry: function toGeometry(geoJSON, foreachFn) {
15847      if (isString(geoJSON)) {
15848        geoJSON = parseJSON(geoJSON);
15849      }
15850
15851      if (Array.isArray(geoJSON)) {
15852        var resultGeos = [];
15853
15854        for (var i = 0, len = geoJSON.length; i < len; i++) {
15855          var geo = GeoJSON._convert(geoJSON[i], foreachFn);
15856
15857          if (Array.isArray(geo)) {
15858            pushIn(resultGeos, geo);
15859          } else {
15860            resultGeos.push(geo);
15861          }
15862        }
15863
15864        return resultGeos;
15865      } else {
15866        var resultGeo = GeoJSON._convert(geoJSON, foreachFn);
15867
15868        return resultGeo;
15869      }
15870    },
15871    _convert: function _convert(json, foreachFn) {
15872      if (!json || isNil(json['type'])) {
15873        return null;
15874      }
15875
15876      var type = json['type'];
15877
15878      if (type === 'Feature') {
15879        var g = json['geometry'];
15880
15881        var geometry = GeoJSON._convert(g, foreachFn);
15882
15883        if (!geometry) {
15884          return null;
15885        }
15886
15887        geometry.setId(json['id']);
15888        geometry.setProperties(json['properties']);
15889        return geometry;
15890      } else if (type === 'FeatureCollection') {
15891        var features = json['features'];
15892
15893        if (!features) {
15894          return null;
15895        }
15896
15897        return GeoJSON.toGeometry(features, foreachFn);
15898      } else if (['Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon'].indexOf(type) >= 0) {
15899        var clazz = type === 'Point' ? 'Marker' : type;
15900        var result = new types$1[clazz](json['coordinates']);
15901
15902        if (foreachFn) {
15903          foreachFn(result);
15904        }
15905
15906        return result;
15907      } else if (type === 'GeometryCollection') {
15908        var geometries = json['geometries'];
15909
15910        if (!isArrayHasData(geometries)) {
15911          var _result2 = new GeometryCollection();
15912
15913          if (foreachFn) {
15914            foreachFn(_result2);
15915          }
15916
15917          return _result2;
15918        }
15919
15920        var mGeos = [];
15921        var size = geometries.length;
15922
15923        for (var i = 0; i < size; i++) {
15924          mGeos.push(GeoJSON._convert(geometries[i]));
15925        }
15926
15927        var _result = new GeometryCollection(mGeos);
15928
15929        if (foreachFn) {
15930          foreachFn(_result);
15931        }
15932
15933        return _result;
15934      }
15935
15936      return null;
15937    }
15938  };
15939
15940  var options$6 = {
15941    'numberOfShellPoints': 60
15942  };
15943
15944  var Circle = function (_CenterMixin) {
15945    _inheritsLoose(Circle, _CenterMixin);
15946
15947    Circle.fromJSON = function fromJSON(json) {
15948      var feature = json['feature'];
15949      var circle = new Circle(json['coordinates'], json['radius'], json['options']);
15950      circle.setProperties(feature['properties']);
15951      return circle;
15952    };
15953
15954    function Circle(coordinates, radius, opts) {
15955      var _this;
15956
15957      _this = _CenterMixin.call(this, null, opts) || this;
15958
15959      if (coordinates) {
15960        _this.setCoordinates(coordinates);
15961      }
15962
15963      _this._radius = radius;
15964      return _this;
15965    }
15966
15967    var _proto = Circle.prototype;
15968
15969    _proto.getRadius = function getRadius() {
15970      return this._radius;
15971    };
15972
15973    _proto.setRadius = function setRadius(radius) {
15974      this._radius = radius;
15975      this.onShapeChanged();
15976      return this;
15977    };
15978
15979    _proto.getShell = function getShell() {
15980      var measurer = this._getMeasurer(),
15981          center = this.getCoordinates(),
15982          numberOfPoints = this.options['numberOfShellPoints'],
15983          radius = this.getRadius();
15984
15985      var shell = [];
15986      var rad, dx, dy;
15987
15988      for (var i = 0, len = numberOfPoints - 1; i < len; i++) {
15989        rad = 360 * i / len * Math.PI / 180;
15990        dx = radius * Math.cos(rad);
15991        dy = radius * Math.sin(rad);
15992        var vertex = measurer.locate(center, dx, dy);
15993        shell.push(vertex);
15994      }
15995
15996      shell.push(shell[0]);
15997      return shell;
15998    };
15999
16000    _proto.getHoles = function getHoles() {
16001      return [];
16002    };
16003
16004    _proto.animateShow = function animateShow() {
16005      return this.show();
16006    };
16007
16008    _proto._containsPoint = function _containsPoint(point, tolerance) {
16009      var map = this.getMap();
16010
16011      if (map.getPitch()) {
16012        return _CenterMixin.prototype._containsPoint.call(this, point, tolerance);
16013      }
16014
16015      var center = map._pointToContainerPoint(this._getCenter2DPoint()),
16016          size = this.getSize(),
16017          t = isNil(tolerance) ? this._hitTestTolerance() : tolerance,
16018          se = center.add(size.width / 2, size.height / 2);
16019
16020      return withInEllipse(point, center, se, t);
16021    };
16022
16023    _proto._computePrjExtent = function _computePrjExtent(projection) {
16024      var minmax = this._getMinMax(projection);
16025
16026      if (!minmax) {
16027        return null;
16028      }
16029
16030      var pcenter = this._getPrjCoordinates();
16031
16032      var pminmax = minmax.map(function (c) {
16033        return projection.project(c);
16034      });
16035      var dx = Math.min(Math.abs(pminmax[0].x - pcenter.x), Math.abs(pminmax[1].x - pcenter.x)),
16036          dy = Math.min(Math.abs(pminmax[2].y - pcenter.y), Math.abs(pminmax[3].y - pcenter.y));
16037      return new Extent(pcenter.sub(dx, dy), pcenter.add(dx, dy));
16038    };
16039
16040    _proto._computeExtent = function _computeExtent(measurer) {
16041      var minmax = this._getMinMax(measurer);
16042
16043      if (!minmax) {
16044        return null;
16045      }
16046
16047      return new Extent(minmax[0].x, minmax[2].y, minmax[1].x, minmax[3].y, this._getProjection());
16048    };
16049
16050    _proto._getMinMax = function _getMinMax(measurer) {
16051      if (!measurer || !this._coordinates || isNil(this._radius)) {
16052        return null;
16053      }
16054
16055      var radius = this._radius;
16056      var p1 = measurer.locate(this._coordinates, -radius, 0),
16057          p2 = measurer.locate(this._coordinates, radius, 0),
16058          p3 = measurer.locate(this._coordinates, 0, radius),
16059          p4 = measurer.locate(this._coordinates, 0, -radius);
16060      return [p1, p2, p3, p4];
16061    };
16062
16063    _proto._computeGeodesicLength = function _computeGeodesicLength() {
16064      if (isNil(this._radius)) {
16065        return 0;
16066      }
16067
16068      return Math.PI * 2 * this._radius;
16069    };
16070
16071    _proto._computeGeodesicArea = function _computeGeodesicArea() {
16072      if (isNil(this._radius)) {
16073        return 0;
16074      }
16075
16076      return Math.PI * Math.pow(this._radius, 2);
16077    };
16078
16079    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
16080      var coordinates = Coordinate.toNumberArrays([this.getShell()]);
16081      return {
16082        'type': 'Polygon',
16083        'coordinates': coordinates
16084      };
16085    };
16086
16087    _proto._toJSON = function _toJSON(options) {
16088      var center = this.getCenter();
16089      var opts = extend({}, options);
16090      opts.geometry = false;
16091      var feature = this.toGeoJSON(opts);
16092      feature['geometry'] = {
16093        'type': 'Polygon'
16094      };
16095      return {
16096        'feature': feature,
16097        'subType': 'Circle',
16098        'coordinates': [center.x, center.y],
16099        'radius': this.getRadius()
16100      };
16101    };
16102
16103    return Circle;
16104  }(CenterMixin(Polygon));
16105
16106  Circle.mergeOptions(options$6);
16107  Circle.registerJSONType('Circle');
16108
16109  var options$7 = {
16110    'numberOfShellPoints': 80
16111  };
16112
16113  var Ellipse = function (_CenterMixin) {
16114    _inheritsLoose(Ellipse, _CenterMixin);
16115
16116    Ellipse.fromJSON = function fromJSON(json) {
16117      var feature = json['feature'];
16118      var ellipse = new Ellipse(json['coordinates'], json['width'], json['height'], json['options']);
16119      ellipse.setProperties(feature['properties']);
16120      return ellipse;
16121    };
16122
16123    function Ellipse(coordinates, width, height, opts) {
16124      var _this;
16125
16126      _this = _CenterMixin.call(this, null, opts) || this;
16127
16128      if (coordinates) {
16129        _this.setCoordinates(coordinates);
16130      }
16131
16132      _this.width = width;
16133      _this.height = height;
16134      return _this;
16135    }
16136
16137    var _proto = Ellipse.prototype;
16138
16139    _proto.getWidth = function getWidth() {
16140      return this.width;
16141    };
16142
16143    _proto.setWidth = function setWidth(width) {
16144      this.width = width;
16145      this.onShapeChanged();
16146      return this;
16147    };
16148
16149    _proto.getHeight = function getHeight() {
16150      return this.height;
16151    };
16152
16153    _proto.setHeight = function setHeight(height) {
16154      this.height = height;
16155      this.onShapeChanged();
16156      return this;
16157    };
16158
16159    _proto.getShell = function getShell() {
16160      var measurer = this._getMeasurer(),
16161          center = this.getCoordinates(),
16162          numberOfPoints = this.options['numberOfShellPoints'],
16163          width = this.getWidth(),
16164          height = this.getHeight();
16165
16166      var shell = [];
16167      var s = Math.pow(width / 2, 2) * Math.pow(height / 2, 2),
16168          sx = Math.pow(width / 2, 2),
16169          sy = Math.pow(height / 2, 2);
16170      var deg, rad, dx, dy;
16171
16172      for (var i = 0; i < numberOfPoints; i++) {
16173        deg = 360 * i / numberOfPoints;
16174        rad = deg * Math.PI / 180;
16175        dx = Math.sqrt(s / (sx * Math.pow(Math.tan(rad), 2) + sy));
16176        dy = Math.sqrt(s / (sy * Math.pow(1 / Math.tan(rad), 2) + sx));
16177
16178        if (deg > 90 && deg < 270) {
16179          dx *= -1;
16180        }
16181
16182        if (deg > 180 && deg < 360) {
16183          dy *= -1;
16184        }
16185
16186        var vertex = measurer.locate(center, dx, dy);
16187        shell.push(vertex);
16188      }
16189
16190      return shell;
16191    };
16192
16193    _proto.getHoles = function getHoles() {
16194      return [];
16195    };
16196
16197    _proto.animateShow = function animateShow() {
16198      return this.show();
16199    };
16200
16201    _proto._containsPoint = function _containsPoint(point, tolerance) {
16202      var map = this.getMap();
16203
16204      if (map.isTransforming()) {
16205        return _CenterMixin.prototype._containsPoint.call(this, point, tolerance);
16206      }
16207
16208      var projection = map.getProjection();
16209
16210      var t = isNil(tolerance) ? this._hitTestTolerance() : tolerance,
16211          pps = projection.projectCoords([this._coordinates, map.locate(this._coordinates, this.getWidth() / 2, this.getHeight() / 2)]),
16212          p0 = map._prjToContainerPoint(pps[0]),
16213          p1 = map._prjToContainerPoint(pps[1]);
16214
16215      return withInEllipse(point, p0, p1, t);
16216    };
16217
16218    _proto._computePrjExtent = function _computePrjExtent() {
16219      return Circle.prototype._computePrjExtent.apply(this, arguments);
16220    };
16221
16222    _proto._computeExtent = function _computeExtent() {
16223      return Circle.prototype._computeExtent.apply(this, arguments);
16224    };
16225
16226    _proto._getMinMax = function _getMinMax(measurer) {
16227      if (!measurer || !this._coordinates || isNil(this.width) || isNil(this.height)) {
16228        return null;
16229      }
16230
16231      var width = this.getWidth(),
16232          height = this.getHeight();
16233      var p1 = measurer.locate(this._coordinates, -width / 2, 0),
16234          p2 = measurer.locate(this._coordinates, width / 2, 0),
16235          p3 = measurer.locate(this._coordinates, 0, -height / 2),
16236          p4 = measurer.locate(this._coordinates, 0, height / 2);
16237      return [p1, p2, p3, p4];
16238    };
16239
16240    _proto._computeGeodesicLength = function _computeGeodesicLength() {
16241      if (isNil(this.width) || isNil(this.height)) {
16242        return 0;
16243      }
16244
16245      var longer = this.width > this.height ? this.width : this.height;
16246      return 2 * Math.PI * longer / 2 - 4 * Math.abs(this.width - this.height);
16247    };
16248
16249    _proto._computeGeodesicArea = function _computeGeodesicArea() {
16250      if (isNil(this.width) || isNil(this.height)) {
16251        return 0;
16252      }
16253
16254      return Math.PI * this.width * this.height / 4;
16255    };
16256
16257    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
16258      var coordinates = Coordinate.toNumberArrays([this.getShell()]);
16259      return {
16260        'type': 'Polygon',
16261        'coordinates': coordinates
16262      };
16263    };
16264
16265    _proto._toJSON = function _toJSON(options) {
16266      var opts = extend({}, options);
16267      var center = this.getCenter();
16268      opts.geometry = false;
16269      var feature = this.toGeoJSON(opts);
16270      feature['geometry'] = {
16271        'type': 'Polygon'
16272      };
16273      return {
16274        'feature': feature,
16275        'subType': 'Ellipse',
16276        'coordinates': [center.x, center.y],
16277        'width': this.getWidth(),
16278        'height': this.getHeight()
16279      };
16280    };
16281
16282    return Ellipse;
16283  }(CenterMixin(Polygon));
16284
16285  Ellipse.mergeOptions(options$7);
16286  Ellipse.registerJSONType('Ellipse');
16287
16288  var Rectangle = function (_Polygon) {
16289    _inheritsLoose(Rectangle, _Polygon);
16290
16291    Rectangle.fromJSON = function fromJSON(json) {
16292      var feature = json['feature'];
16293      var rect = new Rectangle(json['coordinates'], json['width'], json['height'], json['options']);
16294      rect.setProperties(feature['properties']);
16295      return rect;
16296    };
16297
16298    function Rectangle(coordinates, width, height, opts) {
16299      var _this;
16300
16301      _this = _Polygon.call(this, null, opts) || this;
16302
16303      if (coordinates) {
16304        _this.setCoordinates(coordinates);
16305      }
16306
16307      _this._width = width;
16308      _this._height = height;
16309      return _this;
16310    }
16311
16312    var _proto = Rectangle.prototype;
16313
16314    _proto.getCoordinates = function getCoordinates() {
16315      return this._coordinates;
16316    };
16317
16318    _proto.setCoordinates = function setCoordinates(nw) {
16319      this._coordinates = nw instanceof Coordinate ? nw : new Coordinate(nw);
16320
16321      if (!this._coordinates || !this.getMap()) {
16322        this.onPositionChanged();
16323        return this;
16324      }
16325
16326      var projection = this._getProjection();
16327
16328      this._setPrjCoordinates(projection.project(this._coordinates));
16329
16330      return this;
16331    };
16332
16333    _proto.getWidth = function getWidth() {
16334      return this._width;
16335    };
16336
16337    _proto.setWidth = function setWidth(width) {
16338      this._width = width;
16339      this.onShapeChanged();
16340      return this;
16341    };
16342
16343    _proto.getHeight = function getHeight() {
16344      return this._height;
16345    };
16346
16347    _proto.setHeight = function setHeight(height) {
16348      this._height = height;
16349      this.onShapeChanged();
16350      return this;
16351    };
16352
16353    _proto.getShell = function getShell() {
16354      var measurer = this._getMeasurer();
16355
16356      var nw = this._coordinates;
16357      var map = this.getMap();
16358      var sx = 1,
16359          sy = -1;
16360
16361      if (map) {
16362        var fExt = map.getFullExtent();
16363
16364        if (fExt['left'] > fExt['right']) {
16365          sx = -1;
16366        }
16367
16368        if (fExt['bottom'] > fExt['top']) {
16369          sy = 1;
16370        }
16371      }
16372
16373      var points = [];
16374      points.push(nw);
16375      points.push(measurer.locate(nw, sx * this._width, 0));
16376      points.push(measurer.locate(nw, sx * this._width, sy * this._height));
16377      points.push(measurer.locate(nw, 0, sy * this._height));
16378      points.push(nw);
16379      return points;
16380    };
16381
16382    _proto.getHoles = function getHoles() {
16383      return [];
16384    };
16385
16386    _proto.animateShow = function animateShow() {
16387      return this.show();
16388    };
16389
16390    _proto._getPrjCoordinates = function _getPrjCoordinates() {
16391      var projection = this._getProjection();
16392
16393      if (!projection) {
16394        return null;
16395      }
16396
16397      this._verifyProjection();
16398
16399      if (!this._pnw) {
16400        if (this._coordinates) {
16401          this._pnw = projection.project(this._coordinates);
16402        }
16403      }
16404
16405      return this._pnw;
16406    };
16407
16408    _proto._setPrjCoordinates = function _setPrjCoordinates(pnw) {
16409      this._pnw = pnw;
16410      this.onPositionChanged();
16411    };
16412
16413    _proto._getPrjShell = function _getPrjShell() {
16414      var shell = _Polygon.prototype._getPrjShell.call(this);
16415
16416      var projection = this._getProjection();
16417
16418      if (!projection.isSphere()) {
16419        return shell;
16420      }
16421
16422      var sphereExtent = projection.getSphereExtent(),
16423          sx = sphereExtent.sx,
16424          sy = sphereExtent.sy;
16425
16426      var circum = this._getProjection().getCircum();
16427
16428      var nw = shell[0];
16429
16430      for (var i = 1, l = shell.length; i < l; i++) {
16431        var p = shell[i];
16432        var dx = 0,
16433            dy = 0;
16434
16435        if (sx * (nw.x - p.x) > 0) {
16436          dx = circum.x * sx;
16437        }
16438
16439        if (sy * (nw.y - p.y) < 0) {
16440          dy = circum.y * sy;
16441        }
16442
16443        shell[i]._add(dx, dy);
16444      }
16445
16446      return shell;
16447    };
16448
16449    _proto._updateCache = function _updateCache() {
16450      this._clearCache();
16451
16452      var projection = this._getProjection();
16453
16454      if (this._pnw && projection) {
16455        this._coordinates = projection.unproject(this._pnw);
16456      }
16457    };
16458
16459    _proto._clearProjection = function _clearProjection() {
16460      this._pnw = null;
16461
16462      _Polygon.prototype._clearProjection.call(this);
16463    };
16464
16465    _proto._computeCenter = function _computeCenter(measurer) {
16466      return measurer.locate(this._coordinates, this._width / 2, -this._height / 2);
16467    };
16468
16469    _proto._containsPoint = function _containsPoint(point, tolerance) {
16470      var map = this.getMap();
16471
16472      if (map.isTransforming()) {
16473        return _Polygon.prototype._containsPoint.call(this, point, tolerance);
16474      }
16475
16476      var t = isNil(tolerance) ? this._hitTestTolerance() : tolerance,
16477          r = map._getResolution() * t;
16478
16479      var extent = this._getPrjExtent().expand(r);
16480
16481      var p = map._containerPointToPrj(point);
16482
16483      return extent.contains(p);
16484    };
16485
16486    _proto._computePrjExtent = function _computePrjExtent(projection) {
16487      var se = this._getSouthEast(projection);
16488
16489      if (!se) {
16490        return null;
16491      }
16492
16493      var prjs = projection.projectCoords([new Coordinate(this._coordinates.x, se.y), new Coordinate(se.x, this._coordinates.y)]);
16494      return new Extent(prjs[0], prjs[1]);
16495    };
16496
16497    _proto._computeExtent = function _computeExtent(measurer) {
16498      var se = this._getSouthEast(measurer);
16499
16500      if (!se) {
16501        return null;
16502      }
16503
16504      return new Extent(this._coordinates, se, this._getProjection());
16505    };
16506
16507    _proto._getSouthEast = function _getSouthEast(measurer) {
16508      if (!measurer || !this._coordinates || isNil(this._width) || isNil(this._height)) {
16509        return null;
16510      }
16511
16512      var width = this.getWidth(),
16513          height = this.getHeight();
16514      var w = width,
16515          h = -height;
16516
16517      if (measurer.fullExtent) {
16518        var fullExtent = measurer.fullExtent,
16519            sx = fullExtent.right > fullExtent.left ? 1 : -1,
16520            sy = fullExtent.top > fullExtent.bottom ? 1 : -1;
16521        w *= sx;
16522        h *= sy;
16523      }
16524
16525      var se = measurer.locate(this._coordinates, w, h);
16526      return se;
16527    };
16528
16529    _proto._computeGeodesicLength = function _computeGeodesicLength() {
16530      if (isNil(this._width) || isNil(this._height)) {
16531        return 0;
16532      }
16533
16534      return 2 * (this._width + this._height);
16535    };
16536
16537    _proto._computeGeodesicArea = function _computeGeodesicArea() {
16538      if (isNil(this._width) || isNil(this._height)) {
16539        return 0;
16540      }
16541
16542      return this._width * this._height;
16543    };
16544
16545    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
16546      var coordinates = Coordinate.toNumberArrays([this.getShell()]);
16547      return {
16548        'type': 'Polygon',
16549        'coordinates': coordinates
16550      };
16551    };
16552
16553    _proto._toJSON = function _toJSON(options) {
16554      var opts = extend({}, options);
16555      var nw = this.getCoordinates();
16556      opts.geometry = false;
16557      var feature = this.toGeoJSON(opts);
16558      feature['geometry'] = {
16559        'type': 'Polygon'
16560      };
16561      return {
16562        'feature': feature,
16563        'subType': 'Rectangle',
16564        'coordinates': [nw.x, nw.y],
16565        'width': this.getWidth(),
16566        'height': this.getHeight()
16567      };
16568    };
16569
16570    return Rectangle;
16571  }(Polygon);
16572
16573  Rectangle.registerJSONType('Rectangle');
16574
16575  var options$8 = {
16576    'numberOfShellPoints': 60
16577  };
16578
16579  var Sector = function (_Circle) {
16580    _inheritsLoose(Sector, _Circle);
16581
16582    Sector.fromJSON = function fromJSON(json) {
16583      var feature = json['feature'];
16584      var sector = new Sector(json['coordinates'], json['radius'], json['startAngle'], json['endAngle'], json['options']);
16585      sector.setProperties(feature['properties']);
16586      return sector;
16587    };
16588
16589    function Sector(coordinates, radius, startAngle, endAngle, opts) {
16590      var _this;
16591
16592      _this = _Circle.call(this, coordinates, radius, opts) || this;
16593      _this.startAngle = startAngle;
16594      _this.endAngle = endAngle;
16595      return _this;
16596    }
16597
16598    var _proto = Sector.prototype;
16599
16600    _proto.getStartAngle = function getStartAngle() {
16601      return this.startAngle;
16602    };
16603
16604    _proto.setStartAngle = function setStartAngle(startAngle) {
16605      this.startAngle = startAngle;
16606      this.onShapeChanged();
16607      return this;
16608    };
16609
16610    _proto.getEndAngle = function getEndAngle() {
16611      return this.endAngle;
16612    };
16613
16614    _proto.setEndAngle = function setEndAngle(endAngle) {
16615      this.endAngle = endAngle;
16616      this.onShapeChanged();
16617      return this;
16618    };
16619
16620    _proto.getShell = function getShell() {
16621      var measurer = this._getMeasurer(),
16622          center = this.getCoordinates(),
16623          numberOfPoints = this.options['numberOfShellPoints'] - 2,
16624          radius = this.getRadius(),
16625          shell = [center.copy()],
16626          startAngle = this.getStartAngle(),
16627          angle = this.getEndAngle() - startAngle;
16628
16629      var rad, dx, dy;
16630
16631      for (var i = 0; i < numberOfPoints; i++) {
16632        rad = (angle * i / (numberOfPoints - 1) + startAngle) * Math.PI / 180;
16633        dx = radius * Math.cos(rad);
16634        dy = radius * Math.sin(rad);
16635        var vertex = measurer.locate(center, dx, dy);
16636        shell.push(vertex);
16637      }
16638
16639      shell.push(center.copy());
16640      return shell;
16641    };
16642
16643    _proto._containsPoint = function _containsPoint(point, tolerance) {
16644      var map = this.getMap();
16645
16646      if (map.isTransforming()) {
16647        return _Circle.prototype._containsPoint.call(this, point, tolerance);
16648      }
16649
16650      var center = map._pointToContainerPoint(this._getCenter2DPoint()),
16651          t = isNil(tolerance) ? this._hitTestTolerance() : tolerance,
16652          size = this.getSize(),
16653          pc = center,
16654          pp = point,
16655          x = pp.x - pc.x,
16656          y = pc.y - pp.y,
16657          atan2 = Math.atan2(y, x),
16658          angle = atan2 < 0 ? (atan2 + 2 * Math.PI) * 360 / (2 * Math.PI) : atan2 * 360 / (2 * Math.PI);
16659
16660      var sAngle = this.startAngle % 360,
16661          eAngle = this.endAngle % 360;
16662      var between = false;
16663
16664      if (sAngle > eAngle) {
16665        between = !(angle > eAngle && angle < sAngle);
16666      } else {
16667        between = angle >= sAngle && angle <= eAngle;
16668      }
16669
16670      return pp.distanceTo(pc) <= size.width / 2 + t && between;
16671    };
16672
16673    _proto._computeGeodesicLength = function _computeGeodesicLength() {
16674      if (isNil(this._radius)) {
16675        return 0;
16676      }
16677
16678      return Math.PI * 2 * this._radius * Math.abs(this.startAngle - this.endAngle) / 360 + 2 * this._radius;
16679    };
16680
16681    _proto._computeGeodesicArea = function _computeGeodesicArea() {
16682      if (isNil(this._radius)) {
16683        return 0;
16684      }
16685
16686      return Math.PI * Math.pow(this._radius, 2) * Math.abs(this.startAngle - this.endAngle) / 360;
16687    };
16688
16689    _proto._toJSON = function _toJSON(options) {
16690      var opts = extend({}, options);
16691      var center = this.getCenter();
16692      opts.geometry = false;
16693      var feature = this.toGeoJSON(opts);
16694      feature['geometry'] = {
16695        'type': 'Polygon'
16696      };
16697      return {
16698        'feature': feature,
16699        'subType': 'Sector',
16700        'coordinates': [center.x, center.y],
16701        'radius': this.getRadius(),
16702        'startAngle': this.getStartAngle(),
16703        'endAngle': this.getEndAngle()
16704      };
16705    };
16706
16707    return Sector;
16708  }(Circle);
16709
16710  Sector.mergeOptions(options$8);
16711  Sector.registerJSONType('Sector');
16712
16713  var options$9 = {
16714    'enableSimplify': false,
16715    'enableClip': false
16716  };
16717
16718  var Curve = function (_LineString) {
16719    _inheritsLoose(Curve, _LineString);
16720
16721    function Curve() {
16722      return _LineString.apply(this, arguments) || this;
16723    }
16724
16725    var _proto = Curve.prototype;
16726
16727    _proto._arc = function _arc(ctx, points, lineOpacity) {
16728      var degree = this.options['arcDegree'] * Math.PI / 180;
16729
16730      for (var i = 1, l = points.length; i < l; i++) {
16731        var c = Canvas._arcBetween(ctx, points[i - 1], points[i], degree);
16732
16733        var ctrlPoint = [points[i - 1].x + points[i].x - c[0], points[i - 1].y + points[i].y - c[1]];
16734        points[i - 1].nextCtrlPoint = ctrlPoint;
16735        points[i].prevCtrlPoint = ctrlPoint;
16736
16737        Canvas._stroke(ctx, lineOpacity);
16738      }
16739    };
16740
16741    _proto._quadraticCurve = function _quadraticCurve(ctx, points) {
16742      if (points.length <= 2) {
16743        Canvas._path(ctx, points);
16744
16745        return;
16746      }
16747
16748      var i, l;
16749
16750      for (i = 2, l = points.length; i < l; i += 2) {
16751        ctx.quadraticCurveTo(points[i - 1].x, points[i - 1].y, points[i].x, points[i].y);
16752      }
16753
16754      i -= 1;
16755
16756      if (i < l) {
16757        for (; i < l; i++) {
16758          ctx.lineTo(points[i].x, points[i].y);
16759        }
16760      }
16761    };
16762
16763    _proto._bezierCurve = function _bezierCurve(ctx, points) {
16764      if (points.length <= 3) {
16765        Canvas._path(ctx, points);
16766
16767        return;
16768      }
16769
16770      var i, l;
16771
16772      for (i = 1, l = points.length; i + 2 < l; i += 3) {
16773        ctx.bezierCurveTo(points[i].x, points[i].y, points[i + 1].x, points[i + 1].y, points[i + 2].x, points[i + 2].y);
16774      }
16775
16776      if (i < l) {
16777        for (; i < l; i++) {
16778          ctx.lineTo(points[i].x, points[i].y);
16779        }
16780      }
16781    };
16782
16783    _proto._getCurveArrowPoints = function _getCurveArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance, step) {
16784      var l = segments.length;
16785      var i;
16786
16787      for (i = step; i < l; i += step) {
16788        arrows.push(this._getArrowShape(segments[i - 1], segments[i], lineWidth, arrowStyle, tolerance));
16789      }
16790
16791      i -= step;
16792
16793      if (i < l - 1) {
16794        for (i += 1; i < l; i++) {
16795          arrows.push(this._getArrowShape(segments[i - 1], segments[i], lineWidth, arrowStyle, tolerance));
16796        }
16797      }
16798    };
16799
16800    return Curve;
16801  }(LineString);
16802
16803  Curve.mergeOptions(options$9);
16804
16805  var options$a = {
16806    'arcDegree': 90
16807  };
16808
16809  var ArcCurve = function (_Curve) {
16810    _inheritsLoose(ArcCurve, _Curve);
16811
16812    function ArcCurve() {
vendor: 49,006 bytes, lines 16813-18775
16813      return _Curve.apply(this, arguments) || this;
16814    }
16815
16816    var _proto = ArcCurve.prototype;
16817
16818    _proto._toJSON = function _toJSON(options) {
16819      return {
16820        'feature': this.toGeoJSON(options),
16821        'subType': 'ArcCurve'
16822      };
16823    };
16824
16825    _proto._paintOn = function _paintOn(ctx, points, lineOpacity) {
16826      ctx.beginPath();
16827
16828      this._arc(ctx, points, lineOpacity);
16829
16830      Canvas._stroke(ctx, lineOpacity);
16831
16832      this._paintArrow(ctx, points, lineOpacity);
16833    };
16834
16835    ArcCurve.fromJSON = function fromJSON(json) {
16836      var feature = json['feature'];
16837      var arc = new ArcCurve(feature['geometry']['coordinates'], json['options']);
16838      arc.setProperties(feature['properties']);
16839      return arc;
16840    };
16841
16842    return ArcCurve;
16843  }(Curve);
16844
16845  ArcCurve.registerJSONType('ArcCurve');
16846  ArcCurve.mergeOptions(options$a);
16847
16848  var CubicBezierCurve = function (_Curve) {
16849    _inheritsLoose(CubicBezierCurve, _Curve);
16850
16851    function CubicBezierCurve() {
16852      return _Curve.apply(this, arguments) || this;
16853    }
16854
16855    CubicBezierCurve.fromJSON = function fromJSON(json) {
16856      var feature = json['feature'];
16857      var curve = new CubicBezierCurve(feature['geometry']['coordinates'], json['options']);
16858      curve.setProperties(feature['properties']);
16859      return curve;
16860    };
16861
16862    var _proto = CubicBezierCurve.prototype;
16863
16864    _proto._toJSON = function _toJSON(options) {
16865      return {
16866        'feature': this.toGeoJSON(options),
16867        'subType': 'CubicBezierCurve'
16868      };
16869    };
16870
16871    _proto._paintOn = function _paintOn(ctx, points, lineOpacity) {
16872      ctx.beginPath();
16873      ctx.moveTo(points[0].x, points[0].y);
16874
16875      this._bezierCurve(ctx, points);
16876
16877      Canvas._stroke(ctx, lineOpacity);
16878
16879      this._paintArrow(ctx, points, lineOpacity);
16880    };
16881
16882    _proto._getArrowPoints = function _getArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance) {
16883      return this._getCurveArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance, 3);
16884    };
16885
16886    return CubicBezierCurve;
16887  }(Curve);
16888
16889  CubicBezierCurve.registerJSONType('CubicBezierCurve');
16890
16891  var QuadBezierCurve = function (_Curve) {
16892    _inheritsLoose(QuadBezierCurve, _Curve);
16893
16894    function QuadBezierCurve() {
16895      return _Curve.apply(this, arguments) || this;
16896    }
16897
16898    QuadBezierCurve.fromJSON = function fromJSON(json) {
16899      var feature = json['feature'];
16900      var curve = new QuadBezierCurve(feature['geometry']['coordinates'], json['options']);
16901      curve.setProperties(feature['properties']);
16902      return curve;
16903    };
16904
16905    var _proto = QuadBezierCurve.prototype;
16906
16907    _proto._toJSON = function _toJSON(options) {
16908      return {
16909        'feature': this.toGeoJSON(options),
16910        'subType': 'QuadBezierCurve'
16911      };
16912    };
16913
16914    _proto._paintOn = function _paintOn(ctx, points, lineOpacity) {
16915      ctx.beginPath();
16916      ctx.moveTo(points[0].x, points[0].y);
16917
16918      this._quadraticCurve(ctx, points, lineOpacity);
16919
16920      Canvas._stroke(ctx, lineOpacity);
16921
16922      this._paintArrow(ctx, points, lineOpacity);
16923    };
16924
16925    _proto._getArrowPoints = function _getArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance) {
16926      return this._getCurveArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance, 2);
16927    };
16928
16929    return QuadBezierCurve;
16930  }(Curve);
16931
16932  QuadBezierCurve.registerJSONType('QuadBezierCurve');
16933
16934  var defaultSymbol$1 = {
16935    'textFaceName': 'monospace',
16936    'textSize': 12,
16937    'textLineSpacing': 8,
16938    'textWrapCharacter': '\n',
16939    'textHorizontalAlignment': 'middle',
16940    'textVerticalAlignment': 'middle'
16941  };
16942  var defaultBoxSymbol = {
16943    'markerType': 'square',
16944    'markerLineColor': '#000',
16945    'markerLineWidth': 2,
16946    'markerLineOpacity': 1,
16947    'markerFill': '#fff',
16948    'markerOpacity': 1
16949  };
16950
16951  var TextMarker = function (_Marker) {
16952    _inheritsLoose(TextMarker, _Marker);
16953
16954    function TextMarker() {
16955      return _Marker.apply(this, arguments) || this;
16956    }
16957
16958    var _proto = TextMarker.prototype;
16959
16960    _proto.getContent = function getContent() {
16961      return this._content;
16962    };
16963
16964    _proto.setContent = function setContent(content) {
16965      var old = this._content;
16966      this._content = escapeSpecialChars(content);
16967
16968      this._refresh();
16969
16970      this._fireEvent('contentchange', {
16971        'old': old,
16972        'new': content
16973      });
16974
16975      return this;
16976    };
16977
16978    _proto.onAdd = function onAdd() {
16979      this._refresh();
16980    };
16981
16982    _proto.toJSON = function toJSON() {
16983      var json = _Marker.prototype.toJSON.call(this);
16984
16985      delete json['symbol'];
16986      return json;
16987    };
16988
16989    _proto.setSymbol = function setSymbol(symbol) {
16990      if (this._refreshing || !symbol) {
16991        return _Marker.prototype.setSymbol.call(this, symbol);
16992      }
16993
16994      var s = this._parseSymbol(symbol);
16995
16996      if (this.setTextStyle) {
16997        var style = this.getTextStyle() || {};
16998        style.symbol = s[0];
16999        this.setTextStyle(style);
17000      } else if (this.setTextSymbol) {
17001        this.setTextSymbol(s[0]);
17002      }
17003
17004      if (this.setBoxStyle) {
17005        var _style = this.getBoxStyle() || {};
17006
17007        _style.symbol = s[1];
17008        this.setBoxStyle(_style);
17009      } else if (this.setBoxSymbol) {
17010        this.setBoxSymbol(s[1]);
17011      }
17012
17013      return this;
17014    };
17015
17016    _proto._parseSymbol = function _parseSymbol(symbol) {
17017      var t = {};
17018      var b = {};
17019
17020      for (var p in symbol) {
17021        if (hasOwn(symbol, p)) {
17022          if (p.indexOf('text') === 0) {
17023            t[p] = symbol[p];
17024          } else {
17025            b[p] = symbol[p];
17026          }
17027        }
17028      }
17029
17030      return [t, b];
17031    };
17032
17033    _proto._getTextSize = function _getTextSize(symbol) {
17034      return splitTextToRow(this._content, symbol)['size'];
17035    };
17036
17037    _proto._getInternalSymbol = function _getInternalSymbol() {
17038      return this._symbol;
17039    };
17040
17041    _proto._getDefaultTextSymbol = function _getDefaultTextSymbol() {
17042      return extend({}, defaultSymbol$1);
17043    };
17044
17045    _proto._getDefaultBoxSymbol = function _getDefaultBoxSymbol() {
17046      return extend({}, defaultBoxSymbol);
17047    };
17048
17049    _proto._getDefaultPadding = function _getDefaultPadding() {
17050      return [12, 8];
17051    };
17052
17053    return TextMarker;
17054  }(Marker);
17055
17056  var options$b = {
17057    'textStyle': {
17058      'wrap': true,
17059      'padding': [12, 8],
17060      'verticalAlignment': 'middle',
17061      'horizontalAlignment': 'middle'
17062    },
17063    'boxSymbol': null
17064  };
17065
17066  var TextBox = function (_TextMarker) {
17067    _inheritsLoose(TextBox, _TextMarker);
17068
17069    function TextBox(content, coordinates, width, height, options) {
17070      var _this;
17071
17072      if (options === void 0) {
17073        options = {};
17074      }
17075
17076      _this = _TextMarker.call(this, coordinates, options) || this;
17077      _this._content = escapeSpecialChars(content);
17078      _this._width = isNil(width) ? 100 : width;
17079      _this._height = isNil(height) ? 40 : height;
17080
17081      if (options.boxSymbol) {
17082        _this.setBoxSymbol(options.boxSymbol);
17083      }
17084
17085      if (options.textStyle) {
17086        _this.setTextStyle(options.textStyle);
17087      }
17088
17089      _this._refresh();
17090
17091      return _this;
17092    }
17093
17094    var _proto = TextBox.prototype;
17095
17096    _proto.getWidth = function getWidth() {
17097      return this._width;
17098    };
17099
17100    _proto.setWidth = function setWidth(width) {
17101      this._width = width;
17102
17103      this._refresh();
17104
17105      return this;
17106    };
17107
17108    _proto.getHeight = function getHeight() {
17109      return this._height;
17110    };
17111
17112    _proto.setHeight = function setHeight(height) {
17113      this._height = height;
17114
17115      this._refresh();
17116
17117      return this;
17118    };
17119
17120    _proto.getBoxSymbol = function getBoxSymbol() {
17121      return extend({}, this.options.boxSymbol);
17122    };
17123
17124    _proto.setBoxSymbol = function setBoxSymbol(symbol) {
17125      this.options.boxSymbol = symbol ? extend({}, symbol) : symbol;
17126
17127      if (this.getSymbol()) {
17128        this._refresh();
17129      }
17130
17131      return this;
17132    };
17133
17134    _proto.getTextStyle = function getTextStyle() {
17135      if (!this.options.textStyle) {
17136        return null;
17137      }
17138
17139      return extend({}, this.options.textStyle);
17140    };
17141
17142    _proto.setTextStyle = function setTextStyle(style) {
17143      this.options.textStyle = style ? extend({}, style) : style;
17144
17145      if (this.getSymbol()) {
17146        this._refresh();
17147      }
17148
17149      return this;
17150    };
17151
17152    TextBox.fromJSON = function fromJSON(json) {
17153      var feature = json['feature'];
17154      var textBox = new TextBox(json['content'], feature['geometry']['coordinates'], json['width'], json['height'], json['options']);
17155      textBox.setProperties(feature['properties']);
17156      textBox.setId(feature['id']);
17157
17158      if (json['symbol']) {
17159        textBox.setSymbol(json['symbol']);
17160      }
17161
17162      return textBox;
17163    };
17164
17165    _proto._toJSON = function _toJSON(options) {
17166      return {
17167        'feature': this.toGeoJSON(options),
17168        'width': this.getWidth(),
17169        'height': this.getHeight(),
17170        'subType': 'TextBox',
17171        'content': this._content
17172      };
17173    };
17174
17175    _proto._refresh = function _refresh() {
17176      var textStyle = this.getTextStyle() || {},
17177          padding = textStyle['padding'] || [12, 8],
17178          maxWidth = this._width - 2 * padding[0],
17179          maxHeight = this._height - 2 * padding[1];
17180      var symbol = extend({}, textStyle.symbol || this._getDefaultTextSymbol(), this.options.boxSymbol || this._getDefaultBoxSymbol(), {
17181        'textName': this._content,
17182        'markerWidth': this._width,
17183        'markerHeight': this._height,
17184        'textHorizontalAlignment': 'middle',
17185        'textVerticalAlignment': 'middle',
17186        'textMaxWidth': maxWidth,
17187        'textMaxHeight': maxHeight
17188      });
17189
17190      if (textStyle['wrap'] && !symbol['textWrapWidth']) {
17191        symbol['textWrapWidth'] = maxWidth;
17192      }
17193
17194      var hAlign = textStyle['horizontalAlignment'];
17195      symbol['textDx'] = symbol['markerDx'] || 0;
17196      var offsetX = symbol['markerWidth'] / 2 - padding[0];
17197
17198      if (hAlign === 'left') {
17199        symbol['textHorizontalAlignment'] = 'right';
17200        symbol['textDx'] = symbol['textDx'] - offsetX;
17201      } else if (hAlign === 'right') {
17202        symbol['textHorizontalAlignment'] = 'left';
17203        symbol['textDx'] = symbol['textDx'] + offsetX;
17204      }
17205
17206      var vAlign = textStyle['verticalAlignment'];
17207      symbol['textDy'] = symbol['markerDy'] || 0;
17208      var offsetY = symbol['markerHeight'] / 2 - padding[1];
17209
17210      if (vAlign === 'top') {
17211        symbol['textVerticalAlignment'] = 'bottom';
17212        symbol['textDy'] -= offsetY;
17213      } else if (vAlign === 'bottom') {
17214        symbol['textVerticalAlignment'] = 'top';
17215        symbol['textDy'] += offsetY;
17216      }
17217
17218      this._refreshing = true;
17219      this.updateSymbol(symbol);
17220      delete this._refreshing;
17221    };
17222
17223    return TextBox;
17224  }(TextMarker);
17225
17226  TextBox.mergeOptions(options$b);
17227  TextBox.registerJSONType('TextBox');
17228
17229  var options$c = {
17230    'boxStyle': null,
17231    textSymbol: null
17232  };
17233
17234  var Label = function (_TextMarker) {
17235    _inheritsLoose(Label, _TextMarker);
17236
17237    function Label(content, coordinates, options) {
17238      var _this;
17239
17240      if (options === void 0) {
17241        options = {};
17242      }
17243
17244      _this = _TextMarker.call(this, coordinates, options) || this;
17245
17246      if (options.textSymbol) {
17247        _this.setTextSymbol(options.textSymbol);
17248      }
17249
17250      if (options.boxStyle) {
17251        _this.setBoxStyle(options.boxStyle);
17252      }
17253
17254      _this._content = escapeSpecialChars(content);
17255
17256      _this._refresh();
17257
17258      return _this;
17259    }
17260
17261    var _proto = Label.prototype;
17262
17263    _proto.getBoxStyle = function getBoxStyle() {
17264      if (!this.options.boxStyle) {
17265        return null;
17266      }
17267
17268      return extend({}, this.options.boxStyle);
17269    };
17270
17271    _proto.setBoxStyle = function setBoxStyle(style) {
17272      this.options.boxStyle = style ? extend({}, style) : style;
17273
17274      this._refresh();
17275
17276      return this;
17277    };
17278
17279    _proto.getTextSymbol = function getTextSymbol() {
17280      return extend({}, this._getDefaultTextSymbol(), this.options.textSymbol);
17281    };
17282
17283    _proto.setTextSymbol = function setTextSymbol(symbol) {
17284      this.options.textSymbol = symbol ? extend({}, symbol) : symbol;
17285
17286      this._refresh();
17287
17288      return this;
17289    };
17290
17291    Label.fromJSON = function fromJSON(json) {
17292      var feature = json['feature'];
17293      var label = new Label(json['content'], feature['geometry']['coordinates'], json['options']);
17294      label.setProperties(feature['properties']);
17295      label.setId(feature['id']);
17296
17297      if (json['symbol']) {
17298        label.setSymbol(json['symbol']);
17299      }
17300
17301      return label;
17302    };
17303
17304    _proto._canEdit = function _canEdit() {
17305      return false;
17306    };
17307
17308    _proto._toJSON = function _toJSON(options) {
17309      return {
17310        'feature': this.toGeoJSON(options),
17311        'subType': 'Label',
17312        'content': this._content
17313      };
17314    };
17315
17316    _proto._refresh = function _refresh() {
17317      var symbol = extend({}, this.getTextSymbol(), {
17318        'textName': this._content
17319      });
17320      var boxStyle = this.getBoxStyle();
17321
17322      if (boxStyle) {
17323        extend(symbol, boxStyle.symbol);
17324
17325        var sizes = this._getBoxSize(symbol),
17326            textSize = sizes[1],
17327            padding = boxStyle['padding'] || this._getDefaultPadding();
17328
17329        var boxSize = sizes[0];
17330        symbol['markerWidth'] = boxSize['width'];
17331        symbol['markerHeight'] = boxSize['height'];
17332
17333        var dx = symbol['textDx'] || 0,
17334            dy = symbol['textDy'] || 0,
17335            textAlignPoint = getAlignPoint(textSize, symbol['textHorizontalAlignment'], symbol['textVerticalAlignment'])._add(dx, dy);
17336
17337        var hAlign = boxStyle['horizontalAlignment'] || 'middle';
17338        symbol['markerDx'] = textAlignPoint.x;
17339
17340        if (hAlign === 'left') {
17341          symbol['markerDx'] += symbol['markerWidth'] / 2 - padding[0];
17342        } else if (hAlign === 'right') {
17343          symbol['markerDx'] -= symbol['markerWidth'] / 2 - textSize['width'] - padding[0];
17344        } else {
17345          symbol['markerDx'] += textSize['width'] / 2;
17346        }
17347
17348        var vAlign = boxStyle['verticalAlignment'] || 'middle';
17349        symbol['markerDy'] = textAlignPoint.y;
17350
17351        if (vAlign === 'top') {
17352          symbol['markerDy'] += symbol['markerHeight'] / 2 - padding[1];
17353        } else if (vAlign === 'bottom') {
17354          symbol['markerDy'] -= symbol['markerHeight'] / 2 - textSize['height'] - padding[1];
17355        } else {
17356          symbol['markerDy'] += textSize['height'] / 2;
17357        }
17358      }
17359
17360      this._refreshing = true;
17361      this.updateSymbol(symbol);
17362      delete this._refreshing;
17363    };
17364
17365    _proto._getBoxSize = function _getBoxSize(symbol) {
17366      if (!symbol['markerType']) {
17367        symbol['markerType'] = 'square';
17368      }
17369
17370      var boxStyle = this.getBoxStyle();
17371
17372      var size = this._getTextSize(symbol);
17373
17374      var width, height;
17375
17376      var padding = boxStyle['padding'] || this._getDefaultPadding();
17377
17378      width = size['width'] + padding[0] * 2;
17379      height = size['height'] + padding[1] * 2;
17380
17381      if (boxStyle['minWidth']) {
17382        if (!width || width < boxStyle['minWidth']) {
17383          width = boxStyle['minWidth'];
17384        }
17385      }
17386
17387      if (boxStyle['minHeight']) {
17388        if (!height || height < boxStyle['minHeight']) {
17389          height = boxStyle['minHeight'];
17390        }
17391      }
17392
17393      return [new Size(width, height), size];
17394    };
17395
17396    return Label;
17397  }(TextMarker);
17398
17399  Label.mergeOptions(options$c);
17400  Label.registerJSONType('Label');
17401
17402  var Connectable = function Connectable(Base) {
17403    return function (_Base) {
17404      _inheritsLoose(_class, _Base);
17405
17406      function _class() {
17407        return _Base.apply(this, arguments) || this;
17408      }
17409
17410      _class._hasConnectors = function _hasConnectors(geometry) {
17411        return !isNil(geometry.__connectors) && geometry.__connectors.length > 0;
17412      };
17413
17414      _class._getConnectors = function _getConnectors(geometry) {
17415        return geometry.__connectors;
17416      };
17417
17418      var _proto = _class.prototype;
17419
17420      _proto.getConnectSource = function getConnectSource() {
17421        return this._connSource;
17422      };
17423
17424      _proto.setConnectSource = function setConnectSource(src) {
17425        var target = this._connTarget;
17426        this.onRemove();
17427        this._connSource = src;
17428        this._connTarget = target;
17429        this.onAdd();
17430        return this;
17431      };
17432
17433      _proto.getConnectTarget = function getConnectTarget() {
17434        return this._connTarget;
17435      };
17436
17437      _proto.setConnectTarget = function setConnectTarget(target) {
17438        var src = this._connSource;
17439        this.onRemove();
17440        this._connSource = src;
17441        this._connTarget = target;
17442
17443        this._updateCoordinates();
17444
17445        this._registerEvents();
17446
17447        return this;
17448      };
17449
17450      _proto._updateCoordinates = function _updateCoordinates() {
17451        var map = this.getMap();
17452
17453        if (!map && this._connSource) {
17454          map = this._connSource.getMap();
17455        }
17456
17457        if (!map && this._connTarget) {
17458          map = this._connTarget.getMap();
17459        }
17460
17461        if (!map) {
17462          return;
17463        }
17464
17465        if (!this._connSource || !this._connTarget) {
17466          return;
17467        }
17468
17469        var srcPoints = this._connSource._getConnectPoints();
17470
17471        var targetPoints = this._connTarget._getConnectPoints();
17472
17473        var minDist = 0;
17474        var oldCoordinates = this.getCoordinates();
17475        var c1, c2;
17476
17477        for (var i = 0, len = srcPoints.length; i < len; i++) {
17478          var p1 = srcPoints[i];
17479
17480          for (var j = 0, length = targetPoints.length; j < length; j++) {
17481            var p2 = targetPoints[j];
17482            var dist = map.computeLength(p1, p2);
17483
17484            if (i === 0 && j === 0) {
17485              c1 = p1;
17486              c2 = p2;
17487              minDist = dist;
17488            } else if (dist < minDist) {
17489              c1 = p1;
17490              c2 = p2;
17491            }
17492          }
17493        }
17494
17495        if (!isArrayHasData(oldCoordinates) || !oldCoordinates[0].equals(c1) || !oldCoordinates[1].equals(c2)) {
17496          this.setCoordinates([c1, c2]);
17497        }
17498      };
17499
17500      _proto.onAdd = function onAdd() {
17501        this._registerEvents();
17502
17503        this._updateCoordinates();
17504      };
17505
17506      _proto.onRemove = function onRemove() {
17507        if (this._connSource) {
17508          if (this._connSource.__connectors) {
17509            removeFromArray(this, this._connSource.__connectors);
17510          }
17511
17512          this._connSource.off('dragging positionchange', this._updateCoordinates, this).off('remove', this.onRemove, this);
17513
17514          this._connSource.off('dragstart mousedown mouseover', this._showConnect, this);
17515
17516          this._connSource.off('dragend mouseup mouseout', this.hide, this);
17517
17518          this._connSource.off('show', this._showConnect, this).off('hide', this.hide, this);
17519
17520          delete this._connSource;
17521        }
17522
17523        if (this._connTarget) {
17524          removeFromArray(this, this._connTarget.__connectors);
17525
17526          this._connTarget.off('dragging positionchange', this._updateCoordinates, this).off('remove', this.onRemove, this);
17527
17528          this._connTarget.off('show', this._showConnect, this).off('hide', this.hide, this);
17529
17530          delete this._connTarget;
17531        }
17532
17533        if (!(this._connSource instanceof Geometry) || !(this._connTarget instanceof Geometry)) {
17534          var map = this.getMap();
17535
17536          if (map) {
17537            map.off('movestart moving moveend zoomstart zooming zoomend rotate pitch fovchange spatialreferencechange', this._updateCoordinates, this);
17538          }
17539        }
17540      };
17541
17542      _proto._showConnect = function _showConnect() {
17543        if (!this._connSource || !this._connTarget) {
17544          return;
17545        }
17546
17547        if (this._connSource.isVisible() && this._connTarget.isVisible()) {
17548          this._updateCoordinates();
17549
17550          this.show();
17551        }
17552      };
17553
17554      _proto._registerEvents = function _registerEvents() {
17555        if (!this._connSource || !this._connTarget) {
17556          return;
17557        }
17558
17559        if (!this._connSource.__connectors) {
17560          this._connSource.__connectors = [];
17561        }
17562
17563        if (!this._connTarget.__connectors) {
17564          this._connTarget.__connectors = [];
17565        }
17566
17567        this._connSource.__connectors.push(this);
17568
17569        this._connTarget.__connectors.push(this);
17570
17571        this._connSource.on('dragging positionchange', this._updateCoordinates, this).on('remove', this.remove, this);
17572
17573        this._connTarget.on('dragging positionchange', this._updateCoordinates, this).on('remove', this.remove, this);
17574
17575        this._connSource.on('show', this._showConnect, this).on('hide', this.hide, this);
17576
17577        this._connTarget.on('show', this._showConnect, this).on('hide', this.hide, this);
17578
17579        var trigger = this.options['showOn'];
17580        this.hide();
17581
17582        if (trigger === 'moving') {
17583          this._connSource.on('dragstart', this._showConnect, this).on('dragend', this.hide, this);
17584
17585          this._connTarget.on('dragstart', this._showConnect, this).on('dragend', this.hide, this);
17586        } else if (trigger === 'click') {
17587          this._connSource.on('mousedown', this._showConnect, this).on('mouseup', this.hide, this);
17588
17589          this._connTarget.on('mousedown', this._showConnect, this).on('mouseup', this.hide, this);
17590        } else if (trigger === 'mouseover') {
17591          this._connSource.on('mouseover', this._showConnect, this).on('mouseout', this.hide, this);
17592
17593          this._connTarget.on('mouseover', this._showConnect, this).on('mouseout', this.hide, this);
17594        } else {
17595          this._showConnect();
17596        }
17597
17598        if (!(this._connSource instanceof Geometry) || !(this._connTarget instanceof Geometry)) {
17599          var map = this.getMap();
17600
17601          if (map) {
17602            map.on('movestart moving moveend zoomstart zooming zoomend rotate pitch fovchange spatialreferencechange', this._updateCoordinates, this);
17603          }
17604        }
17605      };
17606
17607      return _class;
17608    }(Base);
17609  };
17610
17611  var options$d = {
17612    showOn: 'always'
17613  };
17614
17615  var ConnectorLine = function (_Connectable) {
17616    _inheritsLoose(ConnectorLine, _Connectable);
17617
17618    function ConnectorLine(src, target, options) {
17619      var _this;
17620
17621      _this = _Connectable.call(this, null, options) || this;
17622
17623      if (arguments.length === 1) {
17624        options = src;
17625        src = null;
17626        target = null;
17627      }
17628
17629      _this._connSource = src;
17630      _this._connTarget = target;
17631      return _this;
17632    }
17633
17634    return ConnectorLine;
17635  }(Connectable(LineString));
17636
17637  ConnectorLine.mergeOptions(options$d);
17638  ConnectorLine.registerJSONType('ConnectorLine');
17639
17640  var ArcConnectorLine = function (_Connectable2) {
17641    _inheritsLoose(ArcConnectorLine, _Connectable2);
17642
17643    function ArcConnectorLine(src, target, options) {
17644      var _this2;
17645
17646      _this2 = _Connectable2.call(this, null, options) || this;
17647
17648      if (arguments.length === 1) {
17649        options = src;
17650        src = null;
17651        target = null;
17652      }
17653
17654      _this2._connSource = src;
17655      _this2._connTarget = target;
17656      return _this2;
17657    }
17658
17659    return ArcConnectorLine;
17660  }(Connectable(ArcCurve));
17661
17662  ArcConnectorLine.mergeOptions(options$d);
17663  ArcConnectorLine.registerJSONType('ArcConnectorLine');
17664
17665  var options$e = {
17666    'drawImmediate': false
17667  };
17668  var TEMP_EXTENT$3 = new PointExtent();
17669
17670  var OverlayLayer = function (_Layer) {
17671    _inheritsLoose(OverlayLayer, _Layer);
17672
17673    function OverlayLayer(id, geometries, options) {
17674      var _this;
17675
17676      if (geometries && !(geometries instanceof Geometry) && !Array.isArray(geometries) && GEOJSON_TYPES.indexOf(geometries.type) < 0) {
17677        options = geometries;
17678        geometries = null;
17679      }
17680
17681      _this = _Layer.call(this, id, options) || this;
17682      _this._maxZIndex = 0;
17683      _this._minZIndex = 0;
17684
17685      _this._initCache();
17686
17687      if (geometries) {
17688        _this.addGeometry(geometries);
17689      }
17690
17691      return _this;
17692    }
17693
17694    var _proto = OverlayLayer.prototype;
17695
17696    _proto.getGeometryById = function getGeometryById(id) {
17697      if (isNil(id) || id === '') {
17698        return null;
17699      }
17700
17701      if (!this._geoMap[id]) {
17702        return null;
17703      }
17704
17705      return this._geoMap[id];
17706    };
17707
17708    _proto.getGeometries = function getGeometries(filter, context) {
17709      if (!filter) {
17710        return this._geoList.slice(0);
17711      }
17712
17713      var result = [];
17714      var geometry, filtered;
17715
17716      for (var i = 0, l = this._geoList.length; i < l; i++) {
17717        geometry = this._geoList[i];
17718
17719        if (context) {
17720          filtered = filter.call(context, geometry);
17721        } else {
17722          filtered = filter(geometry);
17723        }
17724
17725        if (filtered) {
17726          result.push(geometry);
17727        }
17728      }
17729
17730      return result;
17731    };
17732
17733    _proto.getFirstGeometry = function getFirstGeometry() {
17734      if (!this._geoList.length) {
17735        return null;
17736      }
17737
17738      return this._geoList[0];
17739    };
17740
17741    _proto.getLastGeometry = function getLastGeometry() {
17742      var len = this._geoList.length;
17743
17744      if (len === 0) {
17745        return null;
17746      }
17747
17748      return this._geoList[len - 1];
17749    };
17750
17751    _proto.getCount = function getCount() {
17752      return this._geoList.length;
17753    };
17754
17755    _proto.getExtent = function getExtent() {
17756      if (this.getCount() === 0) {
17757        return null;
17758      }
17759
17760      var extent = new Extent(this.getProjection());
17761      this.forEach(function (g) {
17762        extent._combine(g.getExtent());
17763      });
17764      return extent;
17765    };
17766
17767    _proto.forEach = function forEach(fn, context) {
17768      var copyOnWrite = this._geoList.slice(0);
17769
17770      for (var i = 0, l = copyOnWrite.length; i < l; i++) {
17771        if (!context) {
17772          fn(copyOnWrite[i], i);
17773        } else {
17774          fn.call(context, copyOnWrite[i], i);
17775        }
17776      }
17777
17778      return this;
17779    };
17780
17781    _proto.filter = function filter(fn, context) {
17782      var selected = [];
17783      var isFn = isFunction(fn);
17784      var filter = isFn ? fn : createFilter(fn);
17785      this.forEach(function (geometry) {
17786        var g = isFn ? geometry : getFilterFeature(geometry);
17787
17788        if (context ? filter.call(context, g) : filter(g)) {
17789          selected.push(geometry);
17790        }
17791      }, this);
17792      return selected;
17793    };
17794
17795    _proto.isEmpty = function isEmpty() {
17796      return !this._geoList.length;
17797    };
17798
17799    _proto.addGeometry = function addGeometry(geometries, fitView) {
17800      if (!geometries) {
17801        return this;
17802      }
17803
17804      if (geometries.type === 'FeatureCollection') {
17805        return this.addGeometry(GeoJSON.toGeometry(geometries), fitView);
17806      } else if (!Array.isArray(geometries)) {
17807        var count = arguments.length;
17808        var last = arguments[count - 1];
17809        geometries = Array.prototype.slice.call(arguments, 0, count - 1);
17810        fitView = last;
17811
17812        if (isObject(last)) {
17813          geometries.push(last);
17814          fitView = false;
17815        }
17816
17817        return this.addGeometry(geometries, fitView);
17818      } else if (geometries.length === 0) {
17819        return this;
17820      }
17821
17822      this._initCache();
17823
17824      var extent;
17825
17826      if (fitView === true) {
17827        extent = new Extent();
17828      }
17829
17830      this._toSort = this._maxZIndex > 0;
17831      var geos = [];
17832
17833      for (var i = 0, l = geometries.length; i < l; i++) {
17834        var geo = geometries[i];
17835
17836        if (!geo) {
17837          throw new Error('Invalid geometry to add to layer(' + this.getId() + ') at index:' + i);
17838        }
17839
17840        if (!(geo instanceof Geometry)) {
17841          geo = Geometry.fromJSON(geo);
17842
17843          if (Array.isArray(geo)) {
17844            for (var ii = 0, ll = geo.length; ii < ll; ii++) {
17845              this._add(geo[ii], extent, i);
17846
17847              geos.push(geo[ii]);
17848            }
17849          }
17850        }
17851
17852        if (!Array.isArray(geo)) {
17853          this._add(geo, extent, i);
17854
17855          geos.push(geo);
17856        }
17857      }
17858
17859      var map = this.getMap();
17860
17861      if (map) {
17862        this._getRenderer().onGeometryAdd(geos);
17863
17864        if (fitView === true && !isNil(extent.xmin)) {
17865          var z = map.getFitZoom(extent);
17866          map.setCenterAndZoom(extent.getCenter(), z);
17867        }
17868      }
17869
17870      this.fire('addgeo', {
17871        'geometries': geometries
17872      });
17873      return this;
17874    };
17875
17876    _proto.getGeoMinZIndex = function getGeoMinZIndex() {
17877      return this._minZIndex;
17878    };
17879
17880    _proto.getGeoMaxZIndex = function getGeoMaxZIndex() {
17881      return this._maxZIndex;
17882    };
17883
17884    _proto._add = function _add(geo, extent, i) {
17885      if (!this._toSort) {
17886        this._toSort = geo.getZIndex() !== 0;
17887      }
17888
17889      this._updateZIndex(geo.getZIndex());
17890
17891      var geoId = geo.getId();
17892
17893      if (!isNil(geoId)) {
17894        if (!isNil(this._geoMap[geoId])) {
17895          throw new Error('Duplicate geometry id in layer(' + this.getId() + '):' + geoId + ', at index:' + i);
17896        }
17897
17898        this._geoMap[geoId] = geo;
17899      }
17900
17901      var internalId = UID();
17902
17903      geo._setInternalId(internalId);
17904
17905      this._geoList.push(geo);
17906
17907      if (this.onAddGeometry) {
17908        this.onAddGeometry(geo);
17909      }
17910
17911      geo._bindLayer(this);
17912
17913      if (geo.onAdd) {
17914        geo.onAdd();
17915      }
17916
17917      if (extent) {
17918        extent._combine(geo.getExtent());
17919      }
17920
17921      geo._fireEvent('add', {
17922        'layer': this
17923      });
17924    };
17925
17926    _proto.removeGeometry = function removeGeometry(geometries) {
17927      if (!Array.isArray(geometries)) {
17928        return this.removeGeometry([geometries]);
17929      }
17930
17931      for (var i = geometries.length - 1; i >= 0; i--) {
17932        if (!(geometries[i] instanceof Geometry)) {
17933          geometries[i] = this.getGeometryById(geometries[i]);
17934        }
17935
17936        if (!geometries[i] || this !== geometries[i].getLayer()) continue;
17937        geometries[i].remove();
17938      }
17939
17940      this.fire('removegeo', {
17941        'geometries': geometries
17942      });
17943      return this;
17944    };
17945
17946    _proto.clear = function clear() {
17947      this._clearing = true;
17948      this.forEach(function (geo) {
17949        geo.remove();
17950      });
17951      this._geoMap = {};
17952      var old = this._geoList;
17953      this._geoList = [];
17954
17955      if (this._getRenderer()) {
17956        this._getRenderer().onGeometryRemove(old);
17957      }
17958
17959      this._clearing = false;
17960      this.fire('clear');
17961      return this;
17962    };
17963
17964    _proto.onRemoveGeometry = function onRemoveGeometry(geometry) {
17965      if (!geometry || this._clearing) {
17966        return;
17967      }
17968
17969      if (this !== geometry.getLayer()) {
17970        return;
17971      }
17972
17973      var internalId = geometry._getInternalId();
17974
17975      if (isNil(internalId)) {
17976        return;
17977      }
17978
17979      var geoId = geometry.getId();
17980
17981      if (!isNil(geoId)) {
17982        delete this._geoMap[geoId];
17983      }
17984
17985      var idx = this._findInList(geometry);
17986
17987      if (idx >= 0) {
17988        this._geoList.splice(idx, 1);
17989      }
17990
17991      if (this._getRenderer()) {
17992        this._getRenderer().onGeometryRemove([geometry]);
17993      }
17994    };
17995
17996    _proto.hide = function hide() {
17997      for (var i = 0, l = this._geoList.length; i < l; i++) {
17998        this._geoList[i].onHide();
17999      }
18000
18001      return Layer.prototype.hide.call(this);
18002    };
18003
18004    _proto.identify = function identify(coordinate, options) {
18005      if (options === void 0) {
18006        options = {};
18007      }
18008
18009      return this._hitGeos(this._geoList, coordinate, options);
18010    };
18011
18012    _proto._hitGeos = function _hitGeos(geometries, coordinate, options) {
18013      if (options === void 0) {
18014        options = {};
18015      }
18016
18017      var filter = options['filter'],
18018          tolerance = options['tolerance'],
18019          hits = [];
18020      var map = this.getMap();
18021      var point = map.coordToPoint(coordinate);
18022
18023      var cp = map._pointToContainerPoint(point, undefined, 0, point);
18024
18025      for (var i = geometries.length - 1; i >= 0; i--) {
18026        var geo = geometries[i];
18027
18028        if (!geo || !geo.isVisible() || !geo._getPainter() || !geo.options['interactive']) {
18029          continue;
18030        }
18031
18032        if (!(geo instanceof LineString) || !geo._getArrowStyle() && !(geo instanceof Curve)) {
18033          var extent = geo.getContainerExtent(TEMP_EXTENT$3);
18034
18035          if (tolerance) {
18036            extent = extent._expand(tolerance);
18037          }
18038
18039          if (!extent || !extent.contains(cp)) {
18040            continue;
18041          }
18042        }
18043
18044        if (geo._containsPoint(cp, tolerance) && (!filter || filter(geo))) {
18045          hits.push(geo);
18046
18047          if (options['count']) {
18048            if (hits.length >= options['count']) {
18049              break;
18050            }
18051          }
18052        }
18053      }
18054
18055      return hits;
18056    };
18057
18058    _proto._initCache = function _initCache() {
18059      if (!this._geoList) {
18060        this._geoList = [];
18061        this._geoMap = {};
18062      }
18063    };
18064
18065    _proto._updateZIndex = function _updateZIndex() {
18066      for (var _len = arguments.length, zIndex = new Array(_len), _key = 0; _key < _len; _key++) {
18067        zIndex[_key] = arguments[_key];
18068      }
18069
18070      this._maxZIndex = Math.max(this._maxZIndex, Math.max.apply(Math, zIndex));
18071      this._minZIndex = Math.min(this._minZIndex, Math.min.apply(Math, zIndex));
18072    };
18073
18074    _proto._sortGeometries = function _sortGeometries() {
18075      var _this2 = this;
18076
18077      if (!this._toSort) {
18078        return;
18079      }
18080
18081      this._maxZIndex = 0;
18082      this._minZIndex = 0;
18083
18084      this._geoList.sort(function (a, b) {
18085        _this2._updateZIndex(a.getZIndex(), b.getZIndex());
18086
18087        return _this2._compare(a, b);
18088      });
18089
18090      this._toSort = false;
18091    };
18092
18093    _proto._compare = function _compare(a, b) {
18094      if (a.getZIndex() === b.getZIndex()) {
18095        return a._getInternalId() - b._getInternalId();
18096      }
18097
18098      return a.getZIndex() - b.getZIndex();
18099    };
18100
18101    _proto._findInList = function _findInList(geo) {
18102      var len = this._geoList.length;
18103
18104      if (len === 0) {
18105        return -1;
18106      }
18107
18108      var low = 0,
18109          high = len - 1,
18110          middle;
18111
18112      while (low <= high) {
18113        middle = Math.floor((low + high) / 2);
18114
18115        if (this._geoList[middle] === geo) {
18116          return middle;
18117        } else if (this._compare(this._geoList[middle], geo) > 0) {
18118          high = middle - 1;
18119        } else {
18120          low = middle + 1;
18121        }
18122      }
18123
18124      return -1;
18125    };
18126
18127    _proto._onGeometryEvent = function _onGeometryEvent(param) {
18128      if (!param || !param['target']) {
18129        return;
18130      }
18131
18132      var type = param['type'];
18133
18134      if (type === 'idchange') {
18135        this._onGeometryIdChange(param);
18136      } else if (type === 'zindexchange') {
18137        this._onGeometryZIndexChange(param);
18138      } else if (type === 'positionchange') {
18139        this._onGeometryPositionChange(param);
18140      } else if (type === 'shapechange') {
18141        this._onGeometryShapeChange(param);
18142      } else if (type === 'symbolchange') {
18143        this._onGeometrySymbolChange(param);
18144      } else if (type === 'show') {
18145        this._onGeometryShow(param);
18146      } else if (type === 'hide') {
18147        this._onGeometryHide(param);
18148      } else if (type === 'propertieschange') {
18149        this._onGeometryPropertiesChange(param);
18150      }
18151    };
18152
18153    _proto._onGeometryIdChange = function _onGeometryIdChange(param) {
18154      if (param['new'] === param['old']) {
18155        if (this._geoMap[param['old']] && this._geoMap[param['old']] === param['target']) {
18156          return;
18157        }
18158      }
18159
18160      if (!isNil(param['new'])) {
18161        if (this._geoMap[param['new']]) {
18162          throw new Error('Duplicate geometry id in layer(' + this.getId() + '):' + param['new']);
18163        }
18164
18165        this._geoMap[param['new']] = param['target'];
18166      }
18167
18168      if (!isNil(param['old']) && param['new'] !== param['old']) {
18169        delete this._geoMap[param['old']];
18170      }
18171    };
18172
18173    _proto._onGeometryZIndexChange = function _onGeometryZIndexChange(param) {
18174      if (param['old'] !== param['new']) {
18175        this._updateZIndex(param['new']);
18176
18177        this._toSort = true;
18178
18179        if (this._getRenderer()) {
18180          this._getRenderer().onGeometryZIndexChange(param);
18181        }
18182      }
18183    };
18184
18185    _proto._onGeometryPositionChange = function _onGeometryPositionChange(param) {
18186      if (this._getRenderer()) {
18187        this._getRenderer().onGeometryPositionChange(param);
18188      }
18189    };
18190
18191    _proto._onGeometryShapeChange = function _onGeometryShapeChange(param) {
18192      if (this._getRenderer()) {
18193        this._getRenderer().onGeometryShapeChange(param);
18194      }
18195    };
18196
18197    _proto._onGeometrySymbolChange = function _onGeometrySymbolChange(param) {
18198      if (this._getRenderer()) {
18199        this._getRenderer().onGeometrySymbolChange(param);
18200      }
18201    };
18202
18203    _proto._onGeometryShow = function _onGeometryShow(param) {
18204      if (this._getRenderer()) {
18205        this._getRenderer().onGeometryShow(param);
18206      }
18207    };
18208
18209    _proto._onGeometryHide = function _onGeometryHide(param) {
18210      if (this._getRenderer()) {
18211        this._getRenderer().onGeometryHide(param);
18212      }
18213    };
18214
18215    _proto._onGeometryPropertiesChange = function _onGeometryPropertiesChange(param) {
18216      if (this._getRenderer()) {
18217        this._getRenderer().onGeometryPropertiesChange(param);
18218      }
18219    };
18220
18221    return OverlayLayer;
18222  }(Layer);
18223
18224  OverlayLayer.mergeOptions(options$e);
18225
18226  var options$f = {
18227    'debug': false,
18228    'enableSimplify': true,
18229    'geometryEvents': true,
18230    'defaultIconSize': [20, 20],
18231    'cacheVectorOnCanvas': true,
18232    'cacheSvgOnCanvas': Browser$1.gecko,
18233    'enableAltitude': false,
18234    'altitudeProperty': 'altitude',
18235    'drawAltitude': false
18236  };
18237
18238  var VectorLayer = function (_OverlayLayer) {
18239    _inheritsLoose(VectorLayer, _OverlayLayer);
18240
18241    function VectorLayer(id, geometries, options) {
18242      var _this;
18243
18244      _this = _OverlayLayer.call(this, id, geometries, options) || this;
18245      var style = _this.options['style'];
18246      delete _this.options['style'];
18247
18248      if (style) {
18249        _this.setStyle(style);
18250      }
18251
18252      return _this;
18253    }
18254
18255    var _proto = VectorLayer.prototype;
18256
18257    _proto.getStyle = function getStyle() {
18258      if (!this._style) {
18259        return null;
18260      }
18261
18262      return this._style;
18263    };
18264
18265    _proto.setStyle = function setStyle(style) {
18266      this._style = style;
18267      this._cookedStyles = compileStyle(style);
18268      this.forEach(function (geometry) {
18269        this._styleGeometry(geometry);
18270      }, this);
18271      this.fire('setstyle', {
18272        'style': style
18273      });
18274      return this;
18275    };
18276
18277    _proto.removeStyle = function removeStyle() {
18278      if (!this._style) {
18279        return this;
18280      }
18281
18282      delete this._style;
18283      delete this._cookedStyles;
18284      this.forEach(function (geometry) {
18285        geometry._setExternSymbol(null);
18286      }, this);
18287      this.fire('removestyle');
18288      return this;
18289    };
18290
18291    _proto.onAddGeometry = function onAddGeometry(geo) {
18292      var style = this.getStyle();
18293
18294      if (style) {
18295        this._styleGeometry(geo);
18296      }
18297    };
18298
18299    _proto.onConfig = function onConfig(conf) {
18300      _OverlayLayer.prototype.onConfig.call(this, conf);
18301
18302      if (conf['enableAltitude'] || conf['drawAltitude'] || conf['altitudeProperty']) {
18303        var renderer = this.getRenderer();
18304
18305        if (renderer && renderer.setToRedraw) {
18306          renderer.setToRedraw();
18307        }
18308      }
18309    };
18310
18311    _proto._styleGeometry = function _styleGeometry(geometry) {
18312      if (!this._cookedStyles) {
18313        return false;
18314      }
18315
18316      var g = getFilterFeature(geometry);
18317
18318      for (var i = 0, len = this._cookedStyles.length; i < len; i++) {
18319        if (this._cookedStyles[i]['filter'](g) === true) {
18320          geometry._setExternSymbol(this._cookedStyles[i]['symbol']);
18321
18322          return true;
18323        }
18324      }
18325
18326      return false;
18327    };
18328
18329    _proto.identify = function identify(coordinate, options) {
18330      if (options === void 0) {
18331        options = {};
18332      }
18333
18334      var renderer = this.getRenderer();
18335
18336      if (options['onlyVisible'] && renderer && renderer.identify) {
18337        return renderer.identify(coordinate, options);
18338      }
18339
18340      return _OverlayLayer.prototype.identify.call(this, coordinate, options);
18341    };
18342
18343    _proto.toJSON = function toJSON(options) {
18344      if (!options) {
18345        options = {};
18346      }
18347
18348      var profile = {
18349        'type': this.getJSONType(),
18350        'id': this.getId(),
18351        'options': this.config()
18352      };
18353
18354      if ((isNil(options['style']) || options['style']) && this.getStyle()) {
18355        profile['style'] = this.getStyle();
18356      }
18357
18358      if (isNil(options['geometries']) || options['geometries']) {
18359        var clipExtent;
18360
18361        if (options['clipExtent']) {
18362          var map = this.getMap();
18363          var projection = map ? map.getProjection() : null;
18364          clipExtent = new Extent(options['clipExtent'], projection);
18365        }
18366
18367        var geoJSONs = [];
18368        var geometries = this.getGeometries();
18369
18370        for (var i = 0, len = geometries.length; i < len; i++) {
18371          var geo = geometries[i];
18372          var geoExt = geo.getExtent();
18373
18374          if (!geoExt || clipExtent && !clipExtent.intersects(geoExt)) {
18375            continue;
18376          }
18377
18378          var json = geo.toJSON(options['geometries']);
18379          geoJSONs.push(json);
18380        }
18381
18382        profile['geometries'] = geoJSONs;
18383      }
18384
18385      return profile;
18386    };
18387
18388    VectorLayer.fromJSON = function fromJSON(json) {
18389      if (!json || json['type'] !== 'VectorLayer') {
18390        return null;
18391      }
18392
18393      var layer = new VectorLayer(json['id'], json['options']);
18394      var geoJSONs = json['geometries'];
18395      var geometries = [];
18396
18397      for (var i = 0; i < geoJSONs.length; i++) {
18398        var geo = Geometry.fromJSON(geoJSONs[i]);
18399
18400        if (geo) {
18401          geometries.push(geo);
18402        }
18403      }
18404
18405      layer.addGeometry(geometries);
18406
18407      if (json['style']) {
18408        layer.setStyle(json['style']);
18409      }
18410
18411      return layer;
18412    };
18413
18414    return VectorLayer;
18415  }(OverlayLayer);
18416
18417  VectorLayer.mergeOptions(options$f);
18418  VectorLayer.registerJSONType('VectorLayer');
18419
18420  var key = '_map_tool';
18421
18422  var MapTool = function (_Eventable) {
18423    _inheritsLoose(MapTool, _Eventable);
18424
18425    function MapTool() {
18426      return _Eventable.apply(this, arguments) || this;
18427    }
18428
18429    var _proto = MapTool.prototype;
18430
18431    _proto.addTo = function addTo(map) {
18432      if (!map) {
18433        return this;
18434      }
18435
18436      this._map = map;
18437
18438      if (map[key]) {
18439        map[key].disable();
18440      }
18441
18442      if (this.onAdd) {
18443        this.onAdd();
18444      }
18445
18446      this.enable();
18447      map[key] = this;
18448
18449      this._fireEvent('add');
18450
18451      return this;
18452    };
18453
18454    _proto.getMap = function getMap() {
18455      return this._map;
18456    };
18457
18458    _proto.enable = function enable() {
18459      var map = this._map;
18460
18461      if (!map || this._enabled) {
18462        return this;
18463      }
18464
18465      this._enabled = true;
18466
18467      this._switchEvents('off');
18468
18469      this._registerEvents();
18470
18471      if (this.onEnable) {
18472        this.onEnable();
18473      }
18474
18475      this._fireEvent('enable');
18476
18477      return this;
18478    };
18479
18480    _proto.disable = function disable() {
18481      if (!this._enabled || !this._map) {
18482        return this;
18483      }
18484
18485      this._enabled = false;
18486
18487      this._switchEvents('off');
18488
18489      if (this.onDisable) {
18490        this.onDisable();
18491      }
18492
18493      this._fireEvent('disable');
18494
18495      return this;
18496    };
18497
18498    _proto.isEnabled = function isEnabled() {
18499      if (!this._enabled) {
18500        return false;
18501      }
18502
18503      return true;
18504    };
18505
18506    _proto.remove = function remove() {
18507      if (!this._map) {
18508        return this;
18509      }
18510
18511      this.disable();
18512
18513      if (this._map) {
18514        delete this._map[key];
18515        delete this._map;
18516      }
18517
18518      this._fireEvent('remove');
18519
18520      return this;
18521    };
18522
18523    _proto._registerEvents = function _registerEvents() {
18524      this._switchEvents('on');
18525    };
18526
18527    _proto._switchEvents = function _switchEvents(to) {
18528      var events = this.getEvents();
18529
18530      if (events) {
18531        this._map[to](events, this);
18532      }
18533    };
18534
18535    _proto._fireEvent = function _fireEvent(eventName, param) {
18536      if (!param) {
18537        param = {};
18538      }
18539
18540      this.fire(eventName, param);
18541    };
18542
18543    return MapTool;
18544  }(Eventable(Class));
18545
18546  var options$g = {
18547    'symbol': {
18548      'lineColor': '#000',
18549      'lineWidth': 2,
18550      'lineOpacity': 1,
18551      'polygonFill': '#fff',
18552      'polygonOpacity': 0.3
18553    },
18554    'doubleClickZoom': false,
18555    'mode': null,
18556    'once': false,
18557    'autoPanAtEdge': false,
18558    'ignoreMouseleave': true
18559  };
18560  var registeredMode = {};
18561
18562  var DrawTool = function (_MapTool) {
18563    _inheritsLoose(DrawTool, _MapTool);
18564
18565    DrawTool.registerMode = function registerMode(name, modeAction) {
18566      registeredMode[name.toLowerCase()] = modeAction;
18567    };
18568
18569    DrawTool.getRegisterMode = function getRegisterMode(name) {
18570      return registeredMode[name.toLowerCase()];
18571    };
18572
18573    function DrawTool(options) {
18574      var _this;
18575
18576      _this = _MapTool.call(this, options) || this;
18577
18578      _this._checkMode();
18579
18580      _this._events = {
18581        'click': _this._firstClickHandler,
18582        'mousemove': _this._mouseMoveHandler,
18583        'dblclick': _this._doubleClickHandler,
18584        'mousedown': _this._mouseDownHandler,
18585        'mouseup': _this._mouseUpHandler
18586      };
18587      return _this;
18588    }
18589
18590    var _proto = DrawTool.prototype;
18591
18592    _proto.getMode = function getMode() {
18593      if (this.options['mode']) {
18594        return this.options['mode'].toLowerCase();
18595      }
18596
18597      return null;
18598    };
18599
18600    _proto.setMode = function setMode(mode) {
18601      if (this._geometry) {
18602        this._geometry.remove();
18603
18604        delete this._geometry;
18605      }
18606
18607      this._clearStage();
18608
18609      this._switchEvents('off');
18610
18611      this.options['mode'] = mode;
18612
18613      this._checkMode();
18614
18615      if (this.isEnabled()) {
18616        this._switchEvents('on');
18617
18618        this._restoreMapCfg();
18619
18620        this._saveMapCfg();
18621      }
18622
18623      return this;
18624    };
18625
18626    _proto.getSymbol = function getSymbol() {
18627      var symbol = this.options['symbol'];
18628
18629      if (symbol) {
18630        return extendSymbol(symbol);
18631      } else {
18632        return extendSymbol(this.options['symbol']);
18633      }
18634    };
18635
18636    _proto.setSymbol = function setSymbol(symbol) {
18637      if (!symbol) {
18638        return this;
18639      }
18640
18641      this.options['symbol'] = symbol;
18642
18643      if (this._geometry) {
18644        this._geometry.setSymbol(symbol);
18645      }
18646
18647      return this;
18648    };
18649
18650    _proto.getCurrentGeometry = function getCurrentGeometry() {
18651      return this._geometry;
18652    };
18653
18654    _proto.onAdd = function onAdd() {
18655      this._checkMode();
18656    };
18657
18658    _proto.onEnable = function onEnable() {
18659      this._saveMapCfg();
18660
18661      this._drawToolLayer = this._getDrawLayer();
18662
18663      this._clearStage();
18664
18665      this._loadResources();
18666
18667      if (this.options['autoPanAtEdge']) {
18668        var map = this.getMap();
18669        this._mapAutoPanAtEdge = map.options['autoPanAtEdge'];
18670
18671        if (!this._mapAutoPanAtEdge) {
18672          map.config({
18673            autoPanAtEdge: true
18674          });
18675        }
18676      }
18677
18678      return this;
18679    };
18680
18681    _proto.onDisable = function onDisable() {
18682      var map = this.getMap();
18683
18684      this._restoreMapCfg();
18685
18686      this.endDraw();
18687
18688      if (this._map) {
18689        map.removeLayer(this._getDrawLayer());
18690
18691        if (this.options['autoPanAtEdge']) {
18692          if (!this._mapAutoPanAtEdge) {
18693            map.config({
18694              autoPanAtEdge: false
18695            });
18696          }
18697        }
18698      }
18699
18700      return this;
18701    };
18702
18703    _proto.undo = function undo() {
18704      var registerMode = this._getRegisterMode();
18705
18706      var action = registerMode.action;
18707
18708      if (!this._shouldRecordHistory(action) || !this._historyPointer) {
18709        return this;
18710      }
18711
18712      var coords = this._clickCoords.slice(0, --this._historyPointer);
18713
18714      registerMode.update(coords, this._geometry);
18715      return this;
18716    };
18717
18718    _proto.redo = function redo() {
18719      var registerMode = this._getRegisterMode();
18720
18721      var action = registerMode.action;
18722
18723      if (!this._shouldRecordHistory(action) || isNil(this._historyPointer) || this._historyPointer === this._clickCoords.length) {
18724        return this;
18725      }
18726
18727      var coords = this._clickCoords.slice(0, ++this._historyPointer);
18728
18729      registerMode.update(coords, this._geometry);
18730      return this;
18731    };
18732
18733    _proto._shouldRecordHistory = function _shouldRecordHistory(actions) {
18734      return Array.isArray(actions) && actions[0] === 'click' && actions[1] === 'mousemove' && actions[2] === 'dblclick';
18735    };
18736
18737    _proto._checkMode = function _checkMode() {
18738      this._getRegisterMode();
18739    };
18740
18741    _proto._saveMapCfg = function _saveMapCfg() {
18742      var map = this.getMap();
18743      this._mapDoubleClickZoom = map.options['doubleClickZoom'];
18744      map.config({
18745        'doubleClickZoom': this.options['doubleClickZoom']
18746      });
18747
18748      var actions = this._getRegisterMode()['action'];
18749
18750      if (actions.indexOf('mousedown') > -1) {
18751        var _map = this.getMap();
18752
18753        this._mapDraggable = _map.options['draggable'];
18754
18755        _map.config({
18756          'draggable': false
18757        });
18758      }
18759    };
18760
18761    _proto._restoreMapCfg = function _restoreMapCfg() {
18762      var map = this.getMap();
18763      map.config({
18764        'doubleClickZoom': this._mapDoubleClickZoom
18765      });
18766
18767      if (!isNil(this._mapDraggable)) {
18768        map.config('draggable', this._mapDraggable);
18769      }
18770
18771      delete this._mapDraggable;
18772      delete this._mapDoubleClickZoom;
18773    };
18774
18775    _proto._loadResources = function _loadResources() {
18776      var symbol = this.getSymbol();
18777      var resources = getExternalResources(symbol);
18778
18779      if (resources.length > 0) {
18780        this._drawToolLayer._getRenderer().loadResources(resources);
18781      }
18782    };
18783
18784    _proto._getProjection = function _getProjection() {
18785      return this._map.getProjection();
18786    };
18787
18788    _proto._getRegisterMode = function _getRegisterMode() {
18789      var mode = this.getMode();
18790      var registerMode = DrawTool.getRegisterMode(mode);
18791
18792      if (!registerMode) {
18793        throw new Error(mode + ' is not a valid mode of DrawTool.');
18794      }
18795
18796      return registerMode;
18797    };
18798
18799    _proto.getEvents = function getEvents() {
18800      var action = this._getRegisterMode()['action'];
18801
18802      var _events = {};
18803
18804      if (Array.isArray(action)) {
18805        for (var i = 0; i < action.length; i++) {
18806          _events[action[i]] = this._events[action[i]];
18807        }
18808
18809        return _events;
18810      }
18811
18812      return null;
18813    };
18814
18815    _proto._mouseDownHandler = function _mouseDownHandler(event) {
18816      this._createGeometry(event);
18817    };
18818
18819    _proto._mouseUpHandler = function _mouseUpHandler(event) {
18820      this.endDraw(event);
18821    };
18822
18823    _proto._firstClickHandler = function _firstClickHandler(event) {
18824      var registerMode = this._getRegisterMode();
18825
18826      var coordinate = event['coordinate'];
18827
18828      if (!this._geometry) {
18829        this._createGeometry(event);
18830      } else {
18831        if (!isNil(this._historyPointer)) {
18832          this._clickCoords = this._clickCoords.slice(0, this._historyPointer);
18833        }
18834
18835        this._clickCoords.push(coordinate);
18836
18837        this._historyPointer = this._clickCoords.length;
18838        event.drawTool = this;
18839
18840        if (registerMode['clickLimit'] && registerMode['clickLimit'] === this._historyPointer) {
18841          registerMode['update']([coordinate], this._geometry, event);
18842          this.endDraw(event);
18843        } else {
18844          registerMode['update'](this._clickCoords, this._geometry, event);
18845        }
18846
18847        this._fireEvent('drawvertex', event);
18848      }
18849    };
18850
18851    _proto._createGeometry = function _createGeometry(event) {
18852      var mode = this.getMode();
18853
18854      var registerMode = this._getRegisterMode();
18855
18856      var coordinate = event['coordinate'];
18857      var symbol = this.getSymbol();
18858
18859      if (!this._geometry) {
18860        this._clickCoords = [coordinate];
18861        event.drawTool = this;
18862        this._geometry = registerMode['create'](this._clickCoords, event);
18863
18864        if (symbol && mode !== 'point') {
18865          this._geometry.setSymbol(symbol);
18866        } else if (this.options.hasOwnProperty('symbol')) {
18867          this._geometry.setSymbol(this.options['symbol']);
18868        }
18869
18870        this._addGeometryToStage(this._geometry);
18871
18872        this._fireEvent('drawstart', event);
18873      }
18874
18875      if (mode === 'point') {
18876        this.endDraw(event);
18877      }
18878    };
18879
18880    _proto._mouseMoveHandler = function _mouseMoveHandler(event) {
18881      var map = this.getMap();
18882      var coordinate = event['coordinate'];
18883
18884      if (!this._geometry || !map || map.isInteracting()) {
18885        return;
18886      }
18887
18888      var containerPoint = this._getMouseContainerPoint(event);
18889
18890      if (!this._isValidContainerPoint(containerPoint)) {
18891        return;
18892      }
18893
18894      event.drawTool = this;
18895
18896      var registerMode = this._getRegisterMode();
18897
18898      if (this._shouldRecordHistory(registerMode.action)) {
18899        var path = this._clickCoords.slice(0, this._historyPointer);
18900
18901        if (path && path.length > 0 && coordinate.equals(path[path.length - 1])) {
18902          return;
18903        }
18904
18905        registerMode['update'](path.concat([coordinate]), this._geometry, event);
18906      } else {
18907        registerMode['update']([coordinate], this._geometry, event);
18908      }
18909
18910      this._fireEvent('mousemove', event);
18911    };
18912
18913    _proto._doubleClickHandler = function _doubleClickHandler(event) {
18914      if (!this._geometry) {
18915        return;
18916      }
18917
18918      var containerPoint = this._getMouseContainerPoint(event);
18919
18920      if (!this._isValidContainerPoint(containerPoint)) {
18921        return;
18922      }
18923
18924      var registerMode = this._getRegisterMode();
18925
18926      var clickCoords = this._clickCoords;
18927
18928      if (clickCoords.length < 2) {
18929        return;
18930      }
18931
18932      var path = [clickCoords[0]];
18933
18934      for (var i = 1, len = clickCoords.length; i < len; i++) {
18935        if (clickCoords[i].x !== clickCoords[i - 1].x || clickCoords[i].y !== clickCoords[i - 1].y) {
18936          path.push(clickCoords[i]);
18937        }
18938      }
18939
18940      if (path.length < 2 || this._geometry && this._geometry instanceof Polygon && path.length < 3) {
18941        return;
18942      }
18943
18944      event.drawTool = this;
18945      registerMode['update'](path, this._geometry, event);
18946      this.endDraw(event);
18947    };
18948
18949    _proto._addGeometryToStage = function _addGeometryToStage(geometry) {
18950      var drawLayer = this._getDrawLayer();
18951
18952      drawLayer.addGeometry(geometry);
18953    };
18954
18955    _proto.endDraw = function endDraw(param) {
18956      if (!this._geometry || this._ending) {
18957        return this;
18958      }
18959
18960      this._ending = true;
18961      var geometry = this._geometry;
18962
18963      this._clearStage();
18964
18965      param = param || {};
18966      this._geometry = geometry;
18967
18968      this._fireEvent('drawend', param);
18969
18970      delete this._geometry;
18971
18972      if (this.options['once']) {
18973        this.disable();
18974      }
18975
18976      delete this._ending;
18977      return this;
18978    };
18979
18980    _proto._clearStage = function _clearStage() {
18981      this._getDrawLayer().clear();
18982
18983      delete this._geometry;
18984      delete this._clickCoords;
18985    };
18986
18987    _proto._getMouseContainerPoint = function _getMouseContainerPoint(event) {
18988      var action = this._getRegisterMode()['action'];
18989
18990      if (action === 'mousedown') {
18991        stopPropagation(event['domEvent']);
18992      }
18993
18994      return event['containerPoint'];
18995    };
18996
18997    _proto._isValidContainerPoint = function _isValidContainerPoint(containerPoint) {
18998      var mapSize = this._map.getSize();
18999
19000      var w = mapSize['width'],
19001          h = mapSize['height'];
19002
19003      if (containerPoint.x < 0 || containerPoint.y < 0) {
19004        return false;
vendor: 48,882 bytes, lines 19005-20888
19005      } else if (containerPoint.x > w || containerPoint.y > h) {
19006        return false;
19007      }
19008
19009      return true;
19010    };
19011
19012    _proto._getDrawLayer = function _getDrawLayer() {
19013      var drawLayerId = INTERNAL_LAYER_PREFIX + 'drawtool';
19014
19015      var drawToolLayer = this._map.getLayer(drawLayerId);
19016
19017      if (!drawToolLayer) {
19018        drawToolLayer = new VectorLayer(drawLayerId, {
19019          'enableSimplify': false
19020        });
19021
19022        this._map.addLayer(drawToolLayer);
19023      }
19024
19025      return drawToolLayer;
19026    };
19027
19028    _proto._fireEvent = function _fireEvent(eventName, param) {
19029      if (!param) {
19030        param = {};
19031      }
19032
19033      if (this._geometry) {
19034        param['geometry'] = this._getRegisterMode()['generate'](this._geometry, {
19035          drawTool: this
19036        }).copy();
19037      }
19038
19039      MapTool.prototype._fireEvent.call(this, eventName, param);
19040    };
19041
19042    return DrawTool;
19043  }(MapTool);
19044
19045  DrawTool.mergeOptions(options$g);
19046
19047  var MapBoxZoomHander = function (_Handler) {
19048    _inheritsLoose(MapBoxZoomHander, _Handler);
19049
19050    function MapBoxZoomHander(target) {
19051      var _this;
19052
19053      _this = _Handler.call(this, target) || this;
19054      _this.drawTool = new DrawTool({
19055        'mode': 'boxZoom',
19056        'ignoreMouseleave': false
19057      });
19058      return _this;
19059    }
19060
19061    var _proto = MapBoxZoomHander.prototype;
19062
19063    _proto.addHooks = function addHooks() {
19064      this.target.on('_mousedown', this._onMouseDown, this);
19065    };
19066
19067    _proto.removeHooks = function removeHooks() {
19068      this.target.off('_mousedown', this._onMouseDown, this);
19069
19070      if (this.drawTool.isEnabled()) {
19071        this.drawTool.remove();
19072      }
19073    };
19074
19075    _proto._onMouseDown = function _onMouseDown(param) {
19076      if (!this.target.options['boxZoom']) {
19077        return;
19078      }
19079
19080      if (param.domEvent.shiftKey) {
19081        this.drawTool.setSymbol(this.target.options['boxZoomSymbol']).on('drawend', this._boxZoom, this).addTo(this.target);
19082      }
19083    };
19084
19085    _proto._boxZoom = function _boxZoom(param) {
19086      var map = this.target;
19087      this.drawTool.remove();
19088      var geometry = param.geometry,
19089          center = geometry.getCenter(),
19090          symbol = geometry.getSymbol(),
19091          w = symbol.markerWidth,
19092          h = symbol.markerHeight;
19093      var extent = new Extent(center, map.locateByPoint(center, w, h), map.getProjection());
19094      var zoom = map.getFitZoom(extent);
19095
19096      map._animateTo({
19097        center: extent.getCenter(),
19098        zoom: zoom
19099      });
19100    };
19101
19102    return MapBoxZoomHander;
19103  }(Handler$1);
19104
19105  Map$1.mergeOptions({
19106    'boxZoom': true,
19107    'boxZoomSymbol': {
19108      'markerType': 'rectangle',
19109      'markerLineWidth': 3,
19110      'markerLineColor': '#1bbc9b',
19111      'markerLineDasharray': [10, 5],
19112      'markerFillOpacity': 0.1,
19113      'markerFill': '#1bbc9b',
19114      'markerWidth': 1,
19115      'markerHeight': 1
19116    }
19117  });
19118  Map$1.addOnLoadHook('addHandler', 'boxZoom', MapBoxZoomHander);
19119
19120  var PANOFFSET = 30;
19121
19122  var MapAutoPanAtEdgeHandler = function (_Handler) {
19123    _inheritsLoose(MapAutoPanAtEdgeHandler, _Handler);
19124
19125    function MapAutoPanAtEdgeHandler() {
19126      return _Handler.apply(this, arguments) || this;
19127    }
19128
19129    var _proto = MapAutoPanAtEdgeHandler.prototype;
19130
19131    _proto.addHooks = function addHooks() {
19132      if (!this.target) {
19133        return;
19134      }
19135
19136      this.target.on('_mousemove', this._onMouseMove, this);
19137    };
19138
19139    _proto.removeHooks = function removeHooks() {
19140      if (!this.target) {
19141        return;
19142      }
19143
19144      this.target.off('_mousemove', this._onMouseMove, this);
19145    };
19146
19147    _proto._onMouseMove = function _onMouseMove(event) {
19148      var map = this.target;
19149
19150      if (map.options['autoPanAtEdge']) {
19151        var containerPoint = event.containerPoint;
19152        var containerExtent = map.getContainerExtent();
19153
19154        if (containerExtent) {
19155          var x = containerPoint.x,
19156              y = containerPoint.y;
19157          var xmax = containerExtent.xmax,
19158              ymax = containerExtent.ymax;
19159          var p;
19160
19161          if (x < PANOFFSET) {
19162            p = [Math.abs(x - PANOFFSET), 0];
19163          }
19164
19165          if (y < PANOFFSET) {
19166            p = [0, Math.abs(y - PANOFFSET)];
19167          }
19168
19169          if (x + PANOFFSET > xmax) {
19170            p = [-Math.abs(x + PANOFFSET - xmax), 0];
19171          }
19172
19173          if (y + PANOFFSET > ymax) {
19174            p = [0, -Math.abs(y + PANOFFSET - ymax)];
19175          }
19176
19177          if (p) {
19178            map.panBy(p, {
19179              duration: 1
19180            });
19181          }
19182        }
19183      }
19184    };
19185
19186    return MapAutoPanAtEdgeHandler;
19187  }(Handler$1);
19188
19189  Map$1.mergeOptions({
19190    'autoPanAtEdge': false
19191  });
19192  Map$1.addOnLoadHook('addHandler', 'autoPanAtEdge', MapAutoPanAtEdgeHandler);
19193
19194  Map$1.include({
19195    animateTo: function animateTo(view, options, step) {
19196      var _this = this;
19197
19198      if (options === void 0) {
19199        options = {};
19200      }
19201
19202      if (isFunction(options)) {
19203        step = options;
19204        options = {};
19205      }
19206
19207      var projection = this.getProjection(),
19208          currView = this.getView(),
19209          props = {};
19210      var empty = true;
19211
19212      for (var p in view) {
19213        if (hasOwn(view, p) && (p === 'prjCenter' || !isNil(currView[p]))) {
19214          empty = false;
19215
19216          if (p === 'center') {
19217            var from = new Coordinate(currView[p]).toFixed(7),
19218                to = new Coordinate(view[p]).toFixed(7);
19219
19220            if (!from.equals(to)) {
19221              props['center'] = [from, to];
19222            }
19223          } else if (p === 'prjCenter') {
19224            var _from = new Coordinate(this._getPrjCenter());
19225
19226            var _to = new Coordinate(view[p]);
19227
19228            if (!_from.equals(_to)) {
19229              props['prjCenter'] = [_from, _to];
19230            }
19231          } else if (currView[p] !== view[p] && p !== 'around') {
19232            props[p] = [currView[p], view[p]];
19233          }
19234        }
19235      }
19236
19237      if (empty) {
19238        return null;
19239      }
19240
19241      if (this._animPlayer) {
19242        if (this._isInternalAnimation) {
19243          this._animPlayer.pause();
19244
19245          this._prevAnimPlayer = this._animPlayer;
19246        } else {
19247          delete this._prevAnimPlayer;
19248
19249          this._stopAnim(this._animPlayer);
19250        }
19251      }
19252
19253      var zoomOrigin = view['around'] || new Point(this.width / 2, this.height / 2);
19254
19255      var renderer = this._getRenderer(),
19256          framer = function framer(fn) {
19257        renderer.callInNextFrame(fn);
19258      };
19259
19260      var player = this._animPlayer = Animation.animate(props, {
19261        'easing': options['easing'] || 'out',
19262        'duration': options['duration'] || this.options['zoomAnimationDuration'],
19263        'framer': framer
19264      }, function (frame) {
19265        if (_this.isRemoved()) {
19266          player.finish();
19267          return;
19268        }
19269
19270        if (player.playState === 'running') {
19271          if (frame.styles['center']) {
19272            var center = frame.styles['center'];
19273
19274            _this._setPrjCenter(projection.project(center));
19275
19276            _this.onMoving(_this._parseEventFromCoord(_this.getCenter()));
19277          } else if (frame.styles['prjCenter']) {
19278            var _center = frame.styles['prjCenter'];
19279
19280            _this._setPrjCenter(_center);
19281
19282            _this.onMoving(_this._parseEventFromCoord(_this.getCenter()));
19283          }
19284
19285          if (!isNil(frame.styles['zoom'])) {
19286            _this.onZooming(frame.styles['zoom'], zoomOrigin);
19287          }
19288
19289          if (!isNil(frame.styles['pitch'])) {
19290            _this.setPitch(frame.styles['pitch']);
19291          }
19292
19293          if (!isNil(frame.styles['bearing'])) {
19294            _this.setBearing(frame.styles['bearing']);
19295          }
19296
19297          _this._fireEvent('animating');
19298        } else if (player.playState === 'finished') {
19299          if (!player._interupted) {
19300            if (props['center']) {
19301              _this._setPrjCenter(projection.project(props['center'][1]));
19302            } else if (props['prjCenter']) {
19303              _this._setPrjCenter(props['prjCenter'][1]);
19304            }
19305
19306            if (!isNil(props['pitch'])) {
19307              _this.setPitch(props['pitch'][1]);
19308            }
19309
19310            if (!isNil(props['bearing'])) {
19311              _this.setBearing(props['bearing'][1]);
19312            }
19313          }
19314
19315          _this._endAnim(player, props, zoomOrigin, options);
19316        }
19317
19318        if (step) {
19319          step(frame);
19320        }
19321      });
19322
19323      this._startAnim(props, zoomOrigin);
19324
19325      return player;
19326    },
19327    _animateTo: function _animateTo(view, options, step) {
19328      if (options === void 0) {
19329        options = {};
19330      }
19331
19332      if (this._mapAnimPlayer) {
19333        this._stopAnim(this._mapAnimPlayer);
19334      }
19335
19336      this._isInternalAnimation = true;
19337      this._mapAnimPlayer = this.animateTo(view, options, step);
19338      delete this._isInternalAnimation;
19339      return this._mapAnimPlayer;
19340    },
19341    isAnimating: function isAnimating() {
19342      return !!this._animPlayer;
19343    },
19344    isRotating: function isRotating() {
19345      return this.isDragRotating() || !!this._animRotating;
19346    },
19347    _endAnim: function _endAnim(player, props, zoomOrigin, options) {
19348      delete this._animRotating;
19349      var evtType = player._interupted ? 'animateinterrupted' : 'animateend';
19350
19351      if (player === this._animPlayer) {
19352        delete this._animPlayer;
19353      }
19354
19355      if (player === this._mapAnimPlayer) {
19356        delete this._mapAnimPlayer;
19357      }
19358
19359      if (props['center']) {
19360        var endCoord;
19361
19362        if (player._interupted) {
19363          endCoord = this.getCenter();
19364        } else {
19365          endCoord = props['center'][1];
19366        }
19367
19368        this.onMoveEnd(this._parseEventFromCoord(endCoord));
19369      } else if (props['prjCenter']) {
19370        var _endCoord;
19371
19372        if (player._interupted) {
19373          _endCoord = this._getPrjCenter();
19374        } else {
19375          _endCoord = props['prjCenter'][1];
19376        }
19377
19378        var event = this._parseEventFromCoord(this.getProjection().unproject(_endCoord));
19379
19380        event['point2d'] = this._prjToPoint(_endCoord);
19381        this.onMoveEnd(event);
19382      }
19383
19384      if (!isNil(props['zoom'])) {
19385        if (player._interupted) {
19386          this.onZoomEnd(this.getZoom(), zoomOrigin);
19387        } else if (!options['wheelZoom']) {
19388          this.onZoomEnd(props['zoom'][1], zoomOrigin);
19389        } else {
19390          this.onZooming(props['zoom'][1], zoomOrigin);
19391        }
19392      }
19393
19394      if (evtType) {
19395        this._fireEvent(evtType);
19396      }
19397
19398      if (!isNil(props['pitch']) && !this.getPitch()) {
19399        this.getRenderer().setToRedraw();
19400      }
19401
19402      if (this._prevAnimPlayer) {
19403        this._animPlayer = this._prevAnimPlayer;
19404
19405        this._prevAnimPlayer.play();
19406      }
19407    },
19408    _startAnim: function _startAnim(props, zoomOrigin) {
19409      if (!this._animPlayer) {
19410        return;
19411      }
19412
19413      if (props['center']) {
19414        this.onMoveStart();
19415      }
19416
19417      if (props['zoom'] && !this.isZooming()) {
19418        this.onZoomStart(props['zoom'][1], zoomOrigin);
19419      }
19420
19421      if (props['pitch'] || props['bearing']) {
19422        this._animRotating = true;
19423      }
19424
19425      this._fireEvent('animatestart');
19426
19427      this._animPlayer.play();
19428    },
19429    _stopAnim: function _stopAnim(player) {
19430      if (!player) {
19431        return;
19432      }
19433
19434      if (player.playState !== 'finished') {
19435        player._interupted = true;
19436        player.cancel();
19437      }
19438
19439      if (player === this._animPlayer && this._prevAnimPlayer) {
19440        this._animPlayer = this._prevAnimPlayer;
19441
19442        this._prevAnimPlayer.play();
19443      }
19444
19445      if (player === this._animPlayer) {
19446        delete this._animPlayer;
19447      }
19448
19449      if (player === this._mapAnimPlayer) {
19450        delete this._mapAnimPlayer;
19451      }
19452    }
19453  });
19454
19455  var events = 'mousedown ' + 'mouseup ' + 'mouseover ' + 'mouseout ' + 'mouseenter ' + 'mouseleave ' + 'mousemove ' + 'click ' + 'dblclick ' + 'contextmenu ' + 'keypress ' + 'touchstart ' + 'touchmove ' + 'touchend ';
19456  Map$1.include({
19457    _registerDomEvents: function _registerDomEvents() {
19458      var dom = this._panels.mapWrapper || this._containerDOM;
19459      addDomEvent(dom, events, this._handleDOMEvent, this);
19460    },
19461    _removeDomEvents: function _removeDomEvents() {
19462      var dom = this._panels.mapWrapper || this._containerDOM;
19463      removeDomEvent(dom, events, this._handleDOMEvent, this);
19464    },
19465    _handleDOMEvent: function _handleDOMEvent(e) {
19466      var type = e.type;
19467
19468      if (type === 'contextmenu') {
19469        preventDefault(e);
19470      }
19471
19472      if (this._ignoreEvent(e)) {
19473        return;
19474      }
19475
19476      var mimicClick = false;
19477
19478      if (type === 'mousedown' || type === 'touchstart' && e.touches.length === 1) {
19479        this._mouseDownTime = now();
19480      } else if (type === 'click' || type === 'touchend' || type === 'contextmenu') {
19481        if (!this._mouseDownTime) {
19482          return;
19483        } else {
19484          var downTime = this._mouseDownTime;
19485          delete this._mouseDownTime;
19486          var time = now();
19487
19488          if (time - downTime > 300) {
19489            if (type === 'click' || type === 'contextmenu') {
19490              return;
19491            }
19492          } else if (type === 'touchend') {
19493            mimicClick = true;
19494          }
19495        }
19496      }
19497
19498      this._fireDOMEvent(this, e, type);
19499
19500      if (mimicClick) {
19501        if (this._clickTime && now() - this._clickTime <= 300) {
19502          delete this._clickTime;
19503
19504          this._fireDOMEvent(this, e, 'dblclick');
19505        } else {
19506          this._clickTime = now();
19507
19508          this._fireDOMEvent(this, e, 'click');
19509        }
19510      }
19511    },
19512    _ignoreEvent: function _ignoreEvent(domEvent) {
19513      if (!domEvent || !this._panels.control) {
19514        return false;
19515      }
19516
19517      if (this._isEventOutMap(domEvent)) {
19518        return true;
19519      }
19520
19521      var target = domEvent.srcElement || domEvent.target;
19522      var preTarget;
19523
19524      if (target) {
19525        while (target && target !== this._containerDOM) {
19526          if (target.className && target.className.indexOf && (target.className.indexOf('maptalks-control') >= 0 || target.className.indexOf('maptalks-ui') >= 0 && !preTarget['eventsPropagation'])) {
19527            return true;
19528          }
19529
19530          preTarget = target;
19531          target = target.parentNode;
19532        }
19533      }
19534
19535      return false;
19536    },
19537    _isEventOutMap: function _isEventOutMap(domEvent) {
19538      if (this.getPitch() > this.options['maxVisualPitch']) {
19539        var actualEvent = this._getActualEvent(domEvent);
19540
19541        var eventPos = getEventContainerPoint(actualEvent, this._containerDOM);
19542
19543        if (!this.getContainerExtent().contains(eventPos)) {
19544          return true;
19545        }
19546      }
19547
19548      return false;
19549    },
19550    _parseEvent: function _parseEvent(e, type) {
19551      if (!e) {
19552        return null;
19553      }
19554
19555      var eventParam = {
19556        'domEvent': e
19557      };
19558
19559      if (type !== 'keypress') {
19560        var actual = this._getActualEvent(e);
19561
19562        if (actual) {
19563          var containerPoint = getEventContainerPoint(actual, this._containerDOM);
19564          eventParam = extend(eventParam, {
19565            'coordinate': this.containerPointToCoord(containerPoint),
19566            'containerPoint': containerPoint,
19567            'viewPoint': this.containerPointToViewPoint(containerPoint),
19568            'point2d': this._containerPointToPoint(containerPoint)
19569          });
19570        }
19571      }
19572
19573      return eventParam;
19574    },
19575    _parseEventFromCoord: function _parseEventFromCoord(coord) {
19576      var containerPoint = this.coordToContainerPoint(coord),
19577          viewPoint = this.containerPointToViewPoint(containerPoint);
19578      var e = {
19579        'coordinate': coord,
19580        'containerPoint': containerPoint,
19581        'viewPoint': viewPoint,
19582        'point2d': this.coordToPoint(coord)
19583      };
19584      return e;
19585    },
19586    _getActualEvent: function _getActualEvent(e) {
19587      return e.touches && e.touches.length > 0 ? e.touches[0] : e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches[0] : e;
19588    },
19589    _fireDOMEvent: function _fireDOMEvent(target, e, type) {
19590      if (this.isRemoved()) {
19591        return;
19592      }
19593
19594      var eventParam = this._parseEvent(e, type);
19595
19596      this._fireEvent(type, eventParam);
19597    }
19598  });
19599  Map$1.addOnLoadHook('_registerDomEvents');
19600
19601  Map$1.include({
19602    isFullScreen: function isFullScreen() {
19603      return !!(document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement);
19604    },
19605    requestFullScreen: function requestFullScreen(dom) {
19606      this._fireEvent('fullscreenstart');
19607
19608      this._requestFullScreen(dom || this._containerDOM);
19609
19610      this._fireEvent('fullscreenend');
19611
19612      return this;
19613    },
19614    cancelFullScreen: function cancelFullScreen() {
19615      this._cancelFullScreen();
19616
19617      this._fireEvent('cancelfullscreen');
19618
19619      return this;
19620    },
19621    _requestFullScreen: function _requestFullScreen(dom) {
19622      if (dom.requestFullScreen) {
19623        dom.requestFullScreen();
19624      } else if (dom.mozRequestFullScreen) {
19625        dom.mozRequestFullScreen();
19626      } else if (dom.webkitRequestFullScreen) {
19627        dom.webkitRequestFullScreen();
19628      } else if (dom.msRequestFullScreen) {
19629        dom.msRequestFullScreen();
19630      } else {
19631        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);
19632        var newWin = window.open(location.href, '_blank', features);
19633
19634        if (newWin !== null) {
19635          window.opener = null;
19636          window.close();
19637        }
19638      }
19639    },
19640    _cancelFullScreen: function _cancelFullScreen() {
19641      if (document.cancelFullScreen) {
19642        document.cancelFullScreen();
19643      } else if (document.mozCancelFullScreen) {
19644        document.mozCancelFullScreen();
19645      } else if (document.webkitCancelFullScreen) {
19646        document.webkitCancelFullScreen();
19647      } else {
19648        var features = 'fullscreen=no,status=yes,resizable=yes,scrollbars=no,' + 'titlebar=no,menubar=yes,location=yes,toolbar=yes,z-look=yes';
19649        var newWin = window.open(location.href, '_blank', features);
19650
19651        if (newWin !== null) {
19652          window.opener = null;
19653          window.close();
19654        }
19655      }
19656    }
19657  });
19658
19659  Map$1.include({
19660    panTo: function panTo(coordinate, options, step) {
19661      if (options === void 0) {
19662        options = {};
19663      }
19664
19665      if (!coordinate) {
19666        return this;
19667      }
19668
19669      if (isFunction(options)) {
19670        step = options;
19671        options = {};
19672      }
19673
19674      coordinate = new Coordinate(coordinate);
19675
19676      if (typeof options['animation'] === 'undefined' || options['animation']) {
19677        var prjCoord = this.getProjection().project(coordinate);
19678        return this._panAnimation(prjCoord, options['duration'], step);
19679      } else {
19680        this.setCenter(coordinate);
19681      }
19682
19683      return this;
19684    },
19685    _panTo: function _panTo(prjCoord, options) {
19686      if (options === void 0) {
19687        options = {};
19688      }
19689
19690      if (typeof options['animation'] === 'undefined' || options['animation']) {
19691        return this._panAnimation(prjCoord, options['duration']);
19692      } else {
19693        this.onMoveStart();
19694
19695        this._setPrjCenter(prjCoord);
19696
19697        this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));
19698        return this;
19699      }
19700    },
19701    panBy: function panBy(offset, options, step) {
19702      if (options === void 0) {
19703        options = {};
19704      }
19705
19706      if (!offset) {
19707        return this;
19708      }
19709
19710      if (isFunction(options)) {
19711        step = options;
19712        options = {};
19713      }
19714
19715      offset = new Point(offset);
19716      this.onMoveStart();
19717
19718      if (typeof options['animation'] === 'undefined' || options['animation']) {
19719        offset = offset.multi(-1);
19720
19721        var target = this._containerPointToPrj(new Point(this.width / 2 + offset.x, this.height / 2 + offset.y));
19722
19723        this._panAnimation(target, options['duration'], step);
19724      } else {
19725        this._offsetCenterByPixel(offset);
19726
19727        this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));
19728      }
19729
19730      return this;
19731    },
19732    _panAnimation: function _panAnimation(target, t, cb) {
19733      return this._animateTo({
19734        'prjCenter': target
19735      }, {
19736        'duration': t || this.options['panAnimationDuration']
19737      }, cb);
19738    }
19739  });
19740
19741  Geometry.fromJSON = function (json) {
19742    if (Array.isArray(json)) {
19743      var result = [];
19744
19745      for (var i = 0, len = json.length; i < len; i++) {
19746        var c = Geometry.fromJSON(json[i]);
19747
19748        if (Array.isArray(json)) {
19749          result = result.concat(c);
19750        } else {
19751          result.push(c);
19752        }
19753      }
19754
19755      return result;
19756    }
19757
19758    if (json && !json['feature']) {
19759      return GeoJSON.toGeometry(json);
19760    }
19761
19762    var geometry;
19763
19764    if (json['subType']) {
19765      geometry = Geometry.getJSONClass(json['subType']).fromJSON(json);
19766
19767      if (!isNil(json['feature']['id'])) {
19768        geometry.setId(json['feature']['id']);
19769      }
19770    } else {
19771      geometry = GeoJSON.toGeometry(json['feature']);
19772
19773      if (json['options']) {
19774        geometry.config(json['options']);
19775      }
19776    }
19777
19778    if (json['symbol']) {
19779      geometry.setSymbol(json['symbol']);
19780    }
19781
19782    if (json['infoWindow']) {
19783      geometry.setInfoWindow(json['infoWindow']);
19784    }
19785
19786    return geometry;
19787  };
19788
19789  Layer.fromJSON = function (layerJSON) {
19790    if (!layerJSON) {
19791      return null;
19792    }
19793
19794    var layerType = layerJSON['type'];
19795    var clazz = Layer.getJSONClass(layerType);
19796
19797    if (!clazz || !clazz.fromJSON) {
19798      throw new Error('unsupported layer type:' + layerType);
19799    }
19800
19801    return clazz.fromJSON(layerJSON);
19802  };
19803
19804  Map$1.include({
19805    'JSON_VERSION': '1.0',
19806    toJSON: function toJSON(options) {
19807      if (!options) {
19808        options = {};
19809      }
19810
19811      var json = {
19812        'jsonVersion': this['JSON_VERSION'],
19813        'version': this.VERSION,
19814        'extent': this.getExtent().toJSON()
19815      };
19816      json['options'] = this.config();
19817      json['options']['center'] = this.getCenter();
19818      json['options']['zoom'] = this.getZoom();
19819      var baseLayer = this.getBaseLayer();
19820
19821      if ((isNil(options['baseLayer']) || options['baseLayer']) && baseLayer) {
19822        json['baseLayer'] = baseLayer.toJSON(options['baseLayer']);
19823      }
19824
19825      var extraLayerOptions = {};
19826
19827      if (options['clipExtent']) {
19828        if (options['clipExtent'] === true) {
19829          extraLayerOptions['clipExtent'] = this.getExtent();
19830        } else {
19831          extraLayerOptions['clipExtent'] = options['clipExtent'];
19832        }
19833      }
19834
19835      var layersJSON = [];
19836
19837      if (isNil(options['layers']) || options['layers'] && !Array.isArray(options['layers'])) {
19838        var layers = this.getLayers();
19839
19840        for (var i = 0, len = layers.length; i < len; i++) {
19841          if (!layers[i].toJSON) {
19842            continue;
19843          }
19844
19845          var opts = extend({}, isObject(options['layers']) ? options['layers'] : {}, extraLayerOptions);
19846          layersJSON.push(layers[i].toJSON(opts));
19847        }
19848
19849        json['layers'] = layersJSON;
19850      } else if (isArrayHasData(options['layers'])) {
19851        var _layers = options['layers'];
19852
19853        for (var _i = 0; _i < _layers.length; _i++) {
19854          var exportOption = _layers[_i];
19855          var layer = this.getLayer(exportOption['id']);
19856
19857          if (!layer.toJSON) {
19858            continue;
19859          }
19860
19861          var _opts = extend({}, exportOption['options'], extraLayerOptions);
19862
19863          layersJSON.push(layer.toJSON(_opts));
19864        }
19865
19866        json['layers'] = layersJSON;
19867      } else {
19868        json['layers'] = [];
19869      }
19870
19871      return json;
19872    }
19873  });
19874
19875  Map$1.fromJSON = function (container, profile, options) {
19876    if (!container || !profile) {
19877      return null;
19878    }
19879
19880    if (!options) {
19881      options = {};
19882    }
19883
19884    var map = new Map$1(container, profile['options']);
19885
19886    if (isNil(options['baseLayer']) || options['baseLayer']) {
19887      var baseLayer = Layer.fromJSON(profile['baseLayer']);
19888
19889      if (baseLayer) {
19890        map.setBaseLayer(baseLayer);
19891      }
19892    }
19893
19894    if (isNil(options['layers']) || options['layers']) {
19895      var layers = [];
19896      var layerJSONs = profile['layers'];
19897
19898      for (var i = 0; i < layerJSONs.length; i++) {
19899        var layer = Layer.fromJSON(layerJSONs[i]);
19900        layers.push(layer);
19901      }
19902
19903      map.addLayer(layers);
19904    }
19905
19906    return map;
19907  };
19908
19909  Map$1.include({
19910    computeLength: function computeLength(coord1, coord2) {
19911      if (!this.getProjection()) {
19912        return null;
19913      }
19914
19915      var p1 = new Coordinate(coord1),
19916          p2 = new Coordinate(coord2);
19917
19918      if (p1.equals(p2)) {
19919        return 0;
19920      }
19921
19922      return this.getProjection().measureLength(p1, p2);
19923    },
19924    computeGeometryLength: function computeGeometryLength(geometry) {
19925      return geometry._computeGeodesicLength(this.getProjection());
19926    },
19927    computeGeometryArea: function computeGeometryArea(geometry) {
19928      return geometry._computeGeodesicArea(this.getProjection());
19929    },
19930    identify: function identify(opts, callback) {
19931      if (!opts) {
19932        return this;
19933      }
19934
19935      var reqLayers = opts['layers'];
19936
19937      if (!isArrayHasData(reqLayers)) {
19938        return this;
19939      }
19940
19941      var layers = [];
19942
19943      for (var i = 0, len = reqLayers.length; i < len; i++) {
19944        if (isString(reqLayers[i])) {
19945          layers.push(this.getLayer(reqLayers[i]));
19946        } else {
19947          layers.push(reqLayers[i]);
19948        }
19949      }
19950
19951      var coordinate = new Coordinate(opts['coordinate']);
19952      var options = extend({}, opts);
19953      var hits = [];
19954
19955      for (var _i = layers.length - 1; _i >= 0; _i--) {
19956        if (opts['count'] && hits.length >= opts['count']) {
19957          break;
19958        }
19959
19960        var layer = layers[_i];
19961
19962        if (!layer || !layer.getMap() || !opts['includeInvisible'] && !layer.isVisible() || !opts['includeInternals'] && layer.getId().indexOf(INTERNAL_LAYER_PREFIX) >= 0) {
19963          continue;
19964        }
19965
19966        var layerHits = layer.identify(coordinate, options);
19967
19968        if (layerHits) {
19969          if (Array.isArray(layerHits)) {
19970            pushIn(hits, layerHits);
19971          } else {
19972            hits.push(layerHits);
19973          }
19974        }
19975      }
19976
19977      callback.call(this, hits);
19978      return this;
19979    }
19980  });
19981
19982  Map$1.include({
19983    _zoom: function _zoom(nextZoom, origin) {
19984      if (!this.options['zoomable'] || this.isZooming()) {
19985        return;
19986      }
19987
19988      origin = this._checkZoomOrigin(origin);
19989      nextZoom = this._checkZoom(nextZoom);
19990      this.onZoomStart(nextZoom, origin);
19991      this._frameZoom = this.getZoom();
19992      this.onZoomEnd(nextZoom, origin);
19993    },
19994    _zoomAnimation: function _zoomAnimation(nextZoom, origin, startScale) {
19995      if (!this.options['zoomable'] || this.isZooming()) {
19996        return;
19997      }
19998
19999      nextZoom = this._checkZoom(nextZoom);
20000
20001      if (this.getZoom() === nextZoom) {
20002        return;
20003      }
20004
20005      origin = this._checkZoomOrigin(origin);
20006
20007      this._startZoomAnim(nextZoom, origin, startScale);
20008    },
20009    _checkZoomOrigin: function _checkZoomOrigin(origin) {
20010      if (!origin || this.options['zoomInCenter']) {
20011        origin = new Point(this.width / 2, this.height / 2);
20012      }
20013
20014      if (this.options['zoomOrigin']) {
20015        origin = new Point(this.options['zoomOrigin']);
20016      }
20017
20018      return origin;
20019    },
20020    _startZoomAnim: function _startZoomAnim(nextZoom, origin, startScale) {
20021      if (isNil(startScale)) {
20022        startScale = 1;
20023      }
20024
20025      var endScale = this._getResolution(this._startZoomVal) / this._getResolution(nextZoom);
20026
20027      var duration = this.options['zoomAnimationDuration'] * Math.abs(endScale - startScale) / Math.abs(endScale - 1);
20028      this._frameZoom = this._startZoomVal;
20029
20030      this._animateTo({
20031        'zoom': nextZoom,
20032        'around': origin
20033      }, {
20034        'continueOnViewChanged': true,
20035        'duration': duration
20036      });
20037    },
20038    onZoomStart: function onZoomStart(nextZoom, origin) {
20039      if (!this.options['zoomable'] || this.isZooming()) {
20040        return;
20041      }
20042
20043      if (this._mapAnimPlayer) {
20044        this._stopAnim(this._mapAnimPlayer);
20045      }
20046
20047      this._zooming = true;
20048      this._startZoomVal = this.getZoom();
20049      this._startZoomCoord = this._containerPointToPrj(origin);
20050
20051      this._fireEvent('zoomstart', {
20052        'from': this._startZoomVal,
20053        'to': nextZoom
20054      });
20055    },
20056    onZooming: function onZooming(nextZoom, origin, startScale) {
20057      if (!this.options['zoomable']) {
20058        return;
20059      }
20060
20061      var frameZoom = this._frameZoom;
20062
20063      if (frameZoom === nextZoom) {
20064        return;
20065      }
20066
20067      if (isNil(startScale)) {
20068        startScale = 1;
20069      }
20070
20071      this._zoomTo(nextZoom, origin);
20072
20073      var res = this.getResolution(nextZoom),
20074          fromRes = this.getResolution(this._startZoomVal),
20075          scale = fromRes / res / startScale,
20076          startPoint = this._prjToContainerPoint(this._startZoomCoord, this._startZoomVal);
20077
20078      var offset = this.getViewPoint();
20079
20080      if (!this.isRotating() && !startPoint.equals(origin) && scale !== 1) {
20081        var pitch = this.getPitch();
20082
20083        var originOffset = startPoint._sub(origin)._multi(1 / (1 - scale));
20084
20085        if (pitch) {
20086          originOffset.y /= Math.cos(pitch * Math.PI / 180);
20087        }
20088
20089        origin = origin.add(originOffset);
20090      }
20091
20092      var matrix = {
20093        'view': [scale, 0, 0, scale, (origin.x - offset.x) * (1 - scale), (origin.y - offset.y) * (1 - scale)]
20094      };
20095      var dpr = this.getDevicePixelRatio();
20096
20097      if (dpr !== 1) {
20098        origin = origin.multi(dpr);
20099      }
20100
20101      matrix['container'] = [scale, 0, 0, scale, origin.x * (1 - scale), origin.y * (1 - scale)];
20102
20103      this._fireEvent('zooming', {
20104        'from': this._startZoomVal,
20105        'to': nextZoom,
20106        'origin': origin,
20107        'matrix': matrix
20108      });
20109
20110      this._frameZoom = nextZoom;
20111    },
20112    onZoomEnd: function onZoomEnd(nextZoom, origin) {
20113      if (!this.options['zoomable']) {
20114        return;
20115      }
20116
20117      var startZoomVal = this._startZoomVal;
20118
20119      this._zoomTo(nextZoom, origin);
20120
20121      this._zooming = false;
20122
20123      this._getRenderer().onZoomEnd();
20124
20125      this._fireEvent('zoomend', {
20126        'from': startZoomVal,
20127        'to': nextZoom
20128      });
20129
20130      if (!this._verifyExtent(this._getPrjCenter())) {
20131        this._panTo(this._prjMaxExtent.getCenter());
20132      }
20133    },
20134    _zoomTo: function _zoomTo(nextZoom, origin) {
20135      this._zoomLevel = nextZoom;
20136
20137      this._calcMatrices();
20138
20139      if (origin) {
20140        this._setPrjCoordAtContainerPoint(this._startZoomCoord, origin);
20141      }
20142    },
20143    _checkZoom: function _checkZoom(nextZoom) {
20144      var maxZoom = this.getMaxZoom(),
20145          minZoom = this.getMinZoom();
20146
20147      if (nextZoom < minZoom) {
20148        nextZoom = minZoom;
20149      }
20150
20151      if (nextZoom > maxZoom) {
20152        nextZoom = maxZoom;
20153      }
20154
20155      return nextZoom;
20156    }
20157  });
20158
20159  function perspective(out, fovy, aspect, near, far) {
20160    var f = 1.0 / Math.tan(fovy / 2),
20161        nf = 1 / (near - far);
20162    out[0] = f / aspect;
20163    out[1] = 0;
20164    out[2] = 0;
20165    out[3] = 0;
20166    out[4] = 0;
20167    out[5] = f;
20168    out[6] = 0;
20169    out[7] = 0;
20170    out[8] = 0;
20171    out[9] = 0;
20172    out[10] = (far + near) * nf;
20173    out[11] = -1;
20174    out[12] = 0;
20175    out[13] = 0;
20176    out[14] = 2 * far * near * nf;
20177    out[15] = 0;
20178    return out;
20179  }
20180  function translate(out, a, v) {
20181    var x = v[0],
20182        y = v[1],
20183        z = v[2],
20184        a00,
20185        a01,
20186        a02,
20187        a03,
20188        a10,
20189        a11,
20190        a12,
20191        a13,
20192        a20,
20193        a21,
20194        a22,
20195        a23;
20196
20197    if (a === out) {
20198      out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
20199      out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
20200      out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
20201      out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
20202    } else {
20203      a00 = a[0];
20204      a01 = a[1];
20205      a02 = a[2];
20206      a03 = a[3];
20207      a10 = a[4];
20208      a11 = a[5];
20209      a12 = a[6];
20210      a13 = a[7];
20211      a20 = a[8];
20212      a21 = a[9];
20213      a22 = a[10];
20214      a23 = a[11];
20215      out[0] = a00;
20216      out[1] = a01;
20217      out[2] = a02;
20218      out[3] = a03;
20219      out[4] = a10;
20220      out[5] = a11;
20221      out[6] = a12;
20222      out[7] = a13;
20223      out[8] = a20;
20224      out[9] = a21;
20225      out[10] = a22;
20226      out[11] = a23;
20227      out[12] = a00 * x + a10 * y + a20 * z + a[12];
20228      out[13] = a01 * x + a11 * y + a21 * z + a[13];
20229      out[14] = a02 * x + a12 * y + a22 * z + a[14];
20230      out[15] = a03 * x + a13 * y + a23 * z + a[15];
20231    }
20232
20233    return out;
20234  }
20235  function scale(out, a, v) {
20236    var x = v[0],
20237        y = v[1],
20238        z = v[2];
20239    out[0] = a[0] * x;
20240    out[1] = a[1] * x;
20241    out[2] = a[2] * x;
20242    out[3] = a[3] * x;
20243    out[4] = a[4] * y;
20244    out[5] = a[5] * y;
20245    out[6] = a[6] * y;
20246    out[7] = a[7] * y;
20247    out[8] = a[8] * z;
20248    out[9] = a[9] * z;
20249    out[10] = a[10] * z;
20250    out[11] = a[11] * z;
20251    out[12] = a[12];
20252    out[13] = a[13];
20253    out[14] = a[14];
20254    out[15] = a[15];
20255    return out;
20256  }
20257  function rotateX(out, a, rad) {
20258    var s = Math.sin(rad),
20259        c = Math.cos(rad),
20260        a10 = a[4],
20261        a11 = a[5],
20262        a12 = a[6],
20263        a13 = a[7],
20264        a20 = a[8],
20265        a21 = a[9],
20266        a22 = a[10],
20267        a23 = a[11];
20268
20269    if (a !== out) {
20270      out[0] = a[0];
20271      out[1] = a[1];
20272      out[2] = a[2];
20273      out[3] = a[3];
20274      out[12] = a[12];
20275      out[13] = a[13];
20276      out[14] = a[14];
20277      out[15] = a[15];
20278    }
20279
20280    out[4] = a10 * c + a20 * s;
20281    out[5] = a11 * c + a21 * s;
20282    out[6] = a12 * c + a22 * s;
20283    out[7] = a13 * c + a23 * s;
20284    out[8] = a20 * c - a10 * s;
20285    out[9] = a21 * c - a11 * s;
20286    out[10] = a22 * c - a12 * s;
20287    out[11] = a23 * c - a13 * s;
20288    return out;
20289  }
20290  function rotateZ(out, a, rad) {
20291    var s = Math.sin(rad),
20292        c = Math.cos(rad),
20293        a00 = a[0],
20294        a01 = a[1],
20295        a02 = a[2],
20296        a03 = a[3],
20297        a10 = a[4],
20298        a11 = a[5],
20299        a12 = a[6],
20300        a13 = a[7];
20301
20302    if (a !== out) {
20303      out[8] = a[8];
20304      out[9] = a[9];
20305      out[10] = a[10];
20306      out[11] = a[11];
20307      out[12] = a[12];
20308      out[13] = a[13];
20309      out[14] = a[14];
20310      out[15] = a[15];
20311    }
20312
20313    out[0] = a00 * c + a10 * s;
20314    out[1] = a01 * c + a11 * s;
20315    out[2] = a02 * c + a12 * s;
20316    out[3] = a03 * c + a13 * s;
20317    out[4] = a10 * c - a00 * s;
20318    out[5] = a11 * c - a01 * s;
20319    out[6] = a12 * c - a02 * s;
20320    out[7] = a13 * c - a03 * s;
20321    return out;
20322  }
20323  function multiply(out, a, b) {
20324    var a00 = a[0],
20325        a01 = a[1],
20326        a02 = a[2],
20327        a03 = a[3],
20328        a10 = a[4],
20329        a11 = a[5],
20330        a12 = a[6],
20331        a13 = a[7],
20332        a20 = a[8],
20333        a21 = a[9],
20334        a22 = a[10],
20335        a23 = a[11],
20336        a30 = a[12],
20337        a31 = a[13],
20338        a32 = a[14],
20339        a33 = a[15];
20340    var b0 = b[0],
20341        b1 = b[1],
20342        b2 = b[2],
20343        b3 = b[3];
20344    out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
20345    out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
20346    out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
20347    out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
20348    b0 = b[4];
20349    b1 = b[5];
20350    b2 = b[6];
20351    b3 = b[7];
20352    out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
20353    out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
20354    out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
20355    out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
20356    b0 = b[8];
20357    b1 = b[9];
20358    b2 = b[10];
20359    b3 = b[11];
20360    out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
20361    out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
20362    out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
20363    out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
20364    b0 = b[12];
20365    b1 = b[13];
20366    b2 = b[14];
20367    b3 = b[15];
20368    out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
20369    out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
20370    out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
20371    out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
20372    return out;
20373  }
20374  function invert(out, a) {
20375    var a00 = a[0],
20376        a01 = a[1],
20377        a02 = a[2],
20378        a03 = a[3],
20379        a10 = a[4],
20380        a11 = a[5],
20381        a12 = a[6],
20382        a13 = a[7],
20383        a20 = a[8],
20384        a21 = a[9],
20385        a22 = a[10],
20386        a23 = a[11],
20387        a30 = a[12],
20388        a31 = a[13],
20389        a32 = a[14],
20390        a33 = a[15],
20391        b00 = a00 * a11 - a01 * a10,
20392        b01 = a00 * a12 - a02 * a10,
20393        b02 = a00 * a13 - a03 * a10,
20394        b03 = a01 * a12 - a02 * a11,
20395        b04 = a01 * a13 - a03 * a11,
20396        b05 = a02 * a13 - a03 * a12,
20397        b06 = a20 * a31 - a21 * a30,
20398        b07 = a20 * a32 - a22 * a30,
20399        b08 = a20 * a33 - a23 * a30,
20400        b09 = a21 * a32 - a22 * a31,
20401        b10 = a21 * a33 - a23 * a31,
20402        b11 = a22 * a33 - a23 * a32,
20403        det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
20404
20405    if (!det) {
20406      return null;
20407    }
20408
20409    det = 1.0 / det;
20410    out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
20411    out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
20412    out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
20413    out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
20414    out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
20415    out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
20416    out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
20417    out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
20418    out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
20419    out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
20420    out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
20421    out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
20422    out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
20423    out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
20424    out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
20425    out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
20426    return out;
20427  }
20428  function identity(out) {
20429    out[0] = 1;
20430    out[1] = 0;
20431    out[2] = 0;
20432    out[3] = 0;
20433    out[4] = 0;
20434    out[5] = 1;
20435    out[6] = 0;
20436    out[7] = 0;
20437    out[8] = 0;
20438    out[9] = 0;
20439    out[10] = 1;
20440    out[11] = 0;
20441    out[12] = 0;
20442    out[13] = 0;
20443    out[14] = 0;
20444    out[15] = 1;
20445    return out;
20446  }
20447
20448  function set$2(out, x, y, z) {
20449    out[0] = x;
20450    out[1] = y;
20451    out[2] = z;
20452    return out;
20453  }
20454  function add(out, a, b) {
20455    out[0] = a[0] + b[0];
20456    out[1] = a[1] + b[1];
20457    out[2] = a[2] + b[2];
20458    return out;
20459  }
20460  function subtract(out, a, b) {
20461    out[0] = a[0] - b[0];
20462    out[1] = a[1] - b[1];
20463    out[2] = a[2] - b[2];
20464    return out;
20465  }
20466  function length(a) {
20467    var x = a[0],
20468        y = a[1],
20469        z = a[2];
20470    return Math.sqrt(x * x + y * y + z * z);
20471  }
20472  function normalize(out, a) {
20473    var x = a[0],
20474        y = a[1],
20475        z = a[2];
20476    var len = x * x + y * y + z * z;
20477
20478    if (len > 0) {
20479      len = 1 / Math.sqrt(len);
20480      out[0] = a[0] * len;
20481      out[1] = a[1] * len;
20482      out[2] = a[2] * len;
20483    }
20484
20485    return out;
20486  }
20487  function dot(a, b) {
20488    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
20489  }
20490  function scale$1(out, a, b) {
20491    out[0] = a[0] * b;
20492    out[1] = a[1] * b;
20493    out[2] = a[2] * b;
20494    return out;
20495  }
20496  function cross(out, a, b) {
20497    var ax = a[0],
20498        ay = a[1],
20499        az = a[2],
20500        bx = b[0],
20501        by = b[1],
20502        bz = b[2];
20503    out[0] = ay * bz - az * by;
20504    out[1] = az * bx - ax * bz;
20505    out[2] = ax * by - ay * bx;
20506    return out;
20507  }
20508
20509  function applyMatrix(out, v, e) {
20510    var x = v[0],
20511        y = v[1],
20512        z = v[2];
20513    var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
20514    out[0] = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
20515    out[1] = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
20516    out[2] = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
20517    return out;
20518  }
20519  function matrixToQuaternion(out, te) {
20520    var m11 = te[0],
20521        m12 = te[4],
20522        m13 = te[8],
20523        m21 = te[1],
20524        m22 = te[5],
20525        m23 = te[9],
20526        m31 = te[2],
20527        m32 = te[6],
20528        m33 = te[10],
20529        trace = m11 + m22 + m33;
20530    var s;
20531
20532    if (trace > 0) {
20533      s = 0.5 / Math.sqrt(trace + 1.0);
20534      out.w = 0.25 / s;
20535      out.x = (m32 - m23) * s;
20536      out.y = (m13 - m31) * s;
20537      out.z = (m21 - m12) * s;
20538    } else if (m11 > m22 && m11 > m33) {
20539      s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
20540      out.w = (m32 - m23) / s;
20541      out.x = 0.25 * s;
20542      out.y = (m12 + m21) / s;
20543      out.z = (m13 + m31) / s;
20544    } else if (m22 > m33) {
20545      s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
20546      out.w = (m13 - m31) / s;
20547      out.x = (m12 + m21) / s;
20548      out.y = 0.25 * s;
20549      out.z = (m23 + m32) / s;
20550    } else {
20551      s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
20552      out.w = (m21 - m12) / s;
20553      out.x = (m13 + m31) / s;
20554      out.y = (m23 + m32) / s;
20555      out.z = 0.25 * s;
20556    }
20557
20558    return this;
20559  }
20560  function quaternionToMatrix(out, q) {
20561    var te = out;
20562    var x = q.x,
20563        y = q.y,
20564        z = q.z,
20565        w = q.w;
20566    var x2 = x + x,
20567        y2 = y + y,
20568        z2 = z + z;
20569    var xx = x * x2,
20570        xy = x * y2,
20571        xz = x * z2;
20572    var yy = y * y2,
20573        yz = y * z2,
20574        zz = z * z2;
20575    var wx = w * x2,
20576        wy = w * y2,
20577        wz = w * z2;
20578    te[0] = 1 - (yy + zz);
20579    te[4] = xy - wz;
20580    te[8] = xz + wy;
20581    te[1] = xy + wz;
20582    te[5] = 1 - (xx + zz);
20583    te[9] = yz - wx;
20584    te[2] = xz - wy;
20585    te[6] = yz + wx;
20586    te[10] = 1 - (xx + yy);
20587    te[3] = 0;
20588    te[7] = 0;
20589    te[11] = 0;
20590    te[12] = 0;
20591    te[13] = 0;
20592    te[14] = 0;
20593    te[15] = 1;
20594    return te;
20595  }
20596  function setPosition(out, v) {
20597    var te = out;
20598    te[12] = v[0];
20599    te[13] = v[1];
20600    te[14] = v[2];
20601    return out;
20602  }
20603  function lookAt(te, eye, target, up) {
20604    var x = [0, 0, 0];
20605    var y = [0, 0, 0];
20606    var z = [0, 0, 0];
20607    subtract(z, eye, target);
20608
20609    if (length(z) === 0) {
20610      z[2] = 1;
20611    }
20612
20613    normalize(z, z);
20614    cross(x, up, z);
20615
20616    if (length(z) === 0) {
20617      if (Math.abs(up[2]) === 1) {
20618        z[0] += 0.0001;
20619      } else {
20620        z[2] += 0.0001;
20621      }
20622
20623      normalize(z, z);
20624      cross(x, up, z);
20625    }
20626
20627    normalize(x, x);
20628    cross(y, z, x);
20629    te[0] = x[0];
20630    te[4] = y[0];
20631    te[8] = z[0];
20632    te[1] = x[1];
20633    te[5] = y[1];
20634    te[9] = z[1];
20635    te[2] = x[2];
20636    te[6] = y[2];
20637    te[10] = z[2];
20638    return te;
20639  }
20640
20641  var RADIAN = Math.PI / 180;
20642  var DEFAULT_FOV = 0.6435011087932844;
20643  var TEMP_COORD = new Coordinate(0, 0);
20644  Map$1.include({
20645    getFov: function getFov() {
20646      if (!this._fov) {
20647        this._fov = DEFAULT_FOV;
20648      }
20649
20650      return this._fov / RADIAN;
20651    },
20652    setFov: function setFov(fov) {
20653      if (this.isZooming()) {
20654        return this;
20655      }
20656
20657      fov = Math.max(0.01, Math.min(60, fov));
20658      if (this._fov === fov) return this;
20659      var from = this.getFov();
20660      this._fov = fov * RADIAN;
20661
20662      this._calcMatrices();
20663
20664      this._renderLayers();
20665
20666      this._fireEvent('fovchange', {
20667        'from': from,
20668        'to': this.getFov()
20669      });
20670
20671      return this;
20672    },
20673    getBearing: function getBearing() {
20674      if (!this._angle) {
20675        return 0;
20676      }
20677
20678      return -this._angle / RADIAN;
20679    },
20680    setBearing: function setBearing(bearing) {
20681      if (Browser$1.ie9) {
20682        throw new Error('map can\'t rotate in IE9.');
20683      }
20684
20685      var b = -wrap(bearing, -180, 180) * RADIAN;
20686      if (this._angle === b) return this;
20687      var from = this.getBearing();
20688
20689      this._fireEvent('rotatestart', {
20690        'from': from,
20691        'to': b
20692      });
20693
20694      this._angle = b;
20695
20696      this._calcMatrices();
20697
20698      this._renderLayers();
20699
20700      this._fireEvent('rotate', {
20701        'from': from,
20702        'to': b
20703      });
20704
20705      this._fireEvent('rotateend', {
20706        'from': from,
20707        'to': b
20708      });
20709
20710      return this;
20711    },
20712    getPitch: function getPitch() {
20713      if (!this._pitch) {
20714        return 0;
20715      }
20716
20717      return this._pitch / Math.PI * 180;
20718    },
20719    setPitch: function setPitch(pitch) {
20720      if (Browser$1.ie9) {
20721        throw new Error('map can\'t tilt in IE9.');
20722      }
20723
20724      var p = clamp(pitch, 0, this.options['maxPitch']) * RADIAN;
20725      if (this._pitch === p) return this;
20726      var from = this.getPitch();
20727
20728      this._fireEvent('pitchstart', {
20729        'from': from,
20730        'to': p
20731      });
20732
20733      this._pitch = p;
20734
20735      this._calcMatrices();
20736
20737      this._renderLayers();
20738
20739      this._fireEvent('pitch', {
20740        'from': from,
20741        'to': p
20742      });
20743
20744      this._fireEvent('pitchend', {
20745        'from': from,
20746        'to': p
20747      });
20748
20749      return this;
20750    },
20751    isTransforming: function isTransforming() {
20752      return !!(this._pitch || this._angle);
20753    },
20754    getFrustumAltitude: function getFrustumAltitude() {
20755      return this._frustumAltitude;
20756    },
20757    _calcFrustumAltitude: function _calcFrustumAltitude() {
20758      var pitch = 90 - this.getPitch();
20759      var fov = this.getFov() / 2;
20760      var cameraAlt = this.cameraPosition ? this.cameraPosition[2] : 0;
20761
20762      if (fov <= pitch) {
20763        return cameraAlt;
20764      }
20765
20766      fov = Math.PI * fov / 180;
20767      var d1 = new Point(this.cameraPosition).distanceTo(new Point(this.cameraLookAt)),
20768          d2 = cameraAlt * Math.tan(fov * 2);
20769      var d = Math.tan(fov) * (d1 + d2);
20770      return cameraAlt + d;
20771    },
20772    _pointToContainerPoint: function () {
20773      var a = [0, 0, 0];
20774      return function (point, zoom, altitude, out) {
20775        if (altitude === void 0) {
20776          altitude = 0;
20777        }
20778
20779        point = this._pointToPoint(point, zoom, out);
20780
20781        if (this.isTransforming() || altitude) {
20782          altitude *= this._getResolution(zoom) / this._getResolution();
20783          var _scale = this._glScale;
20784          set$2(a, point.x * _scale, point.y * _scale, altitude * _scale);
20785
20786          var t = this._projIfBehindCamera(a, this.cameraPosition, this.cameraForward);
20787
20788          applyMatrix(t, t, this.projViewMatrix);
20789          var w2 = this.width / 2,
20790              h2 = this.height / 2;
20791          t[0] = t[0] * w2 + w2;
20792          t[1] = -(t[1] * h2) + h2;
20793
20794          if (out) {
20795            out.x = t[0];
20796            out.y = t[1];
20797            return out;
20798          }
20799
20800          return new Point(t[0], t[1]);
20801        } else {
20802          var centerPoint = this._prjToPoint(this._getPrjCenter(), undefined, TEMP_COORD);
20803
20804          if (out) {
20805            out.x = point.x;
20806            out.y = point.y;
20807          } else {
20808            out = point;
20809          }
20810
20811          return out._sub(centerPoint)._add(this.width / 2, this.height / 2);
20812        }
20813      };
20814    }(),
20815    _projIfBehindCamera: function () {
20816      var vectorFromCam = new Array(3);
20817      var proj = new Array(3);
20818      var sub = new Array(3);
20819      return function (position, cameraPos, camForward) {
20820        subtract(vectorFromCam, position, cameraPos);
20821        var camNormDot = dot(camForward, vectorFromCam);
20822
20823        if (camNormDot <= 0) {
20824          scale$1(proj, camForward, camNormDot * 1.01);
20825          add(position, cameraPos, subtract(sub, vectorFromCam, proj));
20826        }
20827
20828        return position;
20829      };
20830    }(),
20831    _containerPointToPoint: function () {
20832      var cp = [0, 0, 0],
20833          coord0 = [0, 0, 0, 1],
20834          coord1 = [0, 0, 0, 1];
20835      return function (p, zoom, out) {
20836        if (this.isTransforming()) {
20837          var w2 = this.width / 2 || 1,
20838              h2 = this.height / 2 || 1;
20839          set$2(cp, (p.x - w2) / w2, (h2 - p.y) / h2, 0);
20840          set$2(coord0, cp[0], cp[1], 0);
20841          set$2(coord1, cp[0], cp[1], 1);
20842          coord0[3] = coord1[3] = 1;
20843          applyMatrix(coord0, coord0, this.projViewMatrixInverse);
20844          applyMatrix(coord1, coord1, this.projViewMatrixInverse);
20845          var x0 = coord0[0];
20846          var x1 = coord1[0];
20847          var y0 = coord0[1];
20848          var y1 = coord1[1];
20849          var z0 = coord0[2];
20850          var z1 = coord1[2];
20851          var t = z0 === z1 ? 0 : (0 - z0) / (z1 - z0);
20852
20853          var _x = interpolate(x0, x1, t);
20854
20855          var _y = interpolate(y0, y1, t);
20856
20857          if (out) {
20858            out.x = _x;
20859            out.y = _y;
20860          } else {
20861            out = new Point(_x, _y);
20862          }
20863
20864          out._multi(1 / this._glScale);
20865
20866          return zoom === undefined || this.getZoom() === zoom ? out : this._pointToPointAtZoom(out, zoom, out);
20867        }
20868
20869        var centerPoint = this._prjToPoint(this._getPrjCenter(), zoom, out),
20870            scale$$1 = zoom !== undefined ? this._getResolution() / this._getResolution(zoom) : 1;
20871
20872        var x = scale$$1 * (p.x - this.width / 2),
20873            y = scale$$1 * (p.y - this.height / 2);
20874        return centerPoint._add(x, y);
20875      };
20876    }(),
20877    _calcMatrices: function () {
20878      var m0 = Browser$1.ie9 ? null : createMat4(),
20879          m1 = Browser$1.ie9 ? null : createMat4();
20880      return function () {
20881        if (Browser$1.ie9) {
20882          return;
20883        }
20884
20885        delete this._mapRes;
20886        delete this._mapGlRes;
20887        delete this._mapExtent2D;
20888        delete this._mapGlExtent2D;
20889        var size = this.getSize();
20890        var w = size.width || 1,
20891            h = size.height || 1;
20892        this._glScale = this.getGLScale();
20893        var fov = this.getFov() * Math.PI / 180;
20894        var maxScale = this.getScale(this.getMinZoom()) / this.getScale(this.getMaxNativeZoom());
20895        var farZ = maxScale * h / 2 / this._getFovRatio() * 1.4;
20896        var projMatrix = this.projMatrix || createMat4();
20897        perspective(projMatrix, fov, w / h, 0.1, farZ);
20898        this.projMatrix = projMatrix;
20899
20900        var worldMatrix = this._getCameraWorldMatrix();
20901
20902        this.viewMatrix = invert(m0, worldMatrix);
20903        this.projViewMatrix = multiply(this.projViewMatrix || createMat4(), projMatrix, this.viewMatrix);
20904        this.projViewMatrixInverse = multiply(this.projViewMatrixInverse || createMat4(), worldMatrix, invert(m1, projMatrix));
20905        this.domCssMatrix = this._calcDomMatrix();
20906        this._frustumAltitude = this._calcFrustumAltitude();
20907        this._mapRes = this._getResolution();
20908        this._mapGlRes = this._getResolution(this.getGLZoom());
20909        this._mapExtent2D = this._get2DExtent();
20910        this._mapGlExtent2D = this._get2DExtent(this.getGLZoom());
20911      };
20912    }(),
20913    _calcDomMatrix: function () {
20914      var m = Browser$1.ie9 ? null : createMat4(),
20915          m1 = Browser$1.ie9 ? null : createMat4(),
20916          minusY = [1, -1, 1],
20917          arr = [0, 0, 0];
20918      return function () {
20919        var width = this.width || 1;
20920        var height = this.height || 1;
20921        var cameraToCenterDistance = 0.5 / Math.tan(this._fov / 2) * height;
20922        scale(m, this.projMatrix, minusY);
20923        translate(m, m, set$2(arr, 0, 0, -cameraToCenterDistance));
20924
20925        if (this._pitch) {
20926          rotateX(m, m, this._pitch);
20927        }
20928
20929        if (this._angle) {
20930          rotateZ(m, m, this._angle);
20931        }
20932
20933        identity(m1);
20934        scale(m1, m1, set$2(arr, width / 2, -height / 2, 1));
20935        return multiply(this.domCssMatrix || createMat4(), m1, m);
20936      };
20937    }(),
20938    _getCameraWorldMatrix: function () {
20939      var q = {},
20940          minusY = [1, -1, 1];
20941      return function () {
20942        var targetZ = this.getGLZoom();
20943        var size = this.getSize(),
20944            scale$$1 = this.getGLScale();
20945
20946        var center2D = this._prjToPoint(this._prjCenter, targetZ);
20947
20948        this.cameraLookAt = set$2(this.cameraLookAt || [0, 0, 0], center2D.x, center2D.y, 0);
20949        var pitch = this.getPitch() * RADIAN;
20950        var bearing = -this.getBearing() * RADIAN;
20951
20952        var ratio = this._getFovRatio();
20953
20954        var z = scale$$1 * (size.height || 1) / 2 / ratio;
20955        var cz = z * Math.cos(pitch);
20956        var dist = Math.sin(pitch) * z;
20957        var cx = center2D.x + dist * Math.sin(bearing);
20958        var cy = center2D.y + dist * Math.cos(bearing);
20959        this.cameraPosition = set$2(this.cameraPosition || [0, 0, 0], cx, cy, cz);
20960        var d = dist || 1;
20961        var up = this.cameraUp = set$2(this.cameraUp || [0, 0, 0], Math.sin(bearing) * d, Math.cos(bearing) * d, 0);
20962        var m = this.cameraWorldMatrix = this.cameraWorldMatrix || createMat4();
20963        lookAt(m, this.cameraPosition, this.cameraLookAt, up);
20964        var cameraForward = this.cameraForward || [0, 0, 0];
20965        subtract(cameraForward, this.cameraLookAt, this.cameraPosition);
20966        this.cameraForward = normalize(cameraForward, cameraForward);
20967        matrixToQuaternion(q, m);
20968        quaternionToMatrix(m, q);
20969        setPosition(m, this.cameraPosition);
20970        scale(m, m, minusY);
20971        return m;
20972      };
20973    }(),
20974    _getFovRatio: function _getFovRatio() {
20975      var fov = this.getFov();
20976      return Math.tan(fov / 2 * RADIAN);
20977    },
20978    _renderLayers: function _renderLayers() {
20979      if (this.isInteracting()) {
20980        return;
20981      }
20982
20983      var layers = this._getLayers();
20984
20985      layers.forEach(function (layer) {
20986        if (!layer) {
20987          return;
20988        }
20989
20990        var renderer = layer._getRenderer();
20991
20992        if (renderer && renderer.setToRedraw) {
20993          renderer.setToRedraw();
20994        }
20995      });
20996    }
20997  });
20998
20999  function createMat4() {
21000    return identity(new Array(16));
21001  }
21002
21003  Map$1.include({
21004    _onViewChange: function _onViewChange(view) {
21005      if (!this._viewHistory) {
21006        this._viewHistory = [];
21007        this._viewHistoryPointer = 0;
21008      }
21009
21010      var old = this._getCurrentView();
21011
21012      for (var i = this._viewHistory.length - 1; i >= 0; i--) {
21013        if (equalMapView(view, this._viewHistory[i])) {
21014          this._viewHistoryPointer = i;
21015
21016          this._fireViewChange(old, view);
21017
21018          return;
21019        }
21020      }
21021
21022      if (this._viewHistoryPointer < this._viewHistory.length - 1) {
21023        this._viewHistory.splice(this._viewHistoryPointer + 1);
21024      }
21025
21026      this._viewHistory.push(view);
21027
21028      var count = this.options['viewHistoryCount'];
21029
21030      if (count > 0 && this._viewHistory.length > count) {
21031        this._viewHistory.splice(0, this._viewHistory.length - count);
21032      }
21033
21034      this._viewHistoryPointer = this._viewHistory.length - 1;
21035
21036      this._fireViewChange(old, view);
21037    },
21038    zoomToPreviousView: function zoomToPreviousView(options) {
21039      if (options === void 0) {
21040        options = {};
21041      }
21042
21043      if (!this.hasPreviousView()) {
21044        return null;
21045      }
21046
21047      var view = this._viewHistory[--this._viewHistoryPointer];
21048
21049      this._zoomToView(view, options);
21050
21051      return view;
21052    },
21053    hasPreviousView: function hasPreviousView() {
21054      if (!this._viewHistory || this._viewHistoryPointer === 0) {
21055        return false;
vendor: 9,156 bytes, lines 21056-21377
21056      }
21057
21058      return true;
21059    },
21060    zoomToNextView: function zoomToNextView(options) {
21061      if (options === void 0) {
21062        options = {};
21063      }
21064
21065      if (!this.hasNextView()) {
21066        return null;
21067      }
21068
21069      var view = this._viewHistory[++this._viewHistoryPointer];
21070
21071      this._zoomToView(view, options);
21072
21073      return view;
21074    },
21075    hasNextView: function hasNextView() {
21076      if (!this._viewHistory || this._viewHistoryPointer === this._viewHistory.length - 1) {
21077        return false;
21078      }
21079
21080      return true;
21081    },
21082    _zoomToView: function _zoomToView(view, options) {
21083      var _this = this;
21084
21085      var old = this.getView();
21086
21087      if (options['animation']) {
21088        this._animateTo(view, {
21089          'duration': options['duration']
21090        }, function (frame) {
21091          if (frame.state.playState === 'finished') {
21092            _this._fireViewChange(old, view);
21093          }
21094        });
21095      } else {
21096        this.setView(view);
21097
21098        this._fireViewChange(old, view);
21099      }
21100    },
21101    getViewHistory: function getViewHistory() {
21102      return this._viewHistory;
21103    },
21104    _fireViewChange: function _fireViewChange(old, view) {
21105      this._fireEvent('viewchange', {
21106        'old': old,
21107        'new': view
21108      });
21109    },
21110    _getCurrentView: function _getCurrentView() {
21111      if (!this._viewHistory) {
21112        return null;
21113      }
21114
21115      return this._viewHistory[this._viewHistoryPointer];
21116    }
21117  });
21118  Map$1.mergeOptions({
21119    'viewHistory': true,
21120    'viewHistoryCount': 10
21121  });
21122
21123  var options$h = {
21124    'mode': 'LineString',
21125    'language': 'zh-CN',
21126    'metric': true,
21127    'imperial': false,
21128    'symbol': {
21129      'lineColor': '#000',
21130      'lineWidth': 3,
21131      'lineOpacity': 1
21132    },
21133    'vertexSymbol': {
21134      'markerType': 'ellipse',
21135      'markerFill': '#fff',
21136      'markerLineColor': '#000',
21137      'markerLineWidth': 3,
21138      'markerWidth': 11,
21139      'markerHeight': 11
21140    },
21141    'labelOptions': {
21142      'textSymbol': {
21143        'textFaceName': 'monospace',
21144        'textLineSpacing': 1,
21145        'textHorizontalAlignment': 'right',
21146        'textDx': 15
21147      },
21148      'boxStyle': {
21149        'padding': [6, 2],
21150        'symbol': {
21151          'markerType': 'square',
21152          'markerFill': '#fff',
21153          'markerFillOpacity': 0.9,
21154          'markerLineColor': '#b4b3b3'
21155        }
21156      }
21157    },
21158    'clearButtonSymbol': [{
21159      'markerType': 'square',
21160      'markerFill': '#fff',
21161      'markerLineColor': '#b4b3b3',
21162      'markerLineWidth': 2,
21163      'markerWidth': 15,
21164      'markerHeight': 15,
21165      'markerDx': 20
21166    }, {
21167      'markerType': 'x',
21168      'markerWidth': 10,
21169      'markerHeight': 10,
21170      'markerDx': 20
21171    }]
21172  };
21173
21174  var DistanceTool = function (_DrawTool) {
21175    _inheritsLoose(DistanceTool, _DrawTool);
21176
21177    function DistanceTool(options) {
21178      var _this;
21179
21180      _this = _DrawTool.call(this, options) || this;
21181
21182      _this.on('enable', _this._afterEnable, _assertThisInitialized(_assertThisInitialized(_this))).on('disable', _this._afterDisable, _assertThisInitialized(_assertThisInitialized(_this)));
21183
21184      _this._measureLayers = [];
21185      return _this;
21186    }
21187
21188    var _proto = DistanceTool.prototype;
21189
21190    _proto.clear = function clear() {
21191      if (isArrayHasData(this._measureLayers)) {
21192        for (var i = 0; i < this._measureLayers.length; i++) {
21193          this._measureLayers[i].remove();
21194        }
21195      }
21196
21197      delete this._lastMeasure;
21198      delete this._lastVertex;
21199      this._measureLayers = [];
21200      return this;
21201    };
21202
21203    _proto.getMeasureLayers = function getMeasureLayers() {
21204      return this._measureLayers;
21205    };
21206
21207    _proto.getLastMeasure = function getLastMeasure() {
21208      if (!this._lastMeasure) {
21209        return 0;
21210      }
21211
21212      return this._lastMeasure;
21213    };
21214
21215    _proto._measure = function _measure(toMeasure) {
21216      var map = this.getMap();
21217      var length;
21218
21219      if (toMeasure instanceof Geometry) {
21220        length = map.computeGeometryLength(toMeasure);
21221      } else if (Array.isArray(toMeasure)) {
21222        length = map.getProjection().measureLength(toMeasure);
21223      }
21224
21225      this._lastMeasure = length;
21226      var units;
21227
21228      if (this.options['language'] === 'zh-CN') {
21229        units = [' 米', ' 公里', ' 英尺', ' 英里'];
21230      } else {
21231        units = [' m', ' km', ' feet', ' mile'];
21232      }
21233
21234      var content = '';
21235
21236      if (this.options['metric']) {
21237        content += length < 1000 ? length.toFixed(0) + units[0] : (length / 1000).toFixed(2) + units[1];
21238      }
21239
21240      if (this.options['imperial']) {
21241        length *= 3.2808399;
21242
21243        if (content.length > 0) {
21244          content += '\n';
21245        }
21246
21247        content += length < 5280 ? length.toFixed(0) + units[2] : (length / 5280).toFixed(2) + units[3];
21248      }
21249
21250      return content;
21251    };
21252
21253    _proto._registerMeasureEvents = function _registerMeasureEvents() {
21254      this.on('drawstart', this._msOnDrawStart, this).on('drawvertex', this._msOnDrawVertex, this).on('mousemove', this._msOnMouseMove, this).on('drawend', this._msOnDrawEnd, this);
21255    };
21256
21257    _proto._afterEnable = function _afterEnable() {
21258      this._registerMeasureEvents();
21259    };
21260
21261    _proto._afterDisable = function _afterDisable() {
21262      this.off('drawstart', this._msOnDrawStart, this).off('drawvertex', this._msOnDrawVertex, this).off('mousemove', this._msOnMouseMove, this).off('drawend', this._msOnDrawEnd, this);
21263    };
21264
21265    _proto._msOnDrawStart = function _msOnDrawStart(param) {
21266      var map = this.getMap();
21267      var uid = UID();
21268      var layerId = 'distancetool_' + uid;
21269      var markerLayerId = 'distancetool_markers_' + uid;
21270
21271      if (!map.getLayer(layerId)) {
21272        this._measureLineLayer = new VectorLayer(layerId).addTo(map);
21273        this._measureMarkerLayer = new VectorLayer(markerLayerId).addTo(map);
21274      } else {
21275        this._measureLineLayer = map.getLayer(layerId);
21276        this._measureMarkerLayer = map.getLayer(markerLayerId);
21277      }
21278
21279      this._measureLayers.push(this._measureLineLayer);
21280
21281      this._measureLayers.push(this._measureMarkerLayer);
21282
21283      new Marker(param['coordinate'], {
21284        'symbol': this.options['vertexSymbol']
21285      }).addTo(this._measureMarkerLayer);
21286      var content = this.options['language'] === 'zh-CN' ? '起点' : 'start';
21287      var startLabel = new Label(content, param['coordinate'], this.options['labelOptions']);
21288      this._lastVertex = startLabel;
21289
21290      this._measureMarkerLayer.addGeometry(startLabel);
21291    };
21292
21293    _proto._msOnMouseMove = function _msOnMouseMove(param) {
21294      var ms = this._measure(this._msGetCoordsToMeasure(param));
21295
21296      if (!this._tailMarker) {
21297        var symbol = extendSymbol(this.options['vertexSymbol']);
21298        symbol['markerWidth'] /= 2;
21299        symbol['markerHeight'] /= 2;
21300        this._tailMarker = new Marker(param['coordinate'], {
21301          'symbol': symbol
21302        }).addTo(this._measureMarkerLayer);
21303        this._tailLabel = new Label(ms, param['coordinate'], this.options['labelOptions']).addTo(this._measureMarkerLayer);
21304      }
21305
21306      this._tailMarker.setCoordinates(param['coordinate']);
21307
21308      this._tailLabel.setContent(ms);
21309
21310      this._tailLabel.setCoordinates(param['coordinate']);
21311    };
21312
21313    _proto._msGetCoordsToMeasure = function _msGetCoordsToMeasure(param) {
21314      return param['geometry'].getCoordinates().concat([param['coordinate']]);
21315    };
21316
21317    _proto._msOnDrawVertex = function _msOnDrawVertex(param) {
21318      var geometry = param['geometry'];
21319      new Marker(param['coordinate'], {
21320        'symbol': this.options['vertexSymbol']
21321      }).addTo(this._measureMarkerLayer);
21322
21323      var length = this._measure(geometry);
21324
21325      var vertexLabel = new Label(length, param['coordinate'], this.options['labelOptions']);
21326
21327      this._measureMarkerLayer.addGeometry(vertexLabel);
21328
21329      this._lastVertex = vertexLabel;
21330    };
21331
21332    _proto._msOnDrawEnd = function _msOnDrawEnd(param) {
21333      this._clearTailMarker();
21334
21335      var size = this._lastVertex.getSize();
21336
21337      if (!size) {
21338        size = new Size(10, 10);
21339      }
21340
21341      this._addClearMarker(this._lastVertex.getCoordinates(), size['width']);
21342
21343      var geo = param['geometry'].copy();
21344      geo.addTo(this._measureLineLayer);
21345      this._lastMeasure = geo.getLength();
21346    };
21347
21348    _proto._addClearMarker = function _addClearMarker(coordinates, dx) {
21349      var symbol = this.options['clearButtonSymbol'];
21350      var dxSymbol = {
21351        'markerDx': (symbol['markerDx'] || 0) + dx,
21352        'textDx': (symbol['textDx'] || 0) + dx
21353      };
21354
21355      if (Array.isArray(symbol)) {
21356        dxSymbol = symbol.map(function (s) {
21357          if (s) {
21358            return {
21359              'markerDx': (s['markerDx'] || 0) + dx,
21360              'textDx': (s['textDx'] || 0) + dx
21361            };
21362          }
21363
21364          return null;
21365        });
21366      }
21367
21368      symbol = extendSymbol(symbol, dxSymbol);
21369      var endMarker = new Marker(coordinates, {
21370        'symbol': symbol
21371      });
21372      var measureLineLayer = this._measureLineLayer,
21373          measureMarkerLayer = this._measureMarkerLayer;
21374      endMarker.on('click', function () {
21375        measureLineLayer.remove();
21376        measureMarkerLayer.remove();
21377        return false;
21378      }, this);
21379      endMarker.addTo(this._measureMarkerLayer);
21380    };
21381
21382    _proto._clearTailMarker = function _clearTailMarker() {
21383      if (this._tailMarker) {
21384        this._tailMarker.remove();
21385
21386        delete this._tailMarker;
21387      }
21388
21389      if (this._tailLabel) {
21390        this._tailLabel.remove();
21391
21392        delete this._tailLabel;
21393      }
21394    };
21395
21396    return DistanceTool;
21397  }(DrawTool);
21398
21399  DistanceTool.mergeOptions(options$h);
21400
21401  var options$i = {
21402    'mode': 'Polygon',
21403    'symbol': {
21404      'lineColor': '#000000',
21405      'lineWidth': 2,
21406      'lineOpacity': 1,
21407      'lineDasharray': '',
21408      'polygonFill': '#ffffff',
21409      'polygonOpacity': 0.5
21410    }
21411  };
21412
21413  var AreaTool = function (_DistanceTool) {
21414    _inheritsLoose(AreaTool, _DistanceTool);
21415
21416    function AreaTool(options) {
21417      var _this;
21418
21419      _this = _DistanceTool.call(this, options) || this;
21420
21421      _this.on('enable', _this._afterEnable, _assertThisInitialized(_assertThisInitialized(_this))).on('disable', _this._afterDisable, _assertThisInitialized(_assertThisInitialized(_this)));
21422
21423      _this._measureLayers = [];
21424      return _this;
21425    }
21426
21427    var _proto = AreaTool.prototype;
21428
21429    _proto._measure = function _measure(toMeasure) {
21430      var map = this.getMap();
21431      var area;
21432
21433      if (toMeasure instanceof Geometry) {
21434        area = map.computeGeometryArea(toMeasure);
21435      } else if (Array.isArray(toMeasure)) {
21436        area = map.getProjection().measureArea(toMeasure);
21437      }
21438
21439      this._lastMeasure = area;
21440      var units;
21441
21442      if (this.options['language'] === 'zh-CN') {
21443        units = [' 平方米', ' 平方公里', ' 平方英尺', ' 平方英里'];
21444      } else {
21445        units = [' sq.m', ' sq.km', ' sq.ft', ' sq.mi'];
21446      }
21447
21448      var content = '';
21449
21450      if (this.options['metric']) {
21451        content += area < 1E6 ? area.toFixed(0) + units[0] : (area / 1E6).toFixed(2) + units[1];
21452      }
21453
21454      if (this.options['imperial']) {
21455        area *= 3.2808399;
21456
21457        if (content.length > 0) {
21458          content += '\n';
21459        }
21460
21461        var sqmi = 5280 * 5280;
21462        content += area < sqmi ? area.toFixed(0) + units[2] : (area / sqmi).toFixed(2) + units[3];
21463      }
21464
21465      return content;
21466    };
21467
21468    _proto._msGetCoordsToMeasure = function _msGetCoordsToMeasure(param) {
21469      return param['geometry'].getShell().concat([param['coordinate']]);
21470    };
21471
21472    _proto._msOnDrawVertex = function _msOnDrawVertex(param) {
21473      var vertexMarker = new Marker(param['coordinate'], {
21474        'symbol': this.options['vertexSymbol']
21475      }).addTo(this._measureMarkerLayer);
21476
21477      this._measure(param['geometry']);
21478
21479      this._lastVertex = vertexMarker;
21480    };
21481
21482    _proto._msOnDrawEnd = function _msOnDrawEnd(param) {
21483      this._clearTailMarker();
21484
21485      var ms = this._measure(param['geometry']);
21486
21487      var endLabel = new Label(ms, param['coordinate'], this.options['labelOptions']).addTo(this._measureMarkerLayer);
21488      var size = endLabel.getSize();
21489
21490      if (!size) {
21491        size = new Size(10, 10);
21492      }
21493
21494      this._addClearMarker(param['coordinate'], size['width']);
21495
21496      var geo = param['geometry'].copy();
21497      geo.addTo(this._measureLineLayer);
21498      this._lastMeasure = geo.getArea();
21499    };
21500
21501    return AreaTool;
21502  }(DistanceTool);
21503
21504  AreaTool.mergeOptions(options$i);
21505
21506  DrawTool.registerMode('circle', {
21507    'clickLimit': 2,
21508    'action': ['click', 'mousemove', 'click'],
21509    'create': function create(coordinate) {
21510      return new Circle(coordinate[0], 0);
21511    },
21512    'update': function update(path, geometry) {
21513      var map = geometry.getMap();
21514      var radius = map.computeLength(geometry.getCenter(), path[path.length - 1]);
21515      geometry.setRadius(radius);
21516    },
21517    'generate': function generate(geometry) {
21518      return geometry;
21519    }
21520  });
21521  DrawTool.registerMode('freeHandCircle', {
21522    'action': ['mousedown', 'mousemove', 'mouseup'],
21523    'create': function create(coordinate) {
21524      return new Circle(coordinate[0], 0);
21525    },
21526    'update': function update(path, geometry) {
21527      var map = geometry.getMap();
21528      var radius = map.computeLength(geometry.getCenter(), path[path.length - 1]);
21529      geometry.setRadius(radius);
21530    },
21531    'generate': function generate(geometry) {
21532      return geometry;
21533    }
21534  });
21535  DrawTool.registerMode('ellipse', {
21536    'clickLimit': 2,
21537    'action': ['click', 'mousemove', 'click'],
21538    'create': function create(coordinates) {
21539      return new Ellipse(coordinates[0], 0, 0);
21540    },
21541    'update': function update(path, geometry) {
21542      var map = geometry.getMap();
21543      var center = geometry.getCenter();
21544      var rx = map.computeLength(center, new Coordinate({
21545        x: path[path.length - 1].x,
21546        y: center.y
21547      }));
21548      var ry = map.computeLength(center, new Coordinate({
21549        x: center.x,
21550        y: path[path.length - 1].y
21551      }));
21552      geometry.setWidth(rx * 2);
21553      geometry.setHeight(ry * 2);
21554    },
21555    'generate': function generate(geometry) {
21556      return geometry;
21557    }
21558  });
21559  DrawTool.registerMode('freeHandEllipse', {
21560    'action': ['mousedown', 'mousemove', 'mouseup'],
21561    'create': function create(coordinates) {
21562      return new Ellipse(coordinates[0], 0, 0);
21563    },
21564    'update': function update(path, geometry) {
21565      var map = geometry.getMap();
21566      var center = geometry.getCenter();
21567      var rx = map.computeLength(center, new Coordinate({
21568        x: path[path.length - 1].x,
21569        y: center.y
21570      }));
21571      var ry = map.computeLength(center, new Coordinate({
21572        x: center.x,
21573        y: path[path.length - 1].y
21574      }));
21575      geometry.setWidth(rx * 2);
21576      geometry.setHeight(ry * 2);
21577    },
21578    'generate': function generate(geometry) {
21579      return geometry;
21580    }
21581  });
21582  DrawTool.registerMode('rectangle', {
21583    'clickLimit': 2,
21584    'action': ['click', 'mousemove', 'click'],
21585    'create': function create(coordinates) {
21586      var rect = new Polygon([]);
21587      rect._firstClick = coordinates[0];
21588      return rect;
21589    },
21590    'update': function update(coordinates, geometry, param) {
21591      var map = geometry.getMap();
21592      var containerPoint = param['containerPoint'];
21593      var firstClick = map.coordToContainerPoint(geometry._firstClick);
21594      var ring = [[firstClick.x, firstClick.y], [containerPoint.x, firstClick.y], [containerPoint.x, containerPoint.y], [firstClick.x, containerPoint.y]];
21595      geometry.setCoordinates(ring.map(function (c) {
21596        return map.containerPointToCoord(new Point(c));
21597      }));
21598    },
21599    'generate': function generate(geometry) {
21600      return geometry;
21601    }
21602  });
21603  DrawTool.registerMode('freeHandRectangle', {
21604    'action': ['mousedown', 'mousemove', 'mouseup'],
21605    'create': function create(coordinates) {
21606      var rect = new Polygon([]);
21607      rect._firstClick = coordinates[0];
21608      return rect;
21609    },
21610    'update': function update(coordinates, geometry) {
21611      var firstClick = geometry._firstClick;
21612      var ring = [[firstClick.x, firstClick.y], [coordinates[0].x, firstClick.y], [coordinates[0].x, coordinates[0].y], [firstClick.x, coordinates[0].y]];
21613      geometry.setCoordinates(ring);
21614    },
21615    'generate': function generate(geometry) {
21616      return geometry;
21617    }
21618  });
21619  DrawTool.registerMode('point', {
21620    'clickLimit': 1,
21621    'action': ['click'],
21622    'create': function create(coordinate) {
21623      return new Marker(coordinate[0]);
21624    },
21625    'generate': function generate(geometry) {
21626      return geometry;
21627    }
21628  });
21629  DrawTool.registerMode('polygon', {
21630    'action': ['click', 'mousemove', 'dblclick'],
21631    'create': function create(path) {
21632      return new LineString(path);
21633    },
21634    'update': function update(path, geometry) {
21635      var symbol = geometry.getSymbol();
21636      geometry.setCoordinates(path);
21637      var layer = geometry.getLayer();
21638
21639      if (layer) {
21640        var polygon = layer.getGeometryById('polygon');
21641
21642        if (!polygon && path.length >= 3) {
21643          polygon = new Polygon([path], {
21644            'id': 'polygon'
21645          });
21646
21647          if (symbol) {
21648            var pSymbol = extendSymbol(symbol, {
21649              'lineOpacity': 0
21650            });
21651            polygon.setSymbol(pSymbol);
21652          }
21653
21654          polygon.addTo(layer);
21655        }
21656
21657        if (polygon) {
21658          polygon.setCoordinates(path);
21659        }
21660      }
21661    },
21662    'generate': function generate(geometry) {
21663      return new Polygon(geometry.getCoordinates(), {
21664        'symbol': geometry.getSymbol()
21665      });
21666    }
21667  });
21668  DrawTool.registerMode('freeHandPolygon', {
21669    'action': ['mousedown', 'mousemove', 'mouseup'],
21670    'create': function create(path) {
21671      return new LineString(path);
21672    },
21673    'update': function update(path, geometry) {
21674      var coordinates = geometry.getCoordinates();
21675      var symbol = geometry.getSymbol();
21676      geometry.setCoordinates(coordinates.concat(path));
21677      var layer = geometry.getLayer();
21678
21679      if (layer) {
21680        var polygon = layer.getGeometryById('polygon');
21681
21682        if (!polygon && path.length >= 3) {
21683          polygon = new Polygon([path], {
21684            'id': 'polygon'
21685          });
21686
21687          if (symbol) {
21688            var pSymbol = extendSymbol(symbol, {
21689              'lineOpacity': 0
21690            });
21691            polygon.setSymbol(pSymbol);
21692          }
21693
21694          polygon.addTo(layer);
21695        }
21696
21697        if (polygon) {
21698          polygon.setCoordinates(path);
21699        }
21700      }
21701    },
21702    'generate': function generate(geometry) {
21703      return new Polygon(geometry.getCoordinates(), {
21704        'symbol': geometry.getSymbol()
21705      });
21706    }
21707  });
21708  DrawTool.registerMode('linestring', {
21709    'action': ['click', 'mousemove', 'dblclick'],
21710    'create': function create(path) {
21711      return new LineString(path);
21712    },
21713    'update': function update(path, geometry) {
21714      geometry.setCoordinates(path);
21715    },
21716    'generate': function generate(geometry) {
21717      return geometry;
21718    }
21719  });
21720  DrawTool.registerMode('freeHandLinestring', {
21721    'action': ['mousedown', 'mousemove', 'mouseup'],
21722    'create': function create(path) {
21723      return new LineString(path);
21724    },
21725    'update': function update(path, geometry) {
21726      var coordinates = geometry.getCoordinates();
21727      geometry.setCoordinates(coordinates.concat(path));
21728    },
21729    'generate': function generate(geometry) {
21730      return geometry;
21731    }
21732  });
21733  DrawTool.registerMode('arccurve', {
21734    'action': ['click', 'mousemove', 'dblclick'],
21735    'create': function create(path) {
21736      return new ArcCurve(path);
21737    },
21738    'update': function update(path, geometry) {
21739      geometry.setCoordinates(path);
21740    },
21741    'generate': function generate(geometry) {
21742      return geometry;
21743    }
21744  });
21745  DrawTool.registerMode('quadbeziercurve', {
21746    'action': ['click', 'mousemove', 'dblclick'],
21747    'create': function create(path) {
21748      return new QuadBezierCurve(path);
21749    },
21750    'update': function update(path, geometry) {
21751      geometry.setCoordinates(path);
21752    },
21753    'generate': function generate(geometry) {
21754      return geometry;
21755    }
21756  });
21757  DrawTool.registerMode('cubicbeziercurve', {
21758    'action': ['click', 'mousemove', 'dblclick'],
21759    'create': function create(path) {
21760      return new CubicBezierCurve(path);
21761    },
21762    'update': function update(path, geometry) {
21763      geometry.setCoordinates(path);
21764    },
21765    'generate': function generate(geometry) {
21766      return geometry;
21767    }
21768  });
21769  DrawTool.registerMode('boxZoom', {
21770    'action': ['mousedown', 'mousemove', 'mouseup'],
21771    'create': function create(coordinates) {
21772      var marker = new Marker(coordinates[0]);
21773      marker._firstClick = coordinates[0];
21774      return marker;
21775    },
21776    'update': function update(path, geometry, param) {
21777      var map = geometry.getMap();
21778      var p1 = map.coordToContainerPoint(geometry._firstClick),
21779          p2 = param['containerPoint'];
21780      var coords = map.containerPointToCoordinate(new Coordinate(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y)));
21781      geometry.setCoordinates(coords).updateSymbol({
21782        markerWidth: Math.abs(p1.x - p2.x),
21783        markerHeight: Math.abs(p1.y - p2.y)
21784      });
21785    },
21786    'generate': function generate(geometry) {
21787      return geometry;
21788    }
21789  });
21790
21791  function parse(arcConf) {
21792    var tileInfo = arcConf['tileInfo'],
21793        tileSize = [tileInfo['cols'], tileInfo['rows']],
21794        resolutions = [],
21795        lods = tileInfo['lods'];
21796
21797    for (var i = 0, len = lods.length; i < len; i++) {
21798      resolutions.push(lods[i]['resolution']);
21799    }
21800
21801    var fullExtent = arcConf['fullExtent'],
21802        origin = tileInfo['origin'],
21803        tileSystem = [1, -1, origin['x'], origin['y']];
21804    delete fullExtent['spatialReference'];
21805    return {
21806      'spatialReference': {
21807        'resolutions': resolutions,
21808        'fullExtent': fullExtent
21809      },
21810      'tileSystem': tileSystem,
21811      'tileSize': tileSize
21812    };
21813  }
21814
21815  SpatialReference.loadArcgis = function (url, cb, options) {
21816    if (options === void 0) {
21817      options = {
21818        'jsonp': true
21819      };
21820    }
21821
21822    if (isString(url) && url.substring(0, 1) !== '{') {
21823      Ajax.getJSON(url, function (err, json) {
21824        if (err) {
21825          cb(err);
21826          return;
21827        }
21828
21829        var spatialRef = parse(json);
21830        cb(null, spatialRef);
21831      }, options);
21832    } else {
21833      if (isString(url)) {
21834        url = parseJSON(url);
21835      }
21836
21837      var spatialRef = parse(url);
21838      cb(null, spatialRef);
21839    }
21840
21841    return this;
21842  };
21843
21844  var options$j = {
21845    'eventsPropagation': false,
21846    'eventsToStop': null,
21847    'dx': 0,
21848    'dy': 0,
21849    'autoPan': false,
21850    'autoPanDuration': 600,
21851    'single': true,
21852    'animation': 'scale',
21853    'animationOnHide': true,
21854    'animationDuration': 500,
21855    'pitchWithMap': false,
21856    'rotateWithMap': false
21857  };
21858
21859  var UIComponent = function (_Eventable) {
21860    _inheritsLoose(UIComponent, _Eventable);
21861
21862    function UIComponent(options) {
21863      return _Eventable.call(this, options) || this;
21864    }
21865
21866    var _proto = UIComponent.prototype;
21867
21868    _proto.addTo = function addTo(owner) {
21869      this._owner = owner;
21870
21871      this._switchEvents('on');
21872
21873      if (this.onAdd) {
21874        this.onAdd();
21875      }
21876
21877      this.fire('add');
21878      return this;
21879    };
21880
21881    _proto.getMap = function getMap() {
21882      if (!this._owner) {
21883        return null;
21884      }
21885
21886      if (this._owner.getBaseLayer) {
21887        return this._owner;
21888      }
21889
21890      return this._owner.getMap();
21891    };
21892
21893    _proto.show = function show(coordinate) {
21894      var map = this.getMap();
21895
21896      if (!map) {
21897        return this;
21898      }
21899
21900      if (!this._mapEventsOn) {
21901        this._switchMapEvents('on');
21902      }
21903
21904      coordinate = coordinate || this._coordinate || this._owner.getCenter();
21905      var visible = this.isVisible();
21906      this.fire('showstart');
21907
21908      var container = this._getUIContainer();
21909
21910      this._coordinate = coordinate;
21911
21912      this._removePrevDOM();
21913
21914      var dom = this.__uiDOM = this.buildOn(map);
21915      dom['eventsPropagation'] = this.options['eventsPropagation'];
21916
21917      if (!dom) {
vendor: 68,985 bytes, lines 21918-24591
21918        this.fire('showend');
21919        return this;
21920      }
21921
21922      this._measureSize(dom);
21923
21924      if (this._singleton()) {
21925        map[this._uiDomKey()] = dom;
21926      }
21927
21928      this._setPosition();
21929
21930      dom.style[TRANSITION] = null;
21931      container.appendChild(dom);
21932
21933      var anim = this._getAnimation();
21934
21935      if (visible) {
21936        anim.ok = false;
21937      }
21938
21939      if (anim.ok) {
21940        if (anim.fade) {
21941          dom.style.opacity = 0;
21942        }
21943
21944        if (anim.scale) {
21945          if (this.getTransformOrigin) {
21946            var origin = this.getTransformOrigin();
21947            dom.style[TRANSFORMORIGIN] = origin;
21948          }
21949
21950          dom.style[TRANSFORM] = this._toCSSTranslate(this._pos) + ' scale(0)';
21951        }
21952      }
21953
21954      dom.style.display = '';
21955
21956      if (this.options['eventsToStop']) {
21957        on(dom, this.options['eventsToStop'], stopPropagation);
21958      }
21959
21960      if (this.options['autoPan']) {
21961        this._autoPan();
21962      }
21963
21964      var transition = anim.transition;
21965
21966      if (anim.ok && transition) {
21967        dom.offsetHeight;
21968
21969        if (transition) {
21970          dom.style[TRANSITION] = transition;
21971        }
21972
21973        if (anim.fade) {
21974          dom.style.opacity = 1;
21975        }
21976
21977        if (anim.scale) {
21978          dom.style[TRANSFORM] = this._toCSSTranslate(this._pos) + ' scale(1)';
21979        }
21980      }
21981
21982      this.fire('showend');
21983      return this;
21984    };
21985
21986    _proto.hide = function hide() {
21987      var _this = this;
21988
21989      if (!this.getDOM() || !this.getMap()) {
21990        return this;
21991      }
21992
21993      var anim = this._getAnimation(),
21994          dom = this.getDOM();
21995
21996      if (!this.options['animationOnHide']) {
21997        anim.ok = false;
21998      }
21999
22000      if (!anim.ok) {
22001        dom.style.display = 'none';
22002        this.fire('hide');
22003      } else {
22004        dom.offsetHeight;
22005        dom.style[TRANSITION] = anim.transition;
22006        setTimeout(function () {
22007          dom.style.display = 'none';
22008
22009          _this.fire('hide');
22010        }, this.options['animationDuration']);
22011      }
22012
22013      if (anim.fade) {
22014        dom.style.opacity = 0;
22015      }
22016
22017      if (anim.scale) {
22018        dom.style[TRANSFORM] = this._toCSSTranslate(this._pos) + ' scale(0)';
22019      }
22020
22021      return this;
22022    };
22023
22024    _proto.isVisible = function isVisible() {
22025      var dom = this.getDOM();
22026      return this.getMap() && dom && dom.parentNode && dom.style.display !== 'none';
22027    };
22028
22029    _proto.remove = function remove() {
22030      delete this._mapEventsOn;
22031
22032      if (!this._owner) {
22033        return this;
22034      }
22035
22036      this.hide();
22037
22038      this._switchEvents('off');
22039
22040      if (this.onRemove) {
22041        this.onRemove();
22042      }
22043
22044      if (!this._singleton() && this.__uiDOM) {
22045        this._removePrevDOM();
22046      }
22047
22048      delete this._owner;
22049      this.fire('remove');
22050      return this;
22051    };
22052
22053    _proto.getSize = function getSize() {
22054      if (this._size) {
22055        return this._size.copy();
22056      } else {
22057        return null;
22058      }
22059    };
22060
22061    _proto.getOwner = function getOwner() {
22062      return this._owner;
22063    };
22064
22065    _proto.getDOM = function getDOM() {
22066      return this.__uiDOM;
22067    };
22068
22069    _proto.getPosition = function getPosition() {
22070      if (!this.getMap()) {
22071        return null;
22072      }
22073
22074      var p = this._getViewPoint()._round();
22075
22076      if (this.getOffset) {
22077        var o = this.getOffset()._round();
22078
22079        if (o) {
22080          p._add(o);
22081        }
22082      }
22083
22084      return p;
22085    };
22086
22087    _proto._getAnimation = function _getAnimation() {
22088      var anim = {
22089        'fade': false,
22090        'scale': false
22091      };
22092      var animations = this.options['animation'] ? this.options['animation'].split(',') : [];
22093
22094      for (var i = 0; i < animations.length; i++) {
22095        var trimed = trim(animations[i]);
22096
22097        if (trimed === 'fade') {
22098          anim.fade = true;
22099        } else if (trimed === 'scale') {
22100          anim.scale = true;
22101        }
22102      }
22103
22104      var transition = null;
22105
22106      if (anim.fade) {
22107        transition = 'opacity ' + this.options['animationDuration'] + 'ms';
22108      }
22109
22110      if (anim.scale) {
22111        transition = transition ? transition + ',' : '';
22112        transition += TRANSFORM + ' ' + this.options['animationDuration'] + 'ms';
22113      }
22114
22115      anim.transition = transition;
22116      anim.ok = transition !== null;
22117      return anim;
22118    };
22119
22120    _proto._getViewPoint = function _getViewPoint() {
22121      return this.getMap().coordToViewPoint(this._coordinate)._add(this.options['dx'], this.options['dy']);
22122    };
22123
22124    _proto._autoPan = function _autoPan() {
22125      var map = this.getMap(),
22126          dom = this.getDOM();
22127
22128      if (map.isMoving()) {
22129        return;
22130      }
22131
22132      var point = this._pos;
22133      var mapSize = map.getSize(),
22134          mapWidth = mapSize['width'],
22135          mapHeight = mapSize['height'];
22136      var containerPoint = map.viewPointToContainerPoint(point);
22137      var clientWidth = parseInt(dom.clientWidth),
22138          clientHeight = parseInt(dom.clientHeight);
22139      var left = 0,
22140          top = 0;
22141
22142      if (containerPoint.x < 0) {
22143        left = -(containerPoint.x - clientWidth / 2);
22144      } else if (containerPoint.x + clientWidth - 35 > mapWidth) {
22145        left = mapWidth - (containerPoint.x + clientWidth * 3 / 2);
22146      }
22147
22148      if (containerPoint.y - clientHeight < 0) {
22149        top = -(containerPoint.y - clientHeight) + 50;
22150      } else if (containerPoint.y > mapHeight) {
22151        top = mapHeight - containerPoint.y - clientHeight - 30;
22152      }
22153
22154      if (top !== 0 || left !== 0) {
22155        map.panBy(new Point(left, top), {
22156          'duration': this.options['autoPanDuration']
22157        });
22158      }
22159    };
22160
22161    _proto._measureSize = function _measureSize(dom) {
22162      var container = this._getUIContainer();
22163
22164      dom.style.position = 'absolute';
22165      dom.style.left = -99999 + 'px';
22166      var anchor = dom.style.bottom ? 'bottom' : 'top';
22167      dom.style[anchor] = -99999 + 'px';
22168      dom.style.display = '';
22169      container.appendChild(dom);
22170      this._size = new Size(dom.clientWidth, dom.clientHeight);
22171      dom.style.display = 'none';
22172      dom.style.left = '0px';
22173      dom.style[anchor] = '0px';
22174      return this._size;
22175    };
22176
22177    _proto._removePrevDOM = function _removePrevDOM() {
22178      if (this.onDomRemove) {
22179        this.onDomRemove();
22180      }
22181
22182      var eventsToStop = this.options['eventsToStop'];
22183
22184      if (this._singleton()) {
22185        var map = this.getMap(),
22186            key = this._uiDomKey();
22187
22188        if (map[key]) {
22189          if (eventsToStop) {
22190            off(map[key], eventsToStop, stopPropagation);
22191          }
22192
22193          removeDomNode(map[key]);
22194          delete map[key];
22195        }
22196
22197        delete this.__uiDOM;
22198      } else if (this.__uiDOM) {
22199        if (eventsToStop) {
22200          off(this.__uiDOM, eventsToStop, stopPropagation);
22201        }
22202
22203        removeDomNode(this.__uiDOM);
22204        delete this.__uiDOM;
22205      }
22206    };
22207
22208    _proto._uiDomKey = function _uiDomKey() {
22209      return '__ui_' + this._getClassName();
22210    };
22211
22212    _proto._singleton = function _singleton() {
22213      return this.options['single'];
22214    };
22215
22216    _proto._getUIContainer = function _getUIContainer() {
22217      return this.getMap()._panels['ui'];
22218    };
22219
22220    _proto._getClassName = function _getClassName() {
22221      return 'UIComponent';
22222    };
22223
22224    _proto._switchMapEvents = function _switchMapEvents(to) {
22225      var map = this.getMap();
22226
22227      if (!map) {
22228        return;
22229      }
22230
22231      this._mapEventsOn = to === 'on';
22232
22233      var events = this._getDefaultEvents();
22234
22235      if (this.getEvents) {
22236        extend(events, this.getEvents());
22237      }
22238
22239      if (events) {
22240        for (var p in events) {
22241          if (events.hasOwnProperty(p)) {
22242            map[to](p, events[p], this);
22243          }
22244        }
22245      }
22246    };
22247
22248    _proto._switchEvents = function _switchEvents(to) {
22249      this._switchMapEvents(to);
22250
22251      var ownerEvents = this._getOwnerEvents();
22252
22253      if (this._owner) {
22254        for (var p in ownerEvents) {
22255          if (ownerEvents.hasOwnProperty(p)) {
22256            this._owner[to](p, ownerEvents[p], this);
22257          }
22258        }
22259      }
22260    };
22261
22262    _proto._getDefaultEvents = function _getDefaultEvents() {
22263      return {
22264        'zooming rotate pitch': this.onEvent,
22265        'zoomend': this.onZoomEnd,
22266        'moving': this.onMoving
22267      };
22268    };
22269
22270    _proto._getOwnerEvents = function _getOwnerEvents() {
22271      var events = {};
22272
22273      if (this._owner && this._owner instanceof Geometry) {
22274        events.positionchange = this.onGeometryPositionChange;
22275      }
22276
22277      if (this.getOwnerEvents) {
22278        extend(events, this.getOwnerEvents());
22279      }
22280
22281      return events;
22282    };
22283
22284    _proto.onGeometryPositionChange = function onGeometryPositionChange(param) {
22285      if (this._owner && this.isVisible()) {
22286        this.show(param['target'].getCenter());
22287      }
22288    };
22289
22290    _proto.onMoving = function onMoving() {
22291      if (this.isVisible() && this.getMap().isTransforming()) {
22292        this._updatePosition();
22293      }
22294    };
22295
22296    _proto.onEvent = function onEvent() {
22297      if (this.isVisible()) {
22298        this._updatePosition();
22299      }
22300    };
22301
22302    _proto.onZoomEnd = function onZoomEnd() {
22303      if (this.isVisible()) {
22304        this._setPosition();
22305      }
22306    };
22307
22308    _proto._updatePosition = function _updatePosition() {
22309      var renderer = this.getMap()._getRenderer();
22310
22311      renderer.callInNextFrame(this._setPosition.bind(this));
22312    };
22313
22314    _proto._setPosition = function _setPosition() {
22315      var dom = this.getDOM();
22316      if (!dom) return;
22317      dom.style[TRANSITION] = null;
22318      var p = this.getPosition();
22319      this._pos = p;
22320      dom.style[TRANSFORM] = this._toCSSTranslate(p) + ' scale(1)';
22321    };
22322
22323    _proto._toCSSTranslate = function _toCSSTranslate(p) {
22324      if (!p) {
22325        return '';
22326      }
22327
22328      if (Browser$1.any3d) {
22329        var map = this.getMap(),
22330            bearing = map ? map.getBearing() : 0,
22331            pitch = map ? map.getPitch() : 0;
22332        var r = '';
22333
22334        if (this.options['pitchWithMap'] && pitch) {
22335          r += " rotateX(" + Math.round(pitch) + "deg)";
22336        }
22337
22338        if (this.options['rotateWithMap'] && bearing) {
22339          r += " rotateZ(" + Math.round(-bearing) + "deg)";
22340        }
22341
22342        return 'translate3d(' + p.x + 'px,' + p.y + 'px, 0px)' + r;
22343      } else {
22344        return 'translate(' + p.x + 'px,' + p.y + 'px)';
22345      }
22346    };
22347
22348    return UIComponent;
22349  }(Eventable(Class));
22350
22351  UIComponent.mergeOptions(options$j);
22352
22353  var options$k = {
22354    'eventsPropagation': true,
22355    'draggable': false,
22356    'single': false,
22357    'content': null
22358  };
22359  var domEvents = 'mousedown ' + 'mouseup ' + 'mouseenter ' + 'mouseover ' + 'mouseout ' + 'mousemove ' + 'click ' + 'dblclick ' + 'contextmenu ' + 'keypress ' + 'touchstart ' + 'touchmove ' + 'touchend';
22360
22361  var UIMarker = function (_Handlerable) {
22362    _inheritsLoose(UIMarker, _Handlerable);
22363
22364    function UIMarker(coordinate, options) {
22365      var _this;
22366
22367      _this = _Handlerable.call(this, options) || this;
22368      _this._markerCoord = new Coordinate(coordinate);
22369      return _this;
22370    }
22371
22372    var _proto = UIMarker.prototype;
22373
22374    _proto._getClassName = function _getClassName() {
22375      return 'UIMarker';
22376    };
22377
22378    _proto.setCoordinates = function setCoordinates(coordinates) {
22379      this._markerCoord = coordinates;
22380      this.fire('positionchange');
22381
22382      if (this.isVisible()) {
22383        this._coordinate = this._markerCoord;
22384
22385        this._setPosition();
22386      }
22387
22388      return this;
22389    };
22390
22391    _proto.getCoordinates = function getCoordinates() {
22392      return this._markerCoord;
22393    };
22394
22395    _proto.setContent = function setContent(content) {
22396      var old = this.options['content'];
22397      this.options['content'] = content;
22398      this.fire('contentchange', {
22399        'old': old,
22400        'new': content
22401      });
22402
22403      if (this.isVisible()) {
22404        this.show();
22405      }
22406
22407      return this;
22408    };
22409
22410    _proto.getContent = function getContent() {
22411      return this.options['content'];
22412    };
22413
22414    _proto.onAdd = function onAdd() {
22415      this.show();
22416    };
22417
22418    _proto.show = function show() {
22419      return _Handlerable.prototype.show.call(this, this._markerCoord);
22420    };
22421
22422    _proto.flash = function flash$$1(interval, count, cb, context) {
22423      return flash.call(this, interval, count, cb, context);
22424    };
22425
22426    _proto.buildOn = function buildOn() {
22427      var dom;
22428
22429      if (isString(this.options['content'])) {
22430        dom = createEl('div');
22431        dom.innerHTML = this.options['content'];
22432      } else {
22433        dom = this.options['content'];
22434      }
22435
22436      this._registerDOMEvents(dom);
22437
22438      return dom;
22439    };
22440
22441    _proto.getOffset = function getOffset() {
22442      var size = this.getSize();
22443      return new Point(-size.width / 2, -size.height / 2);
22444    };
22445
22446    _proto.getTransformOrigin = function getTransformOrigin() {
22447      return 'center center';
22448    };
22449
22450    _proto.onDomRemove = function onDomRemove() {
22451      var dom = this.getDOM();
22452
22453      this._removeDOMEvents(dom);
22454    };
22455
22456    _proto.isDragging = function isDragging() {
22457      if (this['draggable']) {
22458        return this['draggable'].isDragging();
22459      }
22460
22461      return false;
22462    };
22463
22464    _proto._registerDOMEvents = function _registerDOMEvents(dom) {
22465      on(dom, domEvents, this._onDomEvents, this);
22466    };
22467
22468    _proto._onDomEvents = function _onDomEvents(e) {
22469      var event = this.getMap()._parseEvent(e, e.type);
22470
22471      this.fire(e.type, event);
22472    };
22473
22474    _proto._removeDOMEvents = function _removeDOMEvents(dom) {
22475      off(dom, domEvents, this._onDomEvents, this);
22476    };
22477
22478    _proto._getConnectPoints = function _getConnectPoints() {
22479      var map = this.getMap();
22480      var containerPoint = map.coordToContainerPoint(this.getCoordinates());
22481      var size = this.getSize(),
22482          width = size.width,
22483          height = size.height;
22484      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))];
22485      return anchors;
22486    };
22487
22488    return UIMarker;
22489  }(Handlerable(UIComponent));
22490
22491  UIMarker.mergeOptions(options$k);
22492  var EVENTS$1 = Browser$1.touch ? 'touchstart mousedown' : 'mousedown';
22493
22494  var UIMarkerDragHandler = function (_Handler) {
22495    _inheritsLoose(UIMarkerDragHandler, _Handler);
22496
22497    function UIMarkerDragHandler(target) {
22498      return _Handler.call(this, target) || this;
22499    }
22500
22501    var _proto2 = UIMarkerDragHandler.prototype;
22502
22503    _proto2.addHooks = function addHooks() {
22504      this.target.on(EVENTS$1, this._startDrag, this);
22505    };
22506
22507    _proto2.removeHooks = function removeHooks() {
22508      this.target.off(EVENTS$1, this._startDrag, this);
22509    };
22510
22511    _proto2._startDrag = function _startDrag(param) {
22512      var domEvent = param['domEvent'];
22513
22514      if (domEvent.touches && domEvent.touches.length > 1 || domEvent.button === 2) {
22515        return;
22516      }
22517
22518      if (this.isDragging()) {
22519        return;
22520      }
22521
22522      this.target.on('click', this._endDrag, this);
22523      this._lastCoord = param['coordinate'];
22524      this._lastPoint = param['containerPoint'];
22525
22526      this._prepareDragHandler();
22527
22528      this._dragHandler.onMouseDown(param['domEvent']);
22529
22530      this.target.fire('dragstart', param);
22531    };
22532
22533    _proto2._prepareDragHandler = function _prepareDragHandler() {
22534      this._dragHandler = new DragHandler(this.target.getDOM(), {
22535        'cancelOn': this._cancelOn.bind(this),
22536        'ignoreMouseleave': true
22537      });
22538
22539      this._dragHandler.on('mousedown', this._onMouseDown, this);
22540
22541      this._dragHandler.on('dragging', this._dragging, this);
22542
22543      this._dragHandler.on('mouseup', this._endDrag, this);
22544
22545      this._dragHandler.enable();
22546    };
22547
22548    _proto2._cancelOn = function _cancelOn(domEvent) {
22549      var target = domEvent.srcElement || domEvent.target,
22550          tagName = target.tagName.toLowerCase();
22551
22552      if (tagName === 'button' || tagName === 'input' || tagName === 'select' || tagName === 'option' || tagName === 'textarea') {
22553        return true;
22554      }
22555
22556      return false;
22557    };
22558
22559    _proto2._onMouseDown = function _onMouseDown(param) {
22560      stopPropagation(param['domEvent']);
22561    };
22562
22563    _proto2._dragging = function _dragging(param) {
22564      var target = this.target,
22565          map = target.getMap(),
22566          eventParam = map._parseEvent(param['domEvent']),
22567          domEvent = eventParam['domEvent'];
22568
22569      if (domEvent.touches && domEvent.touches.length > 1) {
22570        return;
22571      }
22572
22573      if (!this._isDragging) {
22574        this._isDragging = true;
22575        return;
22576      }
22577
22578      var coord = eventParam['coordinate'],
22579          point = eventParam['containerPoint'];
22580
22581      if (!this._lastCoord) {
22582        this._lastCoord = coord;
22583      }
22584
22585      if (!this._lastPoint) {
22586        this._lastPoint = point;
22587      }
22588
22589      var coordOffset = coord.sub(this._lastCoord),
22590          pointOffset = point.sub(this._lastPoint);
22591      this._lastCoord = coord;
22592      this._lastPoint = point;
22593      this.target.setCoordinates(this.target.getCoordinates().add(coordOffset));
22594      eventParam['coordOffset'] = coordOffset;
22595      eventParam['pointOffset'] = pointOffset;
22596      target.fire('dragging', eventParam);
22597    };
22598
22599    _proto2._endDrag = function _endDrag(param) {
22600      var target = this.target,
22601          map = target.getMap();
22602
22603      if (this._dragHandler) {
22604        target.off('click', this._endDrag, this);
22605
22606        this._dragHandler.disable();
22607
22608        delete this._dragHandler;
22609      }
22610
22611      delete this._lastCoord;
22612      delete this._lastPoint;
22613      this._isDragging = false;
22614
22615      if (!map) {
22616        return;
22617      }
22618
22619      var eventParam = map._parseEvent(param['domEvent']);
22620
22621      target.fire('dragend', eventParam);
22622    };
22623
22624    _proto2.isDragging = function isDragging() {
22625      if (!this._isDragging) {
22626        return false;
22627      }
22628
22629      return true;
22630    };
22631
22632    return UIMarkerDragHandler;
22633  }(Handler$1);
22634
22635  UIMarker.addInitHook('addHandler', 'draggable', UIMarkerDragHandler);
22636
22637  var options$l = {
22638    'autoPan': true,
22639    'autoCloseOn': null,
22640    'autoOpenOn': 'click',
22641    'width': 300,
22642    'minHeight': 120,
22643    'custom': false,
22644    'title': null,
22645    'content': null
22646  };
22647
22648  var InfoWindow = function (_UIComponent) {
22649    _inheritsLoose(InfoWindow, _UIComponent);
22650
22651    function InfoWindow() {
22652      return _UIComponent.apply(this, arguments) || this;
22653    }
22654
22655    var _proto = InfoWindow.prototype;
22656
22657    _proto._getClassName = function _getClassName() {
22658      return 'InfoWindow';
22659    };
22660
22661    _proto.addTo = function addTo(owner) {
22662      if (owner instanceof Geometry) {
22663        if (owner.getInfoWindow() && owner.getInfoWindow() !== this) {
22664          owner.removeInfoWindow();
22665        }
22666
22667        owner._infoWindow = this;
22668      }
22669
22670      return _UIComponent.prototype.addTo.call(this, owner);
22671    };
22672
22673    _proto.setContent = function setContent(content) {
22674      var old = this.options['content'];
22675      this.options['content'] = content;
22676      this.fire('contentchange', {
22677        'old': old,
22678        'new': content
22679      });
22680
22681      if (this.isVisible()) {
22682        this.show(this._coordinate);
22683      }
22684
22685      return this;
22686    };
22687
22688    _proto.getContent = function getContent() {
22689      return this.options['content'];
22690    };
22691
22692    _proto.setTitle = function setTitle(title) {
22693      var old = title;
22694      this.options['title'] = title;
22695      this.fire('contentchange', {
22696        'old': old,
22697        'new': title
22698      });
22699
22700      if (this.isVisible()) {
22701        this.show(this._coordinate);
22702      }
22703
22704      return this;
22705    };
22706
22707    _proto.getTitle = function getTitle() {
22708      return this.options['title'];
22709    };
22710
22711    _proto.buildOn = function buildOn() {
22712      if (this.options['custom']) {
22713        if (isString(this.options['content'])) {
22714          var _dom = createEl('div');
22715
22716          _dom.innerHTML = this.options['content'];
22717          return _dom;
22718        } else {
22719          return this.options['content'];
22720        }
22721      }
22722
22723      var dom = createEl('div');
22724      dom.className = 'maptalks-msgBox';
22725      dom.style.width = this._getWindowWidth() + 'px';
22726      dom.style.bottom = '0px';
22727      var content = '<em class="maptalks-ico"></em>';
22728
22729      if (this.options['title']) {
22730        content += '<h2>' + this.options['title'] + '</h2>';
22731      }
22732
22733      content += '<a href="javascript:void(0);" class="maptalks-close"></a><div class="maptalks-msgContent"></div>';
22734      dom.innerHTML = content;
22735      var msgContent = dom.querySelector('.maptalks-msgContent');
22736
22737      if (isString(this.options['content'])) {
22738        msgContent.innerHTML = this.options['content'];
22739      } else {
22740        msgContent.appendChild(this.options['content']);
22741      }
22742
22743      this._onCloseBtnClick = this.hide.bind(this);
22744      var closeBtn = dom.querySelector('.maptalks-close');
22745      addDomEvent(closeBtn, 'click touchend', this._onCloseBtnClick);
22746      return dom;
22747    };
22748
22749    _proto.getTransformOrigin = function getTransformOrigin() {
22750      var size = this.getSize();
22751      return size.width / 2 + 'px bottom';
22752    };
22753
22754    _proto.getOffset = function getOffset() {
22755      var size = this.getSize();
22756      var o = new Point(-size['width'] / 2, 0);
22757
22758      if (!this.options['custom']) {
22759        o._sub(4, 12);
22760      } else {
22761        o._sub(0, size['height']);
22762      }
22763
22764      var owner = this.getOwner();
22765
22766      if (owner instanceof Marker || owner instanceof MultiPoint) {
22767        var painter, markerSize;
22768
22769        if (owner instanceof Marker) {
22770          painter = owner._getPainter();
22771          markerSize = owner.getSize();
22772        } else {
22773          var children = owner.getGeometries();
22774
22775          if (!children || !children.length) {
22776            return o;
22777          }
22778
22779          painter = children[0]._getPainter();
22780          markerSize = children[0].getSize();
22781        }
22782
22783        if (painter) {
22784          var fixExtent = painter.getFixedExtent();
22785
22786          o._add(fixExtent.xmax - markerSize.width / 2, fixExtent.ymin);
22787        }
22788      }
22789
22790      return o;
22791    };
22792
22793    _proto.show = function show(coordinate) {
22794      if (!this.getMap()) {
22795        return this;
22796      }
22797
22798      if (!this.getMap().options['enableInfoWindow']) {
22799        return this;
22800      }
22801
22802      return _UIComponent.prototype.show.call(this, coordinate);
22803    };
22804
22805    _proto.getEvents = function getEvents() {
22806      if (!this.options['autoCloseOn']) {
22807        return null;
22808      }
22809
22810      var events = {};
22811      events[this.options['autoCloseOn']] = this.hide;
22812      return events;
22813    };
22814
22815    _proto.getOwnerEvents = function getOwnerEvents() {
22816      var owner = this.getOwner();
22817
22818      if (!this.options['autoOpenOn'] || !owner) {
22819        return null;
22820      }
22821
22822      var events = {};
22823      events[this.options['autoOpenOn']] = this._onAutoOpen;
22824      return events;
22825    };
22826
22827    _proto.onRemove = function onRemove() {
22828      this.onDomRemove();
22829    };
22830
22831    _proto.onDomRemove = function onDomRemove() {
22832      if (this._onCloseBtnClick) {
22833        var dom = this.getDOM();
22834        var closeBtn = dom.childNodes[2];
22835        removeDomEvent(closeBtn, 'click touchend', this._onCloseBtnClick);
22836        delete this._onCloseBtnClick;
22837      }
22838    };
22839
22840    _proto._onAutoOpen = function _onAutoOpen(e) {
22841      var _this = this;
22842
22843      var owner = this.getOwner();
22844      setTimeout(function () {
22845        if (owner instanceof Marker) {
22846          _this.show(owner.getCoordinates());
22847        } else if (owner instanceof MultiPoint) {
22848          _this.show(owner.findClosest(e.coordinate));
22849        } else {
22850          _this.show(e.coordinate);
22851        }
22852      }, 1);
22853    };
22854
22855    _proto._getWindowWidth = function _getWindowWidth() {
22856      var defaultWidth = 300;
22857      var width = this.options['width'];
22858
22859      if (!width) {
22860        width = defaultWidth;
22861      }
22862
22863      return width;
22864    };
22865
22866    return InfoWindow;
22867  }(UIComponent);
22868
22869  InfoWindow.mergeOptions(options$l);
22870
22871  var options$m = {
22872    'width': 0,
22873    'height': 0,
22874    'animation': 'fade',
22875    'cssName': 'maptalks-tooltip',
22876    'showTimeout': 400
22877  };
22878
22879  var ToolTip = function (_UIComponent) {
22880    _inheritsLoose(ToolTip, _UIComponent);
22881
22882    var _proto = ToolTip.prototype;
22883
22884    _proto._getClassName = function _getClassName() {
22885      return 'ToolTip';
22886    };
22887
22888    function ToolTip(content, options) {
22889      var _this;
22890
22891      if (options === void 0) {
22892        options = {};
22893      }
22894
22895      _this = _UIComponent.call(this, options) || this;
22896      _this._content = content;
22897      return _this;
22898    }
22899
22900    _proto.addTo = function addTo(owner) {
22901      if (owner instanceof Geometry || owner instanceof UIMarker) {
22902        owner.on('mousemove', this.onMouseMove, this);
22903        owner.on('mouseout', this.onMouseOut, this);
22904        return _UIComponent.prototype.addTo.call(this, owner);
22905      } else {
22906        throw new Error('Invalid geometry or UIMarker the tooltip is added to.');
22907      }
22908    };
22909
22910    _proto.setStyle = function setStyle$$1(cssName) {
22911      this.options.cssName = cssName;
22912      return this;
22913    };
22914
22915    _proto.getStyle = function getStyle() {
22916      return this.options.cssName;
22917    };
22918
22919    _proto.getContent = function getContent() {
22920      return this._content;
22921    };
22922
22923    _proto.buildOn = function buildOn() {
22924      var dom = createEl('div');
22925      var options = this.options || {};
22926
22927      if (options.height) {
22928        dom.style.height = options.height + 'px';
22929      }
22930
22931      if (options.width) {
22932        dom.style.width = options.width + 'px';
22933      }
22934
22935      var cssName = options.cssName;
22936
22937      if (!cssName && options.height) {
22938        dom.style.lineHeight = options.height + 'px';
22939      }
22940
22941      dom.innerHTML = "<div class=\"" + cssName + "\">" + this._content + "</div>";
22942      return dom;
22943    };
22944
22945    _proto.onMouseOut = function onMouseOut() {
22946      clearTimeout(this._timeout);
22947
22948      if (this.isVisible()) {
22949        this._removePrevDOM();
22950      }
22951    };
22952
22953    _proto.onMouseMove = function onMouseMove(e) {
22954      var _this2 = this;
22955
22956      clearTimeout(this._timeout);
22957      var map = this.getMap();
22958
22959      if (!map) {
22960        return;
22961      }
22962
22963      var coord = map.locateByPoint(e.coordinate, -5, 25);
22964
22965      if (this.options['showTimeout'] === 0) {
22966        this.show(coord);
22967      } else {
22968        this._timeout = setTimeout(function () {
22969          if (map) {
22970            _this2.show(coord);
22971          }
22972        }, this.options['showTimeout']);
22973      }
22974    };
22975
22976    _proto.onRemove = function onRemove() {
22977      clearTimeout(this._timeout);
22978
22979      if (this._owner) {
22980        this._owner.off('mouseover', this.onMouseOver, this);
22981
22982        this._owner.off('mouseout', this.onMouseOut, this);
22983      }
22984    };
22985
22986    return ToolTip;
22987  }(UIComponent);
22988
22989  ToolTip.mergeOptions(options$m);
22990
22991  var defaultOptions = {
22992    'animation': null,
22993    'animationDelay': 10,
22994    'animationOnHide': false,
22995    'autoPan': false,
22996    'width': 160,
22997    'maxHeight': 0,
22998    'custom': false,
22999    'items': []
23000  };
23001
23002  var Menu = function (_UIComponent) {
23003    _inheritsLoose(Menu, _UIComponent);
23004
23005    function Menu(options) {
23006      return _UIComponent.call(this, options) || this;
23007    }
23008
23009    var _proto = Menu.prototype;
23010
23011    _proto._getClassName = function _getClassName() {
23012      return 'Menu';
23013    };
23014
23015    _proto.addTo = function addTo(owner) {
23016      if (owner._menu && owner._menu !== this) {
23017        owner.removeMenu();
23018      }
23019
23020      owner._menu = this;
23021      return UIComponent.prototype.addTo.apply(this, arguments);
23022    };
23023
23024    _proto.setItems = function setItems(items) {
23025      this.options['items'] = items;
23026      return this;
23027    };
23028
23029    _proto.getItems = function getItems() {
23030      return this.options['items'] || [];
23031    };
23032
23033    _proto.buildOn = function buildOn() {
23034      if (this.options['custom']) {
23035        if (isString(this.options['items'])) {
23036          var container = createEl('div');
23037          container.innerHTML = this.options['items'];
23038          return container;
23039        } else {
23040          return this.options['items'];
23041        }
23042      } else {
23043        var dom = createEl('div');
23044        addClass(dom, 'maptalks-menu');
23045        dom.style.width = this._getMenuWidth() + 'px';
23046
23047        var menuItems = this._createMenuItemDom();
23048
23049        dom.appendChild(menuItems);
23050        on(dom, 'contextmenu', preventDefault);
23051        return dom;
23052      }
23053    };
23054
23055    _proto.getOffset = function getOffset() {
23056      if (!this.getMap()) {
23057        return null;
23058      }
23059
23060      var mapSize = this.getMap().getSize(),
23061          p = this.getMap().viewPointToContainerPoint(this._getViewPoint()),
23062          size = this.getSize();
23063      var dx = 0,
23064          dy = 0;
23065
23066      if (p.x + size['width'] > mapSize['width']) {
23067        dx = -size['width'];
23068      }
23069
23070      if (p.y + size['height'] > mapSize['height']) {
23071        dy = -size['height'];
23072      }
23073
23074      return new Point(dx, dy);
23075    };
23076
23077    _proto.getTransformOrigin = function getTransformOrigin() {
23078      var p = this.getOffset()._multi(-1);
23079
23080      return p.x + 'px ' + p.y + 'px';
23081    };
23082
23083    _proto.getEvents = function getEvents() {
23084      return {
23085        '_zoomstart _zoomend _movestart _dblclick _click': this._removePrevDOM
23086      };
23087    };
23088
23089    _proto._createMenuItemDom = function _createMenuItemDom() {
23090      var me = this;
23091      var map = this.getMap();
23092      var ul = createEl('ul');
23093      addClass(ul, 'maptalks-menu-items');
23094      var items = this.getItems();
23095
23096      function onMenuClick(index) {
23097        return function (e) {
23098          var param = map._parseEvent(e, 'click');
23099
23100          param['target'] = me;
23101          param['owner'] = me._owner;
23102          param['index'] = index;
23103
23104          var result = this._callback(param);
23105
23106          if (result === false) {
23107            return;
23108          }
23109
23110          me.hide();
23111        };
23112      }
23113
23114      var item, itemDOM;
23115
23116      for (var i = 0, len = items.length; i < len; i++) {
23117        item = items[i];
23118
23119        if (item === '-' || item === '_') {
23120          itemDOM = createEl('li');
23121          addClass(itemDOM, 'maptalks-menu-splitter');
23122        } else {
23123          itemDOM = createEl('li');
23124          var itemTitle = item['item'];
23125
23126          if (isFunction(itemTitle)) {
23127            itemTitle = itemTitle({
23128              'owner': this._owner,
23129              'index': i
23130            });
23131          }
23132
23133          itemDOM.innerHTML = itemTitle;
23134          itemDOM._callback = item['click'];
23135          on(itemDOM, 'click', onMenuClick(i));
23136        }
23137
23138        ul.appendChild(itemDOM);
23139      }
23140
23141      var maxHeight = this.options['maxHeight'] || 0;
23142
23143      if (maxHeight > 0) {
23144        setStyle(ul, 'max-height: ' + maxHeight + 'px; overflow-y: auto;');
23145      }
23146
23147      return ul;
23148    };
23149
23150    _proto._getMenuWidth = function _getMenuWidth() {
23151      var defaultWidth = 160;
23152      var width = this.options['width'] || defaultWidth;
23153      return width;
23154    };
23155
23156    return Menu;
23157  }(UIComponent);
23158
23159  Menu.mergeOptions(defaultOptions);
23160
23161  var Menuable = {
23162    setMenu: function setMenu(options) {
23163      this._menuOptions = options;
23164
23165      if (this._menu) {
23166        this._menu.setOptions(options);
23167      } else {
23168        this.on('contextmenu', this._defaultOpenMenu, this);
23169      }
23170
23171      return this;
23172    },
23173    openMenu: function openMenu(coordinate) {
23174      var map = this instanceof Map$1 ? this : this.getMap();
23175
23176      if (!coordinate) {
23177        coordinate = this.getCenter();
23178      }
23179
23180      if (!this._menu) {
23181        if (this._menuOptions && map) {
23182          this._bindMenu(this._menuOptions);
23183
23184          this._menu.show(coordinate);
23185        }
23186      } else {
23187        this._menu.show(coordinate);
23188      }
23189
23190      return this;
23191    },
23192    setMenuItems: function setMenuItems(items) {
23193      if (!this._menuOptions) {
23194        this._menuOptions = {};
23195      }
23196
23197      if (Array.isArray(items)) {
23198        this._menuOptions['custom'] = false;
23199      }
23200
23201      this._menuOptions['items'] = items;
23202      this.setMenu(this._menuOptions);
23203      return this;
23204    },
23205    getMenuItems: function getMenuItems() {
23206      if (this._menu) {
23207        return this._menu.getItems();
23208      } else if (this._menuOptions) {
23209        return this._menuOptions['items'] || [];
23210      }
23211
23212      return [];
23213    },
23214    closeMenu: function closeMenu() {
23215      if (this._menu) {
23216        this._menu.hide();
23217      }
23218
23219      return this;
23220    },
23221    removeMenu: function removeMenu() {
23222      this.off('contextmenu', this._defaultOpenMenu, this);
23223
23224      this._unbindMenu();
23225
23226      delete this._menuOptions;
23227      return this;
23228    },
23229    _bindMenu: function _bindMenu(options) {
23230      this._menu = new Menu(options);
23231
23232      this._menu.addTo(this);
23233
23234      return this;
23235    },
23236    _unbindMenu: function _unbindMenu() {
23237      if (this._menu) {
23238        this.closeMenu();
23239
23240        this._menu.remove();
23241
23242        delete this._menu;
23243      }
23244
23245      return this;
23246    },
23247    _defaultOpenMenu: function _defaultOpenMenu(param) {
23248      if (this.listens('contextmenu') > 1) {
23249        return true;
23250      } else {
23251        this.openMenu(param['coordinate']);
23252        return false;
23253      }
23254    }
23255  };
23256  Map$1.include(Menuable);
23257  Geometry.include(Menuable);
23258
23259
23260
23261  var index$4 = /*#__PURE__*/Object.freeze({
23262    UIComponent: UIComponent,
23263    UIMarker: UIMarker,
23264    InfoWindow: InfoWindow,
23265    ToolTip: ToolTip,
23266    Menuable: Menuable,
23267    Menu: Menu
23268  });
23269
23270  var Control = function (_Eventable) {
23271    _inheritsLoose(Control, _Eventable);
23272
23273    function Control(options) {
23274      if (options && options['position'] && !isString(options['position'])) {
23275        options['position'] = extend({}, options['position']);
23276      }
23277
23278      return _Eventable.call(this, options) || this;
23279    }
23280
23281    var _proto = Control.prototype;
23282
23283    _proto.addTo = function addTo(map) {
23284      this.remove();
23285
23286      if (!map.options['control']) {
23287        return this;
23288      }
23289
23290      this._map = map;
23291      var controlContainer = map._panels.control;
23292      this.__ctrlContainer = createEl('div');
23293      setStyle(this.__ctrlContainer, 'position:absolute;overflow:visible;');
23294      this.update();
23295      controlContainer.appendChild(this.__ctrlContainer);
23296
23297      if (this.onAdd) {
23298        this.onAdd();
23299      }
23300
23301      this.fire('add', {
23302        'dom': controlContainer
23303      });
23304      return this;
23305    };
23306
23307    _proto.update = function update() {
23308      this.__ctrlContainer.innerHTML = '';
23309      this._controlDom = this.buildOn(this.getMap());
23310
23311      if (this._controlDom) {
23312        this._updatePosition();
23313
23314        this.__ctrlContainer.appendChild(this._controlDom);
23315      }
23316
23317      return this;
23318    };
23319
23320    _proto.getMap = function getMap() {
23321      return this._map;
23322    };
23323
23324    _proto.getPosition = function getPosition() {
23325      return extend({}, this._parse(this.options['position']));
23326    };
23327
23328    _proto.setPosition = function setPosition(position) {
23329      if (isString(position)) {
23330        this.options['position'] = position;
23331      } else {
23332        this.options['position'] = extend({}, position);
23333      }
23334
23335      this._updatePosition();
23336
23337      return this;
23338    };
23339
23340    _proto.getContainerPoint = function getContainerPoint() {
23341      var position = this.getPosition();
23342      var size = this.getMap().getSize();
23343      var x, y;
23344
23345      if (!isNil(position['left'])) {
23346        x = parseInt(position['left']);
23347      } else if (!isNil(position['right'])) {
23348        x = size['width'] - parseInt(position['right']);
23349      }
23350
23351      if (!isNil(position['top'])) {
23352        y = parseInt(position['top']);
23353      } else if (!isNil(position['bottom'])) {
23354        y = size['height'] - parseInt(position['bottom']);
23355      }
23356
23357      return new Point(x, y);
23358    };
23359
23360    _proto.getContainer = function getContainer() {
23361      return this.__ctrlContainer;
23362    };
23363
23364    _proto.getDOM = function getDOM() {
23365      return this._controlDom;
23366    };
23367
23368    _proto.show = function show() {
23369      this.__ctrlContainer.style.display = '';
23370      return this;
23371    };
23372
23373    _proto.hide = function hide() {
23374      this.__ctrlContainer.style.display = 'none';
23375      return this;
23376    };
23377
23378    _proto.isVisible = function isVisible() {
23379      return this.__ctrlContainer && this.__ctrlContainer.style.display === '';
23380    };
23381
23382    _proto.remove = function remove() {
23383      if (!this._map) {
23384        return this;
23385      }
23386
23387      removeDomNode(this.__ctrlContainer);
23388
23389      if (this.onRemove) {
23390        this.onRemove();
23391      }
23392
23393      delete this._map;
23394      delete this.__ctrlContainer;
23395      delete this._controlDom;
23396      this.fire('remove');
23397      return this;
23398    };
23399
23400    _proto._parse = function _parse(position) {
23401      var p = position;
23402
23403      if (isString(position)) {
23404        p = Control['positions'][p];
23405      }
23406
23407      return p;
23408    };
23409
23410    _proto._updatePosition = function _updatePosition() {
23411      var position = this.getPosition();
23412
23413      if (!position) {
23414        position = {
23415          'top': 20,
23416          'left': 20
23417        };
23418      }
23419
23420      for (var p in position) {
23421        if (position.hasOwnProperty(p)) {
23422          position[p] = parseInt(position[p]);
23423          this.__ctrlContainer.style[p] = position[p] + 'px';
23424        }
23425      }
23426
23427      this.fire('positionchange', {
23428        'position': extend({}, position)
23429      });
23430    };
23431
23432    return Control;
23433  }(Eventable(Class));
23434
23435  Control.positions = {
23436    'top-left': {
23437      'top': 20,
23438      'left': 20
23439    },
23440    'top-right': {
23441      'top': 20,
23442      'right': 20
23443    },
23444    'bottom-left': {
23445      'bottom': 20,
23446      'left': 20
23447    },
23448    'bottom-right': {
23449      'bottom': 20,
23450      'right': 20
23451    }
23452  };
23453  Map$1.mergeOptions({
23454    'control': true
23455  });
23456  Map$1.include({
23457    addControl: function addControl(control) {
23458      if (this._containerDOM.getContext) {
23459        return this;
23460      }
23461
23462      control.addTo(this);
23463      return this;
23464    },
23465    removeControl: function removeControl(control) {
23466      if (!control || control.getMap() !== this) {
23467        return this;
23468      }
23469
23470      control.remove();
23471      return this;
23472    }
23473  });
23474
23475  var options$n = {
23476    'position': {
23477      'bottom': 0,
23478      'left': 0
23479    },
23480    'content': '<a href="http://maptalks.org" target="_blank">maptalks</a>'
23481  };
23482  var layerEvents = 'addlayer removelayer setbaselayer baselayerremove';
23483
23484  var Attribution = function (_Control) {
23485    _inheritsLoose(Attribution, _Control);
23486
23487    function Attribution() {
23488      return _Control.apply(this, arguments) || this;
23489    }
23490
23491    var _proto = Attribution.prototype;
23492
23493    _proto.buildOn = function buildOn() {
23494      this._attributionContainer = createEl('div');
23495      this._attributionContainer.className = 'maptalks-attribution';
23496
23497      this._update();
23498
23499      return this._attributionContainer;
23500    };
23501
23502    _proto.onAdd = function onAdd() {
23503      this.getMap().on(layerEvents, this._update, this);
23504    };
23505
23506    _proto.onRemove = function onRemove() {
23507      this.getMap().off(layerEvents, this._update, this);
23508    };
23509
23510    _proto._update = function _update() {
23511      var map = this.getMap();
23512
23513      if (!map) {
23514        return;
23515      }
23516
23517      var attributions = map._getLayers(function (layer) {
23518        return layer.options['attribution'];
23519      }).reverse().map(function (layer) {
23520        return layer.options['attribution'];
23521      });
23522
23523      var content = this.options['content'] + (attributions.length > 0 ? ' - ' + attributions.join(', ') : '');
23524      this._attributionContainer.innerHTML = '<span style="padding:0px 4px">' + content + '</span>';
23525    };
23526
23527    return Attribution;
23528  }(Control);
23529
23530  Attribution.mergeOptions(options$n);
23531  Map$1.mergeOptions({
23532    'attribution': true
23533  });
23534  Map$1.addOnLoadHook(function () {
23535    var a = this.options['attribution'] || this.options['attributionControl'];
23536
23537    if (a) {
23538      this.attributionControl = new Attribution(a);
23539      this.addControl(this.attributionControl);
23540    }
23541  });
23542
23543  var options$o = {
23544    'position': 'top-right',
23545    'baseTitle': 'Base Layers',
23546    'overlayTitle': 'Layers',
23547    'excludeLayers': [],
23548    'containerClass': 'maptalks-layer-switcher'
23549  };
23550
23551  var LayerSwitcher = function (_Control) {
23552    _inheritsLoose(LayerSwitcher, _Control);
23553
23554    function LayerSwitcher() {
23555      return _Control.apply(this, arguments) || this;
23556    }
23557
23558    var _proto = LayerSwitcher.prototype;
23559
23560    _proto.buildOn = function buildOn() {
23561      var container = this.container = createEl('div', this.options['containerClass']),
23562          panel = this.panel = createEl('div', 'panel'),
23563          button = this.button = createEl('button');
23564      container.appendChild(button);
23565      container.appendChild(panel);
23566      return container;
23567    };
23568
23569    _proto.onAdd = function onAdd() {
23570      on(this.button, 'mouseover', this._show, this);
23571      on(this.panel, 'mouseleave', this._hide, this);
23572      on(this.getMap(), 'click', this._hide, this);
23573    };
23574
23575    _proto.onRemove = function onRemove() {
23576      if (this.panel) {
23577        off(this.button, 'mouseover', this._show, this);
23578        off(this.panel, 'mouseleave', this._hide, this);
23579        off(this.getMap(), 'click', this._hide, this);
23580        removeDomNode(this.panel);
23581        removeDomNode(this.button);
23582        delete this.panel;
23583        delete this.button;
23584        delete this.container;
23585      }
23586    };
23587
23588    _proto._show = function _show() {
23589      if (!hasClass(this.container, 'shown')) {
23590        addClass(this.container, 'shown');
23591
23592        this._createPanel();
23593      }
23594    };
23595
23596    _proto._hide = function _hide(e) {
23597      if (!this.panel.contains(e.toElement || e.relatedTarget)) {
23598        setClass(this.container, this.options['containerClass']);
23599      }
23600    };
23601
23602    _proto._createPanel = function _createPanel() {
23603      this.panel.innerHTML = '';
23604      var ul = createEl('ul');
23605      this.panel.appendChild(ul);
23606
23607      this._renderLayers(this.getMap(), ul);
23608    };
23609
23610    _proto._renderLayers = function _renderLayers(map, elm) {
23611      var base = map.getBaseLayer(),
23612          layers = map.getLayers(),
23613          len = layers.length;
23614
23615      if (base) {
23616        var baseLayers = base.layers || [base],
23617            li = createEl('li', 'group'),
23618            ul = createEl('ul'),
23619            label = createEl('label');
23620        label.innerHTML = this.options['baseTitle'];
23621        li.appendChild(label);
23622
23623        for (var i = 0, _len = baseLayers.length; i < _len; i++) {
23624          var layer = baseLayers[i];
23625
23626          if (this._isExcluded(layer)) {
23627            ul.appendChild(this._renderLayer(baseLayers[i], true));
23628            li.appendChild(ul);
23629            elm.appendChild(li);
23630          }
23631        }
23632      }
23633
23634      if (len) {
23635        var _li = createEl('li', 'group'),
23636            _ul = createEl('ul'),
23637            _label = createEl('label');
23638
23639        _label.innerHTML = this.options['overlayTitle'];
23640
23641        _li.appendChild(_label);
23642
23643        for (var _i = 0; _i < len; _i++) {
23644          var _layer = layers[_i];
23645
23646          if (this._isExcluded(_layer)) {
23647            _ul.appendChild(this._renderLayer(_layer));
23648          }
23649        }
23650
23651        _li.appendChild(_ul);
23652
23653        elm.appendChild(_li);
23654      }
23655    };
23656
23657    _proto._isExcluded = function _isExcluded(layer) {
23658      var id = layer.getId(),
23659          excludeLayers = this.options['excludeLayers'];
23660      return !(excludeLayers.length && excludeLayers.indexOf(id) >= 0);
23661    };
23662
23663    _proto._renderLayer = function _renderLayer(layer, isBase) {
23664      var _this = this;
23665
23666      var li = createEl('li', 'layer'),
23667          label = createEl('label'),
23668          input = createEl('input'),
23669          map = this.getMap();
23670      var visible = layer.options['visible'];
23671      layer.options['visible'] = true;
23672      var enabled = layer.isVisible();
23673      layer.options['visible'] = visible;
23674      li.className = 'layer';
23675
23676      if (isBase) {
23677        input.type = 'radio';
23678        input.name = 'base';
23679      } else {
23680        input.type = 'checkbox';
23681      }
23682
23683      input.checked = visible && enabled;
23684
23685      if (!enabled) {
23686        input.setAttribute('disabled', 'disabled');
23687      }
23688
23689      input.onchange = function (e) {
23690        if (e.target.type === 'radio') {
23691          var baseLayer = map.getBaseLayer(),
23692              baseLayers = baseLayer.layers;
23693
23694          if (baseLayers) {
23695            for (var i = 0, len = baseLayers.length; i < len; i++) {
23696              var _baseLayer = baseLayers[i];
23697
23698              _baseLayer[_baseLayer === layer ? 'show' : 'hide']();
23699            }
23700          } else if (!baseLayer.isVisible()) {
23701            baseLayer.show();
23702          }
23703
23704          map._fireEvent('setbaselayer');
23705        } else {
23706          layer[e.target.checked ? 'show' : 'hide']();
23707        }
23708
23709        _this.fire('layerchange', {
23710          target: layer
23711        });
23712      };
23713
23714      li.appendChild(input);
23715      label.innerHTML = layer.getId();
23716      li.appendChild(label);
23717      return li;
23718    };
23719
23720    return LayerSwitcher;
23721  }(Control);
23722
23723  LayerSwitcher.mergeOptions(options$o);
23724  Map$1.mergeOptions({
23725    'layerSwitcherControl': false
23726  });
23727  Map$1.addOnLoadHook(function () {
23728    if (this.options['layerSwitcherControl']) {
23729      this.layerSwitcherControl = new LayerSwitcher(this.options['layerSwitcherControl']);
23730      this.addControl(this.layerSwitcherControl);
23731    }
23732  });
23733
23734  var options$p = {
23735    'level': 4,
23736    'position': {
23737      'right': 1,
23738      'bottom': 1
23739    },
23740    'size': [300, 200],
23741    'maximize': true,
23742    'symbol': {
23743      'lineWidth': 3,
23744      'lineColor': '#1bbc9b',
23745      'polygonFill': '#1bbc9b',
23746      'polygonOpacity': 0.4
23747    },
23748    'containerClass': 'maptalks-overview',
23749    'buttonClass': 'maptalks-overview-button'
23750  };
23751
23752  var Overview = function (_Control) {
23753    _inheritsLoose(Overview, _Control);
23754
23755    function Overview() {
23756      return _Control.apply(this, arguments) || this;
23757    }
23758
23759    var _proto = Overview.prototype;
23760
23761    _proto.buildOn = function buildOn() {
23762      var size = this.options['size'];
23763
23764      if (!this.options['maximize']) {
23765        size = [0, 0];
23766      }
23767
23768      var container = createEl('div');
23769      var mapContainer = this.mapContainer = createEl('div');
23770      mapContainer.style.width = size[0] + 'px';
23771      mapContainer.style.height = size[1] + 'px';
23772      mapContainer.className = this.options['containerClass'];
23773      var button = this.button = createEl('div');
23774      button.className = this.options['buttonClass'];
23775      container.appendChild(mapContainer);
23776      container.appendChild(button);
23777      return container;
23778    };
23779
23780    _proto.onAdd = function onAdd() {
23781      if (this.options['maximize']) {
23782        this._createOverview();
23783      }
23784
23785      this.getMap().on('resize moving zooming rotate dragrotating viewchange', this._update, this).on('setbaselayer', this._updateBaseLayer, this).on('spatialreferencechange', this._updateSpatialReference, this);
23786      on(this.button, 'click', this._onButtonClick, this);
23787
23788      this._updateButtonText();
23789    };
23790
23791    _proto.onRemove = function onRemove() {
23792      this.getMap().off('resize moving zooming rotate dragrotating viewchange', this._update, this).off('setbaselayer', this._updateBaseLayer, this).off('spatialreferencechange', this._updateSpatialReference, this);
23793
23794      if (this._overview) {
23795        this._overview.remove();
23796
23797        delete this._overview;
23798        delete this._perspective;
23799      }
23800
23801      off(this.button, 'click', this._onButtonClick, this);
23802    };
23803
23804    _proto.maxmize = function maxmize() {
23805      var size = this.options['size'];
23806      var dom = this.mapContainer;
23807      dom.style.width = size[0] + 'px';
23808      dom.style.height = size[1] + 'px';
23809
23810      this._createOverview();
23811
23812      return this;
23813    };
23814
23815    _proto.minimize = function minimize() {
23816      if (this._overview) {
23817        this._overview.remove();
23818      }
23819
23820      delete this._overview;
23821      delete this._perspective;
23822      var dom = this.mapContainer;
23823      dom.style.width = 0 + 'px';
23824      dom.style.height = 0 + 'px';
23825      return this;
23826    };
23827
23828    _proto.getOverviewMap = function getOverviewMap() {
23829      return this._overview;
23830    };
23831
23832    _proto._onButtonClick = function _onButtonClick() {
23833      if (!this._overview) {
23834        this.maxmize();
23835      } else {
23836        this.minimize();
23837      }
23838
23839      this._updateButtonText();
23840    };
23841
23842    _proto._updateButtonText = function _updateButtonText() {
23843      if (this._overview) {
23844        this.button.innerHTML = '-';
23845      } else {
23846        this.button.innerHTML = '+';
23847      }
23848    };
23849
23850    _proto._createOverview = function _createOverview() {
23851      var map = this.getMap(),
23852          dom = this.mapContainer;
23853      var options = map.config();
23854      extend(options, {
23855        'center': map.getCenter(),
23856        'zoom': this._getOverviewZoom(),
23857        'zoomAnimationDuration': 150,
23858        'pitch': 0,
23859        'bearing': 0,
23860        'scrollWheelZoom': false,
23861        'checkSize': false,
23862        'doubleClickZoom': false,
23863        'touchZoom': false,
23864        'control': false,
23865        'draggable': false,
23866        'maxExtent': null
23867      });
23868      this._overview = new Map$1(dom, options);
23869
23870      this._updateBaseLayer();
23871
23872      this._perspective = new Polygon(this._getPerspectiveCoords(), {
23873        'draggable': true,
23874        'cursor': 'move',
23875        'symbol': this.options['symbol']
23876      }).on('dragend', this._onDragEnd, this);
23877      new VectorLayer('perspective_layer', this._perspective).addTo(this._overview);
23878      this.fire('load');
23879    };
23880
23881    _proto._getOverviewZoom = function _getOverviewZoom() {
23882      var map = this.getMap(),
23883          zoom = map.getZoom(),
23884          minZoom = map.getMinZoom(),
23885          level = this.options['level'];
23886
23887      if (level > 0) {
23888        for (var i = level; i > 0; i--) {
23889          if (zoom - i >= minZoom) {
23890            return zoom - i;
23891          }
23892        }
23893      } else {
23894        for (var _i = level; _i < 0; _i++) {
23895          if (zoom - _i >= minZoom) {
23896            return zoom - _i;
23897          }
23898        }
23899      }
23900
23901      return zoom;
23902    };
23903
23904    _proto._onDragEnd = function _onDragEnd() {
23905      var center = this._perspective.getCenter();
23906
23907      this._overview.setCenter(center);
23908
23909      this.getMap().panTo(center);
23910    };
23911
23912    _proto._getPerspectiveCoords = function _getPerspectiveCoords() {
23913      var map = this.getMap();
23914      return map.getContainerExtent().toArray().map(function (c) {
23915        return map.containerPointToCoordinate(c);
23916      });
23917    };
23918
23919    _proto._update = function _update() {
23920      if (!this._overview) {
23921        return;
23922      }
23923
23924      computeDomPosition(this._overview._containerDOM);
23925
23926      var coords = this._getPerspectiveCoords();
23927
23928      this._perspective.setCoordinates(coords);
23929
23930      this._overview.setCenterAndZoom(this.getMap().getCenter(), this._getOverviewZoom());
23931    };
23932
23933    _proto._updateSpatialReference = function _updateSpatialReference() {
23934      if (!this._overview) {
23935        return;
23936      }
23937
23938      var map = this.getMap();
23939      var spatialRef = map.options['spatialReference'];
23940
23941      this._overview.setSpatialReference(spatialRef);
23942    };
23943
23944    _proto._updateBaseLayer = function _updateBaseLayer() {
23945      if (!this._overview) {
23946        return;
23947      }
23948
23949      var map = this.getMap(),
23950          baseLayer = map.getBaseLayer();
23951
23952      if (!baseLayer) {
23953        this._overview.setBaseLayer(null);
23954
23955        return;
23956      }
23957
23958      var layers = baseLayer.layers;
23959      var showIndex = 0;
23960
23961      if (layers) {
23962        for (var i = 0, l = layers.length; i < l; i++) {
23963          var _layer = layers[i];
23964
23965          if (_layer.isVisible()) {
23966            showIndex = i;
23967            break;
23968          }
23969        }
23970      }
23971
23972      var json = baseLayer.toJSON();
23973      var options = null;
23974
23975      if (layers) {
23976        options = json.layers[showIndex].options;
23977        options.visible = true;
23978      } else {
23979        options = json.options;
23980      }
23981
23982      this._overview.setMinZoom(options.minZoom || null).setMaxZoom(options.maxZoom || null);
23983
23984      delete options.minZoom;
23985      delete options.maxZoom;
23986      delete json.options.canvas;
23987      json.options.visible = true;
23988      json.options.renderer = 'canvas';
23989      var layer = Layer.fromJSON(json);
23990
23991      for (var p in baseLayer) {
23992        if (isFunction(baseLayer[p]) && baseLayer.hasOwnProperty(p) && baseLayer[p] !== baseLayer.constructor.prototype[p]) {
23993          layer[p] = baseLayer[p];
23994        }
23995      }
23996
23997      this._overview.setBaseLayer(layer);
23998    };
23999
24000    return Overview;
24001  }(Control);
24002
24003  Overview.mergeOptions(options$p);
24004  Map$1.mergeOptions({
24005    'overviewControl': false
24006  });
24007  Map$1.addOnLoadHook(function () {
24008    if (this.options['overviewControl']) {
24009      this.overviewControl = new Overview(this.options['overviewControl']);
24010      this.addControl(this.overviewControl);
24011    }
24012  });
24013
24014  var options$q = {
24015    'position': 'top-right',
24016    'draggable': true,
24017    'custom': false,
24018    'content': '',
24019    'closeButton': true
24020  };
24021
24022  var Panel = function (_Control) {
24023    _inheritsLoose(Panel, _Control);
24024
24025    function Panel() {
24026      return _Control.apply(this, arguments) || this;
24027    }
24028
24029    var _proto = Panel.prototype;
24030
24031    _proto.buildOn = function buildOn() {
24032      var dom;
24033
24034      if (this.options['custom']) {
24035        if (isString(this.options['content'])) {
24036          dom = createEl('div');
24037          dom.innerHTML = this.options['content'];
24038        } else {
24039          dom = this.options['content'];
24040        }
24041      } else {
24042        dom = createEl('div', 'maptalks-panel');
24043
24044        if (this.options['closeButton']) {
24045          var closeButton = createEl('a', 'maptalks-close');
24046          closeButton.href = 'javascript:;';
24047
24048          closeButton.onclick = function () {
24049            dom.style.display = 'none';
24050          };
24051
24052          dom.appendChild(closeButton);
24053        }
24054
24055        var panelContent = createEl('div', 'maptalks-panel-content');
24056        panelContent.innerHTML = this.options['content'];
24057        dom.appendChild(panelContent);
24058      }
24059
24060      this.draggable = new DragHandler(dom, {
24061        'cancelOn': this._cancelOn.bind(this),
24062        'ignoreMouseleave': true
24063      });
24064      this.draggable.on('dragstart', this._onDragStart, this).on('dragging', this._onDragging, this).on('dragend', this._onDragEnd, this);
24065
24066      if (this.options['draggable']) {
24067        this.draggable.enable();
24068      }
24069
24070      return dom;
24071    };
24072
24073    _proto.update = function update() {
24074      if (this.draggable) {
24075        this.draggable.disable();
24076        delete this.draggable;
24077      }
24078
24079      return Control.prototype.update.call(this);
24080    };
24081
24082    _proto.setContent = function setContent(content) {
24083      var old = this.options['content'];
24084      this.options['content'] = content;
24085      this.fire('contentchange', {
24086        'old': old,
24087        'new': content
24088      });
24089
24090      if (this.isVisible()) {
24091        this.update();
24092      }
24093
24094      return this;
24095    };
24096
24097    _proto.getContent = function getContent() {
24098      return this.options['content'];
24099    };
24100
24101    _proto._cancelOn = function _cancelOn(domEvent) {
24102      var target = domEvent.srcElement || domEvent.target,
24103          tagName = target.tagName.toLowerCase();
24104
24105      if (tagName === 'button' || tagName === 'input' || tagName === 'select' || tagName === 'option' || tagName === 'textarea') {
24106        return true;
24107      }
24108
24109      return false;
24110    };
24111
24112    _proto._onDragStart = function _onDragStart(param) {
24113      this._startPos = param['mousePos'];
24114      this._startPosition = extend({}, this.getPosition());
24115      this.fire('dragstart', param);
24116    };
24117
24118    _proto._onDragging = function _onDragging(param) {
24119      var pos = param['mousePos'];
24120      var offset = pos.sub(this._startPos);
24121      var startPosition = this._startPosition;
24122      var position = this.getPosition();
24123
24124      if (!isNil(position['top'])) {
24125        position['top'] = parseInt(startPosition['top']) + offset.y;
24126      }
24127
24128      if (!isNil(position['bottom'])) {
24129        position['bottom'] = parseInt(startPosition['bottom']) - offset.y;
24130      }
24131
24132      if (!isNil(position['left'])) {
24133        position['left'] = parseInt(startPosition['left']) + offset.x;
24134      }
24135
24136      if (!isNil(position['right'])) {
24137        position['right'] = parseInt(startPosition['right']) - offset.x;
24138      }
24139
24140      this.setPosition(position);
24141      this.fire('dragging', param);
24142    };
24143
24144    _proto._onDragEnd = function _onDragEnd(param) {
24145      delete this._startPos;
24146      delete this._startPosition;
24147      this.fire('dragend', param);
24148    };
24149
24150    _proto._getConnectPoints = function _getConnectPoints() {
24151      var map = this.getMap();
24152      var containerPoint = this.getContainerPoint();
24153      var dom = this.getDOM(),
24154          width = parseInt(dom.clientWidth),
24155          height = parseInt(dom.clientHeight);
24156      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))];
24157      return anchors;
24158    };
24159
24160    return Panel;
24161  }(Control);
24162
24163  Panel.mergeOptions(options$q);
24164
24165  var options$r = {
24166    'position': 'bottom-left',
24167    'maxWidth': 100,
24168    'metric': true,
24169    'imperial': false,
24170    'containerClass': null
24171  };
24172
24173  var Scale = function (_Control) {
24174    _inheritsLoose(Scale, _Control);
24175
24176    function Scale() {
24177      return _Control.apply(this, arguments) || this;
24178    }
24179
24180    var _proto = Scale.prototype;
24181
24182    _proto.buildOn = function buildOn(map) {
24183      this._map = map;
24184      this._scaleContainer = createEl('div', this.options['containerClass']);
24185
24186      this._addScales();
24187
24188      map.on('zoomend', this._update, this);
24189
24190      if (this._map._loaded) {
24191        this._update();
24192      }
24193
24194      return this._scaleContainer;
24195    };
24196
24197    _proto.onRemove = function onRemove() {
24198      this.getMap().off('zoomend', this._update, this);
24199    };
24200
24201    _proto._addScales = function _addScales() {
24202      var css = 'border: 2px solid #000000;border-top: none;line-height: 1.1;padding: 0px;' + '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);';
24203
24204      if (this.options['metric']) {
24205        this._mScale = createElOn('div', this.options['containerClass'] ? null : css, this._scaleContainer);
24206      }
24207
24208      if (this.options['imperial']) {
24209        this._iScale = createElOn('div', this.options['containerClass'] ? null : css, this._scaleContainer);
24210      }
24211    };
24212
24213    _proto._update = function _update() {
24214      var map = this._map;
24215      var maxMeters = map.pixelToDistance(this.options['maxWidth'], 0);
24216
24217      this._updateScales(maxMeters);
24218    };
24219
24220    _proto._updateScales = function _updateScales(maxMeters) {
24221      if (this.options['metric'] && maxMeters) {
24222        this._updateMetric(maxMeters);
24223      }
24224
24225      if (this.options['imperial'] && maxMeters) {
24226        this._updateImperial(maxMeters);
24227      }
24228    };
24229
24230    _proto._updateMetric = function _updateMetric(maxMeters) {
24231      var meters = this._getRoundNum(maxMeters),
24232          label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
24233
24234      this._updateScale(this._mScale, label, meters / maxMeters);
24235    };
24236
24237    _proto._updateImperial = function _updateImperial(maxMeters) {
24238      var maxFeet = maxMeters * 3.2808399;
24239      var maxMiles, miles, feet;
24240
24241      if (maxFeet > 5280) {
24242        maxMiles = maxFeet / 5280;
24243        miles = this._getRoundNum(maxMiles);
24244
24245        this._updateScale(this._iScale, miles + ' mile', miles / maxMiles);
24246      } else {
24247        feet = this._getRoundNum(maxFeet);
24248
24249        this._updateScale(this._iScale, feet + ' feet', feet / maxFeet);
24250      }
24251    };
24252
24253    _proto._updateScale = function _updateScale(scale, text, ratio) {
24254      scale['style']['width'] = Math.round(this.options['maxWidth'] * ratio) + 'px';
24255      scale['innerHTML'] = text;
24256    };
24257
24258    _proto._getRoundNum = function _getRoundNum(num) {
24259      var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
24260      var d = num / pow10;
24261      d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
24262      return pow10 * d;
24263    };
24264
24265    return Scale;
24266  }(Control);
24267
24268  Scale.mergeOptions(options$r);
24269  Map$1.mergeOptions({
24270    'scaleControl': false
24271  });
24272  Map$1.addOnLoadHook(function () {
24273    if (this.options['scaleControl']) {
24274      this.scaleControl = new Scale(this.options['scaleControl']);
24275      this.addControl(this.scaleControl);
24276    }
24277  });
24278
24279  var options$s = {
24280    'height': 28,
24281    'vertical': false,
24282    'position': 'top-right',
24283    'reverseMenu': false,
24284    'items': {}
24285  };
24286
24287  var Toolbar = function (_Control) {
24288    _inheritsLoose(Toolbar, _Control);
24289
24290    function Toolbar() {
24291      return _Control.apply(this, arguments) || this;
24292    }
24293
24294    var _proto = Toolbar.prototype;
24295
24296    _proto.buildOn = function buildOn(map) {
24297      this._map = map;
24298      var dom = createEl('div');
24299      var ul = createEl('ul', 'maptalks-toolbar-hx');
24300      dom.appendChild(ul);
24301
24302      if (this.options['vertical']) {
24303        addClass(dom, 'maptalks-toolbar-vertical');
24304      } else {
24305        addClass(dom, 'maptalks-toolbar-horizonal');
24306      }
24307
24308      var me = this;
24309
24310      function onButtonClick(fn, index, childIndex, targetDom) {
24311        var item = me._getItems()[index];
24312
24313        return function (e) {
24314          stopPropagation(e);
24315          return fn({
24316            'target': item,
24317            'index': index,
24318            'childIndex': childIndex,
24319            'dom': targetDom
24320          });
24321        };
24322      }
24323
24324      var items = this.options['items'];
24325
24326      if (isArrayHasData(items)) {
24327        for (var i = 0, len = items.length; i < len; i++) {
24328          var item = items[i];
24329          var li = createEl('li');
24330
24331          if (this.options['height'] !== 28) {
24332            li.style.lineHeight = this.options['height'] + 'px';
24333          }
24334
24335          li.style.height = this.options['height'] + 'px';
24336          li.style.cursor = 'pointer';
24337
24338          if (isHTML(item['item'])) {
24339            li.style.textAlign = 'center';
24340            var itemSize = measureDom('div', item['item']);
24341            li.innerHTML = '<div style="margin-top:' + (this.options['height'] - itemSize['height']) / 2 + 'px;">' + item['item'] + '</div>';
24342          } else {
24343            li.innerHTML = item['item'];
24344          }
24345
24346          if (item['click']) {
24347            on(li, 'click', onButtonClick(item['click'], i, null, li));
24348          }
24349
24350          if (isArrayHasData(item['children'])) {
24351            var dropMenu = this._createDropMenu(i);
24352
24353            li.appendChild(dropMenu);
24354            li._menu = dropMenu;
24355            on(li, 'mouseover', function () {
24356              this._menu.style.display = '';
24357            });
24358            on(li, 'mouseout', function () {
24359              this._menu.style.display = 'none';
24360            });
24361          }
24362
24363          ul.appendChild(li);
24364        }
24365      }
24366
24367      return dom;
24368    };
24369
24370    _proto._createDropMenu = function _createDropMenu(index) {
24371      var me = this;
24372
24373      function onButtonClick(fn, index, childIndex) {
24374        var item = me._getItems()[index]['children'][childIndex];
24375
24376        return function (e) {
24377          stopPropagation(e);
24378          return fn({
24379            'target': item,
24380            'index': index,
24381            'childIndex': childIndex
24382          });
24383        };
24384      }
24385
24386      var menuDom = createEl('div', 'maptalks-dropMenu'),
24387          items = this._getItems(),
24388          len = items.length,
24389          menuUL = createEl('ul'),
24390          children = items[index]['children'];
24391
24392      if (index === len - 1 && children) {
24393        menuDom.style.cssText = 'right: 0px;';
24394        menuUL.style.cssText = 'right: 0px;position: absolute;';
24395
24396        if (this.options['reverseMenu']) {
24397          menuUL.style.bottom = 0;
24398        }
24399      }
24400
24401      menuDom.appendChild(createEl('em', 'maptalks-ico'));
24402      var liWidth = 0;
24403
24404      for (var i = 0, l = children.length; i < l; i++) {
24405        var size = stringLength(children[i]['item'], '12px');
24406
24407        if (size.width > liWidth) {
24408          liWidth = size.width;
24409        }
24410      }
24411
24412      for (var _i = 0, _l = children.length; _i < _l; _i++) {
24413        var child = children[_i];
24414        var li = createEl('li');
24415        li.innerHTML = '<a href="javascript:;">' + child['item'] + '</a>';
24416        li.style.cursor = 'pointer';
24417        li.style.width = liWidth + 24 + 'px';
24418        on(li.childNodes[0], 'click', onButtonClick(child['click'], index, _i));
24419        menuUL.appendChild(li);
24420      }
24421
24422      if (this.options['vertical']) {
24423        var width = liWidth < 95 ? 95 : liWidth;
24424
24425        if (this.options['reverseMenu']) {
24426          menuDom.style.right = -(width + 10 * 2) + 'px';
24427        } else {
24428          menuDom.style.left = -(width + 10 * 2) + 'px';
24429        }
24430      } else if (this.options['reverseMenu']) {
24431        menuDom.style.bottom = '28px';
24432      } else {
24433        menuDom.style.top = '28px';
24434      }
24435
24436      menuDom.appendChild(menuUL);
24437      menuDom.style.display = 'none';
24438      return menuDom;
24439    };
24440
24441    _proto._getItems = function _getItems() {
24442      return this.options['items'] || [];
24443    };
24444
24445    return Toolbar;
24446  }(Control);
24447
24448  Toolbar.mergeOptions(options$s);
24449
24450  var options$t = {
24451    'position': 'top-left',
24452    'slider': true,
24453    'zoomLevel': true,
24454    'seamless': false
24455  };
24456  var UNIT = 10;
24457
24458  var Zoom = function (_Control) {
24459    _inheritsLoose(Zoom, _Control);
24460
24461    function Zoom() {
24462      return _Control.apply(this, arguments) || this;
24463    }
24464
24465    var _proto = Zoom.prototype;
24466
24467    _proto.buildOn = function buildOn(map) {
24468      var options = this.options;
24469      var dom = createEl('div', 'maptalks-zoom');
24470
24471      if (options['zoomLevel']) {
24472        var levelDOM = createEl('span', 'maptalks-zoom-zoomlevel');
24473        dom.appendChild(levelDOM);
24474        this._levelDOM = levelDOM;
24475      }
24476
24477      var zoomDOM = createEl('div', 'maptalks-zoom-slider');
24478      var zoomInButton = createEl('a', 'maptalks-zoom-zoomin');
24479      zoomInButton.href = 'javascript:;';
24480      zoomInButton.innerHTML = '+';
24481      zoomDOM.appendChild(zoomInButton);
24482      this._zoomInButton = zoomInButton;
24483
24484      if (options['slider']) {
24485        var box = createEl('div', 'maptalks-zoom-slider-box');
24486        var ruler = createEl('div', 'maptalks-zoom-slider-ruler');
24487        var reading = createEl('span', 'maptalks-zoom-slider-reading');
24488        var dot = createEl('span', 'maptalks-zoom-slider-dot');
24489        ruler.appendChild(reading);
24490        box.appendChild(ruler);
24491        box.appendChild(dot);
24492        zoomDOM.appendChild(box);
24493        this._sliderBox = box;
24494        this._sliderRuler = ruler;
24495        this._sliderReading = reading;
24496        this._sliderDot = dot;
24497      }
24498
24499      var zoomOutButton = createEl('a', 'maptalks-zoom-zoomout');
24500      zoomOutButton.href = 'javascript:;';
24501      zoomOutButton.innerHTML = '-';
24502      zoomDOM.appendChild(zoomOutButton);
24503      this._zoomOutButton = zoomOutButton;
24504      dom.appendChild(zoomDOM);
24505      map.on('_zoomend _zooming _zoomstart _spatialreferencechange', this._update, this);
24506
24507      this._update();
24508
24509      this._registerDomEvents();
24510
24511      return dom;
24512    };
24513
24514    _proto.onRemove = function onRemove() {
24515      this.getMap().off('_zoomend _zooming _zoomstart _spatialreferencechange', this._update, this);
24516
24517      if (this._zoomInButton) {
24518        off(this._zoomInButton, 'click', this._onZoomInClick, this);
24519      }
24520
24521      if (this._zoomOutButton) {
24522        off(this._zoomOutButton, 'click', this._onZoomOutClick, this);
24523      }
24524
24525      if (this._sliderRuler) {
24526        off(this._sliderRuler, 'click', this._onClickRuler, this);
24527        this.dotDragger.disable();
24528        delete this.dotDragger;
24529      }
24530    };
24531
24532    _proto._update = function _update() {
24533      var map = this.getMap();
24534
24535      if (this._sliderBox) {
24536        var totalRange = (map.getMaxZoom() - map.getMinZoom()) * UNIT;
24537        this._sliderBox.style.height = totalRange + 16 + 'px';
24538        this._sliderRuler.style.height = totalRange + 8 + 'px';
24539        this._sliderRuler.style.cursor = 'pointer';
24540        var zoomRange = (map.getMaxZoom() - map.getZoom()) * UNIT;
24541        this._sliderReading.style.height = (map.getZoom() - map.getMinZoom() + 1) * UNIT + 'px';
24542        this._sliderDot.style.top = zoomRange + 'px';
24543      }
24544
24545      this._updateText();
24546    };
24547
24548    _proto._updateText = function _updateText() {
24549      if (this._levelDOM) {
24550        var map = this.getMap();
24551        var zoom = map.getZoom();
24552
24553        if (!isInteger(zoom)) {
24554          zoom = Math.floor(zoom * 10) / 10;
24555        }
24556
24557        this._levelDOM.innerHTML = zoom;
24558      }
24559    };
24560
24561    _proto._registerDomEvents = function _registerDomEvents() {
24562      if (this._zoomInButton) {
24563        on(this._zoomInButton, 'click', this._onZoomInClick, this);
24564      }
24565
24566      if (this._zoomOutButton) {
24567        on(this._zoomOutButton, 'click', this._onZoomOutClick, this);
24568      }
24569
24570      if (this._sliderRuler) {
24571        on(this._sliderRuler, 'click', this._onClickRuler, this);
24572        this.dotDragger = new DragHandler(this._sliderDot, {
24573          'ignoreMouseleave': true
24574        });
24575        this.dotDragger.on('dragstart', this._onDotDragstart, this).on('dragging dragend', this._onDotDrag, this).enable();
24576      }
24577    };
24578
24579    _proto._onZoomInClick = function _onZoomInClick(e) {
24580      preventDefault(e);
24581      this.getMap().zoomIn();
24582    };
24583
24584    _proto._onZoomOutClick = function _onZoomOutClick(e) {
24585      preventDefault(e);
24586      this.getMap().zoomOut();
24587    };
24588
24589    _proto._onClickRuler = function _onClickRuler(e) {
24590      preventDefault(e);
24591      var map = this.getMap(),
24592          point = getEventContainerPoint(e, this._sliderRuler),
24593          h = point.y;
24594      var maxZoom = map.getMaxZoom(),
24595          zoom = Math.floor(maxZoom - h / UNIT);
24596      map.setZoom(zoom);
24597    };
24598
24599    _proto._onDotDragstart = function _onDotDragstart(e) {
24600      preventDefault(e.domEvent);
24601
24602      var map = this.getMap(),
24603          origin = map.getSize().toPoint()._multi(1 / 2);
24604
24605      map.onZoomStart(map.getZoom(), origin);
24606    };
24607
24608    _proto._onDotDrag = function _onDotDrag(e) {
24609      preventDefault(e.domEvent);
24610
24611      var map = this.getMap(),
24612          origin = map.getSize().toPoint()._multi(1 / 2),
24613          point = getEventContainerPoint(e.domEvent, this._sliderRuler),
24614          maxZoom = map.getMaxZoom(),
24615          minZoom = map.getMinZoom();
24616
24617      var top = point.y,
24618          z = maxZoom - top / UNIT;
24619
24620      if (maxZoom < z) {
24621        z = maxZoom;
24622        top = 0;
24623      } else if (minZoom > z) {
24624        z = minZoom;
24625        top = (maxZoom - minZoom) * UNIT;
24626      }
24627
24628      if (e.type === 'dragging') {
24629        map.onZooming(z, origin, 1);
24630      } else if (e.type === 'dragend') {
24631        if (this.options['seamless']) {
24632          map.onZoomEnd(z, origin);
24633        } else {
24634          map.onZoomEnd(Math.round(z), origin);
24635        }
24636      }
24637
24638      this._sliderDot.style.top = top + 'px';
24639      this._sliderReading.style.height = (map.getZoom() - minZoom + 1) * UNIT + 'px';
24640
24641      this._updateText();
24642    };
24643
24644    return Zoom;
24645  }(Control);
24646
24647  Zoom.mergeOptions(options$t);
24648  Map$1.mergeOptions({
24649    'zoomControl': false
24650  });
24651  Map$1.addOnLoadHook(function () {
24652    if (this.options['zoomControl']) {
24653      this.zoomControl = new Zoom(this.options['zoomControl']);
24654      this.addControl(this.zoomControl);
24655    }
24656  });
24657
24658
24659
24660  var index$5 = /*#__PURE__*/Object.freeze({
24661    Control: Control,
24662    Attribution: Attribution,
24663    LayerSwitcher: LayerSwitcher,
24664    Overview: Overview,
24665    Panel: Panel,
24666    Scale: Scale,
24667    Toolbar: Toolbar,
24668    Zoom: Zoom
24669  });
24670
24671  var TileSystem = function () {
24672    function TileSystem(sx, sy, ox, oy) {
24673      if (Array.isArray(sx)) {
24674        this.scale = {
24675          x: sx[0],
24676          y: sx[1]
24677        };
24678        this.origin = {
24679          x: sx[2],
24680          y: sx[3]
24681        };
24682      } else {
24683        this.scale = {
24684          x: sx,
24685          y: sy
24686        };
24687        this.origin = {
24688          x: ox,
24689          y: oy
24690        };
24691      }
24692    }
24693
24694    TileSystem.getDefault = function getDefault(projection) {
24695      if (projection['code'].toLowerCase() === 'baidu') {
24696        return 'baidu';
24697      } else if (projection['code'].toLowerCase() === 'EPSG:4326'.toLowerCase()) {
24698        return 'tms-global-geodetic';
24699      } else if (projection['code'].toLowerCase() === 'identity') {
24700        return [1, -1, 0, 0];
24701      } else {
24702        return 'web-mercator';
24703      }
24704    };
24705
24706    return TileSystem;
24707  }();
24708
24709  var semiCircum = 6378137 * Math.PI;
24710  extend(TileSystem, {
24711    'web-mercator': new TileSystem([1, -1, -semiCircum, semiCircum]),
24712    'tms-global-mercator': new TileSystem([1, 1, -semiCircum, -semiCircum]),
24713    'tms-global-geodetic': new TileSystem([1, 1, -180, -90]),
24714    'baidu': new TileSystem([1, 1, 0, 0])
24715  });
24716
24717  var TileConfig = function () {
24718    function TileConfig(tileSystem, fullExtent, tileSize) {
24719      this.tileSize = tileSize;
24720      this.fullExtent = fullExtent;
24721      this.prepareTileInfo(tileSystem, fullExtent);
24722      this._xScale = fullExtent['right'] >= fullExtent['left'] ? 1 : -1;
24723      this._yScale = fullExtent['top'] >= fullExtent['bottom'] ? 1 : -1;
24724    }
24725
24726    var _proto = TileConfig.prototype;
24727
24728    _proto.prepareTileInfo = function prepareTileInfo(tileSystem, fullExtent) {
24729      if (isString(tileSystem)) {
24730        tileSystem = TileSystem[tileSystem.toLowerCase()];
24731      } else if (Array.isArray(tileSystem)) {
24732        tileSystem = new TileSystem(tileSystem);
24733      }
24734
24735      if (!tileSystem) {
24736        throw new Error('Invalid TileSystem');
24737      }
24738
24739      this.tileSystem = tileSystem;
24740      var a = fullExtent['right'] > fullExtent['left'] ? 1 : -1,
24741          b = fullExtent['top'] > fullExtent['bottom'] ? -1 : 1,
24742          c = tileSystem['origin']['x'],
24743          d = tileSystem['origin']['y'];
24744      this.transformation = new Transformation([a, b, c, d]);
24745    };
24746
24747    _proto._getTileNum = function _getTileNum(point, res) {
24748      var tileSystem = this.tileSystem,
24749          tileSize = this['tileSize'],
24750          delta = 1E-7;
24751      var tileX = Math.floor(delta + point.x / (tileSize['width'] * res));
24752      var tileY = -Math.floor(delta + point.y / (tileSize['height'] * res));
24753      return {
24754        'x': tileSystem['scale']['x'] * tileX,
24755        'y': tileSystem['scale']['y'] * tileY
24756      };
24757    };
24758
24759    _proto.getTileIndex = function getTileIndex(pCoord, res) {
24760      var tileSystem = this.tileSystem;
24761      var point = this.transformation.transform(pCoord, 1);
24762
24763      var tileIndex = this._getTileNum(point, res);
24764
24765      if (tileSystem['scale']['x'] < 0) {
24766        tileIndex['x'] -= 1;
24767      }
24768
24769      if (tileSystem['scale']['y'] > 0) {
24770        tileIndex['y'] -= 1;
24771      }
24772
24773      return this.getNeighorTileIndex(tileIndex['x'], tileIndex['y'], 0, 0, res);
24774    };
24775
24776    _proto.getNeighorTileIndex = function getNeighorTileIndex(tileX, tileY, offsetX, offsetY, res, repeatWorld) {
24777      var tileSystem = this.tileSystem;
24778      var x = tileX + tileSystem['scale']['x'] * offsetX;
24779      var y = tileY - tileSystem['scale']['y'] * offsetY;
24780      var out = false;
vendor: 4,158 bytes, lines 24781-24908
24781      var idx = x;
24782      var idy = y;
24783
24784      var ext = this._getTileFullIndex(res);
24785
24786      if (repeatWorld) {
24787        if (repeatWorld === true || repeatWorld === 'x') {
24788          if (ext['xmax'] === ext['xmin']) {
24789            x = ext['xmin'];
24790          } else if (x < ext['xmin']) {
24791            x = ext['xmax'] - (ext['xmin'] - x) % (ext['xmax'] - ext['xmin']);
24792
24793            if (x === ext['xmax']) {
24794              x = ext['xmin'];
24795            }
24796          } else if (x >= ext['xmax']) {
24797            x = ext['xmin'] + (x - ext['xmin']) % (ext['xmax'] - ext['xmin']);
24798          }
24799        }
24800
24801        if (repeatWorld === true || repeatWorld === 'y') {
24802          if (ext['ymax'] === ext['ymin']) {
24803            y = ext['ymin'];
24804          } else if (y >= ext['ymax']) {
24805            y = ext['ymin'] + (y - ext['ymin']) % (ext['ymax'] - ext['ymin']);
24806          } else if (y < ext['ymin']) {
24807            y = ext['ymax'] - (ext['ymin'] - y) % (ext['ymax'] - ext['ymin']);
24808
24809            if (y === ext['ymax']) {
24810              y = ext['ymin'];
24811            }
24812          }
24813        }
24814      }
24815
24816      if (x < ext['xmin'] || x > ext['xmax'] || y > ext['ymax'] || y < ext['ymin']) {
24817        out = true;
24818      }
24819
24820      return {
24821        'x': x,
24822        'y': y,
24823        'idx': idx,
24824        'idy': idy,
24825        out: out
24826      };
24827    };
24828
24829    _proto._getTileFullIndex = function _getTileFullIndex(res) {
24830      var ext = this.fullExtent;
24831      var transformation = this.transformation;
24832
24833      var nwIndex = this._getTileNum(transformation.transform(new Coordinate(ext['left'], ext['top']), 1), res);
24834
24835      var seIndex = this._getTileNum(transformation.transform(new Coordinate(ext['right'], ext['bottom']), 1), res);
24836
24837      var tileSystem = this.tileSystem;
24838
24839      if (tileSystem['scale']['x'] < 0) {
24840        nwIndex.x -= 1;
24841        seIndex.x -= 1;
24842      }
24843
24844      if (tileSystem['scale']['y'] > 0) {
24845        nwIndex.y -= 1;
24846        seIndex.y -= 1;
24847      }
24848
24849      return new Extent(nwIndex, seIndex);
24850    };
24851
24852    _proto.getTilePrjNW = function getTilePrjNW(tileX, tileY, res) {
24853      var tileSystem = this.tileSystem;
24854      var tileSize = this['tileSize'];
24855      var y = tileSystem['origin']['y'] + this._yScale * tileSystem['scale']['y'] * (tileY + (tileSystem['scale']['y'] === 1 ? 1 : 0)) * res * tileSize['height'];
24856      var x = tileSystem['origin']['x'] + this._xScale * tileSystem['scale']['x'] * (tileX + (tileSystem['scale']['x'] === 1 ? 0 : 1)) * res * tileSize['width'];
24857      return new Coordinate(x, y);
24858    };
24859
24860    _proto.getTilePrjSE = function getTilePrjSE(tileX, tileY, res) {
24861      var tileSystem = this.tileSystem;
24862      var tileSize = this['tileSize'];
24863      var y = tileSystem['origin']['y'] + this._yScale * tileSystem['scale']['y'] * (tileY + (tileSystem['scale']['y'] === 1 ? 0 : 1)) * res * tileSize['height'];
24864      var x = tileSystem['origin']['x'] + this._xScale * tileSystem['scale']['x'] * (tileX + (tileSystem['scale']['x'] === 1 ? 1 : 0)) * res * tileSize['width'];
24865      return new Coordinate(x, y);
24866    };
24867
24868    _proto.getTilePrjExtent = function getTilePrjExtent(tileX, tileY, res) {
24869      var nw = this.getTilePrjNW(tileX, tileY, res),
24870          se = this.getTilePrjSE(tileX, tileY, res);
24871      return new Extent(nw, se);
24872    };
24873
24874    return TileConfig;
24875  }();
24876
24877  var options$u = {
24878    'urlTemplate': null,
24879    'subdomains': null,
24880    'repeatWorld': true,
24881    'background': true,
24882    'backgroundZoomDiff': 6,
24883    'loadingLimitOnInteracting': 3,
24884    'tileRetryCount': 0,
24885    'placeholder': false,
24886    'crossOrigin': null,
24887    'tileSize': [256, 256],
24888    'offset': [0, 0],
24889    'tileSystem': null,
24890    'fadeAnimation': !IS_NODE,
24891    'debug': false,
24892    'spatialReference': null,
24893    'maxCacheSize': 256,
24894    'renderer': function () {
24895      return Browser$1.webgl ? 'gl' : 'canvas';
24896    }(),
24897    'clipByPitch': true,
24898    'maxAvailableZoom': null,
24899    'cascadeTiles': true,
24900    'minPitchToCascade': 35,
24901    'zoomOffset': 0
24902  };
24903  var URL_PATTERN = /\{ *([\w_]+) *\}/g;
24904  var TEMP_POINT = new Point(0, 0);
24905  var TEMP_POINT0$3 = new Point(0, 0);
24906  var TEMP_POINT1$2 = new Point(0, 0);
24907  var TEMP_POINT2$1 = new Point(0, 0);
24908  var TEMP_POINT3 = new Point(0, 0);
24909  var TEMP_POINT_EXTENT = new PointExtent();
24910
24911  var TileLayer = function (_Layer) {
24912    _inheritsLoose(TileLayer, _Layer);
24913
24914    function TileLayer() {
24915      return _Layer.apply(this, arguments) || this;
24916    }
24917
24918    TileLayer.fromJSON = function fromJSON(layerJSON) {
24919      if (!layerJSON || layerJSON['type'] !== 'TileLayer') {
24920        return null;
24921      }
24922
24923      return new TileLayer(layerJSON['id'], layerJSON['options']);
24924    };
24925
24926    var _proto = TileLayer.prototype;
24927
24928    _proto.getTileSize = function getTileSize() {
24929      var size = this.options['tileSize'];
24930
24931      if (isNumber(size)) {
24932        size = [size, size];
24933      }
24934
24935      return new Size(size);
24936    };
24937
24938    _proto.getTiles = function getTiles(z, parentLayer) {
24939      var map = this.getMap();
24940      var parentRenderer = parentLayer && parentLayer.getRenderer();
24941      var mapExtent = map.getContainerExtent();
24942      var tileGrids = [];
24943      var count = 0;
24944      var minZoom = this.getMinZoom();
24945      var minPitchToCascade = this.options['minPitchToCascade'];
24946      var tileZoom = isNil(z) ? this._getTileZoom(map.getZoom()) : z;
24947
24948      if (!isNil(z) || !this.options['cascadeTiles'] || map.getPitch() <= minPitchToCascade || !isNil(minZoom) && tileZoom <= minZoom) {
24949        var _currentTiles = this._getTiles(tileZoom, mapExtent, undefined, parentRenderer);
24950
24951        if (_currentTiles) {
24952          count += _currentTiles.tiles.length;
24953          tileGrids.push(_currentTiles);
24954        }
24955
24956        return {
24957          tileGrids: tileGrids,
24958          count: count
24959        };
24960      }
24961
24962      var visualHeight = Math.floor(map._getVisualHeight(minPitchToCascade));
24963      var extent0 = new PointExtent(0, map.height - visualHeight, map.width, map.height);
24964
24965      var currentTiles = this._getTiles(tileZoom, extent0, 0, parentRenderer);
24966
24967      count += currentTiles ? currentTiles.tiles.length : 0;
24968      var extent1 = new PointExtent(0, mapExtent.ymin, map.width, extent0.ymin);
24969      var d = map.getSpatialReference().getZoomDirection();
24970
24971      var parentTiles = this._getTiles(tileZoom - d, extent1, 1, parentRenderer);
24972
24973      count += parentTiles ? parentTiles.tiles.length : 0;
24974      tileGrids.push(currentTiles, parentTiles);
24975      return {
24976        tileGrids: tileGrids,
24977        count: count
24978      };
24979    };
24980
24981    _proto.getTileUrl = function getTileUrl(x, y, z) {
24982      var urlTemplate = this.options['urlTemplate'];
24983      var domain = '';
24984
24985      if (this.options['subdomains']) {
24986        var subdomains = this.options['subdomains'];
24987
24988        if (isArrayHasData(subdomains)) {
24989          var length = subdomains.length;
24990          var s = (x + y) % length;
24991
24992          if (s < 0) {
24993            s = 0;
24994          }
24995
24996          domain = subdomains[s];
24997        }
24998      }
24999
25000      if (isFunction(urlTemplate)) {
25001        return urlTemplate(x, y, z, domain);
25002      }
25003
25004      var data = {
25005        'x': x,
25006        'y': y,
25007        'z': z,
25008        's': domain
25009      };
25010      return urlTemplate.replace(URL_PATTERN, function (str, key) {
25011        var value = data[key];
25012
25013        if (value === undefined) {
25014          throw new Error('No value provided for variable ' + str);
25015        } else if (typeof value === 'function') {
25016          value = value(data);
25017        }
25018
25019        return value;
25020      });
25021    };
25022
25023    _proto.clear = function clear() {
25024      if (this._renderer) {
25025        this._renderer.clear();
25026      }
25027
25028      this.fire('clear');
25029      return this;
25030    };
25031
25032    _proto.toJSON = function toJSON() {
25033      var profile = {
25034        'type': this.getJSONType(),
25035        'id': this.getId(),
25036        'options': this.config()
25037      };
25038      return profile;
25039    };
25040
25041    _proto.getSpatialReference = function getSpatialReference() {
25042      var map = this.getMap();
25043
25044      if (map && (!this.options['spatialReference'] || SpatialReference.equals(this.options['spatialReference'], map.options['spatialReference']))) {
25045        return map.getSpatialReference();
25046      }
25047
25048      this._sr = this._sr || new SpatialReference(this.options['spatialReference']);
25049
25050      if (this._srMinZoom === undefined) {
25051        this._srMinZoom = this._sr.getMinZoom();
25052        this._srMaxZoom = this._sr.getMaxZoom();
25053      }
25054
25055      return this._sr;
25056    };
25057
25058    _proto.getMinZoom = function getMinZoom() {
vendor: 3,437 bytes, lines 25059-25176
25059      var sr = this.getSpatialReference();
25060
25061      if (sr !== this.getMap().getSpatialReference()) {
25062        return Math.max(_Layer.prototype.getMinZoom.call(this), this._srMinZoom);
25063      }
25064
25065      return _Layer.prototype.getMinZoom.call(this);
25066    };
25067
25068    _proto.getMaxZoom = function getMaxZoom() {
25069      var sr = this.getSpatialReference();
25070
25071      if (sr !== this.getMap().getSpatialReference()) {
25072        return Math.min(_Layer.prototype.getMaxZoom.call(this), this._srMaxZoom);
25073      }
25074
25075      return _Layer.prototype.getMaxZoom.call(this);
25076    };
25077
25078    _proto._getTileZoom = function _getTileZoom(zoom) {
25079      if (!isInteger(zoom)) {
25080        zoom = Math.round(zoom);
25081      }
25082
25083      var maxZoom = this.options['maxAvailableZoom'];
25084
25085      if (!isNil(maxZoom) && zoom > maxZoom) {
25086        zoom = maxZoom;
25087      }
25088
25089      return zoom;
25090    };
25091
25092    _proto._getTiles = function _getTiles(z, containerExtent, maskID, parentRenderer) {
25093      var map = this.getMap();
25094      var zoom = z + this.options['zoomOffset'];
25095
25096      var offset = this._getTileOffset(zoom),
25097          hasOffset = offset[0] || offset[1];
25098
25099      var emptyGrid = {
25100        'zoom': z,
25101        'extent': null,
25102        'offset': offset,
25103        'tiles': []
25104      };
25105
25106      if (zoom < 0) {
25107        return emptyGrid;
25108      }
25109
25110      var minZoom = this.getMinZoom(),
25111          maxZoom = this.getMaxZoom();
25112
25113      if (!map || !this.isVisible() || !map.width || !map.height) {
25114        return emptyGrid;
25115      }
25116
25117      if (!isNil(minZoom) && z < minZoom || !isNil(maxZoom) && z > maxZoom) {
25118        return emptyGrid;
25119      }
25120
25121      var tileConfig = this._getTileConfig();
25122
25123      if (!tileConfig) {
25124        return emptyGrid;
25125      }
25126
25127      var sr = this.getSpatialReference(),
25128          mapSR = map.getSpatialReference(),
25129          res = sr.getResolution(zoom);
25130      var extent2d = containerExtent.convertTo(function (c) {
25131        return map._containerPointToPoint(c, undefined, TEMP_POINT);
25132      });
25133
25134      var innerExtent2D = this._getInnerExtent(z, containerExtent, extent2d)._add(offset);
25135
25136      extent2d._add(offset);
25137
25138      var offsetExtent2D = extent2d.sub(offset);
25139
25140      var maskExtent = this._getMask2DExtent();
25141
25142      if (maskExtent) {
25143        var intersection = maskExtent.intersection(extent2d);
25144
25145        if (!intersection) {
25146          return emptyGrid;
25147        }
25148
25149        containerExtent = intersection.convertTo(function (c) {
25150          return map._pointToContainerPoint(c, undefined, 0, TEMP_POINT);
25151        });
25152      }
25153
25154      var prjCenter = map._containerPointToPrj(containerExtent.getCenter(), TEMP_POINT0$3);
25155
25156      var c;
25157
25158      if (hasOffset) {
25159        c = this._project(map._pointToPrj(map._prjToPoint(prjCenter, undefined, TEMP_POINT1$2)._add(offset), undefined, TEMP_POINT1$2), TEMP_POINT1$2);
25160      } else {
25161        c = this._project(prjCenter, TEMP_POINT1$2);
25162      }
25163
25164      TEMP_POINT2$1.x = extent2d.xmin;
25165      TEMP_POINT2$1.y = extent2d.ymin;
25166      TEMP_POINT3.x = extent2d.xmax;
25167      TEMP_POINT3.y = extent2d.ymax;
25168
25169      var pmin = this._project(map._pointToPrj(TEMP_POINT2$1, undefined, TEMP_POINT2$1), TEMP_POINT2$1);
25170
25171      var pmax = this._project(map._pointToPrj(TEMP_POINT3, undefined, TEMP_POINT3), TEMP_POINT3);
25172
25173      var centerTile = tileConfig.getTileIndex(c, res);
25174      var ltTile = tileConfig.getTileIndex(pmin, res);
25175      var rbTile = tileConfig.getTileIndex(pmax, res);
25176      var top = Math.ceil(Math.abs(centerTile.y - ltTile.y)),
25177          left = Math.ceil(Math.abs(centerTile.x - ltTile.x)),
25178          bottom = Math.ceil(Math.abs(centerTile.y - rbTile.y)),
25179          right = Math.ceil(Math.abs(centerTile.x - rbTile.x));
25180      var tileSize = this.getTileSize();
25181
25182      var layerId = this.getId(),
25183          renderer = this.getRenderer() || parentRenderer,
25184          scale = this._getTileConfig().tileSystem.scale;
25185
25186      var visited = {};
25187      var tiles = [],
25188          extent = new PointExtent();
25189
25190      for (var i = -top; i <= bottom; i++) {
25191        var j = -left;
25192        var leftVisitEnd = -Infinity;
25193        var rightVisitEnd = false;
25194
25195        while (j >= leftVisitEnd && j <= right) {
25196          var idx = tileConfig.getNeighorTileIndex(centerTile['x'], centerTile['y'], j, i, res, sr === mapSR && this.options['repeatWorld']);
25197
25198          if (leftVisitEnd === -Infinity) {
25199            j++;
25200          } else {
25201            j--;
25202          }
25203
25204          if (idx.out) {
25205            continue;
25206          }
25207
25208          var hasCachedInfo = false;
25209
25210          var tileId = this._getTileId(idx, zoom);
25211
25212          var tileInfo = void 0;
25213
25214          if (!visited[tileId]) {
25215            tileInfo = renderer && renderer.isTileCachedOrLoading(tileId);
25216            visited[tileId] = 1;
25217          }
25218
25219          if (tileInfo) {
25220            tileInfo = tileInfo.info;
25221            hasCachedInfo = true;
25222          }
25223
25224          var p = void 0;
25225
25226          if (tileInfo) {
25227            var _tileInfo = tileInfo,
25228                point0 = _tileInfo.point0;
25229            p = tileInfo.point.set(point0.x, point0.y);
25230          } else {
25231            var pnw = tileConfig.getTilePrjNW(idx.x, idx.y, res);
25232            p = map._prjToPoint(this._unproject(pnw, TEMP_POINT3), z);
25233          }
25234
25235          var width = void 0,
25236              height = void 0;
25237
25238          if (sr === mapSR) {
25239            width = tileSize.width;
25240            height = tileSize.height;
25241          } else {
25242            var pse = tileConfig.getTilePrjSE(idx.x, idx.y, res),
25243                pp = map._prjToPoint(this._unproject(pse, TEMP_POINT3), z, TEMP_POINT3);
25244
25245            width = Math.ceil(Math.abs(pp.x - p.x));
25246            height = Math.ceil(Math.abs(pp.y - p.y));
25247          }
25248
25249          var dx = scale.x * (idx.idx - idx.x) * width,
25250              dy = -scale.y * (idx.idy - idx.y) * height;
25251
25252          if (dx || dy) {
25253            p._add(dx, dy);
25254          }
25255
25256          if (hasOffset) {
25257            p._sub(offset);
25258          }
25259
25260          if (!tileInfo) {
25261            var _tileExtent = new PointExtent(p.x, p.y, p.x + width, p.y + height);
25262
25263            tileInfo = {
25264              'point0': p.add(offset)._sub(dx, dy),
25265              'point': p,
25266              'z': z,
25267              'x': idx.x,
25268              'y': idx.y,
25269              'extent2d': _tileExtent,
25270              'mask': maskID
25271            };
25272          }
25273
25274          var tileExtent = tileInfo.extent2d;
25275
25276          if (rightVisitEnd || innerExtent2D.intersects(tileExtent) || !innerExtent2D.equals(offsetExtent2D) && this._isTileInExtent(tileInfo, containerExtent)) {
25277            if (hasOffset) {
25278              tileExtent.set(p.x, p.y, p.x + width, p.y + height);
25279              tileInfo.point = p._add(offset);
25280
25281              tileExtent._add(offset);
25282            }
25283
25284            if (!hasCachedInfo) {
25285              tileInfo['size'] = [width, height];
25286              tileInfo['id'] = tileId;
25287              tileInfo['dupKey'] = tileId;
25288              tileInfo['layer'] = layerId;
25289              tileInfo['url'] = this.getTileUrl(idx.x, idx.y, zoom);
25290            }
25291
25292            tiles.push(tileInfo);
25293
25294            extent._combine(tileExtent);
25295
25296            if (leftVisitEnd === -Infinity) {
25297              leftVisitEnd = j;
25298              j = right;
25299            } else if (!rightVisitEnd) {
25300              rightVisitEnd = true;
25301            }
25302          }
25303        }
25304      }
25305
25306      var center = map._containerPointToPoint(containerExtent.getCenter(), z, TEMP_POINT)._add(offset);
25307
25308      tiles.sort(function (a, b) {
25309        return a.point.distanceTo(center) - b.point.distanceTo(center);
25310      });
25311      return {
25312        'offset': offset,
25313        'zoom': z,
25314        'extent': extent,
25315        'tiles': tiles
25316      };
25317    };
25318
25319    _proto._getInnerExtent = function _getInnerExtent(zoom, containerExtent, extent2d) {
25320      var map = this.getMap(),
25321          res = map.getResolution(zoom),
25322          scale = map.getResolution() / res,
25323          center = extent2d.getCenter()._multi(scale),
25324          bearing = map.getBearing() * Math.PI / 180,
25325          ch = containerExtent.getHeight() / 2 * scale,
25326          cw = containerExtent.getWidth() / 2 * scale,
25327          h = Math.abs(Math.cos(bearing) * ch) || ch,
25328          w = Math.abs(Math.sin(bearing) * ch) || cw;
25329
25330      return new PointExtent(center.x - w, center.y - h, center.x + w, center.y + h);
25331    };
25332
25333    _proto._getTileOffset = function _getTileOffset(z) {
25334      var map = this.getMap();
25335
25336      var scale = map._getResolution() / map._getResolution(z);
25337
25338      var offset = this.options['offset'];
25339
25340      if (isFunction(offset)) {
25341        offset = offset(this);
25342      }
25343
25344      offset[0] *= scale;
25345      offset[1] *= scale;
25346      return offset;
25347    };
25348
25349    _proto._getTileId = function _getTileId(idx, zoom, id) {
25350      return (id || this.getId()) + "-" + idx.idy + "-" + idx.idx + "-" + zoom;
25351    };
25352
25353    _proto._project = function _project(pcoord, out) {
25354      var map = this.getMap();
25355      var sr = this.getSpatialReference();
25356      var mapSR = map.getSpatialReference();
25357
25358      if (sr !== mapSR) {
25359        var mapProjection = map.getProjection();
25360        var projection = sr.getProjection();
25361        return projection.project(mapProjection.unproject(pcoord, out), out);
25362      } else {
25363        return pcoord;
25364      }
25365    };
25366
25367    _proto._unproject = function _unproject(pcoord, out) {
25368      var map = this.getMap();
25369      var sr = this.getSpatialReference();
25370      var mapSR = map.getSpatialReference();
25371
25372      if (sr !== mapSR) {
25373        var mapProjection = map.getProjection();
25374        var projection = sr.getProjection();
25375        return mapProjection.project(projection.unproject(pcoord, out), out);
25376      } else {
25377        return pcoord;
25378      }
25379    };
25380
25381    _proto._initTileConfig = function _initTileConfig() {
25382      var map = this.getMap(),
25383          tileSize = this.getTileSize();
25384      var sr = this.getSpatialReference();
25385      var projection = sr.getProjection(),
25386          fullExtent = sr.getFullExtent();
25387      this._defaultTileConfig = new TileConfig(TileSystem.getDefault(projection), fullExtent, tileSize);
25388
25389      if (this.options['tileSystem']) {
25390        this._tileConfig = new TileConfig(this.options['tileSystem'], fullExtent, tileSize);
25391      }
25392
25393      if (map && !this._tileConfig && map.getSpatialReference() === sr && map.getBaseLayer() && map.getBaseLayer() !== this && map.getBaseLayer()._getTileConfig) {
25394        var base = map.getBaseLayer()._getTileConfig();
25395
25396        this._tileConfig = new TileConfig(base.tileSystem, base.fullExtent, tileSize);
25397      }
25398    };
25399
25400    _proto._getTileConfig = function _getTileConfig() {
25401      if (!this._defaultTileConfig) {
25402        this._initTileConfig();
25403      }
25404
25405      return this._tileConfig || this._defaultTileConfig;
25406    };
25407
25408    _proto._bindMap = function _bindMap(map) {
25409      var baseLayer = map.getBaseLayer();
25410
25411      if (baseLayer === this) {
25412        if (!baseLayer.options.hasOwnProperty('forceRenderOnMoving')) {
25413          this.config({
25414            'forceRenderOnMoving': true
25415          });
25416        }
25417      }
25418
25419      return _Layer.prototype._bindMap.apply(this, arguments);
25420    };
25421
25422    _proto._isTileInExtent = function _isTileInExtent(tileInfo, extent) {
25423      if (!this._convertPointCallback) {
25424        this._convertPointCallback = convertPoint.bind(this);
25425      }
25426
25427      var tileZoom = tileInfo.z;
25428      this._coordTileZoom = tileZoom;
25429      var tileExtent = tileInfo.extent2d.convertTo(this._convertPointCallback, TEMP_POINT_EXTENT);
25430      return extent.intersects(tileExtent);
25431    };
25432
25433    _proto.getEvents = function getEvents() {
25434      return {
25435        'spatialreferencechange': this._onSpatialReferenceChange
25436      };
25437    };
25438
25439    _proto._onSpatialReferenceChange = function _onSpatialReferenceChange() {
25440      delete this._tileConfig;
25441      delete this._defaultTileConfig;
25442      delete this._sr;
25443      var renderer = this.getRenderer();
25444
25445      if (renderer) {
25446        renderer.clear();
25447      }
25448    };
25449
25450    return TileLayer;
25451  }(Layer);
25452
25453  TileLayer.registerJSONType('TileLayer');
25454  TileLayer.mergeOptions(options$u);
25455
25456  function convertPoint(c) {
25457    return this.getMap()._pointToContainerPoint(c, this._coordTileZoom, 0, TEMP_POINT);
25458  }
25459
25460  var GroupTileLayer = function (_TileLayer) {
25461    _inheritsLoose(GroupTileLayer, _TileLayer);
25462
25463    GroupTileLayer.fromJSON = function fromJSON(layerJSON) {
25464      if (!layerJSON || layerJSON['type'] !== 'GroupTileLayer') {
25465        return null;
25466      }
25467
25468      var layers = layerJSON['layers'].map(function (json) {
25469        return Layer.fromJSON(json);
25470      });
25471      return new GroupTileLayer(layerJSON['id'], layers, layerJSON['options']);
25472    };
25473
25474    function GroupTileLayer(id, layers, options) {
25475      var _this;
25476
25477      _this = _TileLayer.call(this, id, options) || this;
25478      _this.layers = layers || [];
25479
25480      _this._checkChildren();
25481
25482      _this.layerMap = {};
25483      _this._groupChildren = [];
25484      return _this;
25485    }
25486
25487    var _proto = GroupTileLayer.prototype;
25488
25489    _proto.getLayers = function getLayers() {
25490      return this.layers;
25491    };
25492
25493    _proto.toJSON = function toJSON() {
25494      var profile = {
25495        'type': this.getJSONType(),
25496        'id': this.getId(),
25497        'layers': this.layers.map(function (layer) {
25498          return layer.toJSON();
25499        }),
25500        'options': this.config()
25501      };
25502      return profile;
25503    };
25504
25505    _proto.getTiles = function getTiles(z) {
25506      var layers = this.layers;
25507      var tiles = [];
25508      var count = 0;
25509
25510      for (var i = 0, l = layers.length; i < l; i++) {
25511        var layer = layers[i];
25512
25513        if (!layer.options['visible']) {
25514          continue;
25515        }
25516
25517        var childGrid = layer.getTiles(z, this);
25518
25519        if (!childGrid || childGrid.count === 0) {
25520          continue;
25521        }
25522
25523        count += childGrid.count;
25524        pushIn(tiles, childGrid.tileGrids);
25525      }
25526
25527      return {
25528        count: count,
25529        tileGrids: tiles
25530      };
25531    };
25532
25533    _proto.onAdd = function onAdd() {
25534      var _this2 = this;
25535
25536      var map = this.getMap();
vendor: 10,518 bytes, lines 25537-25909
25537      this.layers.forEach(function (layer) {
25538        _this2.layerMap[layer.getId()] = layer;
25539
25540        if (layer.getChildLayer) {
25541          _this2._groupChildren.push(layer);
25542        }
25543
25544        layer._bindMap(map);
25545
25546        layer.on('show hide', _this2._onLayerShowHide, _this2);
25547      });
25548
25549      _TileLayer.prototype.onAdd.call(this);
25550    };
25551
25552    _proto.onRemove = function onRemove() {
25553      var _this3 = this;
25554
25555      this.layers.forEach(function (layer) {
25556        layer._doRemove();
25557
25558        layer.off('show hide', _this3._onLayerShowHide, _this3);
25559      });
25560      this.layerMap = {};
25561      this._groupChildren = [];
25562
25563      _TileLayer.prototype.onRemove.call(this);
25564    };
25565
25566    _proto.getChildLayer = function getChildLayer(id) {
25567      var layer = this.layerMap[id];
25568
25569      if (layer) {
25570        return layer;
25571      }
25572
25573      for (var i = 0; i < this._groupChildren.length; i++) {
25574        var child = this._groupChildren[i].getChildLayer(id);
25575
25576        if (child) {
25577          return child;
25578        }
25579      }
25580
25581      return null;
25582    };
25583
25584    _proto._onLayerShowHide = function _onLayerShowHide() {
25585      var renderer = this.getRenderer();
25586
25587      if (renderer) {
25588        renderer.setToRedraw();
25589      }
25590    };
25591
25592    _proto.isVisible = function isVisible() {
25593      if (!_TileLayer.prototype.isVisible.call(this)) {
25594        return false;
25595      }
25596
25597      var children = this.layers;
25598
25599      for (var i = 0, l = children.length; i < l; i++) {
25600        if (children[i].isVisible()) {
25601          return true;
25602        }
25603      }
25604
25605      return false;
25606    };
25607
25608    _proto._checkChildren = function _checkChildren() {
25609      var _this4 = this;
25610
25611      var ids = {};
25612      this.layers.forEach(function (layer) {
25613        var layerId = layer.getId();
25614
25615        if (ids[layerId]) {
25616          throw new Error("Duplicate child layer id (" + layerId + ") in the GroupTileLayer (" + _this4.getId() + ")");
25617        } else {
25618          ids[layerId] = 1;
25619        }
25620      });
25621    };
25622
25623    return GroupTileLayer;
25624  }(TileLayer);
25625
25626  GroupTileLayer.registerJSONType('GroupTileLayer');
25627
25628  var options$v = {
25629    crs: null,
25630    uppercase: false,
25631    detectRetina: false
25632  };
25633  var defaultWmsParams = {
25634    service: 'WMS',
25635    request: 'GetMap',
25636    layers: '',
25637    styles: '',
25638    format: 'image/jpeg',
25639    transparent: false,
25640    version: '1.1.1'
25641  };
25642
25643  var WMSTileLayer = function (_TileLayer) {
25644    _inheritsLoose(WMSTileLayer, _TileLayer);
25645
25646    function WMSTileLayer(id, options) {
25647      var _this;
25648
25649      _this = _TileLayer.call(this, id) || this;
25650      var wmsParams = extend({}, defaultWmsParams);
25651
25652      for (var p in options) {
25653        if (!(p in _this.options)) {
25654          wmsParams[p] = options[p];
25655        }
25656      }
25657
25658      _this.setOptions(options);
25659
25660      _this.setZIndex(options.zIndex);
25661
25662      var tileSize = _this.getTileSize();
25663
25664      wmsParams.width = tileSize.width;
25665      wmsParams.height = tileSize.height;
25666      _this.wmsParams = wmsParams;
25667      _this._wmsVersion = parseFloat(wmsParams.version);
25668      return _this;
25669    }
25670
25671    var _proto = WMSTileLayer.prototype;
25672
25673    _proto.onAdd = function onAdd() {
25674      var dpr = this.getMap().getDevicePixelRatio();
25675      var r = options$v.detectRetina ? dpr : 1;
25676      this.wmsParams.width *= r;
25677      this.wmsParams.height *= r;
25678      var crs = this.options.crs || this.getMap().getProjection().code;
25679      var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';
25680      this.wmsParams[projectionKey] = crs;
25681
25682      _TileLayer.prototype.onAdd.call(this);
25683    };
25684
25685    _proto.getTileUrl = function getTileUrl(x, y, z) {
25686      var res = this.getSpatialReference().getResolution(z),
25687          tileConfig = this._getTileConfig(),
25688          tileExtent = tileConfig.getTilePrjExtent(x, y, res);
25689
25690      var max = tileExtent.getMax(),
25691          min = tileExtent.getMin();
25692      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(',');
25693
25694      var url = _TileLayer.prototype.getTileUrl.call(this, x, y, z);
25695
25696      return url + getParamString(this.wmsParams, url, this.options.uppercase) + (this.options.uppercase ? '&BBOX=' : '&bbox=') + bbox;
25697    };
25698
25699    _proto.toJSON = function toJSON() {
25700      return {
25701        'type': 'WMSTileLayer',
25702        'id': this.getId(),
25703        'options': this.config()
25704      };
25705    };
25706
25707    WMSTileLayer.fromJSON = function fromJSON(layerJSON) {
25708      if (!layerJSON || layerJSON['type'] !== 'WMSTileLayer') {
25709        return null;
25710      }
25711
25712      return new WMSTileLayer(layerJSON['id'], layerJSON['options']);
25713    };
25714
25715    return WMSTileLayer;
25716  }(TileLayer);
25717
25718  WMSTileLayer.registerJSONType('WMSTileLayer');
25719  WMSTileLayer.mergeOptions(options$v);
25720  function getParamString(obj, existingUrl, uppercase) {
25721    var params = [];
25722
25723    for (var i in obj) {
25724      params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));
25725    }
25726
25727    return (!existingUrl || existingUrl.indexOf('?') === -1 ? '?' : '&') + params.join('&');
25728  }
25729
25730  var CanvasTileLayer = function (_TileLayer) {
25731    _inheritsLoose(CanvasTileLayer, _TileLayer);
25732
25733    function CanvasTileLayer(id, options) {
25734      var _this;
25735
25736      _this = _TileLayer.call(this, id, options) || this;
25737
25738      if (!_this.options.hasOwnProperty('forceRenderOnMoving')) {
25739        _this.options['forceRenderOnMoving'] = false;
25740      }
25741
25742      return _this;
25743    }
25744
25745    var _proto = CanvasTileLayer.prototype;
25746
25747    _proto.drawTile = function drawTile() {};
25748
25749    _proto.toJSON = function toJSON() {
25750      return {
25751        'type': 'CanvasTileLayer',
25752        'id': this.getId(),
25753        'options': this.config()
25754      };
25755    };
25756
25757    CanvasTileLayer.fromJSON = function fromJSON(layerJSON) {
25758      if (!layerJSON || layerJSON['type'] !== 'CanvasTileLayer') {
25759        return null;
25760      }
25761
25762      return new CanvasTileLayer(layerJSON['id'], layerJSON['options']);
25763    };
25764
25765    return CanvasTileLayer;
25766  }(TileLayer);
25767
25768  CanvasTileLayer.registerJSONType('CanvasTileLayer');
25769
25770  function createGLContext(canvas, options) {
25771    var attributes = {
25772      'alpha': true,
25773      'stencil': true,
25774      'preserveDrawingBuffer': true,
25775      'antialias': false
25776    };
25777    var names = ['webgl', 'experimental-webgl'];
25778    var context = null;
25779
25780    for (var i = 0; i < names.length; ++i) {
25781      try {
25782        context = canvas.getContext(names[i], options || attributes);
25783      } catch (e) {}
25784
25785      if (context) {
25786        break;
25787      }
25788    }
25789
25790    return context;
25791  }
25792  function compileShader(gl, type, source) {
25793    var shader = gl.createShader(type);
25794    gl.shaderSource(shader, source);
25795    gl.compileShader(shader);
25796    var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
25797
25798    if (!compiled) {
25799      var error = gl.getShaderInfoLog(shader);
25800      gl.deleteShader(shader);
25801      throw new Error('Failed to compile shader: ' + error);
25802    }
25803
25804    return shader;
25805  }
25806  function createProgram(gl, vert, frag) {
25807    var vertexShader = compileShader(gl, gl.VERTEX_SHADER, vert);
25808    var fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, frag);
25809
25810    if (!vertexShader || !fragmentShader) {
25811      return null;
25812    }
25813
25814    var program = gl.createProgram();
25815
25816    if (!program) {
25817      return null;
25818    }
25819
25820    gl.attachShader(program, vertexShader);
25821    gl.attachShader(program, fragmentShader);
25822    gl.linkProgram(program);
25823    return {
25824      program: program,
25825      vertexShader: vertexShader,
25826      fragmentShader: fragmentShader
25827    };
25828  }
25829  function enableVertexAttrib(gl, program, attributes) {
25830    if (Array.isArray(attributes[0])) {
25831      var FSIZE = Float32Array.BYTES_PER_ELEMENT;
25832      var STRIDE = 0;
25833
25834      for (var i = 0; i < attributes.length; i++) {
25835        STRIDE += attributes[i][1] || 0;
25836      }
25837
25838      var offset = 0;
25839
25840      for (var _i = 0; _i < attributes.length; _i++) {
25841        var attr = gl.getAttribLocation(program, attributes[_i][0]);
25842
25843        if (attr < 0) {
25844          throw new Error('Failed to get the storage location of ' + attributes[_i][0]);
25845        }
25846
25847        gl.vertexAttribPointer(attr, attributes[_i][1], gl[attributes[_i][2] || 'FLOAT'], false, FSIZE * STRIDE, FSIZE * offset);
25848        offset += attributes[_i][1] || 0;
25849        gl.enableVertexAttribArray(attr);
25850      }
25851    } else {
25852      var _attr = gl.getAttribLocation(program, attributes[0]);
25853
25854      gl.vertexAttribPointer(_attr, attributes[1], gl[attributes[2] || 'FLOAT'], false, 0, 0);
25855      gl.enableVertexAttribArray(_attr);
25856    }
25857  }
25858
25859  var shaders = {
25860    '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    ",
25861    '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    "
25862  };
25863  var v2 = [0, 0],
25864      v3 = [0, 0, 0],
25865      arr16 = new Array(16);
25866
25867  var ImageGLRenderable = function ImageGLRenderable(Base) {
25868    var renderable = function (_Base) {
25869      _inheritsLoose(renderable, _Base);
25870
25871      function renderable() {
25872        return _Base.apply(this, arguments) || this;
25873      }
25874
25875      var _proto = renderable.prototype;
25876
25877      _proto.drawGLImage = function drawGLImage(image, x, y, w, h, opacity) {
25878        var gl = this.gl;
25879        this.loadTexture(image);
25880        v3[0] = x || 0;
25881        v3[1] = y || 0;
25882        var uMatrix = identity(arr16);
25883        translate(uMatrix, uMatrix, v3);
25884        multiply(uMatrix, this.getMap().projViewMatrix, uMatrix);
25885        gl.uniformMatrix4fv(this.program['u_matrix'], false, uMatrix);
25886        gl.uniform1f(this.program['u_opacity'], opacity);
25887        var glBuffer = image.glBuffer;
25888
25889        if (glBuffer && (glBuffer.width !== w || glBuffer.height !== h)) {
25890          this.saveImageBuffer(glBuffer);
25891          delete image.glBuffer;
25892        }
25893
25894        if (!image.glBuffer) {
25895          image.glBuffer = this.bufferTileData(0, 0, w, h);
25896        } else {
25897          gl.bindBuffer(gl.ARRAY_BUFFER, glBuffer);
25898        }
25899
25900        v2[0] = 'a_position';
25901        v2[1] = 3;
25902        this.enableVertexAttrib(v2);
25903        gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
25904      };
25905
25906      _proto.bufferTileData = function bufferTileData(x, y, w, h, buffer) {
25907        var x1 = x;
25908        var x2 = x + w;
25909        var y1 = y;
25910        var y2 = y + h;
25911        var glBuffer = this.loadImageBuffer(this.set12(x1, y1, 0, x1, y2, 0, x2, y1, 0, x2, y2, 0), buffer);
25912        glBuffer.width = w;
25913        glBuffer.height = h;
25914        return glBuffer;
25915      };
25916
25917      _proto.drawTinImage = function drawTinImage(image, vertices, texCoords, indices, opacity) {
25918        var gl = this.gl;
25919        this.loadTexture(image);
25920        gl.uniformMatrix4fv(this.program['u_matrix'], false, this.getMap().projViewMatrix);
25921        gl.uniform1f(this.program['u_opacity'], opacity);
25922        gl.bindBuffer(gl.ARRAY_BUFFER, this.posBuffer);
25923        this.enableVertexAttrib(['a_position', 3]);
25924        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.DYNAMIC_DRAW);
25925        gl.bindBuffer(gl.ARRAY_BUFFER, this.texBuffer);
25926        this.enableVertexAttrib(['a_texCoord', 2]);
25927        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(texCoords), gl.DYNAMIC_DRAW);
25928        gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.DYNAMIC_DRAW);
25929        gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0);
25930      };
25931
25932      _proto.createCanvas2 = function createCanvas2() {
25933        this.canvas2 = Canvas.createCanvas(this.canvas.width, this.canvas.height);
25934      };
25935
25936      _proto.createGLContext = function createGLContext$$1() {
25937        if (this.canvas.gl && this.canvas.gl.wrap) {
25938          this.gl = this.canvas.gl.wrap();
25939        } else {
25940          this.gl = createGLContext(this.canvas2 || this.canvas, this.layer.options['glOptions']);
25941        }
25942
25943        var gl = this.gl;
25944        gl.clearColor(0.0, 0.0, 0.0, 0.0);
25945        gl.disable(gl.DEPTH_TEST);
25946        gl.enable(gl.STENCIL_TEST);
25947        gl.enable(gl.BLEND);
25948        gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
25949        this.program = this.createProgram(shaders['vertexShader'], this.layer.options['fragmentShader'] || shaders['fragmentShader'], ['u_matrix', 'u_image', 'u_opacity']);
25950        this.useProgram(this.program);
25951        this.texBuffer = this.createBuffer();
25952        gl.bindBuffer(gl.ARRAY_BUFFER, this.texBuffer);
25953        this.enableVertexAttrib(['a_texCoord', 2]);
25954        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);
25955        this.enableSampler('u_image');
25956        gl.activeTexture(gl['TEXTURE0']);
25957        gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
25958        this.posBuffer = this.createBuffer();
25959        gl.bindBuffer(gl.ARRAY_BUFFER, this.posBuffer);
25960        this.enableVertexAttrib(['a_position', 3]);
25961        this.indicesBuffer = this.createBuffer();
25962        gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
25963      };
25964
25965      _proto.resizeGLCanvas = function resizeGLCanvas() {
25966        if (this.gl) {
25967          this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
25968        }
25969
25970        if (!this.canvas2) {
25971          return;
25972        }
25973
25974        if (this.canvas2.width !== this.canvas.width || this.canvas2.height !== this.canvas.height) {
25975          this.canvas2.width = this.canvas.width;
25976          this.canvas2.height = this.canvas.height;
25977        }
25978      };
25979
25980      _proto.clearGLCanvas = function clearGLCanvas() {
25981        if (this.gl) {
25982          this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.STENCIL_BUFFER_BIT);
25983        }
25984      };
25985
25986      _proto.disposeImage = function disposeImage(image) {
25987        if (!image) {
25988          return;
25989        }
25990
25991        if (image.texture) {
25992          this.saveTexture(image.texture);
25993        }
25994
25995        if (image.glBuffer) {
25996          this.saveImageBuffer(image.glBuffer);
25997        }
25998
25999        delete image.texture;
26000        delete image.glBuffer;
26001      };
26002
26003      _proto._createTexture = function _createTexture(image) {
26004        var gl = this.gl;
26005        var texture = this.getTexture() || gl.createTexture();
26006        gl.bindTexture(gl.TEXTURE_2D, texture);
26007        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
26008        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
26009        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
26010        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
26011        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
26012
vendor: 21,995 bytes, lines 26013-26879
26013        if (isInteger(log2(image.width)) && isInteger(log2(image.width))) {
26014          gl.generateMipmap(gl.TEXTURE_2D);
26015        }
26016
26017        return texture;
26018      };
26019
26020      _proto.getTexture = function getTexture() {
26021        if (!this._textures) {
26022          this._textures = [];
26023        }
26024
26025        var textures = this._textures;
26026        return textures && textures.length > 0 ? textures.pop() : null;
26027      };
26028
26029      _proto.saveTexture = function saveTexture(texture) {
26030        this._textures.push(texture);
26031      };
26032
26033      _proto.loadTexture = function loadTexture(image) {
26034        var gl = this.gl;
26035        var texture = image.texture;
26036
26037        if (!texture) {
26038          texture = this._createTexture(image);
26039          image.texture = texture;
26040        }
26041
26042        gl.bindTexture(gl.TEXTURE_2D, texture);
26043        return texture;
26044      };
26045
26046      _proto.getImageBuffer = function getImageBuffer() {
26047        if (!this._imageBuffers) {
26048          this._imageBuffers = [];
26049        }
26050
26051        var imageBuffers = this._imageBuffers;
26052        return imageBuffers && imageBuffers.length > 0 ? imageBuffers.pop() : null;
26053      };
26054
26055      _proto.saveImageBuffer = function saveImageBuffer(buffer) {
26056        this._imageBuffers.push(buffer);
26057      };
26058
26059      _proto.loadImageBuffer = function loadImageBuffer(data, glBuffer) {
26060        var gl = this.gl;
26061        var buffer = glBuffer || this.createImageBuffer();
26062        gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
26063        gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
26064        return buffer;
26065      };
26066
26067      _proto.createImageBuffer = function createImageBuffer() {
26068        return this.getImageBuffer() || this.createBuffer();
26069      };
26070
26071      _proto.removeGLCanvas = function removeGLCanvas() {
26072        var gl = this.gl;
26073
26074        if (!gl) {
26075          return;
26076        }
26077
26078        if (this._buffers) {
26079          this._buffers.forEach(function (b) {
26080            gl.deleteBuffer(b);
26081          });
26082
26083          delete this._buffers;
26084        }
26085
26086        if (this._textures) {
26087          this._textures.forEach(function (t) {
26088            return gl.deleteTexture(t);
26089          });
26090
26091          delete this._textures;
26092        }
26093
26094        delete this.posBuffer;
26095        var program = gl.program;
26096        gl.deleteShader(program.fragmentShader);
26097        gl.deleteShader(program.vertexShader);
26098        gl.deleteProgram(program);
26099        delete this.gl;
26100        delete this.canvas2;
26101      };
26102
26103      _proto.createBuffer = function createBuffer() {
26104        var gl = this.gl;
26105        var buffer = gl.createBuffer();
26106
26107        if (!buffer) {
26108          throw new Error('Failed to create the buffer object');
26109        }
26110
26111        if (!this._buffers) {
26112          this._buffers = [];
26113        }
26114
26115        this._buffers.push(buffer);
26116
26117        return buffer;
26118      };
26119
26120      _proto.enableVertexAttrib = function enableVertexAttrib$$1(attributes) {
26121        enableVertexAttrib(this.gl, this.gl.program, attributes);
26122      };
26123
26124      _proto.createProgram = function createProgram$$1(vert, frag, uniforms) {
26125        var gl = this.gl;
26126
26127        var _createProgram2 = createProgram(gl, vert, frag),
26128            program = _createProgram2.program,
26129            vertexShader = _createProgram2.vertexShader,
26130            fragmentShader = _createProgram2.fragmentShader;
26131
26132        program.vertexShader = vertexShader;
26133        program.fragmentShader = fragmentShader;
26134
26135        this._initUniforms(program, uniforms);
26136
26137        return program;
26138      };
26139
26140      _proto.useProgram = function useProgram(program) {
26141        var gl = this.gl;
26142        gl.useProgram(program);
26143        gl.program = program;
26144        return this;
26145      };
26146
26147      _proto.enableSampler = function enableSampler(sampler, texIdx) {
26148        var gl = this.gl;
26149
26150        var uSampler = this._getUniform(gl.program, sampler);
26151
26152        if (!texIdx) {
26153          texIdx = 0;
26154        }
26155
26156        gl.uniform1i(uSampler, texIdx);
26157        return uSampler;
26158      };
26159
26160      _proto._initUniforms = function _initUniforms(program, uniforms) {
26161        for (var i = 0; i < uniforms.length; i++) {
26162          var name = uniforms[i];
26163          var uniform = uniforms[i];
26164          var b = name.indexOf('[');
26165
26166          if (b >= 0) {
26167            name = name.substring(0, b);
26168
26169            if (!IS_NODE) {
26170              uniform = uniform.substring(0, b);
26171            }
26172          }
26173
26174          program[name] = this._getUniform(program, uniform);
26175        }
26176      };
26177
26178      _proto._getUniform = function _getUniform(program, uniformName) {
26179        var gl = this.gl;
26180        var uniform = gl.getUniformLocation(program, uniformName);
26181
26182        if (!uniform) {
26183          throw new Error('Failed to get the storage location of ' + uniformName);
26184        }
26185
26186        return uniform;
26187      };
26188
26189      return renderable;
26190    }(Base);
26191
26192    extend(renderable.prototype, {
26193      set12: function () {
26194        var out = Browser$1.ie9 ? null : new Float32Array(12);
26195        return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) {
26196          out[0] = a0;
26197          out[1] = a1;
26198          out[2] = a2;
26199          out[3] = a3;
26200          out[4] = a4;
26201          out[5] = a5;
26202          out[6] = a6;
26203          out[7] = a7;
26204          out[8] = a8;
26205          out[9] = a9;
26206          out[10] = a10;
26207          out[11] = a11;
26208          return out;
26209        };
26210      }()
26211    });
26212    return renderable;
26213  };
26214
26215  var options$w = {
26216    renderer: Browser$1.webgl ? 'gl' : 'canvas',
26217    crossOrigin: null
26218  };
26219
26220  var ImageLayer = function (_Layer) {
26221    _inheritsLoose(ImageLayer, _Layer);
26222
26223    function ImageLayer(id, images, options) {
26224      var _this;
26225
26226      if (images && !Array.isArray(images) && !images.url) {
26227        options = images;
26228        images = null;
26229      }
26230
26231      _this = _Layer.call(this, id, options) || this;
26232      _this._images = images;
26233      return _this;
26234    }
26235
26236    var _proto = ImageLayer.prototype;
26237
26238    _proto.onAdd = function onAdd() {
26239      this._prepareImages(this._images);
26240    };
26241
26242    _proto.setImages = function setImages(images) {
26243      this._images = images;
26244
26245      this._prepareImages(images);
26246
26247      return this;
26248    };
26249
26250    _proto.getImages = function getImages() {
26251      return this._images;
26252    };
26253
26254    _proto._prepareImages = function _prepareImages(images) {
26255      images = images || [];
26256
26257      if (!Array.isArray(images)) {
26258        images = [images];
26259      }
26260
26261      var map = this.getMap();
26262      this._imageData = images.map(function (img) {
26263        var extent = new Extent(img.extent);
26264        return extend({}, img, {
26265          extent: extent,
26266          extent2d: extent.convertTo(function (c) {
26267            return map.coordToPoint(c, map.getGLZoom());
26268          })
26269        });
26270      });
26271      this._images = images;
26272      var renderer = this.getRenderer();
26273
26274      if (renderer) {
26275        renderer.refreshImages();
26276      }
26277    };
26278
26279    return ImageLayer;
26280  }(Layer);
26281
26282  ImageLayer.mergeOptions(options$w);
26283  var EMPTY_ARRAY = [];
26284  var ImageLayerCanvasRenderer = function (_CanvasRenderer) {
26285    _inheritsLoose(ImageLayerCanvasRenderer, _CanvasRenderer);
26286
26287    function ImageLayerCanvasRenderer() {
26288      return _CanvasRenderer.apply(this, arguments) || this;
26289    }
26290
26291    var _proto2 = ImageLayerCanvasRenderer.prototype;
26292
26293    _proto2.isDrawable = function isDrawable() {
26294      if (this.getMap().getPitch()) {
26295        if (console) {
26296          console.warn('ImageLayer with canvas renderer can\'t be pitched, use gl renderer (\'renderer\' : \'gl\') instead.');
26297        }
26298
26299        return false;
26300      }
26301
26302      return true;
26303    };
26304
26305    _proto2.checkResources = function checkResources() {
26306      var _this2 = this;
26307
26308      if (this._imageLoaded) {
26309        return EMPTY_ARRAY;
26310      }
26311
26312      var layer = this.layer;
26313
26314      var urls = layer._imageData.map(function (img) {
26315        return [img.url, null, null];
26316      });
26317
26318      if (this.resources) {
26319        var unloaded = [];
26320        var resources = new ResourceCache();
26321        urls.forEach(function (url) {
26322          if (_this2.resources.isResourceLoaded(url)) {
26323            var img = _this2.resources.getImage(url);
26324
26325            resources.addResource(url, img);
26326          } else {
26327            unloaded.push(url);
26328          }
26329        });
26330        this.resources.forEach(function (url, res) {
26331          if (!resources.isResourceLoaded(url)) {
26332            _this2.retireImage(res.image);
26333          }
26334        });
26335        this.resources = resources;
26336        urls = unloaded;
26337      }
26338
26339      this._imageLoaded = true;
26340      return urls;
26341    };
26342
26343    _proto2.retireImage = function retireImage() {};
26344
26345    _proto2.refreshImages = function refreshImages() {
26346      this._imageLoaded = false;
26347      this.setToRedraw();
26348    };
26349
26350    _proto2.needToRedraw = function needToRedraw() {
26351      var map = this.getMap();
26352
26353      if (map.isZooming() && !map.getPitch()) {
26354        return false;
26355      }
26356
26357      return _CanvasRenderer.prototype.needToRedraw.call(this);
26358    };
26359
26360    _proto2.draw = function draw() {
26361      if (!this.isDrawable()) {
26362        return;
26363      }
26364
26365      this.prepareCanvas();
26366      this._painted = false;
26367
26368      this._drawImages();
26369
26370      this.completeRender();
26371    };
26372
26373    _proto2._drawImages = function _drawImages() {
26374      var imgData = this.layer._imageData;
26375      var map = this.getMap();
26376
26377      var mapExtent = map._get2DExtent(map.getGLZoom());
26378
26379      if (imgData && imgData.length) {
26380        for (var i = 0; i < imgData.length; i++) {
26381          var extent = imgData[i].extent2d;
26382          var image = this.resources && this.resources.getImage(imgData[i].url);
26383
26384          if (image && mapExtent.intersects(extent)) {
26385            this._painted = true;
26386
26387            this._drawImage(image, extent, imgData[i].opacity || 1);
26388          }
26389        }
26390      }
26391    };
26392
26393    _proto2._drawImage = function _drawImage(image, extent, opacity) {
26394      var globalAlpha = 0;
26395      var ctx = this.context;
26396
26397      if (opacity < 1) {
26398        globalAlpha = ctx.globalAlpha;
26399        ctx.globalAlpha = opacity;
26400      }
26401
26402      var map = this.getMap();
26403      var min = extent.getMin(),
26404          max = extent.getMax();
26405
26406      var point = map._pointToContainerPoint(min, map.getGLZoom());
26407
26408      var x = point.x,
26409          y = point.y;
26410      var bearing = map.getBearing();
26411
26412      if (bearing) {
26413        ctx.save();
26414        ctx.translate(x, y);
26415
26416        if (bearing) {
26417          ctx.rotate(-bearing * Math.PI / 180);
26418        }
26419
26420        x = y = 0;
26421      }
26422
26423      var scale = map.getGLScale();
26424      ctx.drawImage(image, x, y, (max.x - min.x) / scale, (max.y - min.y) / scale);
26425
26426      if (bearing) {
26427        ctx.restore();
26428      }
26429
26430      if (globalAlpha) {
26431        ctx.globalAlpha = globalAlpha;
26432      }
26433    };
26434
26435    _proto2.drawOnInteracting = function drawOnInteracting() {
26436      this.draw();
26437    };
26438
26439    return ImageLayerCanvasRenderer;
26440  }(CanvasRenderer);
26441  var ImageLayerGLRenderer = function (_ImageGLRenderable) {
26442    _inheritsLoose(ImageLayerGLRenderer, _ImageGLRenderable);
26443
26444    function ImageLayerGLRenderer() {
26445      return _ImageGLRenderable.apply(this, arguments) || this;
26446    }
26447
26448    var _proto3 = ImageLayerGLRenderer.prototype;
26449
26450    _proto3.isDrawable = function isDrawable() {
26451      return true;
26452    };
26453
26454    _proto3._drawImage = function _drawImage(image, extent, opacity) {
26455      this.drawGLImage(image, extent.xmin, extent.ymin, extent.getWidth(), extent.getHeight(), opacity);
26456    };
26457
26458    _proto3.createContext = function createContext() {
26459      this.createGLContext();
26460    };
26461
26462    _proto3.resizeCanvas = function resizeCanvas(canvasSize) {
26463      if (!this.canvas) {
26464        return;
26465      }
26466
26467      _ImageGLRenderable.prototype.resizeCanvas.call(this, canvasSize);
26468
26469      this.resizeGLCanvas();
26470    };
26471
26472    _proto3.clearCanvas = function clearCanvas() {
26473      if (!this.canvas) {
26474        return;
26475      }
26476
26477      _ImageGLRenderable.prototype.clearCanvas.call(this);
26478
26479      this.clearGLCanvas();
26480    };
26481
26482    _proto3.retireImage = function retireImage(image) {
26483      this.disposeImage(image);
26484    };
26485
26486    _proto3.onRemove = function onRemove() {
26487      this.removeGLCanvas();
26488
26489      _ImageGLRenderable.prototype.onRemove.call(this);
26490    };
26491
26492    return ImageLayerGLRenderer;
26493  }(ImageGLRenderable(ImageLayerCanvasRenderer));
26494  ImageLayer.registerRenderer('canvas', ImageLayerCanvasRenderer);
26495  ImageLayer.registerRenderer('gl', ImageLayerGLRenderer);
26496
26497  var CanvasLayerRenderer = function (_CanvasRenderer) {
26498    _inheritsLoose(CanvasLayerRenderer, _CanvasRenderer);
26499
26500    function CanvasLayerRenderer() {
26501      return _CanvasRenderer.apply(this, arguments) || this;
26502    }
26503
26504    var _proto = CanvasLayerRenderer.prototype;
26505
26506    _proto.getPrepareParams = function getPrepareParams() {
26507      return [];
26508    };
26509
26510    _proto.getDrawParams = function getDrawParams() {
26511      return [];
26512    };
26513
26514    _proto.onCanvasCreate = function onCanvasCreate() {
26515      if (this.canvas && this.layer.options['doubleBuffer']) {
26516        this.buffer = Canvas.createCanvas(this.canvas.width, this.canvas.height, this.getMap().CanvasClass);
26517      }
26518    };
26519
26520    _proto.needToRedraw = function needToRedraw() {
26521      if (this.layer.options['animation']) {
26522        return true;
26523      }
26524
26525      var map = this.getMap();
26526
26527      if (map.isInteracting() && !this.layer.drawOnInteracting) {
26528        return false;
26529      }
26530
26531      return _CanvasRenderer.prototype.needToRedraw.call(this);
26532    };
26533
26534    _proto.draw = function draw() {
26535      this.prepareCanvas();
26536      this.prepareDrawContext();
26537
26538      this._drawLayer();
26539    };
26540
26541    _proto.drawOnInteracting = function drawOnInteracting() {
26542      this._drawLayerOnInteracting();
26543    };
26544
26545    _proto.getCanvasImage = function getCanvasImage() {
26546      var canvasImg = _CanvasRenderer.prototype.getCanvasImage.call(this);
26547
26548      if (canvasImg && canvasImg.image && this.layer.options['doubleBuffer']) {
26549        var canvas = canvasImg.image;
26550
26551        if (this.buffer.width !== canvas.width || this.buffer.height !== canvas.height) {
26552          this.buffer.width = canvas.width;
26553          this.buffer.height = canvas.height;
26554        }
26555
26556        var bufferContext = this.buffer.getContext('2d');
26557        var prevent = this.layer.doubleBuffer(bufferContext, this.context);
26558
26559        if (prevent === undefined || prevent) {
26560          Canvas.image(bufferContext, canvas, 0, 0);
26561          canvasImg.image = this.buffer;
26562        }
26563      }
26564
26565      return canvasImg;
26566    };
26567
26568    _proto.remove = function remove() {
26569      delete this._drawContext;
26570      return _CanvasRenderer.prototype.remove.call(this);
26571    };
26572
26573    _proto.onZoomStart = function onZoomStart(param) {
26574      this.layer.onZoomStart(param);
26575
26576      _CanvasRenderer.prototype.onZoomStart.call(this, param);
26577    };
26578
26579    _proto.onZooming = function onZooming(param) {
26580      this.layer.onZooming(param);
26581
26582      _CanvasRenderer.prototype.onZooming.call(this, param);
26583    };
26584
26585    _proto.onZoomEnd = function onZoomEnd(param) {
26586      this.layer.onZoomEnd(param);
26587
26588      _CanvasRenderer.prototype.onZoomEnd.call(this, param);
26589    };
26590
26591    _proto.onMoveStart = function onMoveStart(param) {
26592      this.layer.onMoveStart(param);
26593
26594      _CanvasRenderer.prototype.onMoveStart.call(this, param);
26595    };
26596
26597    _proto.onMoving = function onMoving(param) {
26598      this.layer.onMoving(param);
26599
26600      _CanvasRenderer.prototype.onMoving.call(this, param);
26601    };
26602
26603    _proto.onMoveEnd = function onMoveEnd(param) {
26604      this.layer.onMoveEnd(param);
26605
26606      _CanvasRenderer.prototype.onMoveEnd.call(this, param);
26607    };
26608
26609    _proto.onResize = function onResize(param) {
26610      this.layer.onResize(param);
26611
26612      _CanvasRenderer.prototype.onResize.call(this, param);
26613    };
26614
26615    _proto.prepareDrawContext = function prepareDrawContext() {
26616      if (!this._predrawed) {
26617        var params = ensureParams(this.getPrepareParams());
26618        this._drawContext = this.layer.prepareToDraw.apply(this.layer, [this.context].concat(params));
26619
26620        if (!this._drawContext) {
26621          this._drawContext = [];
26622        }
26623
26624        if (!Array.isArray(this._drawContext)) {
26625          this._drawContext = [this._drawContext];
26626        }
26627
26628        this._predrawed = true;
26629      }
26630    };
26631
26632    _proto._prepareDrawParams = function _prepareDrawParams() {
26633      if (!this.getMap()) {
26634        return null;
26635      }
26636
26637      var view = this.getViewExtent();
26638
26639      if (view['maskExtent'] && !view['extent'].intersects(view['maskExtent'])) {
26640        this.completeRender();
26641        return null;
26642      }
26643
26644      var args = [this.context, view];
26645      var params = ensureParams(this.getDrawParams());
26646      args.push.apply(args, params);
26647      args.push.apply(args, this._drawContext);
26648      return args;
26649    };
26650
26651    _proto._drawLayer = function _drawLayer() {
26652      var args = this._prepareDrawParams();
26653
26654      if (!args) {
26655        return;
26656      }
26657
26658      this.layer.draw.apply(this.layer, args);
26659      this.completeRender();
26660    };
26661
26662    _proto._drawLayerOnInteracting = function _drawLayerOnInteracting() {
26663      if (!this.layer.drawOnInteracting) {
26664        return;
26665      }
26666
26667      var args = this._prepareDrawParams();
26668
26669      if (!args) {
26670        return;
26671      }
26672
26673      this.layer.drawOnInteracting.apply(this.layer, args);
26674      this.completeRender();
26675    };
26676
26677    return CanvasLayerRenderer;
26678  }(CanvasRenderer);
26679
26680  function ensureParams(params) {
26681    if (!params) {
26682      params = [];
26683    }
26684
26685    if (!Array.isArray(params)) {
26686      params = [params];
26687    }
26688
26689    return params;
26690  }
26691
26692  var options$x = {
26693    'doubleBuffer': false,
26694    'animation': false
26695  };
26696
26697  var CanvasLayer = function (_Layer) {
26698    _inheritsLoose(CanvasLayer, _Layer);
26699
26700    function CanvasLayer() {
26701      return _Layer.apply(this, arguments) || this;
26702    }
26703
26704    var _proto = CanvasLayer.prototype;
26705
26706    _proto.isCanvasRender = function isCanvasRender() {
26707      return true;
26708    };
26709
26710    _proto.prepareToDraw = function prepareToDraw() {};
26711
26712    _proto.draw = function draw() {};
26713
26714    _proto.redraw = function redraw() {
26715      if (this._getRenderer()) {
26716        this._getRenderer().setToRedraw();
26717      }
26718
26719      return this;
26720    };
26721
26722    _proto.play = function play() {
26723      this.config('animation', true);
26724      return this;
26725    };
26726
26727    _proto.pause = function pause() {
26728      this.config('animation', false);
26729      return this;
26730    };
26731
26732    _proto.isPlaying = function isPlaying() {
26733      return this.options['animation'];
26734    };
26735
26736    _proto.clearCanvas = function clearCanvas() {
26737      if (this._getRenderer()) {
26738        this._getRenderer().clearCanvas();
26739      }
26740
26741      return this;
26742    };
26743
26744    _proto.requestMapToRender = function requestMapToRender() {
26745      if (this._getRenderer()) {
26746        this._getRenderer().requestMapToRender();
26747      }
26748
26749      return this;
26750    };
26751
26752    _proto.completeRender = function completeRender() {
26753      if (this._getRenderer()) {
26754        this._getRenderer().completeRender();
26755      }
26756
26757      return this;
26758    };
26759
26760    _proto.onCanvasCreate = function onCanvasCreate() {
26761      return this;
26762    };
26763
26764    _proto.onZoomStart = function onZoomStart() {};
26765
26766    _proto.onZooming = function onZooming() {};
26767
26768    _proto.onZoomEnd = function onZoomEnd() {};
26769
26770    _proto.onMoveStart = function onMoveStart() {};
26771
26772    _proto.onMoving = function onMoving() {};
26773
26774    _proto.onMoveEnd = function onMoveEnd() {};
26775
26776    _proto.onResize = function onResize() {};
26777
26778    _proto.doubleBuffer = function doubleBuffer(bufferContext) {
26779      bufferContext.clearRect(0, 0, bufferContext.canvas.width, bufferContext.canvas.height);
26780      return this;
26781    };
26782
26783    return CanvasLayer;
26784  }(Layer);
26785
26786  CanvasLayer.mergeOptions(options$x);
26787  CanvasLayer.registerRenderer('canvas', CanvasLayerRenderer);
26788
26789  var TEMP_POINT$1 = new Point(0, 0);
26790  var options$y = {
26791    'animation': true
26792  };
26793
26794  var ParticleLayer = function (_CanvasLayer) {
26795    _inheritsLoose(ParticleLayer, _CanvasLayer);
26796
26797    function ParticleLayer() {
26798      return _CanvasLayer.apply(this, arguments) || this;
26799    }
26800
26801    var _proto = ParticleLayer.prototype;
26802
26803    _proto.getParticles = function getParticles() {};
26804
26805    _proto.draw = function draw(context, view) {
26806      var points = this.getParticles(now());
26807
26808      if (!points || points.length === 0) {
26809        var renderer = this._getRenderer();
26810
26811        if (renderer) {
26812          this._getRenderer()._shouldClear = true;
26813        }
26814
26815        return;
26816      }
26817
26818      var map = this.getMap();
26819      var extent = view.extent;
26820
26821      if (view.maskExtent) {
26822        extent = view.extent.intersection(view.maskExtent);
26823      }
26824
26825      extent = extent.convertTo(function (c) {
26826        return map._pointToContainerPoint(c, undefined, 0, TEMP_POINT$1);
26827      });
26828      var e = 2 * Math.PI;
26829
26830      for (var i = 0, l = points.length; i < l; i++) {
26831        var pos = points[i].point;
26832
26833        if (extent.contains(pos)) {
26834          var color = points[i].color || this.options['lineColor'] || '#fff',
26835              r = points[i].r;
26836
26837          if (context.fillStyle !== color) {
26838            context.fillStyle = color;
26839          }
26840
26841          if (r <= 2) {
26842            context.fillRect(pos.x - r / 2, pos.y - r / 2, r, r);
26843          } else {
26844            context.beginPath();
26845            context.arc(pos.x, pos.y, r / 2, 0, e);
26846            context.fill();
26847          }
26848        }
26849      }
26850
26851      this._fillCanvas(context);
26852    };
26853
26854    _proto._fillCanvas = function _fillCanvas(context) {
26855      var g = context.globalCompositeOperation;
26856      context.globalCompositeOperation = 'destination-out';
26857      var trail = this.options['trail'] || 30;
26858      context.fillStyle = 'rgba(0, 0, 0, ' + 1 / trail + ')';
26859      context.fillRect(0, 0, context.canvas.width, context.canvas.height);
26860      context.globalCompositeOperation = g;
26861    };
26862
26863    return ParticleLayer;
26864  }(CanvasLayer);
26865
26866  ParticleLayer.mergeOptions(options$y);
26867  ParticleLayer.registerRenderer('canvas', function (_CanvasLayerRenderer) {
26868    _inheritsLoose(_class, _CanvasLayerRenderer);
26869
26870    function _class() {
26871      return _CanvasLayerRenderer.apply(this, arguments) || this;
26872    }
26873
26874    var _proto2 = _class.prototype;
26875
26876    _proto2.draw = function draw() {
26877      if (!this.canvas || !this.layer.options['animation'] || this._shouldClear) {
26878        this.prepareCanvas();
26879        this._shouldClear = false;
26880      }
26881
26882      this.prepareDrawContext();
26883
26884      this._drawLayer();
26885    };
26886
26887    _proto2.drawOnInteracting = function drawOnInteracting() {
26888      this.draw();
26889      this._shouldClear = false;
26890    };
26891
26892    _proto2.onSkipDrawOnInteracting = function onSkipDrawOnInteracting() {
26893      this._shouldClear = true;
26894    };
26895
26896    return _class;
26897  }(CanvasLayerRenderer));
26898
26899  var EDIT_STAGE_LAYER_PREFIX = INTERNAL_LAYER_PREFIX + '_edit_stage_';
26900
26901  function createHandleSymbol(markerType, opacity) {
26902    return {
26903      'markerType': markerType,
26904      'markerFill': '#fff',
26905      'markerLineColor': '#000',
26906      'markerLineWidth': 2,
26907      'markerWidth': 10,
26908      'markerHeight': 10,
26909      'opacity': opacity
26910    };
26911  }
26912
26913  var options$z = {
26914    'fixAspectRatio': false,
26915    'symbol': null,
26916    'removeVertexOn': 'contextmenu',
26917    'centerHandleSymbol': createHandleSymbol('ellipse', 1),
26918    'vertexHandleSymbol': createHandleSymbol('square', 1),
26919    'newVertexHandleSymbol': createHandleSymbol('square', 0.4)
26920  };
26921
26922  var GeometryEditor = function (_Eventable) {
26923    _inheritsLoose(GeometryEditor, _Eventable);
26924
26925    function GeometryEditor(geometry, opts) {
26926      var _this;
26927
26928      _this = _Eventable.call(this, opts) || this;
26929      _this._geometry = geometry;
26930
26931      if (!_this._geometry) {
26932        return _assertThisInitialized(_this);
26933      }
26934
26935      return _this;
26936    }
26937
26938    var _proto = GeometryEditor.prototype;
26939
26940    _proto.getMap = function getMap() {
26941      return this._geometry.getMap();
26942    };
26943
26944    _proto.prepare = function prepare() {
26945      var map = this.getMap();
26946
26947      if (!map) {
26948        return;
26949      }
26950
26951      if (this.options['symbol']) {
26952        this._originalSymbol = this._geometry.getSymbol();
26953
26954        this._geometry.setSymbol(this.options['symbol']);
26955      }
26956
26957      this._prepareEditStageLayer();
26958    };
26959
26960    _proto._prepareEditStageLayer = function _prepareEditStageLayer() {
26961      var map = this.getMap();
26962      var uid = UID();
26963      var stageId = EDIT_STAGE_LAYER_PREFIX + uid,
26964          shadowId = EDIT_STAGE_LAYER_PREFIX + uid + '_shadow';
26965      this._editStageLayer = map.getLayer(stageId);
26966      this._shadowLayer = map.getLayer(shadowId);
26967
26968      if (!this._editStageLayer) {
26969        this._editStageLayer = new VectorLayer(stageId);
26970        map.addLayer(this._editStageLayer);
26971      }
26972
26973      if (!this._shadowLayer) {
26974        this._shadowLayer = new VectorLayer(shadowId);
26975        map.addLayer(this._shadowLayer);
26976      }
26977    };
26978
26979    _proto.start = function start() {
26980      var _this2 = this;
26981
26982      if (!this._geometry || !this._geometry.getMap() || this._geometry.editing) {
26983        return;
26984      }
26985
26986      var map = this.getMap();
26987      this.editing = true;
26988      var geometry = this._geometry;
26989      this._geometryDraggble = geometry.options['draggable'];
26990      geometry.config('draggable', false);
26991      this.prepare();
26992      var shadow = geometry.copy();
26993      shadow.setSymbol(geometry._getInternalSymbol());
26994      shadow.copyEventListeners(geometry);
26995
26996      if (geometry._getParent()) {
26997        shadow.copyEventListeners(geometry._getParent());
26998      }
26999
27000      shadow.setId(null).config({
27001        'draggable': false
27002      });
27003      this._shadow = shadow;
27004
27005      this._switchGeometryEvents('on');
27006
27007      geometry.hide();
27008
27009      if (geometry instanceof Marker || geometry instanceof Circle || geometry instanceof Rectangle || geometry instanceof Ellipse) {
27010        this._createOrRefreshOutline();
27011      }
27012
27013      this._shadowLayer.bringToFront().addGeometry(shadow);
27014
27015      this._editStageLayer.bringToFront();
27016
27017      this._addListener([map, 'zoomstart', function () {
27018        _this2._editStageLayer.hide();
27019      }]);
27020
27021      this._addListener([map, 'zoomend', function () {
27022        _this2._editStageLayer.show();
27023      }]);
27024
27025      if (!(geometry instanceof Marker)) {
27026        this._createCenterHandle();
27027      } else {
27028        shadow.config('draggable', true);
27029        shadow.on('dragend', this._onMarkerDragEnd, this);
27030      }
27031
27032      if (geometry instanceof Marker) {
27033        this.createMarkerEditor();
27034      } else if (geometry instanceof Circle) {
27035        this.createCircleEditor();
27036      } else if (geometry instanceof Rectangle) {
27037        this.createEllipseOrRectEditor();
27038      } else if (geometry instanceof Ellipse) {
27039        this.createEllipseOrRectEditor();
27040      } else if (geometry instanceof Sector) ; else if (geometry instanceof Polygon || geometry instanceof LineString) {
27041        this.createPolygonEditor();
27042      }
27043    };
27044
27045    _proto.stop = function stop() {
27046      delete this._history;
27047      delete this._historyPointer;
27048      delete this._editOutline;
27049
27050      this._switchGeometryEvents('off');
27051
27052      var map = this.getMap();
27053
27054      if (!map) {
27055        return;
27056      }
27057
27058      delete this._shadow;
27059
27060      this._geometry.config('draggable', this._geometryDraggble);
27061
27062      delete this._geometryDraggble;
27063
27064      this._geometry.show();
27065
27066      this._editStageLayer.remove();
27067
27068      this._shadowLayer.remove();
27069
27070      this._clearAllListeners();
27071
27072      this._refreshHooks = [];
27073
27074      if (this.options['symbol']) {
27075        this._geometry.setSymbol(this._originalSymbol);
27076
27077        delete this._originalSymbol;
27078      }
27079
27080      this.editing = false;
27081    };
27082
27083    _proto.isEditing = function isEditing() {
27084      if (isNil(this.editing)) {
27085        return false;
27086      }
27087
27088      return this.editing;
27089    };
27090
27091    _proto._getGeometryEvents = function _getGeometryEvents() {
27092      return {
27093        'symbolchange': this._onGeoSymbolChange,
27094        'positionchange shapechange': this._exeAndReset
27095      };
27096    };
27097
27098    _proto._switchGeometryEvents = function _switchGeometryEvents(oper) {
27099      if (this._geometry) {
27100        var events = this._getGeometryEvents();
27101
27102        for (var p in events) {
27103          this._geometry[oper](p, events[p], this);
27104        }
27105      }
27106    };
27107
27108    _proto._onGeoSymbolChange = function _onGeoSymbolChange(param) {
27109      if (this._shadow) {
27110        this._shadow.setSymbol(param.target._getInternalSymbol());
27111      }
27112    };
27113
27114    _proto._onMarkerDragEnd = function _onMarkerDragEnd() {
27115      this._update('setCoordinates', this._shadow.getCoordinates().toArray());
27116
27117      this._refresh();
27118    };
27119
27120    _proto._createOrRefreshOutline = function _createOrRefreshOutline() {
27121      var geometry = this._geometry;
27122      var outline = this._editOutline;
27123
27124      if (!outline) {
27125        outline = geometry.getOutline();
27126
27127        this._editStageLayer.addGeometry(outline);
27128
27129        this._editOutline = outline;
27130
27131        this._addRefreshHook(this._createOrRefreshOutline);
27132      } else {
27133        outline.remove();
27134        this._editOutline = outline = geometry.getOutline();
27135
27136        this._editStageLayer.addGeometry(outline);
27137      }
27138
27139      return outline;
27140    };
27141
27142    _proto._createCenterHandle = function _createCenterHandle() {
27143      var _this3 = this;
27144
27145      var center = this._shadow.getCenter();
27146
27147      var symbol = this.options['centerHandleSymbol'];
27148      var shadow;
27149      var handle = this.createHandle(center, {
27150        'symbol': symbol,
27151        'cursor': 'move',
27152        onDown: function onDown() {
27153          shadow = _this3._shadow.copy();
27154          var symbol = lowerSymbolOpacity(shadow._getInternalSymbol(), 0.5);
27155          shadow.setSymbol(symbol).addTo(_this3._editStageLayer);
27156        },
27157        onMove: function onMove(v, param) {
27158          var offset = param['coordOffset'];
27159          shadow.translate(offset);
27160        },
27161        onUp: function onUp() {
27162          _this3._update('setCoordinates', Coordinate.toNumberArrays(shadow.getCoordinates()));
27163
27164          shadow.remove();
27165
27166          _this3._refresh();
27167        }
27168      });
27169
27170      this._addRefreshHook(function () {
27171        var center = _this3._shadow.getCenter();
27172
27173        handle.setCoordinates(center);
27174      });
27175    };
27176
27177    _proto._createHandleInstance = function _createHandleInstance(coordinate, opts) {
27178      var symbol = opts['symbol'];
27179      var handle = new Marker(coordinate, {
27180        'draggable': true,
27181        'dragShadow': false,
27182        'dragOnAxis': opts['axis'],
27183        'cursor': opts['cursor'],
27184        'symbol': symbol
27185      });
27186      return handle;
27187    };
27188
27189    _proto.createHandle = function createHandle(coordinate, opts) {
27190      if (!opts) {
27191        opts = {};
27192      }
27193
27194      var map = this.getMap();
27195
27196      var handle = this._createHandleInstance(coordinate, opts);
27197
27198      var me = this;
27199
27200      function onHandleDragstart(param) {
27201        if (opts.onDown) {
27202          this._geometry.fire('handledragstart');
27203
27204          opts.onDown.call(me, param['viewPoint'], param);
27205        }
27206
27207        return false;
27208      }
27209
27210      function onHandleDragging(param) {
27211        me._hideContext();
27212
27213        var viewPoint = map._prjToViewPoint(handle._getPrjCoordinates());
27214
27215        if (opts.onMove) {
27216          this._geometry.fire('handledragging');
27217
27218          opts.onMove.call(me, viewPoint, param);
27219        }
27220
27221        return false;
27222      }
27223
27224      function onHandleDragEnd(ev) {
27225        if (opts.onUp) {
27226          this._geometry.fire('handledragend');
27227
27228          opts.onUp.call(me, ev);
27229        }
27230
27231        return false;
27232      }
27233
27234      function onHandleRemove() {
27235        handle.config('draggable', false);
27236        handle.off('dragstart', onHandleDragstart, me);
27237        handle.off('dragging', onHandleDragging, me);
27238        handle.off('dragend', onHandleDragEnd, me);
27239        handle.off('removestart', onHandleRemove, me);
27240        delete handle['maptalks--editor-refresh-fn'];
27241      }
27242
27243      handle.on('dragstart', onHandleDragstart, this);
27244      handle.on('dragging', onHandleDragging, this);
27245      handle.on('dragend', onHandleDragEnd, this);
27246      handle.on('removestart', onHandleRemove, this);
27247
27248      if (opts.onRefresh) {
27249        handle['maptalks--editor-refresh-fn'] = opts.onRefresh;
27250      }
27251
27252      this._editStageLayer.addGeometry(handle);
27253
27254      return handle;
27255    };
27256
27257    _proto._createResizeHandles = function _createResizeHandles(blackList, onHandleMove, onHandleUp) {
27258      var _this4 = this;
27259
27260      var cursors = ['nw-resize', 'n-resize', 'ne-resize', 'w-resize', 'e-resize', 'sw-resize', 's-resize', 'se-resize'];
27261      var axis = [null, 'y', null, 'x', 'x', null, 'y', null];
27262      var geometry = this._geometry;
27263
27264      function getResizeAnchors(ext) {
27265        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()];
27266      }
27267
27268      if (!blackList) {
27269        blackList = [];
27270      }
27271
27272      var me = this;
27273      var resizeHandles = [],
27274          anchorIndexes = {},
27275          map = this.getMap(),
27276          handleSymbol = this.options['vertexHandleSymbol'];
27277
27278      var fnLocateHandles = function fnLocateHandles() {
27279        var pExt = geometry._getPainter().get2DExtent(),
27280            anchors = getResizeAnchors(pExt);
27281
27282        var _loop = function _loop(i) {
27283          if (Array.isArray(blackList)) {
27284            var isBlack = blackList.some(function (ele) {
27285              return ele === i;
27286            });
27287
27288            if (isBlack) {
27289              return "continue";
27290            }
27291          }
27292
27293          var anchor = anchors[i],
27294              coordinate = map.pointToCoordinate(anchor);
27295
27296          if (resizeHandles.length < anchors.length - blackList.length) {
27297            var handle = _this4.createHandle(coordinate, {
27298              'symbol': handleSymbol,
27299              'cursor': cursors[i],
27300              'axis': axis[i],
27301              onMove: function (_index) {
27302                return function (handleViewPoint) {
27303                  me._updating = true;
27304                  onHandleMove(handleViewPoint, _index);
27305                  geometry.fire('resizing');
27306                };
27307              }(i),
27308              onUp: function onUp() {
27309                me._updating = false;
27310                onHandleUp();
27311
27312                _this4._refresh();
27313              }
27314            });
27315
27316            handle.setId(i);
27317            anchorIndexes[i] = resizeHandles.length;
27318            resizeHandles.push(handle);
27319          } else {
27320            resizeHandles[anchorIndexes[i]].setCoordinates(coordinate);
27321          }
27322        };
27323
27324        for (var i = 0; i < anchors.length; i++) {
27325          var _ret = _loop(i);
27326
27327          if (_ret === "continue") continue;
27328        }
27329      };
27330
27331      fnLocateHandles();
27332
27333      this._addRefreshHook(fnLocateHandles);
27334
27335      return resizeHandles;
27336    };
27337
27338    _proto.createMarkerEditor = function createMarkerEditor() {
27339      var _this5 = this;
27340
27341      var geometryToEdit = this._geometry,
27342          shadow = this._shadow,
27343          map = this.getMap();
27344
27345      if (!shadow._canEdit()) {
27346        if (console) {
27347          console.warn('A marker can\'t be resized with symbol:', shadow.getSymbol());
27348        }
27349
27350        return;
27351      }
27352
27353      if (!this._history) {
27354        this._recordHistory(getUpdates());
27355      }
27356
27357      var symbol = shadow._getInternalSymbol();
27358
27359      var dxdy = new Point(0, 0);
27360
27361      if (isNumber(symbol['markerDx'])) {
27362        dxdy.x = symbol['markerDx'];
27363      }
27364
27365      if (isNumber(symbol['markerDy'])) {
27366        dxdy.y = symbol['markerDy'];
27367      }
27368
27369      var blackList = null;
27370
27371      if (VectorMarkerSymbolizer.test(symbol)) {
27372        if (symbol['markerType'] === 'pin' || symbol['markerType'] === 'pie' || symbol['markerType'] === 'bar') {
27373          blackList = [5, 6, 7];
27374        }
27375      } else if (ImageMarkerSymbolizer.test(symbol) || VectorPathMarkerSymbolizer.test(symbol)) {
27376        blackList = [5, 6, 7];
27377      }
27378
27379      var resizeAbilities = [2, 1, 2, 0, 0, 2, 1, 2];
27380      var aspectRatio;
27381
27382      if (this.options['fixAspectRatio']) {
27383        var size = shadow.getSize();
27384        aspectRatio = size.width / size.height;
27385      }
27386
27387      var resizeHandles = this._createResizeHandles(null, function (handleViewPoint, i) {
27388        if (blackList && blackList.indexOf(i) >= 0) {
27389          var newCoordinates = map.viewPointToCoordinate(handleViewPoint.sub(dxdy));
27390          var coordinates = shadow.getCoordinates();
27391          newCoordinates.x = coordinates.x;
27392          shadow.setCoordinates(newCoordinates);
27393
27394          _this5._updateCoordFromShadow(true);
27395
27396          var mirrorHandle = resizeHandles[resizeHandles.length - 1 - i];
27397          var mirrorViewPoint = map.coordToViewPoint(mirrorHandle.getCoordinates());
27398          handleViewPoint = mirrorViewPoint;
27399        }
27400
27401        var viewCenter = map._pointToViewPoint(shadow._getCenter2DPoint()).add(dxdy),
27402            symbol = shadow._getInternalSymbol();
27403
27404        var wh = handleViewPoint.sub(viewCenter);
27405
27406        if (blackList && handleViewPoint.y > viewCenter.y) {
27407          wh.y = 0;
27408        }
27409
27410        var r = blackList ? 1 : 2;
27411        var width = Math.abs(wh.x) * 2,
27412            height = Math.abs(wh.y) * r;
27413
27414        if (aspectRatio) {
27415          width = Math.max(width, height * aspectRatio);
27416          height = width / aspectRatio;
27417        }
27418
27419        var ability = resizeAbilities[i];
27420
27421        if (!(shadow instanceof TextBox)) {
27422          if (aspectRatio || ability === 0 || ability === 2) {
27423            symbol['markerWidth'] = width;
27424          }
27425
27426          if (aspectRatio || ability === 1 || ability === 2) {
27427            symbol['markerHeight'] = height;
27428          }
27429
27430          shadow.setSymbol(symbol);
27431          geometryToEdit.setSymbol(symbol);
27432        } else {
27433          if (aspectRatio || ability === 0 || ability === 2) {
27434            shadow.setWidth(width);
27435            geometryToEdit.setWidth(width);
27436          }
27437
27438          if (aspectRatio || ability === 1 || ability === 2) {
27439            shadow.setHeight(height);
27440            geometryToEdit.setHeight(height);
27441          }
27442        }
27443      }, function () {
27444        _this5._update(getUpdates());
27445      });
27446
27447      function getUpdates() {
27448        var updates = [['setCoordinates', shadow.getCoordinates().toArray()]];
27449
27450        if (shadow instanceof TextBox) {
27451          updates.push(['setWidth', shadow.getWidth()]);
27452          updates.push(['setHeight', shadow.getHeight()]);
27453        } else {
27454          updates.push(['setSymbol', shadow.getSymbol()]);
27455        }
27456
27457        return updates;
27458      }
27459
27460      function onZoomEnd() {
27461        this._refresh();
27462      }
27463
27464      this._addListener([map, 'zoomend', onZoomEnd]);
27465    };
27466
27467    _proto.createCircleEditor = function createCircleEditor() {
27468      var _this6 = this;
27469
27470      var circle = this._geometry,
27471          shadow = this._shadow;
27472      var map = this.getMap();
27473
27474      if (!this._history) {
27475        this._recordHistory([['setCoordinates', shadow.getCoordinates().toArray()], ['setRadius', shadow.getRadius()]]);
27476      }
27477
27478      this._createResizeHandles(null, function (handleViewPoint) {
27479        var viewCenter = map._pointToViewPoint(shadow._getCenter2DPoint());
27480
27481        var wh = handleViewPoint.sub(viewCenter);
27482        var w = Math.abs(wh.x),
27483            h = Math.abs(wh.y);
27484        var r;
27485
27486        if (w > h) {
27487          r = map.pixelToDistance(w, 0);
27488        } else {
27489          r = map.pixelToDistance(0, h);
27490        }
27491
27492        shadow.setRadius(r);
27493        circle.setRadius(r);
27494      }, function () {
27495        _this6._update('setRadius', shadow.getRadius());
27496      });
27497    };
27498
27499    _proto.createEllipseOrRectEditor = function createEllipseOrRectEditor() {
27500      var _this7 = this;
27501
27502      var resizeAbilities = [2, 1, 2, 0, 0, 2, 1, 2];
27503      var geometryToEdit = this._geometry,
27504          shadow = this._shadow;
27505
27506      if (!this._history) {
27507        this._recordHistory(getUpdates());
27508      }
27509
27510      var map = this.getMap();
27511      var isRect = this._geometry instanceof Rectangle;
27512      var aspectRatio;
27513
27514      if (this.options['fixAspectRatio']) {
27515        aspectRatio = geometryToEdit.getWidth() / geometryToEdit.getHeight();
27516      }
27517
27518      var resizeHandles = this._createResizeHandles(null, function (mouseViewPoint, i) {
27519        var r = isRect ? 1 : 2;
27520        var pointSub, w, h;
27521        var targetPoint = mouseViewPoint;
27522        var ability = resizeAbilities[i];
27523
27524        if (isRect) {
27525          var mirror = resizeHandles[7 - i];
27526          var mirrorViewPoint = map.coordToViewPoint(mirror.getCoordinates());
27527          pointSub = targetPoint.sub(mirrorViewPoint);
27528          var absSub = pointSub.abs();
27529          w = map.pixelToDistance(absSub.x, 0);
27530          h = map.pixelToDistance(0, absSub.y);
27531          var size = geometryToEdit.getSize();
27532
27533          if (ability === 0) {
27534            if (aspectRatio) {
27535              absSub.y = absSub.x / aspectRatio;
27536              size.height = Math.abs(absSub.y);
27537              h = w / aspectRatio;
27538            }
27539
27540            targetPoint.y = mirrorViewPoint.y - size.height / 2;
27541          } else if (ability === 1) {
27542            if (aspectRatio) {
27543              absSub.x = absSub.y * aspectRatio;
27544              size.width = Math.abs(absSub.x);
27545              w = h * aspectRatio;
27546            }
27547
27548            targetPoint.x = mirrorViewPoint.x - size.width / 2;
27549          } else if (aspectRatio) {
27550            if (w > h * aspectRatio) {
27551              h = w / aspectRatio;
27552              targetPoint.y = mirrorViewPoint.y + absSub.x * sign(pointSub.y) / aspectRatio;
27553            } else {
27554              w = h * aspectRatio;
27555              targetPoint.x = mirrorViewPoint.x + absSub.y * sign(pointSub.x) * aspectRatio;
27556            }
27557          }
27558
27559          var newCoordinates = map.viewPointToCoordinate(new Point(Math.min(targetPoint.x, mirrorViewPoint.x), Math.min(targetPoint.y, mirrorViewPoint.y)));
27560          shadow.setCoordinates(newCoordinates);
27561
27562          _this7._updateCoordFromShadow(true);
27563        } else {
27564          var viewCenter = map.coordToViewPoint(geometryToEdit.getCenter());
27565          pointSub = viewCenter.sub(targetPoint)._abs();
27566          w = map.pixelToDistance(pointSub.x, 0);
27567          h = map.pixelToDistance(0, pointSub.y);
27568
27569          if (aspectRatio) {
27570            w = Math.max(w, h * aspectRatio);
27571            h = w / aspectRatio;
27572          }
27573        }
27574
27575        if (aspectRatio || ability === 0 || ability === 2) {
27576          shadow.setWidth(w * r);
27577          geometryToEdit.setWidth(w * r);
27578        }
27579
27580        if (aspectRatio || ability === 1 || ability === 2) {
27581          shadow.setHeight(h * r);
27582          geometryToEdit.setHeight(h * r);
27583        }
27584      }, function () {
27585        _this7._update(getUpdates());
27586      });
27587
27588      function getUpdates() {
27589        return [['setCoordinates', shadow.getCoordinates().toArray()], ['setWidth', shadow.getWidth()], ['setHeight', shadow.getHeight()]];
27590      }
27591    };
27592
27593    _proto.createPolygonEditor = function createPolygonEditor() {
27594      var map = this.getMap(),
27595          shadow = this._shadow,
27596          me = this,
27597          projection = map.getProjection();
27598
27599      if (!this._history) {
27600        this._recordHistory('setCoordinates', Coordinate.toNumberArrays(shadow.getCoordinates()));
27601      }
27602
27603      var verticeLimit = shadow instanceof Polygon ? 3 : 2;
27604      var propertyOfVertexRefreshFn = 'maptalks--editor-refresh-fn',
27605          propertyOfVertexIndex = 'maptalks--editor-vertex-index';
27606      var vertexHandles = [],
27607          newVertexHandles = [];
27608
27609      function getVertexCoordinates() {
27610        if (shadow instanceof Polygon) {
27611          var coordinates = shadow.getCoordinates()[0];
27612          return coordinates.slice(0, coordinates.length - 1);
27613        } else {
27614          return shadow.getCoordinates();
27615        }
27616      }
27617
27618      function getVertexPrjCoordinates() {
27619        return shadow._getPrjCoordinates();
27620      }
27621
27622      function onVertexAddOrRemove() {
27623        for (var i = vertexHandles.length - 1; i >= 0; i--) {
27624          vertexHandles[i][propertyOfVertexIndex] = i;
27625        }
27626
27627        for (var _i = newVertexHandles.length - 1; _i >= 0; _i--) {
27628          newVertexHandles[_i][propertyOfVertexIndex] = _i;
27629        }
27630
27631        me._updateCoordFromShadow();
27632      }
27633
27634      function removeVertex(param) {
27635        var handle = param['target'],
27636            index = handle[propertyOfVertexIndex];
27637        var prjCoordinates = getVertexPrjCoordinates();
27638
27639        if (prjCoordinates.length <= verticeLimit) {
27640          return;
27641        }
27642
27643        prjCoordinates.splice(index, 1);
27644
27645        shadow._setPrjCoordinates(prjCoordinates);
27646
27647        shadow._updateCache();
27648
27649        vertexHandles.splice(index, 1)[0].remove();
27650
27651        if (index < newVertexHandles.length) {
27652          newVertexHandles.splice(index, 1)[0].remove();
27653        }
27654
27655        var nextIndex;
27656
27657        if (index === 0) {
27658          nextIndex = newVertexHandles.length - 1;
27659        } else {
27660          nextIndex = index - 1;
27661        }
27662
27663        newVertexHandles.splice(nextIndex, 1)[0].remove();
27664        newVertexHandles.splice(nextIndex, 0, createNewVertexHandle.call(me, nextIndex));
27665        onVertexAddOrRemove();
27666
27667        me._refresh();
27668      }
27669
27670      function moveVertexHandle(handleViewPoint, index) {
27671        var vertice = getVertexPrjCoordinates();
27672
27673        var nVertex = map._viewPointToPrj(handleViewPoint);
27674
27675        var pVertex = vertice[index];
27676        pVertex.x = nVertex.x;
27677        pVertex.y = nVertex.y;
27678
27679        shadow._updateCache();
27680
27681        shadow.onShapeChanged();
27682
27683        me._updateCoordFromShadow(true);
27684
27685        var nextIndex;
27686
27687        if (index === 0) {
27688          nextIndex = newVertexHandles.length - 1;
27689        } else {
27690          nextIndex = index - 1;
27691        }
27692
27693        if (newVertexHandles[index]) {
27694          newVertexHandles[index][propertyOfVertexRefreshFn]();
27695        }
27696
27697        if (newVertexHandles[nextIndex]) {
27698          newVertexHandles[nextIndex][propertyOfVertexRefreshFn]();
27699        }
27700      }
27701
27702      function createVertexHandle(index) {
27703        var vertex = getVertexCoordinates()[index];
27704        var handle = me.createHandle(vertex, {
27705          'symbol': me.options['vertexHandleSymbol'],
27706          'cursor': 'pointer',
27707          'axis': null,
27708          onMove: function onMove(handleViewPoint) {
27709            moveVertexHandle(handleViewPoint, handle[propertyOfVertexIndex]);
27710          },
27711          onRefresh: function onRefresh() {
27712            vertex = getVertexCoordinates()[handle[propertyOfVertexIndex]];
27713            handle.setCoordinates(vertex);
27714          },
27715          onUp: function onUp() {
27716            me._refresh();
27717
27718            me._updateCoordFromShadow();
27719          },
27720          onDown: function onDown(param, e) {
27721            if (e && e.domEvent && e.domEvent.button === 2) {
27722              return;
27723            }
27724          }
27725        });
27726        handle[propertyOfVertexIndex] = index;
27727        handle.on(me.options['removeVertexOn'], removeVertex);
27728        return handle;
27729      }
27730
27731      function createNewVertexHandle(index) {
27732        var vertexCoordinates = getVertexCoordinates();
27733        var nextVertex;
27734
27735        if (index + 1 >= vertexCoordinates.length) {
27736          nextVertex = vertexCoordinates[0];
27737        } else {
27738          nextVertex = vertexCoordinates[index + 1];
27739        }
27740
27741        var vertex = vertexCoordinates[index].add(nextVertex).multi(1 / 2);
27742        var handle = me.createHandle(vertex, {
27743          'symbol': me.options['newVertexHandleSymbol'],
27744          'cursor': 'pointer',
27745          'axis': null,
27746          onDown: function onDown(param, e) {
27747            if (e && e.domEvent && e.domEvent.button === 2) {
27748              return;
27749            }
27750
27751            var prjCoordinates = getVertexPrjCoordinates();
27752            var vertexIndex = handle[propertyOfVertexIndex];
27753            var pVertex = projection.project(handle.getCoordinates());
27754            prjCoordinates.splice(vertexIndex + 1, 0, pVertex);
27755
27756            shadow._setPrjCoordinates(prjCoordinates);
27757
27758            shadow._updateCache();
27759
27760            var symbol = handle.getSymbol();
27761            delete symbol['opacity'];
27762            handle.setSymbol(symbol);
27763            newVertexHandles.splice(vertexIndex, 0, createNewVertexHandle.call(me, vertexIndex), createNewVertexHandle.call(me, vertexIndex + 1));
27764          },
27765          onMove: function onMove(handleViewPoint) {
27766            moveVertexHandle(handleViewPoint, handle[propertyOfVertexIndex] + 1);
27767          },
27768          onUp: function onUp(e) {
27769            if (e && e.domEvent && e.domEvent.button === 2) {
27770              return;
27771            }
27772
27773            var vertexIndex = handle[propertyOfVertexIndex];
27774            removeFromArray(handle, newVertexHandles);
27775            handle.remove();
27776            vertexHandles.splice(vertexIndex + 1, 0, createVertexHandle.call(me, vertexIndex + 1));
27777            onVertexAddOrRemove();
27778
27779            me._updateCoordFromShadow();
27780
27781            me._refresh();
27782          },
27783          onRefresh: function onRefresh() {
27784            vertexCoordinates = getVertexCoordinates();
27785            var vertexIndex = handle[propertyOfVertexIndex];
27786            var nextIndex;
27787
27788            if (vertexIndex === vertexCoordinates.length - 1) {
27789              nextIndex = 0;
27790            } else {
27791              nextIndex = vertexIndex + 1;
27792            }
27793
27794            var refreshVertex = vertexCoordinates[vertexIndex].add(vertexCoordinates[nextIndex]).multi(1 / 2);
27795            handle.setCoordinates(refreshVertex);
27796          }
27797        });
27798        handle[propertyOfVertexIndex] = index;
27799        return handle;
27800      }
27801
27802      var vertexCoordinates = getVertexCoordinates();
27803
27804      for (var i = 0, len = vertexCoordinates.length; i < len; i++) {
27805        vertexHandles.push(createVertexHandle.call(this, i));
27806
27807        if (i < len - 1) {
27808          newVertexHandles.push(createNewVertexHandle.call(this, i));
27809        }
27810      }
27811
27812      if (shadow instanceof Polygon) {
27813        newVertexHandles.push(createNewVertexHandle.call(this, vertexCoordinates.length - 1));
27814      }
27814
27815
27816      this._addRefreshHook(function () {
27817        for (var _i2 = newVertexHandles.length - 1; _i2 >= 0; _i2--) {
27818          newVertexHandles[_i2][propertyOfVertexRefreshFn]();
27819        }
27820
27821        for (var _i3 = vertexHandles.length - 1; _i3 >= 0; _i3--) {
27822          vertexHandles[_i3][propertyOfVertexRefreshFn]();
27823        }
27824      });
27825    };
27826
27827    _proto._refresh = function _refresh() {
27828      if (this._refreshHooks) {
27829        for (var i = this._refreshHooks.length - 1; i >= 0; i--) {
27830          this._refreshHooks[i].call(this);
27831        }
27832      }
27833    };
27834
27835    _proto._hideContext = function _hideContext() {
27836      if (this._geometry) {
27837        this._geometry.closeMenu();
27838
27839        this._geometry.closeInfoWindow();
27840      }
27841    };
27842
27843    _proto._addListener = function _addListener(listener) {
27844      if (!this._eventListeners) {
27845        this._eventListeners = [];
27846      }
27847
27848      this._eventListeners.push(listener);
27849
27850      listener[0].on(listener[1], listener[2], this);
27851    };
27852
27853    _proto._clearAllListeners = function _clearAllListeners() {
27854      if (this._eventListeners && this._eventListeners.length > 0) {
27855        for (var i = this._eventListeners.length - 1; i >= 0; i--) {
27856          var listener = this._eventListeners[i];
27857          listener[0].off(listener[1], listener[2], this);
27858        }
27859
27860        this._eventListeners = [];
27861      }
27862    };
27863
27864    _proto._addRefreshHook = function _addRefreshHook(fn) {
27865      if (!fn) {
27866        return;
27867      }
27868
27869      if (!this._refreshHooks) {
27870        this._refreshHooks = [];
27871      }
27872
27873      this._refreshHooks.push(fn);
27874    };
27875
27876    _proto._update = function _update(method) {
27877      for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
27878        args[_key - 1] = arguments[_key];
27879      }
27880
27881      this._exeHistory([method, args]);
27882
27883      this._recordHistory.apply(this, [method].concat(args));
27884    };
27885
27886    _proto._updateCoordFromShadow = function _updateCoordFromShadow(ignoreRecord) {
27887      if (!this._shadow) {
27888        return;
27889      }
27890
27891      var coords = this._shadow.getCoordinates();
27892
27893      var geo = this._geometry;
27894      var updating = this._updating;
27895      this._updating = true;
27896      geo.setCoordinates(coords);
27897
27898      if (!ignoreRecord) {
27899        this._recordHistory('setCoordinates', Coordinate.toNumberArrays(geo.getCoordinates()));
27900      }
27901
27902      this._updating = updating;
27903    };
27904
27905    _proto._recordHistory = function _recordHistory(method) {
27906      if (!this._history) {
27907        this._history = [];
27908        this._historyPointer = 0;
27909      }
27910
27911      if (this._historyPointer < this._history.length - 1) {
27912        this._history.splice(this._historyPointer + 1);
27913      }
27914
27915      for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
27916        args[_key2 - 1] = arguments[_key2];
27917      }
27918
27919      this._history.push([method, args]);
27920
27921      this._historyPointer = this._history.length - 1;
27922
27923      this._geometry.fire('editrecord');
27924    };
27925
27926    _proto.undo = function undo() {
27927      if (!this._history || this._historyPointer === 0) {
27928        return this;
27929      }
27930
27931      var record = this._history[--this._historyPointer];
27932
27933      this._exeAndReset(record);
27934
27935      return this;
27936    };
27937
27938    _proto.redo = function redo() {
27939      if (!this._history || this._historyPointer === this._history.length - 1) {
27940        return null;
27941      }
27942
27943      var record = this._history[++this._historyPointer];
27944
27945      this._exeAndReset(record);
27946
27947      return this;
27948    };
27949
27950    _proto._exeAndReset = function _exeAndReset(record) {
27951      if (this._updating) {
27952        return;
27953      }
27954
27955      this._exeHistory(record);
27956
27957      var history = this._history,
27958          pointer = this._historyPointer;
27959      this.stop();
27960      this._history = history;
27961      this._historyPointer = pointer;
27962      this.start();
27963    };
27964
27965    _proto._exeHistory = function _exeHistory(record) {
27966      var _this8 = this;
27967
27968      if (!Array.isArray(record)) {
27969        return;
27970      }
27971
27972      var updating = this._updating;
27973      this._updating = true;
27974      var geo = this._geometry;
27975
27976      if (Array.isArray(record[0])) {
vendor: 19,128 bytes, lines 27977-28692
27977        record[0].forEach(function (o) {
27978          var m = o[0],
27979              args = o.slice(1);
27980
27981          _this8._shadow[m].apply(_this8._shadow, args);
27982
27983          geo[m].apply(geo, args);
27984        });
27985      } else {
27986        this._shadow[record[0]].apply(this._shadow, record[1]);
27987
27988        geo[record[0]].apply(geo, record[1]);
27989      }
27990
27991      this._updating = updating;
27992    };
27993
27994    return GeometryEditor;
27995  }(Eventable(Class));
27996
27997  GeometryEditor.mergeOptions(options$z);
27998
27999  var TextEditable = {
28000    startEditText: function startEditText() {
28001      if (!this.getMap()) {
28002        return this;
28003      }
28004
28005      this.hide();
28006      this.endEditText();
28007
28008      this._prepareEditor();
28009
28010      this._fireEvent('edittextstart');
28011
28012      return this;
28013    },
28014    endEditText: function endEditText() {
28015      if (this._textEditor) {
28016        var html = this._textEditor.innerHTML;
28017        html = html.replace(/<p>/ig, '').replace(/<\/p>/ig, '<br/>');
28018        this._textEditor.innerHTML = html;
28019
28020        var content = this._textEditor.innerText.replace(/[\r\n]+$/gi, '');
28021
28022        this.setContent(content);
28023        off(this._textEditor, 'mousedown dblclick', stopPropagation);
28024        this.getMap().off('mousedown', this.endEditText, this);
28025
28026        this._editUIMarker.remove();
28027
28028        delete this._editUIMarker;
28029        this._textEditor.onkeyup = null;
28030        delete this._textEditor;
28031        this.show();
28032
28033        this._fireEvent('edittextend');
28034      }
28035
28036      return this;
28037    },
28038    isEditingText: function isEditingText() {
28039      if (this._textEditor) {
28040        return true;
28041      }
28042
28043      return false;
28044    },
28045    getTextEditor: function getTextEditor() {
28046      return this._editUIMarker;
28047    },
28048    _prepareEditor: function _prepareEditor() {
28049      var map = this.getMap();
28050
28051      var editContainer = this._createEditor();
28052
28053      this._textEditor = editContainer;
28054      map.on('mousedown', this.endEditText, this);
28055
28056      var offset = this._getEditorOffset();
28057
28058      this._editUIMarker = new UIMarker(this.getCoordinates(), {
28059        'animation': null,
28060        'content': editContainer,
28061        'dx': offset.dx,
28062        'dy': offset.dy
28063      }).addTo(map);
28064
28065      this._setCursorToLast(this._textEditor);
28066    },
28067    _getEditorOffset: function _getEditorOffset() {
28068      var symbol = this._getInternalSymbol() || {};
28069      var dx = 0,
28070          dy = 0;
28071      var textAlign = symbol['textHorizontalAlignment'];
28072
28073      if (textAlign === 'middle' || isNil(textAlign)) {
28074        dx = (symbol['textDx'] || 0) - 2;
28075        dy = (symbol['textDy'] || 0) - 2;
28076      } else {
28077        dx = (symbol['markerDx'] || 0) - 2;
28078        dy = (symbol['markerDy'] || 0) - 2;
28079      }
28080
28081      return {
28082        'dx': dx,
28083        'dy': dy
28084      };
28085    },
28086    _createEditor: function _createEditor() {
28087      var content = this.getContent();
28088      var labelSize = this.getSize(),
28089          symbol = this._getInternalSymbol() || {},
28090          width = labelSize.width,
28091          textColor = symbol['textFill'] || '#000000',
28092          textSize = symbol['textSize'] || 12,
28093          height = labelSize.height,
28094          lineColor = symbol['markerLineColor'] || '#000',
28095          fill = symbol['markerFill'] || '#3398CC',
28096          spacing = symbol['textLineSpacing'] || 0;
28097      var editor = createEl('div');
28098      editor.contentEditable = true;
28099      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;";
28100      editor.innerText = content;
28101      on(editor, 'mousedown dblclick', stopPropagation);
28102
28103      editor.onkeyup = function (event) {
28104        var h = editor.style.height || 0;
28105
28106        if (event.keyCode === 13) {
28107          editor.style.height = parseInt(h) + textSize / 2 + 'px';
28108        }
28109      };
28110
28111      return editor;
28112    },
28113    _setCursorToLast: function _setCursorToLast(obj) {
28114      var range;
28115
28116      if (window.getSelection) {
28117        obj.focus();
28118        range = window.getSelection();
28119        range.selectAllChildren(obj);
28120        range.collapseToEnd();
28121      } else if (document.selection) {
28122        range = document.selection.createRange();
28123        range.moveToElementText(obj);
28124        range.collapse(false);
28125        range.select();
28126      }
28127    }
28128  };
28129  TextMarker.include(TextEditable);
28130
28131  Geometry.include({
28132    animate: function animate(styles, options, step) {
28133      var _this = this;
28134
28135      if (this._animPlayer) {
28136        this._animPlayer.finish();
28137      }
28138
28139      if (isFunction(options)) {
28140        step = options;
28141      }
28142
28143      if (!options) {
28144        options = {};
28145      }
28146
28147      var map = this.getMap(),
28148          projection = this._getProjection(),
28149          symbol = this.getSymbol() || {},
28150          stylesToAnimate = this._prepareAnimationStyles(styles);
28151
28152      var preTranslate;
28153      var isFocusing = options['focus'];
28154      delete this._animationStarted;
28155
28156      if (map) {
28157        var renderer = map._getRenderer();
28158
28159        var framer = function framer(fn) {
28160          renderer.callInNextFrame(fn);
28161        };
28162
28163        options['framer'] = framer;
28164      }
28165
28166      var player = Animation.animate(stylesToAnimate, options, function (frame) {
28167        if (map && map.isRemoved()) {
28168          player.finish();
28169          return;
28170        }
28171
28172        if (map && !_this._animationStarted && isFocusing) {
28173          map.onMoveStart();
28174        }
28175
28176        var styles = frame.styles;
28177
28178        for (var p in styles) {
28179          if (p !== 'symbol' && p !== 'translate' && styles.hasOwnProperty(p)) {
28180            var fnName = 'set' + p[0].toUpperCase() + p.slice(1);
28181
28182            _this[fnName](styles[p]);
28183          }
28184        }
28185
28186        var translate = styles['translate'];
28187
28188        if (translate) {
28189          var toTranslate = translate;
28190
28191          if (preTranslate) {
28192            toTranslate = translate.sub(preTranslate);
28193          }
28194
28195          preTranslate = translate;
28196
28197          _this.translate(toTranslate);
28198        }
28199
28200        var dSymbol = styles['symbol'];
28201
28202        if (dSymbol) {
28203          _this.setSymbol(extendSymbol(symbol, dSymbol));
28204        }
28205
28206        if (map && isFocusing) {
28207          var pcenter = projection.project(_this.getCenter());
28208
28209          map._setPrjCenter(pcenter);
28210
28211          var e = map._parseEventFromCoord(projection.unproject(pcenter));
28212
28213          if (player.playState !== 'running') {
28214            map.onMoveEnd(e);
28215          } else {
28216            map.onMoving(e);
28217          }
28218        }
28219
28220        _this._fireAnimateEvent(player.playState);
28221
28222        if (step) {
28223          step(frame);
28224        }
28225      });
28226      this._animPlayer = player;
28227      return this._animPlayer.play();
28228    },
28229    _prepareAnimationStyles: function _prepareAnimationStyles(styles) {
28230      var symbol = this._getInternalSymbol();
28231
28232      var stylesToAnimate = {};
28233
28234      for (var p in styles) {
28235        if (styles.hasOwnProperty(p)) {
28236          var v = styles[p];
28237
28238          if (p !== 'translate' && p !== 'symbol') {
28239            var fnName = 'get' + p[0].toUpperCase() + p.substring(1);
28240            var current = this[fnName]();
28241            stylesToAnimate[p] = [current, v];
28242          } else if (p === 'symbol') {
28243            var symbolToAnimate = void 0;
28244
28245            if (Array.isArray(styles['symbol'])) {
28246              if (!Array.isArray(symbol)) {
28247                throw new Error('geometry\'symbol isn\'t a composite symbol, while the symbol in styles is.');
28248              }
28249
28250              symbolToAnimate = [];
28251              var symbolInStyles = styles['symbol'];
28252
28253              for (var i = 0; i < symbolInStyles.length; i++) {
28254                if (!symbolInStyles[i]) {
28255                  symbolToAnimate.push(null);
28256                  continue;
28257                }
28258
28259                var a = {};
28260
28261                for (var sp in symbolInStyles[i]) {
28262                  if (symbolInStyles[i].hasOwnProperty(sp)) {
28263                    a[sp] = [symbol[i][sp], symbolInStyles[i][sp]];
28264                  }
28265                }
28266
28267                symbolToAnimate.push(a);
28268              }
28269            } else {
28270              if (Array.isArray(symbol)) {
28271                throw new Error('geometry\'symbol is a composite symbol, while the symbol in styles isn\'t.');
28272              }
28273
28274              symbolToAnimate = {};
28275
28276              for (var _sp in v) {
28277                if (v.hasOwnProperty(_sp)) {
28278                  symbolToAnimate[_sp] = [symbol[_sp], v[_sp]];
28279                }
28280              }
28281            }
28282
28283            stylesToAnimate['symbol'] = symbolToAnimate;
28284          } else if (p === 'translate') {
28285            stylesToAnimate['translate'] = new Coordinate(v);
28286          }
28287        }
28288      }
28289
28290      return stylesToAnimate;
28291    },
28292    _fireAnimateEvent: function _fireAnimateEvent(playState) {
28293      if (playState === 'finished') {
28294        delete this._animationStarted;
28295
28296        this._fireEvent('animateend');
28297      } else if (playState === 'running') {
28298        if (this._animationStarted) {
28299          this._fireEvent('animating');
28300        } else {
28301          this._fireEvent('animatestart');
28302
28303          this._animationStarted = true;
28304        }
28305      }
28306    }
28307  });
28308
28309  var DRAG_STAGE_LAYER_ID = INTERNAL_LAYER_PREFIX + '_drag_stage';
28310  var EVENTS$2 = Browser$1.touch ? 'touchstart mousedown' : 'mousedown';
28311
28312  var GeometryDragHandler = function (_Handler) {
28313    _inheritsLoose(GeometryDragHandler, _Handler);
28314
28315    function GeometryDragHandler(target) {
28316      return _Handler.call(this, target) || this;
28317    }
28318
28319    var _proto = GeometryDragHandler.prototype;
28320
28321    _proto.addHooks = function addHooks() {
28322      this.target.on(EVENTS$2, this._startDrag, this);
28323    };
28324
28325    _proto.removeHooks = function removeHooks() {
28326      this._endDrag();
28327
28328      this.target.off(EVENTS$2, this._startDrag, this);
28329      delete this.container;
28330    };
28331
28332    _proto._prepareDragHandler = function _prepareDragHandler() {
28333      this._dragHandler = new DragHandler(this.container);
28334
28335      this._dragHandler.on('dragging', this._dragging, this).on('mouseup', this._endDrag, this).enable();
28336    };
28337
28338    _proto._prepareShadow = function _prepareShadow() {
28339      var target = this.target;
28340
28341      this._prepareDragStageLayer();
28342
28343      if (this._shadow) {
28344        this._shadow.remove();
28345      }
28346
28347      var shadow = this._shadow = target.copy();
28348
28349      this._shadow.setSymbol(target._getInternalSymbol());
28350
28351      if (target.options['dragShadow']) {
28352        var symbol = lowerSymbolOpacity(shadow._getInternalSymbol(), 0.5);
28353        shadow.setSymbol(symbol);
28354      }
28355
28356      shadow.setId(null);
28357
28358      this._prepareShadowConnectors();
28359    };
28360
28361    _proto._prepareShadowConnectors = function _prepareShadowConnectors() {
28362      var target = this.target;
28363      var shadow = this._shadow;
28364
28365      var resources = this._dragStageLayer._getRenderer().resources;
28366
28367      var shadowConnectors = [];
28368
28369      if (ConnectorLine._hasConnectors(target)) {
28370        var connectors = ConnectorLine._getConnectors(target);
28371
28372        for (var i = 0, l = connectors.length; i < l; i++) {
28373          var targetConn = connectors[i];
28374
28375          var connOptions = targetConn.config(),
28376              connSymbol = targetConn._getInternalSymbol();
28377
28378          connOptions['symbol'] = lowerSymbolOpacity(connSymbol, 0.5);
28379          var conn = void 0;
28380
28381          if (targetConn.getConnectSource() === target) {
28382            conn = new targetConn.constructor(shadow, targetConn.getConnectTarget(), connOptions);
28383          } else {
28384            conn = new targetConn.constructor(targetConn.getConnectSource(), shadow, connOptions);
28385          }
28386
28387          shadowConnectors.push(conn);
28388
28389          if (targetConn.getLayer() && targetConn.getLayer()._getRenderer()) {
28390            resources.merge(targetConn.getLayer()._getRenderer().resources);
28391          }
28392        }
28393      }
28394
28395      this._shadowConnectors = shadowConnectors;
28396      shadowConnectors.push(shadow);
28397
28398      this._dragStageLayer.bringToFront().addGeometry(shadowConnectors);
28399    };
28400
28401    _proto._onTargetUpdated = function _onTargetUpdated() {
28402      if (this._shadow) {
28403        this._shadow.setSymbol(this.target._getSymbol());
28404      }
28405    };
28406
28407    _proto._prepareDragStageLayer = function _prepareDragStageLayer() {
28408      var map = this.target.getMap(),
28409          layer = this.target.getLayer();
28410      this._dragStageLayer = map.getLayer(DRAG_STAGE_LAYER_ID);
28411
28412      if (!this._dragStageLayer) {
28413        this._dragStageLayer = new VectorLayer(DRAG_STAGE_LAYER_ID, {
28414          enableAltitude: layer.options['enableAltitude'],
28415          altitudeProperty: layer.options['altitudeProperty']
28416        });
28417        map.addLayer(this._dragStageLayer);
28418      }
28419
28420      var resources = new ResourceCache();
28421      resources.merge(layer._getRenderer().resources);
28422      this._dragStageLayer._getRenderer().resources = resources;
28423    };
28424
28425    _proto._startDrag = function _startDrag(param) {
28426      var map = this.target.getMap();
28427
28428      if (!map) {
28429        return;
28430      }
28431
28432      var parent = this.target._getParent();
28433
28434      if (parent) {
28435        return;
28436      }
28437
28438      if (this.isDragging()) {
28439        return;
28440      }
28441
28442      var domEvent = param['domEvent'];
28443
28444      if (domEvent.touches && domEvent.touches.length > 1 || domEvent.button === 2) {
28445        return;
28446      }
28447
28448      this.container = map._panels.mapWrapper || map._containerDOM;
28449      this.target.on('click', this._endDrag, this);
28450      this._lastCoord = this._correctCoord(param['coordinate']);
28451      this._lastPoint = param['containerPoint'];
28452
28453      this._prepareDragHandler();
28454
28455      this._dragHandler.onMouseDown(param['domEvent']);
28456
28457      on(this.container, 'mouseleave', this._endDrag, this);
28458      this._startParam = param;
28459      this._moved = false;
28460      return;
28461    };
28462
28463    _proto._dragging = function _dragging(param) {
28464      var target = this.target;
28465
28466      var map = target.getMap(),
28467          e = map._parseEvent(param['domEvent']);
28468
28469      var domEvent = e['domEvent'];
28470
28471      if (domEvent.touches && domEvent.touches.length > 1) {
28472        return;
28473      }
28474
28475      if (!this._moved) {
28476        this._moved = true;
28477        target.on('symbolchange', this._onTargetUpdated, this);
28478        this._isDragging = true;
28479
28480        this._prepareShadow();
28481
28482        if (!target.options['dragShadow']) {
28483          target.hide();
28484        }
28485
28486        this._shadow._fireEvent('dragstart', e);
28487
28488        this.target._fireEvent('dragstart', this._startParam || e);
28489
28490        delete this._startParam;
28491        return;
28492      }
28493
28494      if (!this._shadow) {
28495        return;
28496      }
28497
28498      var axis = this._shadow.options['dragOnAxis'],
28499          coord = this._correctCoord(e['coordinate']),
28500          point = e['containerPoint'];
28501
28502      this._lastPoint = this._lastPoint || point;
28503      this._lastCoord = this._lastCoord || coord;
28504      var pointOffset = point.sub(this._lastPoint);
28505      var coordOffset = coord.sub(this._lastCoord);
28506
28507      if (axis === 'x') {
28508        pointOffset.y = coordOffset.y = 0;
28509      } else if (axis === 'y') {
28510        pointOffset.x = coordOffset.x = 0;
28511      }
28512
28513      this._lastPoint = point;
28514      this._lastCoord = coord;
28515
28516      this._shadow.translate(coordOffset);
28517
28518      if (!target.options['dragShadow']) {
28519        target.translate(coordOffset);
28520      }
28521
28522      e['coordOffset'] = coordOffset;
28523      e['pointOffset'] = pointOffset;
28524
28525      this._shadow._fireEvent('dragging', e);
28526
28527      target._fireEvent('dragging', e);
28528    };
28529
28530    _proto._endDrag = function _endDrag(param) {
28531      if (this._dragHandler) {
28532        this._dragHandler.disable();
28533
28534        delete this._dragHandler;
28535      }
28536
28537      if (this.container) {
28538        off(this.container, 'mouseleave', this._endDrag, this);
28539      }
28540
28541      if (!this.target) {
28542        return;
28543      }
28544
28545      var target = this.target;
28546      target.off('click', this._endDrag, this);
28547      target.off('symbolchange', this._onTargetUpdated, this);
28548      delete this._lastCoord;
28549      delete this._lastPoint;
28550      this._isDragging = false;
28551      var map = target.getMap();
28552
28553      if (this.enabled() && map) {
28554        var e = map._parseEvent(param ? param['domEvent'] : null);
28555
28556        this._updateTargetAndRemoveShadow(e);
28557
28558        if (this._moved) {
28559          target._fireEvent('dragend', e);
28560        }
28561      }
28562    };
28563
28564    _proto.isDragging = function isDragging() {
28565      if (!this._isDragging) {
28566        return false;
28567      }
28568
28569      return true;
28570    };
28571
28572    _proto._updateTargetAndRemoveShadow = function _updateTargetAndRemoveShadow(eventParam) {
28573      var target = this.target,
28574          map = target.getMap();
28575
28576      if (!target.options['dragShadow']) {
28577        target.show();
28578      }
28579
28580      var shadow = this._shadow;
28581
28582      if (shadow) {
28583        if (target.options['dragShadow']) {
28584          target.setCoordinates(shadow.getCoordinates());
28585        }
28586
28587        shadow._fireEvent('dragend', eventParam);
28588
28589        shadow.remove();
28590        delete this._shadow;
28591      }
28592
28593      if (this._shadowConnectors) {
28594        map.getLayer(DRAG_STAGE_LAYER_ID).removeGeometry(this._shadowConnectors);
28595        delete this._shadowConnectors;
28596      }
28597
28598      if (this._dragStageLayer) {
28599        this._dragStageLayer.remove();
28600      }
28601    };
28602
28603    _proto._correctCoord = function _correctCoord(coord) {
28604      var map = this.target.getMap();
28605
28606      if (!map.getPitch()) {
28607        return coord;
28608      }
28609
28610      var painter = this.target._getPainter();
28611
28612      if (!painter.getMinAltitude()) {
28613        return coord;
28614      }
28615
28616      var alt = (painter.getMinAltitude() + painter.getMaxAltitude()) / 2;
28617      return map.locateByPoint(coord, 0, -alt);
28618    };
28619
28620    return GeometryDragHandler;
28621  }(Handler$1);
28622
28623  Geometry.mergeOptions({
28624    'draggable': false,
28625    'dragShadow': true,
28626    'dragOnAxis': null
28627  });
28628  Geometry.addInitHook('addHandler', 'draggable', GeometryDragHandler);
28629  Geometry.include({
28630    isDragging: function isDragging() {
28631      if (this._getParent()) {
28632        return this._getParent().isDragging();
28633      }
28634
28635      if (this['draggable']) {
28636        return this['draggable'].isDragging();
28637      }
28638
28639      return false;
28640    }
28641  });
28642
28643  Geometry.include({
28644    startEdit: function startEdit(opts) {
28645      if (!this.getMap() || !this.options['editable']) {
28646        return this;
28647      }
28648
28649      this.endEdit();
28650      this._editor = new GeometryEditor(this, opts);
28651
28652      this._editor.start();
28653
28654      this.fire('editstart');
28655      return this;
28656    },
28657    endEdit: function endEdit() {
28658      if (this._editor) {
28659        this._editor.stop();
28660
28661        delete this._editor;
28662        this.fire('editend');
28663      }
28664
28665      return this;
28666    },
28667    redoEdit: function redoEdit() {
28668      if (!this.isEditing()) {
28669        return this;
28670      }
28671
28672      this._editor.redo();
28673
28674      this.fire('redoedit');
28675      return this;
28676    },
28677    undoEdit: function undoEdit() {
28678      if (!this.isEditing()) {
28679        return this;
28680      }
28681
28682      this._editor.undo();
28683
28684      this.fire('undoedit');
28685      return this;
28686    },
28687    isEditing: function isEditing() {
28688      if (this._editor) {
28689        return this._editor.isEditing();
28690      }
28691
28692      return false;
28693    }
28694  });
28695
28696  Geometry.include({
28697    _onEvent: function _onEvent(event, type) {
28698      if (!this.getMap()) {
28699        return;
28700      }
28701
28702      var eventType = type || this._getEventTypeToFire(event);
28703
28704      if (eventType === 'contextmenu' && this.listens('contextmenu')) {
28705        stopPropagation(event);
28706        preventDefault(event);
28707      }
28708
28709      var params = this._getEventParams(event);
28710
28711      this._fireEvent(eventType, params);
28712    },
28713    _getEventTypeToFire: function _getEventTypeToFire(domEvent) {
28714      return domEvent.type;
28715    },
28716    _getEventParams: function _getEventParams(e) {
28717      var map = this.getMap();
28718      var eventParam = {
28719        'domEvent': e
28720      };
28721      var actual = e.touches && e.touches.length > 0 ? e.touches[0] : e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches[0] : e;
28722
28723      if (actual) {
28724        var containerPoint = getEventContainerPoint(actual, map._containerDOM);
28725        eventParam['coordinate'] = map.containerPointToCoordinate(containerPoint);
28726        eventParam['containerPoint'] = containerPoint;
28727        eventParam['viewPoint'] = map.containerPointToViewPoint(containerPoint);
28728        eventParam['pont2d'] = map._containerPointToPoint(containerPoint);
28729      }
28730
28731      return eventParam;
28732    }
28733  });
28734
28735  Geometry.include({
28736    setInfoWindow: function setInfoWindow(options) {
28737      this.removeInfoWindow();
28738
28739      if (options instanceof InfoWindow) {
28740        this._infoWindow = options;
28741        this._infoWinOptions = extend({}, this._infoWindow.options);
28742
28743        this._infoWindow.addTo(this);
28744
28745        return this;
28746      }
28747
28748      this._infoWinOptions = extend({}, options);
28749
28750      if (this._infoWindow) {
28751        this._infoWindow.setOptions(options);
28752      } else if (this.getMap()) {
28753        this._bindInfoWindow(this._infoWinOptions);
28754      }
28755
28756      return this;
28757    },
28758    getInfoWindow: function getInfoWindow() {
28759      if (!this._infoWindow) {
28760        return null;
28761      }
28762
28763      return this._infoWindow;
28764    },
28765    openInfoWindow: function openInfoWindow(coordinate) {
28766      if (!this.getMap()) {
28767        return this;
28768      }
28769
28770      if (!coordinate) {
28771        coordinate = this.getCenter();
28772      }
28773
28774      if (!this._infoWindow) {
28775        if (this._infoWinOptions && this.getMap()) {
28776          this._bindInfoWindow(this._infoWinOptions);
28777
28778          this._infoWindow.show(coordinate);
28779        }
28780      } else {
28781        this._infoWindow.show(coordinate);
28782      }
28783
28784      return this;
28785    },
28786    closeInfoWindow: function closeInfoWindow() {
28787      if (this._infoWindow) {
28788        this._infoWindow.hide();
28789      }
28790
28791      return this;
28792    },
28793    removeInfoWindow: function removeInfoWindow() {
28794      this._unbindInfoWindow();
28795
28796      delete this._infoWinOptions;
28797      delete this._infoWindow;
28798      return this;
28799    },
28800    _bindInfoWindow: function _bindInfoWindow(options) {
28801      this._infoWindow = new InfoWindow(options);
28802
28803      this._infoWindow.addTo(this);
28804
28805      return this;
28806    },
28807    _unbindInfoWindow: function _unbindInfoWindow() {
28808      if (this._infoWindow) {
28809        this.closeInfoWindow();
28810
28811        this._infoWindow.remove();
28812
28813        delete this._infoWindow;
28814      }
28815
28816      return this;
28817    }
28818  });
28819
28820  var LRUCache = function () {
28821    function LRUCache(max, onRemove) {
28822      this.max = max;
28823      this.onRemove = onRemove;
28824      this.reset();
28825    }
28826
28827    var _proto = LRUCache.prototype;
28828
28829    _proto.reset = function reset() {
28830      for (var key in this.data) {
28831        this.onRemove(this.data[key]);
28832      }
28833
28834      this.data = {};
28835      this.order = [];
28836      return this;
28837    };
28838
28839    _proto.clear = function clear() {
28840      this.reset();
28841      delete this.onRemove;
28842    };
28843
28844    _proto.add = function add(key, data) {
28845      if (this.has(key)) {
28846        this.order.splice(this.order.indexOf(key), 1);
28847        this.data[key] = data;
28848        this.order.push(key);
28849      } else {
28850        this.data[key] = data;
28851        this.order.push(key);
28852
28853        if (this.order.length > this.max) {
28854          var removedData = this.getAndRemove(this.order[0]);
28855          if (removedData) this.onRemove(removedData);
28856        }
28857      }
28858
28859      return this;
28860    };
28861
28862    _proto.has = function has(key) {
28863      return key in this.data;
28864    };
28865
28866    _proto.keys = function keys() {
28867      return this.order;
28868    };
28869
28870    _proto.getAndRemove = function getAndRemove(key) {
28871      if (!this.has(key)) {
28872        return null;
28873      }
28874
28875      var data = this.data[key];
28876      delete this.data[key];
28877      this.order.splice(this.order.indexOf(key), 1);
28878      return data;
28879    };
28880
28881    _proto.get = function get(key) {
28882      if (!this.has(key)) {
28883        return null;
28884      }
28885
28886      var data = this.data[key];
28887      return data;
28888    };
28889
28890    _proto.remove = function remove(key) {
28891      if (!this.has(key)) {
28892        return this;
28893      }
28894
28895      var data = this.data[key];
28896      delete this.data[key];
28897      this.onRemove(data);
28898      this.order.splice(this.order.indexOf(key), 1);
28899      return this;
28900    };
28901
28902    _proto.setMaxSize = function setMaxSize(max) {
28903      this.max = max;
28904
28905      while (this.order.length > this.max) {
28906        var removedData = this.getAndRemove(this.order[0]);
28907        if (removedData) this.onRemove(removedData);
28908      }
28909
28910      return this;
28911    };
28912
28913    return LRUCache;
28914  }();
28915
28916  var TEMP_POINT$2 = new Point(0, 0);
28917  var TEMP_POINT1$3 = new Point(0, 0);
28918  var TEMP_POINT2$2 = new Point(0, 0);
28919
28920  var TileLayerCanvasRenderer = function (_CanvasRenderer) {
28921    _inheritsLoose(TileLayerCanvasRenderer, _CanvasRenderer);
28922
28923    function TileLayerCanvasRenderer(layer) {
28924      var _this;
28925
28926      _this = _CanvasRenderer.call(this, layer) || this;
28927      _this.tilesInView = {};
28928      _this.tilesLoading = {};
28929      _this._parentTiles = [];
28930      _this._childTiles = [];
28931      _this.tileCache = new LRUCache(layer.options['maxCacheSize'], _this.deleteTile.bind(_assertThisInitialized(_assertThisInitialized(_this))));
28932      return _this;
28933    }
28934
28935    var _proto = TileLayerCanvasRenderer.prototype;
28936
28937    _proto.getCurrentTileZoom = function getCurrentTileZoom() {
28938      return this._tileZoom;
28939    };
28940
28941    _proto.draw = function draw() {
28942      var map = this.getMap();
28943
28944      if (!this.isDrawable()) {
28945        return;
28946      }
28947
28948      var mask2DExtent = this.prepareCanvas();
28949
28950      if (mask2DExtent) {
28951        if (!mask2DExtent.intersects(this.canvasExtent2D)) {
28952          this.completeRender();
28953          return;
28954        }
28955      }
28956
28957      var layer = this.layer;
28958      var tileGrids = layer.getTiles().tileGrids;
28959
28960      if (!tileGrids || !tileGrids.length) {
28961        this.completeRender();
28962        return;
28963      }
28964
28965      var loadingCount = 0;
28966      var loading = false;
28967      var checkedTiles = {};
28968      var tiles = [],
28969          parentTiles = [],
28970          parentKeys = {},
28971          childTiles = [],
28972          childKeys = {},
28973          placeholders = [],
28974          placeholderKeys = {};
28975      var tileQueue = {};
28976
28977      var preLoadingCount = this._markTiles(),
28978          loadingLimit = this._getLoadLimit();
28979
28980      var l = tileGrids.length;
28981      this._tileZoom = tileGrids[0]['zoom'];
28982      this._tileOffset = tileGrids[0]['offset'];
28983
28984      for (var i = 0; i < l; i++) {
28985        var tileGrid = tileGrids[i];
28986        var allTiles = tileGrid['tiles'];
28987
28988        var placeholder = this._generatePlaceHolder(tileGrid.zoom);
28989
28990        for (var _i = 0, _l = allTiles.length; _i < _l; _i++) {
28991          var tile = allTiles[_i],
28992              tileId = tile['id'];
28993
28994          var cached = this._getCachedTile(tileId);
28995
28996          var tileLoading = false;
28997
28998          if (this._isLoadingTile(tileId)) {
28999            tileLoading = loading = true;
29000            this.tilesLoading[tileId].current = true;
29001          } else if (cached) {
29002            if (this.getTileOpacity(cached.image) < 1) {
29003              tileLoading = loading = true;
29004            }
29005
29006            tiles.push(cached);
29007          } else {
29008            tileLoading = loading = true;
29009            var hitLimit = loadingLimit && loadingCount + preLoadingCount[0] > loadingLimit;
29010
29011            if (!hitLimit && (!map.isInteracting() || map.isMoving() || map.isRotating())) {
29012              loadingCount++;
29013              tileQueue[tileId + '@' + tile['point'].toArray().join()] = tile;
29014            }
29015          }
29016
29017          if (!tileLoading) continue;
29018
29019          if (checkedTiles[tileId]) {
29020            continue;
29021          }
29022
29023          checkedTiles[tileId] = 1;
29024
29025          if (placeholder && !placeholderKeys[tileId]) {
29026            tile.cache = false;
29027            placeholders.push({
29028              image: placeholder,
29029              info: tile
29030            });
29031            placeholderKeys[tileId] = 1;
29032          }
29033
29034          var parentTile = this._findParentTile(tile);
29035
29036          if (parentTile) {
29037            var parentId = parentTile.info.id;
29038
29039            if (parentKeys[parentId] === undefined) {
29040              parentKeys[parentId] = parentTiles.length;
29041              parentTiles.push(parentTile);
29042            }
29043          } else if (!parentTiles.length) {
29044            var children = this._findChildTiles(tile);
29045
29046            if (children.length) {
29047              children.forEach(function (c) {
29048                if (!childKeys[c.info.id]) {
29049                  childTiles.push(c);
29050                  childKeys[c.info.id] = 1;
29051                }
29052              });
29053            }
29054          }
29055        }
29056      }
29057
29058      if (parentTiles.length) {
29059        childTiles.length = 0;
29060        this._childTiles.length = 0;
29061      }
29062
29063      this._drawTiles(tiles, parentTiles, childTiles, placeholders);
29064
29065      if (!loadingCount) {
29066        if (!loading) {
29067          if (!map.isAnimating() && (this._parentTiles.length || this._childTiles.length)) {
29068            this._parentTiles = [];
29069            this._childTiles = [];
29070            this.setToRedraw();
29071          }
29072
29073          this.completeRender();
29074        }
29075      } else {
29076        this.loadTileQueue(tileQueue);
29077      }
29078
29079      this._retireTiles();
29080    };
29081
29082    _proto.isTileCachedOrLoading = function isTileCachedOrLoading(tileId) {
29083      return this.tilesLoading[tileId] || this.tilesInView[tileId] || this.tileCache.get(tileId);
29084    };
29085
29086    _proto._drawTiles = function _drawTiles(tiles, parentTiles, childTiles, placeholders) {
29087      var _this2 = this;
29088
29089      if (parentTiles.length) {
29090        parentTiles.sort(function (t1, t2) {
29091          return Math.abs(t2.info.z - _this2._tileZoom) - Math.abs(t1.info.z - _this2._tileZoom);
29092        });
29093        this._parentTiles = parentTiles;
29094      }
29095
29096      if (childTiles.length) {
29097        this._childTiles = childTiles;
29098      }
29099
29100      var context = {
29101        tiles: tiles,
29102        parentTiles: this._parentTiles,
29103        childTiles: this._childTiles
29104      };
29105      this.onDrawTileStart(context);
29106
29107      this._parentTiles.forEach(function (t) {
29108        return _this2._drawTileAndCache(t);
29109      });
29110
29111      this._childTiles.forEach(function (t) {
29112        return _this2._drawTileOffset(t.info, t.image);
29113      });
29114
29115      placeholders.forEach(function (t) {
29116        return _this2._drawTileOffset(t.info, t.image);
29117      });
29118      var layer = this.layer,
29119          map = this.getMap();
29120
29121      if (!layer.options['cascadeTiles'] || map.getPitch() <= layer.options['minPitchToCascade']) {
29122        tiles.forEach(function (t) {
29123          return _this2._drawTileAndCache(t);
29124        });
29125      } else {
29126        this.writeZoomStencil();
29127        var started = false;
29128
29129        for (var i = 0, l = tiles.length; i < l; i++) {
29130          if (tiles[i].info.z !== this._tileZoom) {
29131            if (!started) {
29132              this.startZoomStencilTest();
29133              started = true;
29134            } else {
29135              this.resumeZoomStencilTest();
29136            }
29137          } else if (started) {
29138            this.pauseZoomStencilTest();
29139          }
29140
29141          this._drawTileAndCache(tiles[i]);
29142        }
29143
29144        this.endZoomStencilTest();
29145      }
29146
29147      this.onDrawTileEnd(context);
29148    };
29149
29150    _proto.writeZoomStencil = function writeZoomStencil() {};
29151
29152    _proto.startZoomStencilTest = function startZoomStencilTest() {};
29153
29154    _proto.endZoomStencilTest = function endZoomStencilTest() {};
29155
29156    _proto.pauseZoomStencilTest = function pauseZoomStencilTest() {};
29157
29158    _proto.resumeZoomStencilTest = function resumeZoomStencilTest() {};
29159
29160    _proto.onDrawTileStart = function onDrawTileStart() {};
29161
29162    _proto.onDrawTileEnd = function onDrawTileEnd() {};
29163
29164    _proto._drawTileOffset = function _drawTileOffset(info, image) {
29165      var offset = this._tileOffset;
29166
29167      if (!offset[0] && !offset[1]) {
29168        this.drawTile(info, image);
29169        return;
29170      }
29171
29172      var map = this.getMap();
29173
29174      var scale = map._getResolution(this._tileZoom) / map._getResolution(info.z);
29175
29176      offset[0] *= scale;
29177      offset[1] *= scale;
29178
29179      info.point._sub(offset);
29180
29181      info.extent2d._sub(offset);
29182
29183      this.drawTile(info, image);
29184
29185      info.point._add(offset);
29186
29187      info.extent2d._add(offset);
29188
29189      offset[0] /= scale;
29190      offset[1] /= scale;
29191    };
29192
29193    _proto._drawTileAndCache = function _drawTileAndCache(tile) {
29194      tile.current = true;
29195      this.tilesInView[tile.info.id] = tile;
29196
29197      this._drawTileOffset(tile.info, tile.image);
29198
29199      this.tileCache.add(tile.info.id, tile);
29200    };
29201
29202    _proto.drawOnInteracting = function drawOnInteracting() {
29203      this.draw();
29204    };
29205
29206    _proto.needToRedraw = function needToRedraw() {
29207      var map = this.getMap();
29208
29209      if (map.getPitch()) {
29210        return _CanvasRenderer.prototype.needToRedraw.call(this);
29211      }
29212
29213      if (map.isRotating() || map.isZooming()) {
29214        return true;
29215      }
29216
29217      if (map.isMoving()) {
29218        return !!this.layer.options['forceRenderOnMoving'];
29219      }
29220
29221      return _CanvasRenderer.prototype.needToRedraw.call(this);
29222    };
29223
29224    _proto.hitDetect = function hitDetect() {
29225      return false;
29226    };
29227
29228    _proto._getLoadLimit = function _getLoadLimit() {
29229      if (this.getMap().isInteracting()) {
29230        return this.layer.options['loadingLimitOnInteracting'];
29231      }
29232
29233      return 0;
29234    };
29235
29236    _proto.isDrawable = function isDrawable() {
29237      if (this.getMap().getPitch()) {
29238        if (console) {
29239          console.warn('TileLayer with canvas renderer can\'t be pitched, use gl renderer (\'renderer\' : \'gl\') instead.');
29240        }
29241
29242        this.clear();
29243        return false;
29244      }
29245
29246      return true;
29247    };
29248
29249    _proto.clear = function clear() {
29250      this._retireTiles(true);
29251
29252      this.tileCache.reset();
29253      this.tilesInView = {};
29254      this.tilesLoading = {};
29255      this._parentTiles = [];
29256      this._childTiles = [];
29257
29258      _CanvasRenderer.prototype.clear.call(this);
29259    };
29260
29261    _proto._isLoadingTile = function _isLoadingTile(tileId) {
29262      return !!this.tilesLoading[tileId];
29263    };
29264
29265    _proto.clipCanvas = function clipCanvas(context) {
29266      var mask = this.layer.getMask();
29267
29268      if (!mask) {
29269        return this._clipByPitch(context);
29270      }
29271
29272      return _CanvasRenderer.prototype.clipCanvas.call(this, context);
29273    };
29274
29275    _proto._clipByPitch = function _clipByPitch(ctx) {
29276      var map = this.getMap();
29277
29278      if (map.getPitch() <= map.options['maxVisualPitch']) {
29279        return false;
29280      }
29281
29282      if (!this.layer.options['clipByPitch']) {
29283        return false;
29284      }
29285
29286      var clipExtent = map.getContainerExtent();
29287      var r = map.getDevicePixelRatio();
29288      ctx.save();
29289      ctx.strokeStyle = 'rgba(0, 0, 0, 0)';
29290      ctx.beginPath();
29291      ctx.rect(0, Math.ceil(clipExtent.ymin) * r, Math.ceil(clipExtent.getWidth()) * r, Math.ceil(clipExtent.getHeight()) * r);
29292      ctx.stroke();
29293      ctx.clip();
29294      return true;
29295    };
29296
29297    _proto.loadTileQueue = function loadTileQueue(tileQueue) {
29298      for (var p in tileQueue) {
29299        if (tileQueue.hasOwnProperty(p)) {
29300          var tile = tileQueue[p];
29301          var tileImage = this.loadTile(tile);
29302
29303          if (tileImage.loadTime === undefined) {
29304            this.tilesLoading[tile['id']] = {
29305              image: tileImage,
29306              current: true,
29307              info: tile
29308            };
29309          }
29310        }
29311      }
29312    };
29313
29314    _proto.loadTile = function loadTile(tile) {
29315      var tileSize = this.layer.getTileSize();
29316      var tileImage = new Image();
29317      tileImage.width = tileSize['width'];
29318      tileImage.height = tileSize['height'];
29319      tileImage.onload = this.onTileLoad.bind(this, tileImage, tile);
29320      tileImage.onerror = this.onTileError.bind(this, tileImage, tile);
29321      this.loadTileImage(tileImage, tile['url']);
29322      return tileImage;
29323    };
29324
29325    _proto.loadTileImage = function loadTileImage(tileImage, url) {
29326      var crossOrigin = this.layer.options['crossOrigin'];
29327
29328      if (!isNil(crossOrigin)) {
29329        tileImage.crossOrigin = crossOrigin;
29330      }
29331
29332      return loadImage(tileImage, [url]);
29333    };
29334
29335    _proto.abortTileLoading = function abortTileLoading(tileImage) {
29336      if (!tileImage) return;
29337      tileImage.onload = falseFn;
29338      tileImage.onerror = falseFn;
29339      tileImage.src = emptyImageUrl;
29340    };
29341
29342    _proto.onTileLoad = function onTileLoad(tileImage, tileInfo) {
29343      if (!this.layer) {
29344        return;
29345      }
29346
29347      var id = tileInfo['id'];
29348
29349      if (!this.tilesInView) {
29350        return;
29351      }
29352
29353      tileImage.loadTime = now();
29354      delete this.tilesLoading[id];
29355
29356      this._addTileToCache(tileInfo, tileImage);
29357
29358      this.setToRedraw();
29359      this.layer.fire('tileload', {
29360        tile: tileInfo,
29361        tileImage: tileImage
29362      });
29363    };
29364
29365    _proto.onTileError = function onTileError(tileImage, tileInfo) {
29366      if (!this.layer) {
29367        return;
29368      }
29369
29370      tileImage.onerrorTick = tileImage.onerrorTick || 0;
29371      var tileRetryCount = this.layer.options['tileRetryCount'];
29372
29373      if (tileRetryCount > tileImage.onerrorTick) {
29374        tileImage.onerrorTick++;
29375        tileImage.src = tileInfo.url;
29376        return;
29377      }
29378
29379      if (tileImage instanceof Image) {
29380        this.abortTileLoading(tileImage, tileInfo);
29381      }
29382
29383      tileImage.loadTime = 0;
29384      delete this.tilesLoading[tileInfo['id']];
29385
29386      this._addTileToCache(tileInfo, tileImage);
29387
29388      this.setToRedraw();
29389      this.layer.fire('tileerror', {
29390        tile: tileInfo
29391      });
29392    };
29393
29394    _proto.drawTile = function drawTile(tileInfo, tileImage) {
29395      if (!tileImage || !this.getMap()) {
29396        return;
29397      }
29398
29399      var point = tileInfo.point,
29400          tileZoom = tileInfo.z,
29401          tileId = tileInfo.id;
29402
29403      var map = this.getMap(),
29404          tileSize = tileInfo.size,
29405          zoom = map.getZoom(),
29406          ctx = this.context,
29407          cp = map._pointToContainerPoint(point, tileZoom, 0, TEMP_POINT$2),
29408          bearing = map.getBearing(),
29409          transformed = bearing || zoom !== tileZoom;
29410
29411      var opacity = this.getTileOpacity(tileImage);
29412      var alpha = ctx.globalAlpha;
29413
29414      if (opacity < 1) {
29415        ctx.globalAlpha = opacity;
29416        this.setToRedraw();
29417      }
29418
29419      if (!transformed) {
29420        cp._round();
29421      }
29422
29423      var x = cp.x,
29424          y = cp.y;
29425      var w = tileSize[0],
29426          h = tileSize[1];
29427
29428      if (transformed) {
29429        w += 0.1;
29430        h += 0.1;
29431        ctx.save();
29432        ctx.translate(x, y);
29433
29434        if (bearing) {
29435          ctx.rotate(-bearing * Math.PI / 180);
29436        }
29437
29438        if (zoom !== tileZoom) {
29439          var scale = map._getResolution(tileZoom) / map._getResolution();
29440
29441          ctx.scale(scale, scale);
29442        }
29443
29444        x = y = 0;
29445      }
29446
29447      Canvas.image(ctx, tileImage, x, y, w, h);
29448
29449      if (this.layer.options['debug']) {
29450        var color = this.layer.options['debugOutline'],
29451            xyz = tileId.split('-');
29452        var length = xyz.length;
29453        ctx.save();
29454        ctx.strokeStyle = color;
29455        ctx.fillStyle = color;
29456        ctx.strokeWidth = 10;
29457        ctx.font = '15px monospace';
29458
29459        var _point = new Point(x, y);
29460
29461        Canvas.rectangle(ctx, _point, {
29462          width: w,
29463          height: h
29464        }, 1, 0);
29465        Canvas.fillText(ctx, 'x:' + xyz[length - 3] + ', y:' + xyz[length - 2] + ', z:' + xyz[length - 1], _point._add(10, 20), color);
29466        Canvas.drawCross(ctx, x + w / 2, y + h / 2, 2, color);
29467        ctx.restore();
29468      }
29469
29470      if (transformed) {
29471        ctx.restore();
29472      }
29473
29474      if (ctx.globalAlpha !== alpha) {
29475        ctx.globalAlpha = alpha;
29476      }
29477
29478      this.setCanvasUpdated();
29479    };
29480
29481    _proto._findChildTiles = function _findChildTiles(info) {
29482      var layer = this._getLayerOfTile(info.layer);
29483
29484      if (!layer.options['background']) {
29485        return [];
29486      }
29487
29488      var map = this.getMap();
29489      var children = [];
29490
29491      var min = info.extent2d.getMin(),
29492          max = info.extent2d.getMax(),
29493          pmin = layer._project(map._pointToPrj(min, info.z, TEMP_POINT1$3), TEMP_POINT1$3),
29494          pmax = layer._project(map._pointToPrj(max, info.z, TEMP_POINT2$2), TEMP_POINT2$2);
29495
29496      var zoomDiff = 2;
29497
29498      for (var i = 1; i < zoomDiff; i++) {
29499        this._findChildTilesAt(children, pmin, pmax, layer, info.z + i);
29500      }
29501
29502      return children;
29503    };
29504
29505    _proto._findChildTilesAt = function _findChildTilesAt(children, pmin, pmax, layer, childZoom) {
29506      var zoomOffset = layer.options['zoomOffset'];
29507      var layerId = layer.getId(),
29508          res = layer.getSpatialReference().getResolution(childZoom + zoomOffset);
29509
29510      if (!res) {
29511        return;
29512      }
29513
29514      var dmin = layer._getTileConfig().getTileIndex(pmin, res),
29515          dmax = layer._getTileConfig().getTileIndex(pmax, res);
29516
29517      var sx = Math.min(dmin.idx, dmax.idx),
29518          ex = Math.max(dmin.idx, dmax.idx);
29519      var sy = Math.min(dmin.idy, dmax.idy),
29520          ey = Math.max(dmin.idy, dmax.idy);
29521      var id, tile;
29522
29523      for (var i = sx; i < ex; i++) {
29524        for (var ii = sy; ii < ey; ii++) {
29525          id = layer._getTileId({
29526            idx: i,
29527            idy: ii
29528          }, childZoom + zoomOffset, layerId);
29529
29530          if (this.tileCache.has(id)) {
29531            tile = this.tileCache.getAndRemove(id);
29532            children.push(tile);
29533            this.tileCache.add(id, tile);
29534          }
29535        }
29536      }
29537    };
29538
29539    _proto._findParentTile = function _findParentTile(info) {
29540      var map = this.getMap(),
29541          layer = this._getLayerOfTile(info.layer);
29542
29543      if (!layer.options['background']) {
29544        return null;
29545      }
29546
29547      var sr = layer.getSpatialReference();
29548      var d = sr.getZoomDirection(),
29549          zoomOffset = layer.options['zoomOffset'],
29550          zoomDiff = layer.options['backgroundZoomDiff'];
29551
29552      var center = info.extent2d.getCenter(),
29553          prj = layer._project(map._pointToPrj(center, info.z));
29554
29555      for (var diff = 1; diff <= zoomDiff; diff++) {
29556        var z = info.z - d * diff;
29557        var res = sr.getResolution(z + zoomOffset);
29558        if (!res) continue;
29559
29560        var tileIndex = layer._getTileConfig().getTileIndex(prj, res);
29561
29562        var id = layer._getTileId(tileIndex, z + zoomOffset, info.layer);
29563
29564        if (this.tileCache.has(id)) {
29565          var tile = this.tileCache.getAndRemove(id);
29566          this.tileCache.add(id, tile);
29567          return tile;
29568        }
29569      }
29570
29571      return null;
29572    };
29573
29574    _proto._getLayerOfTile = function _getLayerOfTile(layerId) {
29575      return this.layer.getChildLayer ? this.layer.getChildLayer(layerId) : this.layer;
29576    };
29577
29578    _proto._getCachedTile = function _getCachedTile(tileId) {
29579      var tilesInView = this.tilesInView;
29580      var cached = this.tileCache.getAndRemove(tileId);
29581
29582      if (cached) {
29583        tilesInView[tileId] = cached;
29584        var tilesLoading = this.tilesLoading;
29585
29586        if (tilesLoading && tilesLoading[tileId]) {
29587          tilesLoading[tileId].current = false;
29588          var _tilesLoading$tileId = tilesLoading[tileId],
29589              image = _tilesLoading$tileId.image,
29590              info = _tilesLoading$tileId.info;
29591          this.abortTileLoading(image, info);
29592          delete tilesLoading[tileId];
29593        }
29594      } else {
29595        cached = tilesInView[tileId];
29596      }
29597
29598      return cached;
29599    };
29600
29601    _proto._addTileToCache = function _addTileToCache(tileInfo, tileImage) {
29602      this.tilesInView[tileInfo.id] = {
29603        image: tileImage,
29604        current: true,
29605        info: tileInfo
29606      };
29607    };
29608
29609    _proto.getTileOpacity = function getTileOpacity(tileImage) {
29610      if (!this.layer.options['fadeAnimation'] || !tileImage.loadTime) {
29611        return 1;
29612      }
29613
29614      return Math.min(1, (now() - tileImage.loadTime) / (1000 / 60 * 10));
29615    };
29616
29617    _proto.onRemove = function onRemove() {
29618      this.clear();
29619      delete this.tileCache;
29620      delete this._tilePlaceHolder;
29621
29622      _CanvasRenderer.prototype.onRemove.call(this);
29623    };
29624
29625    _proto._markTiles = function _markTiles() {
29626      var a = 0,
29627          b = 0;
29628
29629      if (this.tilesLoading) {
29630        for (var p in this.tilesLoading) {
29631          this.tilesLoading[p].current = false;
vendor: 38,784 bytes, lines 29632-31122
29632          a++;
29633        }
29634      }
29635
29636      if (this.tilesInView) {
29637        for (var _p in this.tilesInView) {
29638          this.tilesInView[_p].current = false;
29639          b++;
29640        }
29641      }
29642
29643      return [a, b];
29644    };
29645
29646    _proto._retireTiles = function _retireTiles(force) {
29647      for (var i in this.tilesLoading) {
29648        var tile = this.tilesLoading[i];
29649
29650        if (force || !tile.current) {
29651          if (tile.image) {
29652            this.abortTileLoading(tile.image, tile.info);
29653          }
29654
29655          this.deleteTile(tile);
29656          delete this.tilesLoading[i];
29657        }
29658      }
29659
29660      for (var _i2 in this.tilesInView) {
29661        var _tile = this.tilesInView[_i2];
29662
29663        if (!_tile.current) {
29664          delete this.tilesInView[_i2];
29665
29666          if (!this.tileCache.has(_i2)) {
29667            this.deleteTile(_tile);
29668          }
29669        }
29670      }
29671    };
29672
29673    _proto.deleteTile = function deleteTile(tile) {
29674      if (!tile || !tile.image) {
29675        return;
29676      }
29677
29678      tile.image.onload = null;
29679      tile.image.onerror = null;
29680    };
29681
29682    _proto._generatePlaceHolder = function _generatePlaceHolder(z) {
29683      var map = this.getMap();
29684      var placeholder = this.layer.options['placeholder'];
29685
29686      if (!placeholder || map.getPitch()) {
29687        return null;
29688      }
29689
29690      var tileSize = this.layer.getTileSize(),
29691          scale = map._getResolution(z) / map._getResolution(),
29692          canvas = this._tilePlaceHolder = this._tilePlaceHolder || Canvas.createCanvas(1, 1);
29693
29694      canvas.width = tileSize.width * scale;
29695      canvas.height = tileSize.height * scale;
29696
29697      if (isFunction(placeholder)) {
29698        placeholder(canvas);
29699      } else {
29700        defaultPlaceholder(canvas);
29701      }
29702
29703      return canvas;
29704    };
29705
29706    return TileLayerCanvasRenderer;
29707  }(CanvasRenderer);
29708
29709  TileLayer.registerRenderer('canvas', TileLayerCanvasRenderer);
29710
29711  function falseFn() {
29712    return false;
29713  }
29714
29715  function defaultPlaceholder(canvas) {
29716    var ctx = canvas.getContext('2d'),
29717        cw = canvas.width,
29718        ch = canvas.height,
29719        w = cw / 16,
29720        h = ch / 16;
29721    ctx.beginPath();
29722
29723    for (var i = 0; i < 16; i++) {
29724      ctx.moveTo(0, i * h);
29725      ctx.lineTo(cw, i * h);
29726      ctx.moveTo(i * w, 0);
29727      ctx.lineTo(i * w, ch);
29728    }
29729
29730    ctx.strokeStyle = 'rgba(180, 180, 180, 0.1)';
29731    ctx.lineWidth = 1;
29732    ctx.stroke();
29733    ctx.beginPath();
29734    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]];
29735
29736    for (var _i3 = 1; _i3 < path.length; _i3 += 2) {
29737      ctx.moveTo(path[_i3 - 1][0], path[_i3 - 1][1]);
29738      ctx.lineTo(path[_i3][0], path[_i3][1]);
29739    }
29740
29741    ctx.lineWidth = 1 * 4;
29742    ctx.stroke();
29743  }
29744
29745  var TileLayerGLRenderer = function (_ImageGLRenderable) {
29746    _inheritsLoose(TileLayerGLRenderer, _ImageGLRenderable);
29747
29748    function TileLayerGLRenderer() {
29749      return _ImageGLRenderable.apply(this, arguments) || this;
29750    }
29751
29752    var _proto = TileLayerGLRenderer.prototype;
29753
29754    _proto.isDrawable = function isDrawable() {
29755      return true;
29756    };
29757
29758    _proto.needToRedraw = function needToRedraw() {
29759      var map = this.getMap();
29760
29761      if (this._gl() && !map.getPitch() && map.isZooming() && !map.isMoving() && !map.isRotating()) {
29762        return true;
29763      }
29764
29765      return _ImageGLRenderable.prototype.needToRedraw.call(this);
29766    };
29767
29768    _proto.drawTile = function drawTile(tileInfo, tileImage) {
29769      var map = this.getMap();
29770
29771      if (!tileInfo || !map || !tileImage) {
29772        return;
29773      }
29774
29775      var scale = tileInfo._glScale = tileInfo._glScale || map.getGLScale(tileInfo.z),
29776          w = tileInfo.size[0] * scale,
29777          h = tileInfo.size[1] * scale;
29778
29779      if (tileInfo.cache !== false) {
29780        this._bindGLBuffer(tileImage, w, h);
29781      }
29782
29783      if (!this._gl()) {
29784        _ImageGLRenderable.prototype.drawTile.call(this, tileInfo, tileImage);
29785
29786        return;
29787      }
29788
29789      var point = tileInfo.point;
29790      var x = point.x * scale,
29791          y = point.y * scale;
29792      var opacity = this.getTileOpacity(tileImage);
29793      this.drawGLImage(tileImage, x, y, w, h, opacity);
29794
29795      if (opacity < 1) {
29796        this.setToRedraw();
29797      } else {
29798        this.setCanvasUpdated();
29799      }
29800    };
29801
29802    _proto.writeZoomStencil = function writeZoomStencil() {
29803      var gl = this.gl;
29804      gl.stencilFunc(gl.ALWAYS, 1, 0xFF);
29805      gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);
29806    };
29807
29808    _proto.startZoomStencilTest = function startZoomStencilTest() {
29809      var gl = this.gl;
29810      gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
29811      gl.stencilFunc(gl.EQUAL, 0, 0xFF);
29812    };
29813
29814    _proto.endZoomStencilTest = function endZoomStencilTest() {
29815      this.pauseZoomStencilTest();
29816    };
29817
29818    _proto.pauseZoomStencilTest = function pauseZoomStencilTest() {
29819      var gl = this.gl;
29820      gl.stencilFunc(gl.ALWAYS, 1, 0xFF);
29821    };
29822
29823    _proto.resumeZoomStencilTest = function resumeZoomStencilTest() {
29824      var gl = this.gl;
29825      gl.stencilFunc(gl.EQUAL, 0, 0xFF);
29826    };
29827
29828    _proto._bindGLBuffer = function _bindGLBuffer(image, w, h) {
29829      if (!image.glBuffer) {
29830        image.glBuffer = this.bufferTileData(0, 0, w, h);
29831      }
29832    };
29833
29834    _proto.loadTileImage = function loadTileImage(tileImage, url) {
29835      var crossOrigin = this.layer.options['crossOrigin'];
29836      tileImage.crossOrigin = crossOrigin !== null ? crossOrigin : '';
29837      tileImage.src = url;
29838      return;
29839    };
29840
29841    _proto.onCanvasCreate = function onCanvasCreate() {
29842      if (!this.canvas.gl || !this.canvas.gl.wrap) {
29843        this.createCanvas2();
29844      }
29845    };
29846
29847    _proto.createContext = function createContext() {
29848      _ImageGLRenderable.prototype.createContext.call(this);
29849
29850      this.createGLContext();
29851    };
29852
29853    _proto.resizeCanvas = function resizeCanvas(canvasSize) {
29854      if (!this.canvas) {
29855        return;
29856      }
29857
29858      _ImageGLRenderable.prototype.resizeCanvas.call(this, canvasSize);
29859
29860      this.resizeGLCanvas();
29861    };
29862
29863    _proto.clearCanvas = function clearCanvas() {
29864      if (!this.canvas) {
29865        return;
29866      }
29867
29868      _ImageGLRenderable.prototype.clearCanvas.call(this);
29869
29870      this.clearGLCanvas();
29871    };
29872
29873    _proto.getCanvasImage = function getCanvasImage() {
29874      if (!this._gl() || !this.canvas2) {
29875        return _ImageGLRenderable.prototype.getCanvasImage.call(this);
29876      }
29877
29878      var img = _ImageGLRenderable.prototype.getCanvasImage.call(this);
29879
29880      if (img) {
29881        img.image = this.canvas2;
29882      }
29883
29884      return img;
29885    };
29886
29887    _proto._gl = function _gl() {
29888      if (this.canvas.gl && this.canvas.gl.wrap) {
29889        return true;
29890      }
29891
29892      var map = this.getMap();
29893      return map && (map.getPitch() || map.getBearing()) || this.layer && !!this.layer.options['fragmentShader'];
29894    };
29895
29896    _proto.deleteTile = function deleteTile(tile) {
29897      _ImageGLRenderable.prototype.deleteTile.call(this, tile);
29898
29899      if (tile && tile.image) {
29900        this.disposeImage(tile.image);
29901      }
29902    };
29903
29904    _proto.onRemove = function onRemove() {
29905      _ImageGLRenderable.prototype.onRemove.call(this);
29906
29907      this.removeGLCanvas();
29908    };
29909
29910    return TileLayerGLRenderer;
29911  }(ImageGLRenderable(TileLayerCanvasRenderer));
29912
29913  TileLayer.registerRenderer('gl', TileLayerGLRenderer);
29914
29915  function _loadTile(tile) {
29916    var tileSize = this.layer.getTileSize(),
29917        canvasClass = this.canvas.constructor,
29918        map = this.getMap();
29919    var r = map.getDevicePixelRatio();
29920    var tileCanvas = Canvas.createCanvas(tileSize['width'] * r, tileSize['height'] * r, canvasClass);
29921    tileCanvas['layer'] = this.layer;
29922    var me = this;
29923    var extent = new Extent(map.pointToCoordinate(tile['point']), map.pointToCoordinate(tile['point'].add(tileSize.toPoint())), map.getProjection());
29924    this.layer.drawTile(tileCanvas, {
29925      'url': tile['url'],
29926      'point': tile['point'],
29927      'center': map.pointToCoordinate(tile['point'].add(tileSize['width'] / 2, tileSize['height'] / 2)),
29928      'extent': extent,
29929      'z': tile['z'],
29930      'x': tile['x'],
29931      'y': tile['y']
29932    }, function (error) {
29933      if (error) {
29934        me.onTileError(tileCanvas, tile);
29935        return;
29936      }
29937
29938      me.onTileLoad(tileCanvas, tile);
29939    });
29940    return tileCanvas;
29941  }
29942
29943  var CanvasRenderer$1 = function (_TileLayerCanvasRende) {
29944    _inheritsLoose(CanvasRenderer, _TileLayerCanvasRende);
29945
29946    function CanvasRenderer() {
29947      return _TileLayerCanvasRende.apply(this, arguments) || this;
29948    }
29949
29950    var _proto = CanvasRenderer.prototype;
29951
29952    _proto.loadTile = function loadTile() {
29953      return _loadTile.apply(this, arguments);
29954    };
29955
29956    return CanvasRenderer;
29957  }(TileLayerCanvasRenderer);
29958
29959  var GLRenderer = function (_TileLayerGLRenderer) {
29960    _inheritsLoose(GLRenderer, _TileLayerGLRenderer);
29961
29962    function GLRenderer() {
29963      return _TileLayerGLRenderer.apply(this, arguments) || this;
29964    }
29965
29966    var _proto2 = GLRenderer.prototype;
29967
29968    _proto2.loadTile = function loadTile() {
29969      return _loadTile.apply(this, arguments);
29970    };
29971
29972    return GLRenderer;
29973  }(TileLayerGLRenderer);
29974
29975  CanvasTileLayer.registerRenderer('canvas', CanvasRenderer$1);
29976  CanvasTileLayer.registerRenderer('gl', GLRenderer);
29977
29978  var OverlayLayerRenderer = function (_CanvasRenderer) {
29979    _inheritsLoose(OverlayLayerRenderer, _CanvasRenderer);
29980
29981    function OverlayLayerRenderer() {
29982      return _CanvasRenderer.apply(this, arguments) || this;
29983    }
29984
29985    var _proto = OverlayLayerRenderer.prototype;
29986
29987    _proto.checkResources = function checkResources() {
29988      var geometries = this._geosToCheck;
29989
29990      if (!this._resourceChecked && !geometries) {
29991        geometries = this.layer._geoList;
29992      }
29993
29994      if (!isArrayHasData(geometries)) {
29995        return [];
29996      }
29997
29998      var resources = [];
29999      var cache = {};
30000
30001      for (var i = geometries.length - 1; i >= 0; i--) {
30002        var geo = geometries[i];
30003
30004        var res = geo._getExternalResources();
30005
30006        if (!res.length) {
30007          continue;
30008        }
30009
30010        if (!this.resources) {
30011          resources.push.apply(resources, res);
30012        } else {
30013          for (var _i = 0; _i < res.length; _i++) {
30014            var url = res[_i][0];
30015
30016            if (!this.resources.isResourceLoaded(res[_i]) && !cache[url]) {
30017              resources.push(res[_i]);
30018              cache[url] = 1;
30019            }
30020          }
30021        }
30022      }
30023
30024      this._resourceChecked = true;
30025      delete this._geosToCheck;
30026      return resources;
30027    };
30028
30029    _proto.render = function render() {
30030      this.layer._sortGeometries();
30031
30032      return _CanvasRenderer.prototype.render.apply(this, arguments);
30033    };
30034
30035    _proto._addGeoToCheckRes = function _addGeoToCheckRes(res) {
30036      if (!res) {
30037        return;
30038      }
30039
30040      if (!Array.isArray(res)) {
30041        res = [res];
30042      }
30043
30044      if (!this._geosToCheck) {
30045        this._geosToCheck = [];
30046      }
30047
30048      pushIn(this._geosToCheck, res);
30049    };
30050
30051    _proto.onGeometryAdd = function onGeometryAdd(geometries) {
30052      this._addGeoToCheckRes(geometries);
30053
30054      redraw(this);
30055    };
30056
30057    _proto.onGeometryRemove = function onGeometryRemove() {
30058      redraw(this);
30059    };
30060
30061    _proto.onGeometrySymbolChange = function onGeometrySymbolChange(e) {
30062      this._addGeoToCheckRes(e.target);
30063
30064      redraw(this);
30065    };
30066
30067    _proto.onGeometryShapeChange = function onGeometryShapeChange() {
30068      redraw(this);
30069    };
30070
30071    _proto.onGeometryPositionChange = function onGeometryPositionChange() {
30072      redraw(this);
30073    };
30074
30075    _proto.onGeometryZIndexChange = function onGeometryZIndexChange() {
30076      redraw(this);
30077    };
30078
30079    _proto.onGeometryShow = function onGeometryShow() {
30080      redraw(this);
30081    };
30082
30083    _proto.onGeometryHide = function onGeometryHide() {
30084      redraw(this);
30085    };
30086
30087    _proto.onGeometryPropertiesChange = function onGeometryPropertiesChange() {
30088      redraw(this);
30089    };
30090
30091    return OverlayLayerRenderer;
30092  }(CanvasRenderer);
30093
30094  function redraw(renderer) {
30095    if (renderer.layer.options['drawImmediate']) {
30096      renderer.render();
30097    }
30098
30099    renderer.setToRedraw();
30100  }
30101
30102  var TEMP_EXTENT$4 = new PointExtent();
30103
30104  var VectorLayerRenderer = function (_OverlayLayerCanvasRe) {
30105    _inheritsLoose(VectorLayerRenderer, _OverlayLayerCanvasRe);
30106
30107    function VectorLayerRenderer() {
30108      return _OverlayLayerCanvasRe.apply(this, arguments) || this;
30109    }
30110
30111    var _proto = VectorLayerRenderer.prototype;
30112
30113    _proto.checkResources = function checkResources() {
30114      var _this = this;
30115
30116      var resources = _OverlayLayerCanvasRe.prototype.checkResources.apply(this, arguments);
30117
30118      var style = this.layer.getStyle();
30119
30120      if (style) {
30121        if (!Array.isArray(style)) {
30122          style = [style];
30123        }
30124
30125        style.forEach(function (s) {
30126          var res = getExternalResources(s['symbol'], true);
30127
30128          for (var i = 0, l = res.length; i < l; i++) {
30129            if (!_this.resources.isResourceLoaded(res[i])) {
30130              resources.push(res[i]);
30131            }
30132          }
30133        });
30134      }
30135
30136      return resources;
30137    };
30138
30139    _proto.needToRedraw = function needToRedraw() {
30140      var map = this.getMap();
30141
30142      if (map.isInteracting() && this.layer.options['enableAltitude']) {
30143        return true;
30144      }
30145
30146      if (map.isZooming() && !map.isRotating() && !map.getPitch() && !this._hasPoint && this.layer.constructor === VectorLayer) {
30147        return false;
30148      }
30149
30150      return _OverlayLayerCanvasRe.prototype.needToRedraw.call(this);
30151    };
30152
30153    _proto.draw = function draw() {
30154      if (!this.getMap()) {
30155        return;
30156      }
30157
30158      if (!this.layer.isVisible() || this.layer.isEmpty()) {
30159        this.clearCanvas();
30160        this.completeRender();
30161        return;
30162      }
30163
30164      this.prepareCanvas();
30165      this.drawGeos();
30166      this.completeRender();
30167    };
30168
30169    _proto.isBlank = function isBlank() {
30170      if (!this.context) {
30171        return false;
30172      }
30173
30174      return !this.context.canvas._drawn;
30175    };
30176
30177    _proto.drawOnInteracting = function drawOnInteracting() {
30178      if (!this._geosToDraw) {
30179        return;
30180      }
30181
30182      this._updateDisplayExtent();
30183
30184      var map = this.getMap();
30185      var count = this.layer.getCount();
30186
30187      if (map.isZooming() && map.options['seamlessZoom'] && this._geosToDraw.length < count) {
30188        var res = this.getMap().getResolution();
30189
30190        if (this._drawnRes !== undefined && res > this._drawnRes * 1.5) {
30191          this.prepareToDraw();
30192          this.forEachGeo(this.checkGeo, this);
30193          this._drawnRes = res;
30194        }
30195      }
30196
30197      for (var i = 0, l = this._geosToDraw.length; i < l; i++) {
30198        var geo = this._geosToDraw[i];
30199
30200        if (!geo.isVisible()) {
30201          continue;
30202        }
30203
30204        geo._paint(this._displayExtent);
30205      }
30206    };
30207
30208    _proto.show = function show() {
30209      this.layer.forEach(function (geo) {
30210        geo._repaint();
30211      });
30212
30213      _OverlayLayerCanvasRe.prototype.show.apply(this, arguments);
30214    };
30215
30216    _proto.forEachGeo = function forEachGeo(fn, context) {
30217      this.layer.forEach(fn, context);
30218    };
30219
30220    _proto.drawGeos = function drawGeos() {
30221      this._drawnRes = this.getMap().getResolution();
30222
30223      this._updateDisplayExtent();
30224
30225      this.prepareToDraw();
30226      this.forEachGeo(this.checkGeo, this);
30227
30228      for (var i = 0, len = this._geosToDraw.length; i < len; i++) {
30229        this._geosToDraw[i]._paint();
30230      }
30231    };
30232
30233    _proto.prepareToDraw = function prepareToDraw() {
30234      this._hasPoint = false;
30235      this._geosToDraw = [];
30236    };
30237
30238    _proto.checkGeo = function checkGeo(geo) {
30239      if (!geo || !geo.isVisible() || !geo.getMap() || !geo.getLayer() || !geo.getLayer().isCanvasRender()) {
30240        return;
30241      }
30242
30243      var painter = geo._getPainter();
30244
30245      var extent2D = painter.get2DExtent(this.resources, TEMP_EXTENT$4);
30246
30247      if (!extent2D || !extent2D.intersects(this._displayExtent)) {
30248        return;
30249      }
30250
30251      if (painter.hasPoint()) {
30252        this._hasPoint = true;
30253      }
30254
30255      this._geosToDraw.push(geo);
30256    };
30257
30258    _proto.onZoomEnd = function onZoomEnd() {
30259      delete this.canvasExtent2D;
30260
30261      _OverlayLayerCanvasRe.prototype.onZoomEnd.apply(this, arguments);
30262    };
30263
30264    _proto.onRemove = function onRemove() {
30265      this.forEachGeo(function (g) {
30266        g.onHide();
30267      });
30268      delete this._geosToDraw;
30269    };
30270
30271    _proto.onGeometryPropertiesChange = function onGeometryPropertiesChange(param) {
30272      if (param) {
30273        this.layer._styleGeometry(param['target']);
30274      }
30275
30276      _OverlayLayerCanvasRe.prototype.onGeometryPropertiesChange.call(this, param);
30277    };
30278
30279    _proto._updateDisplayExtent = function _updateDisplayExtent() {
30280      var extent2D = this.canvasExtent2D;
30281
30282      if (this._maskExtent) {
30283        if (!this._maskExtent.intersects(extent2D)) {
30284          this.completeRender();
30285          return;
30286        }
30287
30288        extent2D = extent2D.intersection(this._maskExtent);
30289      }
30290
30291      this._displayExtent = extent2D;
30292    };
30293
30294    _proto.identify = function identify(coordinate, options) {
30295      if (options === void 0) {
30296        options = {};
30297      }
30298
30299      var geometries = this._geosToDraw;
30300
30301      if (!geometries) {
30302        return [];
30303      }
30304
30305      return this.layer._hitGeos(geometries, coordinate, options);
30306    };
30307
30308    return VectorLayerRenderer;
30309  }(OverlayLayerRenderer);
30310
30311  VectorLayer.registerRenderer('canvas', VectorLayerRenderer);
30312
30313  var MapRenderer = function (_Class) {
30314    _inheritsLoose(MapRenderer, _Class);
30315
30316    function MapRenderer(map) {
30317      var _this;
30318
30319      _this = _Class.call(this) || this;
30320      _this.map = map;
30321      _this._handlerQueue = {};
30322      return _this;
30323    }
30324
30325    var _proto = MapRenderer.prototype;
30326
30327    _proto.callInNextFrame = function callInNextFrame(fn) {
30328      this._handlerQueue.push(fn);
30329    };
30330
30331    _proto.executeFrameCallbacks = function executeFrameCallbacks() {
30332      var running = this._handlerQueue;
30333      this._handlerQueue = [];
30334
30335      for (var i = 0, l = running.length; i < l; i++) {
30336        running[i]();
30337      }
30338    };
30339
30340    _proto.offsetPlatform = function offsetPlatform(offset, force) {
30341      if (!this.map._panels.front) {
30342        return this;
30343      }
30344
30345      if (!force && offset.x === 0 && offset.y === 0) {
30346        return this;
30347      }
30348
30349      var panels = this.map._panels;
30350      var hasFront = this._frontCount = panels.back.layerDOM.childElementCount;
30351      var hasBack = this._backCount = panels.front.layerDOM.childElementCount;
30352      var hasUI = this._uiCount = panels.front.uiDOM.childElementCount;
30353
30354      if (hasFront || hasBack || hasUI) {
30355        var pos = this.map.offsetPlatform();
30356
30357        if (offset) {
30358          pos = pos.add(offset)._round();
30359        } else {
30360          pos = pos.round();
30361        }
30362
30363        if (hasBack) {
30364          offsetDom(panels.back, pos);
30365        }
30366
30367        if (hasFront || hasUI) {
30368          offsetDom(panels.front, pos);
30369        }
30370      }
30371
30372      return this;
30373    };
30374
30375    _proto.domChanged = function domChanged() {
30376      var panels = this.map._panels;
30377
30378      if (!panels.front) {
30379        return false;
30380      }
30381
30382      var frontCount = panels.back.layerDOM.childElementCount;
30383
30384      if (this._frontCount === undefined || this._frontCount !== frontCount) {
30385        return true;
30386      }
30387
30388      var backCount = panels.front.layerDOM.childElementCount;
30389
30390      if (this._backCount === undefined || this._backCount !== backCount) {
30391        return true;
30392      }
30393
30394      var uiCount = panels.front.uiDOM.childElementCount;
30395
30396      if (this._uiCount === undefined || this._uiCount !== uiCount) {
30397        return true;
30398      }
30399
30400      return false;
30401    };
30402
30403    _proto.resetContainer = function resetContainer() {
30404      if (!this.map) {
30405        return;
30406      }
30407
30408      this.map._resetMapViewPoint();
30409
30410      if (this.map._panels.front) {
30411        var pos = new Point(0, 0);
30412        offsetDom(this.map._panels.back, pos);
30413        offsetDom(this.map._panels.front, pos);
30414      }
30415    };
30416
30417    _proto.onZoomEnd = function onZoomEnd() {
30418      this.resetContainer();
30419    };
30420
30421    _proto.onLoad = function onLoad() {
30422      this._frameLoop();
30423    };
30424
30425    return MapRenderer;
30426  }(Class);
30427
30428  var MapCanvasRenderer = function (_MapRenderer) {
30429    _inheritsLoose(MapCanvasRenderer, _MapRenderer);
30430
30431    function MapCanvasRenderer(map) {
30432      var _this;
30433
30434      _this = _MapRenderer.call(this, map) || this;
30435      _this._containerIsCanvas = !!map._containerDOM.getContext;
30436
30437      _this._registerEvents();
30438
30439      _this._loopTime = 0;
30440      return _this;
30441    }
30442
30443    var _proto = MapCanvasRenderer.prototype;
30444
30445    _proto.load = function load() {
30446      this.initContainer();
30447    };
30448
30449    _proto.renderFrame = function renderFrame(framestamp) {
30450      if (!this.map) {
30451        return false;
30452      }
30453
30454      var map = this.map;
30455
30456      map._fireEvent('framestart');
30457
30458      this.updateMapDOM();
30459
30460      var layers = this._getAllLayerToRender();
30461
30462      this.drawLayers(layers, framestamp);
30463      this.drawLayerCanvas(layers);
30464
30465      map._fireEvent('frameend');
30466
30467      this._recordView();
30468
30469      this._mapview = this._getMapView();
30470      delete this._spatialRefChanged;
30471
30472      this._fireLayerLoadEvents();
30473
30474      this.executeFrameCallbacks();
30475      this._canvasUpdated = false;
30476      return true;
30477    };
30478
30479    _proto.updateMapDOM = function updateMapDOM() {
30480      var map = this.map;
30481
30482      if (map.isZooming()) {
30483        return;
30484      }
30485
30486      var offset = map._getViewPointFrameOffset();
30487
30488      if (offset) {
30489        map.offsetPlatform(offset);
30490      } else if (this.domChanged()) {
30491        this.offsetPlatform(null, true);
30492      }
30493    };
30494
30495    _proto.drawLayers = function drawLayers(layers, framestamp) {
30496      var map = this.map,
30497          isInteracting = map.isInteracting(),
30498          canvasIds = [],
30499          updatedIds = [],
30500          fps = map.options['fpsOnInteracting'] || 0,
30501          timeLimit = fps === 0 ? 0 : 1000 / fps,
30502          layerLimit = this.map.options['layerCanvasLimitOnInteracting'],
30503          l = layers.length;
30504      var baseLayer = map.getBaseLayer();
30505      var t = 0;
30506
30507      for (var i = 0; i < l; i++) {
30508        var layer = layers[i];
30509
30510        if (!layer.isVisible()) {
30511          continue;
30512        }
30513
30514        var isCanvas = layer.isCanvasRender();
30515
30516        if (isCanvas) {
30517          canvasIds.push(layer.getId());
30518        }
30519
30520        var renderer = layer._getRenderer();
30521
30522        if (!renderer) {
30523          continue;
30524        }
30525
30526        var needsRedraw = this._checkLayerRedraw(layer);
30527
30528        if (isCanvas && renderer.isCanvasUpdated()) {
30529          if (!needsRedraw) {
30530            updatedIds.push(layer.getId());
30531          }
30532
30533          this.setLayerCanvasUpdated();
30534        }
30535
30536        var transformMatrix = renderer.__zoomTransformMatrix;
30537        delete renderer.__zoomTransformMatrix;
30538
30539        if (!needsRedraw) {
30540          if (isCanvas && isInteracting) {
30541            if (map.isZooming() && !map.getPitch()) {
30542              renderer.prepareRender();
30543              renderer.__zoomTransformMatrix = this._zoomMatrix;
30544            } else if (map.getPitch() || map.isRotating()) {
30545              renderer.clearCanvas();
30546            }
30547          }
30548
30549          continue;
30550        }
30551
30552        if (isInteracting && isCanvas) {
30553          if (layerLimit > 0 && l - 1 - i > layerLimit && layer !== baseLayer) {
30554            layer._getRenderer().clearCanvas();
30555
30556            continue;
30557          }
30558
30559          t += this._drawCanvasLayerOnInteracting(layer, t, timeLimit, framestamp);
30560        } else if (isInteracting && renderer.drawOnInteracting) {
30561          if (renderer.prepareRender) {
30562            renderer.prepareRender();
30563          }
30564
30565          renderer.drawOnInteracting(this._eventParam, framestamp);
30566        } else {
30567          renderer.render(framestamp);
30568
30569          if (isCanvas && transformMatrix && renderer.isLoadingResource()) {
30570            renderer.__zoomTransformMatrix = transformMatrix;
30571          }
30572        }
30573
30574        if (isCanvas) {
30575          updatedIds.push(layer.getId());
30576          this.setLayerCanvasUpdated();
30577        }
30578      }
30579
30580      var preCanvasIds = this._canvasIds || [];
30581      var preUpdatedIds = this._updatedIds || [];
30582      this._canvasIds = canvasIds;
30583      this._updatedIds = updatedIds;
30584
30585      if (!this.isLayerCanvasUpdated()) {
30586        var sep = '---';
30587
30588        if (preCanvasIds.join(sep) !== canvasIds.join(sep) || preUpdatedIds.join(sep) !== updatedIds.join(sep)) {
30589          this.setLayerCanvasUpdated();
30590        }
30591      }
30592    };
30593
30594    _proto._checkLayerRedraw = function _checkLayerRedraw(layer) {
30595      if (this.isSpatialReferenceChanged()) {
30596        return true;
30597      }
30598
30599      var map = this.map;
30600
30601      var renderer = layer._getRenderer();
30602
30603      if (layer.isCanvasRender()) {
30604        return renderer.testIfNeedRedraw();
30605      } else {
30606        if (renderer.needToRedraw && renderer.needToRedraw()) {
30607          return true;
30608        }
30609
30610        return map.isInteracting() || this.isViewChanged();
30611      }
30612    };
30613
30614    _proto._drawCanvasLayerOnInteracting = function _drawCanvasLayerOnInteracting(layer, t, timeLimit, framestamp) {
30615      var map = this.map,
30616          renderer = layer._getRenderer(),
30617          drawTime = renderer.getDrawTime(),
30618          inTime = timeLimit === 0 || timeLimit > 0 && t + drawTime <= timeLimit;
30619
30620      if (renderer.mustRenderOnInteracting && renderer.mustRenderOnInteracting()) {
30621        renderer.render(framestamp);
30622      } else if (renderer.drawOnInteracting && (layer === map.getBaseLayer() || inTime || map.isZooming() && layer.options['forceRenderOnZooming'] || map.isMoving() && layer.options['forceRenderOnMoving'] || map.isRotating() && layer.options['forceRenderOnRotating'])) {
30623        renderer.prepareRender();
30624        renderer.prepareCanvas();
30625        renderer.drawOnInteracting(this._eventParam, framestamp);
30626        return drawTime;
30627      } else if (map.isZooming() && !map.getPitch() && !map.isRotating()) {
30628        renderer.prepareRender();
30629        renderer.__zoomTransformMatrix = this._zoomMatrix;
30630      } else if (map.getPitch() || map.isRotating()) {
30631        renderer.clearCanvas();
30632      }
30633
30634      if (renderer.drawOnInteracting && !inTime) {
30635        renderer.onSkipDrawOnInteracting(this._eventParam, framestamp);
30636      }
30637
30638      return 0;
30639    };
30640
30641    _proto._fireLayerLoadEvents = function _fireLayerLoadEvents() {
30642      if (this._updatedIds && this._updatedIds.length > 0) {
30643        var map = this.map;
30644
30645        this._updatedIds.reverse().forEach(function (id) {
30646          var layer = map.getLayer(id);
30647
30648          if (!layer) {
30649            return;
30650          }
30651
30652          var renderer = layer._getRenderer();
30653
30654          if (!renderer || !renderer.isRenderComplete()) {
30655            return;
30656          }
30657
30658          layer.fire('layerload');
30659        });
30660      }
30661    };
30662
30663    _proto.isLayerCanvasUpdated = function isLayerCanvasUpdated() {
30664      return this._canvasUpdated;
30665    };
30666
30667    _proto.setLayerCanvasUpdated = function setLayerCanvasUpdated() {
30668      this._canvasUpdated = true;
30669    };
30670
30671    _proto.drawLayerCanvas = function drawLayerCanvas(layers) {
30672      var map = this.map;
30673
30674      if (!map) {
30675        return;
30676      }
30677
30678      if (!this.isLayerCanvasUpdated() && !this.isViewChanged()) {
30679        return;
30680      }
30681
30682      if (!this.canvas) {
30683        this.createCanvas();
30684      }
30685
30686      map._fireEvent('renderstart', {
30687        'context': this.context
30688      });
30689
30690      if (!this._updateCanvasSize()) {
30691        this.clearCanvas();
30692      }
30693
30694      var interacting = map.isInteracting(),
30695          limit = map.options['layerCanvasLimitOnInteracting'];
30696      var len = layers.length;
30697      var baseLayerImage;
30698      var images = [];
30699
30700      for (var i = 0; i < len; i++) {
30701        if (!layers[i].isVisible() || !layers[i].isCanvasRender()) {
30702          continue;
30703        }
30704
30705        var renderer = layers[i]._getRenderer();
30706
30707        if (!renderer) {
30708          continue;
30709        }
30710
30711        var layerImage = this._getLayerImage(layers[i]);
30712
30713        if (layerImage && layerImage['image']) {
30714          if (layers[i] === map.getBaseLayer()) {
30715            baseLayerImage = [layers[i], layerImage];
30716          } else {
30717            images.push([layers[i], layerImage]);
30718          }
30719        }
30720      }
30721
30722      if (baseLayerImage) {
30723        this._drawLayerCanvasImage(baseLayerImage[0], baseLayerImage[1]);
30724
30725        this._drawFog();
30726      }
30727
30728      len = images.length;
30729      var start = interacting && limit >= 0 && len > limit ? len - limit : 0;
30730
30731      for (var _i = start; _i < len; _i++) {
30732        this._drawLayerCanvasImage(images[_i][0], images[_i][1]);
30733      }
30734
30735      this._drawCenterCross();
30736
30737      map._fireEvent('renderend', {
30738        'context': this.context
30739      });
30740    };
30741
30742    _proto.setToRedraw = function setToRedraw() {
30743      var layers = this._getAllLayerToRender();
30744
30745      for (var i = 0, l = layers.length; i < l; i++) {
30746        var renderer = layers[i].getRenderer();
30747
30748        if (renderer && renderer.canvas && renderer.setToRedraw) {
30749          renderer.setToRedraw();
30750        }
30751      }
30752    };
30753
30754    _proto.updateMapSize = function updateMapSize(size) {
30755      if (!size || this._containerIsCanvas) {
30756        return;
30757      }
30758
30759      var width = size['width'] + 'px',
30760          height = size['height'] + 'px';
30761      var panels = this.map._panels;
30762      panels.mapWrapper.style.width = width;
30763      panels.mapWrapper.style.height = height;
30764
30765      this._updateCanvasSize();
30766    };
30767
30768    _proto.getMainPanel = function getMainPanel() {
30769      if (!this.map) {
30770        return null;
30771      }
30772
30773      if (this._containerIsCanvas) {
30774        return this.map._containerDOM;
30775      }
30776
30777      if (this.map._panels) {
30778        return this.map._panels.mapWrapper;
30779      }
30780
30781      return null;
30782    };
30783
30784    _proto.toDataURL = function toDataURL(mimeType) {
30785      if (!this.canvas) {
30786        return null;
30787      }
30788
30789      return this.canvas.toDataURL(mimeType);
30790    };
30791
30792    _proto.remove = function remove() {
30793      if (Browser$1.webgl && typeof document !== 'undefined') {
30794        removeDomEvent(document, 'visibilitychange', this._onVisibilitychange, this);
30795      }
30796
30797      if (this._resizeInterval) {
30798        clearInterval(this._resizeInterval);
30799      }
30800
30801      delete this.context;
30802      delete this.canvas;
30803      delete this.map;
30804      delete this._spatialRefChanged;
30805
30806      this._cancelFrameLoop();
30807    };
30808
30809    _proto.hitDetect = function hitDetect(point) {
30810      var map = this.map;
30811
30812      if (!map || !map.options['hitDetect'] || map.isInteracting()) {
30813        return;
30814      }
30815
30816      var layers = map._getLayers();
30817
30818      var cursor = 'default';
30819      var limit = map.options['hitDetectLimit'] || 0;
30820      var counter = 0;
30821
30822      for (var i = layers.length - 1; i >= 0; i--) {
30823        var layer = layers[i];
30824
30825        if (layer.isEmpty && layer.isEmpty()) {
30826          continue;
30827        }
30828
30829        var renderer = layer._getRenderer();
30830
30831        if (!renderer || !renderer.hitDetect) {
30832          continue;
30833        }
30834
30835        if (renderer.isBlank && renderer.isBlank()) {
30836          continue;
30837        }
30838
30839        if (layer.options['cursor'] !== 'default' && renderer.hitDetect(point)) {
30840          cursor = layer.options['cursor'] || 'pointer';
30841          break;
30842        }
30843
30844        counter++;
30845
30846        if (limit > 0 && counter > limit) {
30847          break;
30848        }
30849      }
30850
30851      map._trySetCursor(cursor);
30852    };
30853
30854    _proto._getLayerImage = function _getLayerImage(layer) {
30855      var renderer = layer._getRenderer();
30856
30857      if (renderer.getCanvasImage) {
30858        return renderer.getCanvasImage();
30859      }
30860
30861      return null;
30862    };
30863
30864    _proto.initContainer = function initContainer() {
30865      var panels = this.map._panels;
30866
30867      function createContainer(name, className, cssText, enableSelect) {
30868        var c = createEl('div', className);
30869
30870        if (cssText) {
30871          c.style.cssText = cssText;
30872        }
30873
30874        panels[name] = c;
30875
30876        if (!enableSelect) {
30877          preventSelection(c);
30878        }
30879
30880        return c;
30881      }
30882
30883      var containerDOM = this.map._containerDOM;
30884
30885      if (this._containerIsCanvas) {
30886        return;
30887      }
30888
30889      containerDOM.innerHTML = '';
30890      var POSITION0 = 'position:absolute;top:0px;left:0px;';
30891      var mapWrapper = createContainer('mapWrapper', 'maptalks-wrapper', 'position:absolute;overflow:hidden;', true),
30892          mapAllLayers = createContainer('allLayers', 'maptalks-all-layers', POSITION0 + 'padding:0px;margin:0px;z-index:0;overflow:visible;', true),
30893          backStatic = createContainer('backStatic', 'maptalks-back-static', POSITION0 + 'z-index:0;', true),
30894          back = createContainer('back', 'maptalks-back', POSITION0 + 'z-index:1;'),
30895          backLayer = createContainer('backLayer', 'maptalks-back-layer', POSITION0),
30896          canvasContainer = createContainer('canvasContainer', 'maptalks-canvas-layer', POSITION0 + 'border:none;z-index:2;'),
30897          frontStatic = createContainer('frontStatic', 'maptalks-front-static', POSITION0 + 'z-index:3;', true),
30898          front = createContainer('front', 'maptalks-front', POSITION0 + 'z-index:4;', true),
30899          frontLayer = createContainer('frontLayer', 'maptalks-front-layer', POSITION0 + 'z-index:0;'),
30900          ui = createContainer('ui', 'maptalks-ui', POSITION0 + 'border:none;z-index:1;', true),
30901          control = createContainer('control', 'maptalks-control', 'z-index:1', true);
30902      containerDOM.appendChild(mapWrapper);
30903      mapAllLayers.appendChild(backStatic);
30904      back.appendChild(backLayer);
30905      back.layerDOM = backLayer;
30906      mapAllLayers.appendChild(back);
30907      mapAllLayers.appendChild(canvasContainer);
30908      front.appendChild(frontLayer);
30909      front.layerDOM = frontLayer;
30910      front.uiDOM = ui;
30911      mapAllLayers.appendChild(frontStatic);
30912      mapAllLayers.appendChild(front);
30913      front.appendChild(ui);
30914      mapWrapper.appendChild(mapAllLayers);
30915      mapWrapper.appendChild(control);
30916      this.createCanvas();
30917      this.resetContainer();
30918
30919      var mapSize = this.map._getContainerDomSize();
30920
30921      this.updateMapSize(mapSize);
30922    };
30923
30924    _proto.isViewChanged = function isViewChanged() {
30925      var previous = this._mapview;
30926
30927      var view = this._getMapView();
30928
30929      if (!previous || !equalMapView(previous, view)) {
30930        return true;
30931      }
30932
30933      return false;
30934    };
30935
30936    _proto._recordView = function _recordView() {
30937      var map = this.map;
30938
30939      if (!map._onViewChange || map.isInteracting() || map.isAnimating()) {
30940        return;
30941      }
30942
30943      if (!equalMapView(map.getView(), map._getCurrentView())) {
30944        map._onViewChange(map.getView());
30945      }
30946    };
30947
30948    _proto.isSpatialReferenceChanged = function isSpatialReferenceChanged() {
30949      return this._spatialRefChanged;
30950    };
30951
30952    _proto._getMapView = function _getMapView() {
30953      var map = this.map;
30954
30955      var center = map._getPrjCenter();
30956
30957      return {
30958        x: center.x,
30959        y: center.y,
30960        zoom: map.getZoom(),
30961        pitch: map.getPitch(),
30962        bearing: map.getBearing(),
30963        width: map.width,
30964        height: map.height
30965      };
30966    };
30967
30968    _proto._frameLoop = function _frameLoop(framestamp) {
30969      var _this2 = this;
30970
30971      if (!this.map) {
30972        this._cancelFrameLoop();
30973
30974        return;
30975      }
30976
30977      this.renderFrame(framestamp);
30978      this._animationFrame = requestAnimFrame(function (framestamp) {
30979        _this2._frameLoop(framestamp);
30980      });
30981    };
30982
30983    _proto._cancelFrameLoop = function _cancelFrameLoop() {
30984      if (this._animationFrame) {
30985        cancelAnimFrame(this._animationFrame);
30986      }
30987    };
30988
30989    _proto._drawLayerCanvasImage = function _drawLayerCanvasImage(layer, layerImage) {
30990      var ctx = this.context;
30991      var point = layerImage['point'].round();
30992      var dpr = this.map.getDevicePixelRatio();
30993
30994      if (dpr !== 1) {
30995        point._multi(dpr);
30996      }
30997
30998      var canvasImage = layerImage['image'];
30999      var width = canvasImage.width,
31000          height = canvasImage.height;
31001
31002      if (point.x + width <= 0 || point.y + height <= 0) {
31003        return;
31004      }
31005
31006      var op = layer.options['opacity'];
31007
31008      if (!isNumber(op)) {
31009        op = 1;
31010      }
31011
31012      if (op <= 0) {
31013        return;
31014      }
31015
31016      var imgOp = layerImage['opacity'];
31017
31018      if (!isNumber(imgOp)) {
31019        imgOp = 1;
31020      }
31021
31022      if (imgOp <= 0) {
31023        return;
31024      }
31025
31026      var alpha = ctx.globalAlpha;
31027
31028      if (op < 1) {
31029        ctx.globalAlpha *= op;
31030      }
31031
31032      if (imgOp < 1) {
31033        ctx.globalAlpha *= imgOp;
31034      }
31035
31036      if (layer.options['cssFilter']) {
31037        ctx.filter = layer.options['cssFilter'];
31038      }
31039
31040      var renderer = layer.getRenderer();
31041      var matrix = renderer.__zoomTransformMatrix;
31042      var clipped = renderer.clipCanvas(this.context);
31043
31044      if (matrix) {
31045        ctx.save();
31046        ctx.setTransform.apply(ctx, matrix);
31047      }
31048
31049      ctx.drawImage(canvasImage, 0, 0, width, height, point.x, point.y, width, height);
31050
31051      if (matrix) {
31052        ctx.restore();
31053      }
31054
31055      if (clipped) {
31056        ctx.restore();
31057      }
31058
31059      if (ctx.filter !== 'none') {
31060        ctx.filter = 'none';
31061      }
31062
31063      ctx.globalAlpha = alpha;
31064    };
31065
31066    _proto._drawCenterCross = function _drawCenterCross() {
31067      var cross = this.map.options['centerCross'];
31068
31069      if (cross) {
31070        var ctx = this.context;
31071        var p = new Point(this.canvas.width / 2, this.canvas.height / 2);
31072
31073        if (isFunction(cross)) {
31074          cross(ctx, p);
31075        } else {
31076          Canvas.drawCross(this.context, p.x, p.y, 2, '#f00');
31077        }
31078      }
31079    };
31080
31081    _proto._drawFog = function _drawFog() {
31082      var map = this.map;
31083
31084      if (map.getPitch() <= map.options['maxVisualPitch'] || !map.options['fog']) {
31085        return;
31086      }
31087
31088      var fogThickness = 30;
31089      var r = map.getDevicePixelRatio();
31090      var ctx = this.context,
31091          clipExtent = map.getContainerExtent();
31092      var top = (map.height - map._getVisualHeight(75)) * r;
31093      if (top < 0) top = 0;
31094      var bottom = clipExtent.ymin * r,
31095          h = Math.ceil(bottom - top),
31096          color = map.options['fogColor'].join();
31097      var gradient = ctx.createLinearGradient(0, top, 0, bottom + fogThickness);
31098      var landscape = 1 - fogThickness / (h + fogThickness);
31099      gradient.addColorStop(0, "rgba(" + color + ", 0)");
31100      gradient.addColorStop(0.3, "rgba(" + color + ", 0.3)");
31101      gradient.addColorStop(landscape, "rgba(" + color + ", 1)");
31102      gradient.addColorStop(1, "rgba(" + color + ", 0)");
31103      ctx.beginPath();
31104      ctx.fillStyle = gradient;
31105      ctx.fillRect(0, top, Math.ceil(clipExtent.getWidth()) * r, Math.ceil(h + fogThickness));
31106    };
31107
31108    _proto._getAllLayerToRender = function _getAllLayerToRender() {
31109      return this.map._getLayers();
31110    };
31111
31112    _proto.clearCanvas = function clearCanvas() {
31113      if (!this.canvas) {
31114        return;
31115      }
31116
31117      Canvas.clearRect(this.context, 0, 0, this.canvas.width, this.canvas.height);
31118    };
31119
31120    _proto._updateCanvasSize = function _updateCanvasSize() {
31121      if (!this.canvas || this._containerIsCanvas) {
31122        return false;
31123      }
31124
31125      var map = this.map,
31126          mapSize = map.getSize(),
31127          canvas = this.canvas,
31128          r = map.getDevicePixelRatio();
31129
31130      if (mapSize['width'] * r === canvas.width && mapSize['height'] * r === canvas.height) {
31131        return false;
31132      }
31133
31134      canvas.height = r * mapSize['height'];
31135      canvas.width = r * mapSize['width'];
31136
31137      if (canvas.style) {
31138        canvas.style.width = mapSize['width'] + 'px';
31139        canvas.style.height = mapSize['height'] + 'px';
31140      }
31141
31142      return true;
31143    };
31144
31145    _proto.createCanvas = function createCanvas() {
31146      if (this._containerIsCanvas) {
31147        this.canvas = this.map._containerDOM;
31148      } else {
31149        this.canvas = createEl('canvas');
31150
31151        this._updateCanvasSize();
31152
31153        this.map._panels.canvasContainer.appendChild(this.canvas);
31154      }
31155
31156      this.context = this.canvas.getContext('2d');
31157    };
31158
31159    _proto._checkSize = function _checkSize() {
31160      if (!this.map || this.map.isInteracting()) {
31161        return;
31162      }
31163
31164      computeDomPosition(this.map._containerDOM);
31165      this.map.checkSize();
31166    };
31167
31168    _proto._setCheckSizeInterval = function _setCheckSizeInterval(interval) {
31169      var _this3 = this;
31170
31171      clearInterval(this._resizeInterval);
31172      this._checkSizeInterval = interval;
31173      this._resizeInterval = setInterval(function () {
31174        if (!_this3.map || _this3.map.isRemoved()) {
31175          clearInterval(_this3._resizeInterval);
31176        } else {
31177          _this3._checkSize();
31178        }
31179      }, this._checkSizeInterval);
31180    };
31181
31182    _proto._registerEvents = function _registerEvents() {
31183      var _this4 = this;
31184
31185      var map = this.map;
31186
31187      if (map.options['checkSize'] && !IS_NODE && typeof window !== 'undefined') {
31188        this._setCheckSizeInterval(map.options['checkSizeInterval']);
31189      }
31190
31191      if (!Browser$1.mobile) {
31192        map.on('_mousemove', this._onMapMouseMove, this);
31193      }
31194
31195      map.on('_dragrotatestart _dragrotating _dragrotateend _movestart _moving _moveend _zoomstart', function (param) {
31196        _this4._eventParam = param;
31197      });
31198      map.on('_zooming', function (param) {
31199        if (!map.getPitch()) {
31200          _this4._zoomMatrix = param['matrix']['container'];
31201        }
31202
31203        _this4._eventParam = param;
31204      });
31205      map.on('_zoomend', function (param) {
31206        _this4._eventParam = param;
31207        delete _this4._zoomMatrix;
31208      });
31209      map.on('_spatialreferencechange', function () {
31210        _this4._spatialRefChanged = true;
31211      });
31212
31213      if (Browser$1.webgl && typeof document !== 'undefined') {
31214        addDomEvent(document, 'visibilitychange', this._onVisibilitychange, this);
31215      }
31216    };
31217
31218    _proto._onMapMouseMove = function _onMapMouseMove(param) {
31219      var _this5 = this;
31220
31221      var map = this.map;
31222
31223      if (map.isInteracting() || !map.options['hitDetect']) {
31224        return;
31225      }
31226
31227      if (this._hitDetectFrame) {
31228        cancelAnimFrame(this._hitDetectFrame);
31229      }
31230
31231      this._hitDetectFrame = requestAnimFrame(function () {
31232        _this5.hitDetect(param['containerPoint']);
31233      });
31234    };
31235
31236    _proto._getCanvasLayers = function _getCanvasLayers() {
31237      return this.map._getLayers(function (layer) {
31238        return layer.isCanvasRender();
31239      });
31240    };
31241
31242    _proto._onVisibilitychange = function _onVisibilitychange() {
31243      if (document.visibilityState !== 'visible') {
31244        return;
31245      }
31246
31247      this.setToRedraw();
31248    };
31249
31250    return MapCanvasRenderer;
31251  }(MapRenderer);
31252
31253  Map$1.registerRenderer('canvas', MapCanvasRenderer);
31254  Map$1.mergeOptions({
31255    'fog': true,
31256    'fogColor': [233, 233, 233]
31257  });
31258
31259
31260
31261  var index$6 = /*#__PURE__*/Object.freeze({
31262    ResourceCache: ResourceCache,
31263    CanvasRenderer: CanvasRenderer,
31264    ImageGLRenderable: ImageGLRenderable,
31265    MapRenderer: MapRenderer,
31266    MapCanvasRenderer: MapCanvasRenderer,
31267    Renderable: Renderable,
31268    ImageLayerCanvasRenderer: ImageLayerCanvasRenderer,
31269    ImageLayerGLRenderer: ImageLayerGLRenderer,
31270    TileLayerCanvasRenderer: TileLayerCanvasRenderer,
31271    TileLayerGLRenderer: TileLayerGLRenderer,
31272    CanvasTileLayerCanvasRenderer: CanvasRenderer$1,
31273    CanvasTileLayerGLRenderer: GLRenderer,
31274    OverlayLayerCanvasRenderer: OverlayLayerRenderer,
31275    VectorLayerCanvasRenderer: VectorLayerRenderer,
31276    CanvasLayerRenderer: CanvasLayerRenderer
31277  });
31278
31279  var CenterPointRenderer = {
31280    _getRenderPoints: function _getRenderPoints() {
31281      return [[this._getCenter2DPoint(this.getMap().getGLZoom())], null];
31282    }
31283  };
31284  Marker.include(CenterPointRenderer);
31285  Ellipse.include(CenterPointRenderer);
31286  Circle.include(CenterPointRenderer);
31287  Sector.include(CenterPointRenderer);
31288  Rectangle.include({
31289    _getRenderPoints: function _getRenderPoints(placement) {
31290      var map = this.getMap();
31291
31292      if (placement === 'vertex') {
31293        var shell = this._trimRing(this.getShell());
31294
31295        var points = [];
31296
31297        for (var i = 0, len = shell.length; i < len; i++) {
31298          points.push(map.coordToPoint(shell[i], map.getGLZoom()));
31299        }
31300
31301        return [points, null];
31302      } else {
31303        var c = map.coordToPoint(this.getCenter(), map.getGLZoom());
31304        return [[c], null];
31305      }
31306    }
31307  });
31308  var PolyRenderer = {
31309    _getRenderPoints: function _getRenderPoints(placement) {
31310      var map = this.getMap();
31311      var glZoom = map.getGLZoom();
31312      var points,
31313          rotations = null;
31314
31315      if (placement === 'point') {
31316        points = this._getPath2DPoints(this._getPrjCoordinates(), false, glZoom);
31317
31318        if (points && points.length > 0 && Array.isArray(points[0])) {
31319          points = points[0].concat(points[1]);
31320        }
31321      } else if (placement === 'vertex') {
31322        points = this._getPath2DPoints(this._getPrjCoordinates(), false, glZoom);
31323        rotations = [];
31324
31325        if (points && points.length > 0 && Array.isArray(points[0])) {
31326          for (var i = 0, l = points.length; i < l; i++) {
31327            for (var ii = 0, ll = points[i].length; ii < ll; ii++) {
31328              if (ii === 0) {
31329                rotations.push([points[i][ii], points[i][ii + 1]]);
31330              } else {
31331                rotations.push([points[i][ii - 1], points[i][ii]]);
31332              }
31333            }
31334          }
31335
31336          points = points[0].concat(points[1]);
31337        } else {
31338          for (var _i = 0, _l = points.length; _i < _l; _i++) {
31339            if (_i === 0) {
31340              rotations.push([points[_i], points[_i + 1]]);
31341            } else {
31342              rotations.push([points[_i - 1], points[_i]]);
31343            }
31344          }
31345        }
31346      } else if (placement === 'line') {
31347        points = [];
31348        rotations = [];
31349
31350        var vertice = this._getPath2DPoints(this._getPrjCoordinates(), false, glZoom),
31351            isSplitted = vertice.length > 0 && Array.isArray(vertice[0]);
31352
31353        if (isSplitted) {
31354          var ring;
31355
31356          for (var _i2 = 1, _l2 = vertice.length; _i2 < _l2; _i2++) {
31357            ring = vertice[_i2];
31358
31359            if (this instanceof Polygon && ring.length > 0 && !ring[0].equals(ring[ring.length - 1])) {
31360              ring.push(ring[0]);
31361            }
31362
31363            for (var _ii = 1, _ll = ring.length; _ii < _ll; _ii++) {
31364              points.push(ring[_ii].add(ring[_ii - 1])._multi(0.5));
31365              rotations.push([ring[_ii - 1], ring[_ii]]);
31366            }
31367          }
31368        } else {
31369          if (this instanceof Polygon && vertice.length > 0 && !vertice[0].equals(vertice[vertice.length - 1])) {
31370            vertice.push(vertice[0]);
31371          }
31372
31373          for (var _i3 = 1, _l3 = vertice.length; _i3 < _l3; _i3++) {
31374            points.push(vertice[_i3].add(vertice[_i3 - 1])._multi(0.5));
31375            rotations.push([vertice[_i3 - 1], vertice[_i3]]);
31376          }
31377        }
31378      } else if (placement === 'vertex-first') {
31379        var coords = this._getPrjCoordinates();
31380
31381        points = coords.length ? [map._prjToPoint(coords[0], glZoom)] : [];
31382        rotations = coords.length ? [[map._prjToPoint(coords[0], glZoom), map._prjToPoint(coords[1], glZoom)]] : [];
31383      } else if (placement === 'vertex-last') {
31384        var _coords = this._getPrjCoordinates();
31385
31386        var _l4 = _coords.length;
31387        points = _l4 ? [map._prjToPoint(_coords[_l4 - 1], glZoom)] : [];
31388        var current = _l4 - 1,
31389            previous = _l4 > 1 ? _l4 - 2 : _l4 - 1;
31390        rotations = _l4 ? [[map._prjToPoint(_coords[previous], glZoom), map._prjToPoint(_coords[current], glZoom)]] : [];
31391      } else {
31392        var pcenter = this._getProjection().project(this.getCenter());
31393
31394        points = [map._prjToPoint(pcenter, glZoom)];
31395      }
31396
31397      return [points, rotations];
31398    }
31399  };
31400  LineString.include(PolyRenderer);
31401  Polygon.include(PolyRenderer);
31402
31403  Geometry.include({
31404    _redrawWhenPitch: function _redrawWhenPitch() {
31405      return false;
31406    },
31407    _redrawWhenRotate: function _redrawWhenRotate() {
31408      return false;
31409    }
31410  });
31411  var el = {
31412    _redrawWhenPitch: function _redrawWhenPitch() {
31413      return true;
31414    },
31415    _redrawWhenRotate: function _redrawWhenRotate() {
31416      return this instanceof Ellipse || this instanceof Sector;
31417    },
31418    _paintAsPath: function _paintAsPath() {
31419      var map = this.getMap();
31420
31421      var altitude = this._getPainter().getAltitude();
31422
31423      return altitude > 0 || map.getPitch() || this instanceof Ellipse && map.getBearing();
31424    },
31425    _getPaintParams: function _getPaintParams() {
31426      var map = this.getMap();
31427
31428      if (this._paintAsPath()) {
31429        return Polygon.prototype._getPaintParams.call(this, true);
31430      }
31431
31432      var pcenter = this._getPrjCoordinates();
31433
31434      var pt = map._prjToPoint(pcenter, map.getGLZoom());
31435
31436      var size = this._getRenderSize();
31437
31438      return [pt, size['width'], size['height']];
31439    },
31440    _paintOn: function _paintOn() {
31441      if (this._paintAsPath()) {
31442        return Canvas.polygon.apply(Canvas, arguments);
31443      } else {
31444        return Canvas.ellipse.apply(Canvas, arguments);
31445      }
31446    },
31447    _getRenderSize: function _getRenderSize() {
31448      var map = this.getMap(),
31449          z = map.getGLZoom();
31450
31451      var prjExtent = this._getPrjExtent();
31452
31453      var pmin = map._prjToPoint(prjExtent.getMin(), z),
31454          pmax = map._prjToPoint(prjExtent.getMax(), z);
31455
31456      return new Size(Math.abs(pmax.x - pmin.x) / 2, Math.abs(pmax.y - pmin.y) / 2);
31457    }
31458  };
31459  Ellipse.include(el);
31460  Circle.include(el);
31461  Rectangle.include({
31462    _getPaintParams: function _getPaintParams() {
31463      var map = this.getMap();
31464      var pointZoom = map.getGLZoom();
31465
31466      var shell = this._getPrjShell();
31467
31468      var points = this._getPath2DPoints(shell, false, pointZoom);
31469
31470      return [points];
31471    },
31472    _paintOn: Canvas.polygon
31473  });
31474  Sector.include(el, {
31475    _redrawWhenPitch: function _redrawWhenPitch() {
31476      return true;
31477    },
31478    _getPaintParams: function _getPaintParams() {
31479      if (this._paintAsPath()) {
31480        return Polygon.prototype._getPaintParams.call(this, true);
31481      }
31482
31483      var map = this.getMap();
31484
31485      var pt = map._prjToPoint(this._getPrjCoordinates(), map.getGLZoom());
31486
31487      var size = this._getRenderSize();
31488
31489      return [pt, size['width'], [this.getStartAngle(), this.getEndAngle()]];
31490    },
31491    _paintOn: function _paintOn() {
31492      if (this._paintAsPath()) {
31493        return Canvas.polygon.apply(Canvas, arguments);
31494      } else {
31495        var r = this.getMap().getBearing();
31496        var args = arguments;
31497
31498        if (r) {
31499          args[3] = args[3].slice(0);
31500          args[3][0] += r;
31501          args[3][1] += r;
31502        }
31503
31504        return Canvas.sector.apply(Canvas, args);
31505      }
31506    }
31507  });
31508  Path.include({
31509    _paintAsPath: function _paintAsPath() {
31510      return true;
31511    }
31512  });
31513  LineString.include({
31514    arrowStyles: {
31515      'classic': [3, 4]
31516    },
31517    _getArrowShape: function _getArrowShape(prePoint, point, lineWidth, arrowStyle, tolerance) {
31518      if (!tolerance) {
31519        tolerance = 0;
31520      }
31521
31522      var width = lineWidth * arrowStyle[0],
31523          height = lineWidth * arrowStyle[1] + tolerance,
31524          hw = width / 2 + tolerance;
31525      var normal;
31526
31527      if (point.nextCtrlPoint || point.prevCtrlPoint) {
31528        if (point.prevCtrlPoint) {
31529          normal = point.sub(new Point(point.prevCtrlPoint));
31530        } else {
31531          normal = point.sub(new Point(point.nextCtrlPoint));
31532        }
31533      } else {
31534        normal = point.sub(prePoint);
31535      }
31536
31537      normal._unit();
31538
31539      var p1 = point.sub(normal.multi(height));
31540
31541      normal._perp();
31542
31543      var p0 = p1.add(normal.multi(hw));
31544
31545      normal._multi(-1);
31546
31547      var p2 = p1.add(normal.multi(hw));
31548      return [p0, point, p2, p0];
31549    },
31550    _getPaintParams: function _getPaintParams() {
31551      var prjVertexes = this._getPrjCoordinates();
31552
31553      var points = this._getPath2DPoints(prjVertexes, false, this.getMap().getGLZoom());
31554
31555      return [points];
31556    },
31557    _paintOn: function _paintOn(ctx, points, lineOpacity, fillOpacity, dasharray) {
31558      if (this.options['smoothness']) {
31559        Canvas.paintSmoothLine(ctx, points, lineOpacity, this.options['smoothness'], false, this._animIdx, this._animTailRatio);
31560      } else {
31561        Canvas.path(ctx, points, lineOpacity, null, dasharray);
31562      }
31563
31564      this._paintArrow(ctx, points, lineOpacity);
31565    },
31566    _getArrowPlacement: function _getArrowPlacement() {
31567      return this.options['arrowPlacement'];
31568    },
31569    _getArrowStyle: function _getArrowStyle() {
31570      var arrowStyle = this.options['arrowStyle'];
31571
31572      if (arrowStyle) {
31573        return Array.isArray(arrowStyle) ? arrowStyle : this.arrowStyles[arrowStyle];
31574      }
31575
31576      return null;
31577    },
31578    _getArrows: function _getArrows(points, lineWidth, tolerance) {
31579      var arrowStyle = this._getArrowStyle();
31580
31581      if (!arrowStyle || points.length < 2) {
31582        return [];
31583      }
31584
31585      var isSplitted = points.length > 0 && Array.isArray(points[0]);
31586      var segments = isSplitted ? points : [points];
31587
31588      var placement = this._getArrowPlacement();
31589
31590      var arrows = [];
31591      var map = this.getMap(),
31592          first = map.coordToContainerPoint(this.getFirstCoordinate()),
31593          last = map.coordToContainerPoint(this.getLastCoordinate());
31594
31595      for (var i = segments.length - 1; i >= 0; i--) {
31596        if (placement === 'vertex-first' || placement === 'vertex-firstlast' && segments[i][0].closeTo(first, 0.01)) {
31597          arrows.push(this._getArrowShape(segments[i][1], segments[i][0], lineWidth, arrowStyle, tolerance));
31598        }
31599
31600        if (placement === 'vertex-last' || placement === 'vertex-firstlast' && segments[i][segments[i].length - 1].closeTo(last, 0.01)) {
31601          arrows.push(this._getArrowShape(segments[i][segments[i].length - 2], segments[i][segments[i].length - 1], lineWidth, arrowStyle, tolerance));
31602        } else if (placement === 'point') {
31603          this._getArrowPoints(arrows, segments[i], lineWidth, arrowStyle, tolerance);
31604        }
31605      }
31606
31607      return arrows;
31608    },
31609    _getArrowPoints: function _getArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance) {
31610      for (var ii = 0, ll = segments.length - 1; ii < ll; ii++) {
31611        arrows.push(this._getArrowShape(segments[ii], segments[ii + 1], lineWidth, arrowStyle, tolerance));
31612      }
31613    },
31614    _paintArrow: function _paintArrow(ctx, points, lineOpacity) {
31615      var lineWidth = this._getInternalSymbol()['lineWidth'];
31616
31617      if (!isNumber(lineWidth) || lineWidth < 3) {
31618        lineWidth = 3;
31619      }
31620
31621      var arrows = this._getArrows(points, lineWidth);
31622
31623      if (!arrows.length) {
31624        return;
31625      }
31626
31627      if (ctx.setLineDash) {
31628        ctx.setLineDash([]);
31629      }
31630
31631      for (var i = arrows.length - 1; i >= 0; i--) {
31632        ctx.fillStyle = ctx.strokeStyle;
31633        Canvas.polygon(ctx, arrows[i], lineOpacity, lineOpacity);
31634      }
31635    }
31636  });
31637  Polygon.include({
31638    _getPaintParams: function _getPaintParams(disableSimplify) {
31639      var maxZoom = this.getMap().getGLZoom();
31640
vendor: 4,121 bytes, lines 31641-31772
31641      var prjVertexes = this._getPrjShell();
31642
31643      var points = this._getPath2DPoints(prjVertexes, disableSimplify, maxZoom);
31644
31645      var isSplitted = points.length > 0 && Array.isArray(points[0]);
31646
31647      if (isSplitted) {
31648        points = [[points[0]], [points[1]]];
31649      }
31650
31651      var prjHoles = this._getPrjHoles();
31652
31653      var holePoints = [];
31654
31655      if (prjHoles && prjHoles.length > 0) {
31656        var simplified = this._simplified;
31657
31658        for (var i = 0; i < prjHoles.length; i++) {
31659          var hole = this._getPath2DPoints(prjHoles[i], disableSimplify, maxZoom);
31660
31661          if (Array.isArray(hole) && isSplitted) {
31662            if (Array.isArray(hole[0])) {
31663              points[0].push(hole[0]);
31664              points[1].push(hole[1]);
31665            } else {
31666              points[0].push(hole);
31667            }
31668          } else {
31669            holePoints.push(hole);
31670          }
31671        }
31672
31673        if (simplified) {
31674          this._simplified = simplified;
31675        }
31676      }
31677
31678      if (!isSplitted) {
31679        points = [points];
31680        pushIn(points, holePoints);
31681      }
31682
31683      return [points];
31684    },
31685    _paintOn: function _paintOn(ctx, points, lineOpacity, fillOpacity, dasharray) {
31686      Canvas.polygon(ctx, points, lineOpacity, fillOpacity, dasharray, this.options['smoothness']);
31687    }
31688  });
31689
31690  Map$1.VERSION = version;
31691
31692  exports.Util = index$1;
31693  exports.DomUtil = dom;
31694  exports.StringUtil = strings;
31695  exports.MapboxUtil = index;
31696  exports.Map = Map$1;
31697  exports.ui = index$4;
31698  exports.control = index$5;
31699  exports.renderer = index$6;
31700  exports.symbolizer = index$3;
31701  exports.animation = Animation$1;
31702  exports.Browser = Browser$1;
31703  exports.Ajax = Ajax;
31704  exports.Canvas = Canvas;
31705  exports.Promise = Promise$1;
31706  exports.Class = Class;
31707  exports.Eventable = Eventable;
31708  exports.JSONAble = JSONAble;
31709  exports.Handlerable = Handlerable;
31710  exports.Handler = Handler$1;
31711  exports.DragHandler = DragHandler;
31712  exports.MapTool = MapTool;
31713  exports.DrawTool = DrawTool;
31714  exports.AreaTool = AreaTool;
31715  exports.DistanceTool = DistanceTool;
31716  exports.SpatialReference = SpatialReference;
31717  exports.INTERNAL_LAYER_PREFIX = INTERNAL_LAYER_PREFIX;
31718  exports.GEOMETRY_COLLECTION_TYPES = GEOMETRY_COLLECTION_TYPES;
31719  exports.GEOJSON_TYPES = GEOJSON_TYPES;
31720  exports.RESOURCE_PROPERTIES = RESOURCE_PROPERTIES;
31721  exports.RESOURCE_SIZE_PROPERTIES = RESOURCE_SIZE_PROPERTIES;
31722  exports.NUMERICAL_PROPERTIES = NUMERICAL_PROPERTIES;
31723  exports.COLOR_PROPERTIES = COLOR_PROPERTIES;
31724  exports.projection = projections;
31725  exports.measurer = index$2;
31726  exports.Coordinate = Coordinate;
31727  exports.CRS = CRS;
31728  exports.Extent = Extent;
31729  exports.Point = Point;
31730  exports.PointExtent = PointExtent;
31731  exports.Size = Size;
31732  exports.Transformation = Transformation;
31733  exports.Layer = Layer;
31734  exports.TileLayer = TileLayer;
31735  exports.GroupTileLayer = GroupTileLayer;
31736  exports.WMSTileLayer = WMSTileLayer;
31737  exports.CanvasTileLayer = CanvasTileLayer;
31738  exports.ImageLayer = ImageLayer;
31739  exports.OverlayLayer = OverlayLayer;
31740  exports.VectorLayer = VectorLayer;
31741  exports.CanvasLayer = CanvasLayer;
31742  exports.ParticleLayer = ParticleLayer;
31743  exports.TileSystem = TileSystem;
31744  exports.TileConfig = TileConfig;
31745  exports.ArcCurve = ArcCurve;
31746  exports.Circle = Circle;
31747  exports.ConnectorLine = ConnectorLine;
31748  exports.ArcConnectorLine = ArcConnectorLine;
31749  exports.CubicBezierCurve = CubicBezierCurve;
31750  exports.Curve = Curve;
31751  exports.Ellipse = Ellipse;
31752  exports.GeoJSON = GeoJSON;
31753  exports.Geometry = Geometry;
31754  exports.GeometryCollection = GeometryCollection;
31755  exports.Label = Label;
31756  exports.LineString = LineString;
31757  exports.Marker = Marker;
31758  exports.MultiLineString = MultiLineString;
31759  exports.MultiPoint = MultiPoint;
31760  exports.MultiPolygon = MultiPolygon;
31761  exports.Polygon = Polygon;
31762  exports.QuadBezierCurve = QuadBezierCurve;
31763  exports.Rectangle = Rectangle;
31764  exports.Sector = Sector;
31765  exports.TextBox = TextBox;
31766  exports.TextMarker = TextMarker;
31767
31768  Object.defineProperty(exports, '__esModule', { value: true });
31769
31770  typeof console !== 'undefined' && console.log && console.log('maptalks v0.45.1');
31771
31772})));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.