UNPKG

@sakitam-gis/react-map

Version:
1,664 lines (1,453 loc) 1.11 MB
/*! * author: sakitam-fdd <smilefdd@gmail.com> * @sakitam-gis/react-map v0.0.2 * build-time: 2018-7-22 20:13 * LICENSE: BSD-3-Clause * (c) 2018-2018 https://sakitam-gis.github.io/react-map/ */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["ReactMap"] = factory(); else root["ReactMap"] = factory(); })(typeof self !== 'undefined' ? self : this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 33); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ if ("development".NODE_ENV !== 'production') { var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || 0xeac7; var isValidElement = function(object) { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; }; // By explicitly using `prop-types` you are opting into new development behavior. // http://fb.me/prop-types-in-prod var throwOnDirectAccess = true; module.exports = __webpack_require__(105)(isValidElement, throwOnDirectAccess); } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod module.exports = __webpack_require__(106)(); } /***/ }), /* 1 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(process, global) {/* unused harmony export Util */ /* unused harmony export DomUtil */ /* unused harmony export StringUtil */ /* unused harmony export MapboxUtil */ /* unused harmony export ui */ /* unused harmony export control */ /* unused harmony export renderer */ /* unused harmony export symbolizer */ /* unused harmony export animation */ /* unused harmony export Browser */ /* unused harmony export Ajax */ /* unused harmony export Canvas */ /* unused harmony export Class */ /* unused harmony export Eventable */ /* unused harmony export JSONAble */ /* unused harmony export Handlerable */ /* unused harmony export Handler */ /* unused harmony export DragHandler */ /* unused harmony export MapTool */ /* unused harmony export DrawTool */ /* unused harmony export AreaTool */ /* unused harmony export DistanceTool */ /* unused harmony export SpatialReference */ /* unused harmony export INTERNAL_LAYER_PREFIX */ /* unused harmony export GEOMETRY_COLLECTION_TYPES */ /* unused harmony export GEOJSON_TYPES */ /* unused harmony export RESOURCE_PROPERTIES */ /* unused harmony export RESOURCE_SIZE_PROPERTIES */ /* unused harmony export NUMERICAL_PROPERTIES */ /* unused harmony export COLOR_PROPERTIES */ /* unused harmony export projection */ /* unused harmony export measurer */ /* unused harmony export Coordinate */ /* unused harmony export CRS */ /* unused harmony export Extent */ /* unused harmony export Point */ /* unused harmony export PointExtent */ /* unused harmony export Size */ /* unused harmony export Transformation */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return Map; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Layer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return TileLayer; }); /* unused harmony export GroupTileLayer */ /* unused harmony export WMSTileLayer */ /* unused harmony export CanvasTileLayer */ /* unused harmony export ImageLayer */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return OverlayLayer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return VectorLayer; }); /* unused harmony export CanvasLayer */ /* unused harmony export ParticleLayer */ /* unused harmony export TileSystem */ /* unused harmony export TileConfig */ /* unused harmony export ArcCurve */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Circle; }); /* unused harmony export ConnectorLine */ /* unused harmony export ArcConnectorLine */ /* unused harmony export CubicBezierCurve */ /* unused harmony export Curve */ /* unused harmony export Ellipse */ /* unused harmony export GeoJSON */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Geometry; }); /* unused harmony export GeometryCollection */ /* unused harmony export Label */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return LineString; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return Marker; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return MultiLineString; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return MultiPoint; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return MultiPolygon; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return Polygon; }); /* unused harmony export QuadBezierCurve */ /* unused harmony export Rectangle */ /* unused harmony export Sector */ /* unused harmony export TextBox */ /* unused harmony export TextMarker */ /*! * maptalks v0.40.5 * LICENSE : BSD-3-Clause * (c) 2016-2018 maptalks.org */ var INTERNAL_LAYER_PREFIX = '_maptalks__internal_layer_'; var GEOMETRY_COLLECTION_TYPES = ['MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection']; var GEOJSON_TYPES = ['FeatureCollection', 'Feature', 'Point', 'LineString', 'Polygon'].concat(GEOMETRY_COLLECTION_TYPES); var RESOURCE_PROPERTIES = ['markerFile', 'polygonPatternFile', 'linePatternFile', 'markerFillPatternFile', 'markerLinePatternFile']; var RESOURCE_SIZE_PROPERTIES = [['markerWidth', 'markerHeight'], [], [null, 'lineWidth'], [], [null, 'markerLineWidth']]; var NUMERICAL_PROPERTIES = { 'lineWidth': 1, 'lineOpacity': 1, 'lineDx': 1, 'lineDy': 1, 'polygonOpacity': 1, 'markerWidth': 1, 'markerHeight': 1, 'markerDx': 1, 'markerDy': 1, 'markerOpacity': 1, 'markerFillOpacity': 1, 'markerLineWidth': 1, 'markerLineOpacity': 1, 'textSize': 1, 'textOpacity': 1, 'textHaloRadius': 1, 'textWrapWidth': 1, 'textLineSpacing': 1, 'textDx': 1, 'textDy': 1 }; var COLOR_PROPERTIES = ['lineColor', 'polygonFill', 'markerFill', 'markerLineColor', 'textFill']; function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; var inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }; var possibleConstructorReturn = function (self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }; function now() { return Date.now(); } function extend(dest) { for (var i = 1; i < arguments.length; i++) { var src = arguments[i]; for (var k in src) { dest[k] = src[k]; } } return dest; } function isNil(obj) { return obj == null; } function isNumber(val) { return typeof val === 'number' && !isNaN(val); } function isInteger(n) { return (n | 0) === n; } function isObject(obj) { return (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && !!obj; } function isString(obj) { if (isNil(obj)) { return false; } return typeof obj === 'string' || obj.constructor !== null && obj.constructor === String; } function isFunction(obj) { if (isNil(obj)) { return false; } return typeof obj === 'function' || obj.constructor !== null && obj.constructor === Function; } var hasOwnProperty = Object.prototype.hasOwnProperty; function hasOwn(obj, key) { return hasOwnProperty.call(obj, key); } function join(arr, seperator) { if (arr.join) { return arr.join(seperator || ','); } else { return Array.prototype.join.call(arr, seperator || ','); } } var pi = Math.PI / 180; function toRadian(d) { return d * pi; } function toDegree(r) { return r / pi; } var IS_NODE = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]' && !process.versions['electron'] && !process.versions['nw'] && !process.versions['node-webkit']; var requestAnimFrame = void 0; var cancelAnimFrame = void 0; (function () { if (IS_NODE) { requestAnimFrame = function requestAnimFrame(fn) { return setTimeout(fn, 16); }; cancelAnimFrame = clearTimeout; return; } var requestFn = void 0, cancelFn = void 0; var timeToCall = 1000 / 30; function timeoutDefer(fn) { return setTimeout(fn, timeToCall); } function getPrefixed(name) { return window['webkit' + name] || window['moz' + name] || window['ms' + name]; } if (typeof window != 'undefined') { requestFn = window['requestAnimationFrame'] || getPrefixed('RequestAnimationFrame') || timeoutDefer; cancelFn = window['cancelAnimationFrame'] || getPrefixed('CancelAnimationFrame') || getPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); }; } else { requestFn = timeoutDefer; cancelFn = clearTimeout; } requestAnimFrame = function requestAnimFrame(fn) { return requestFn(fn); }; cancelAnimFrame = function cancelAnimFrame(id) { if (id) { cancelFn(id); } }; })(); function isSVG(url) { var prefix = 'data:image/svg+xml'; if (url.length > 4 && url.slice(-4) === '.svg') { return 1; } else if (url.slice(0, prefix.length) === prefix) { return 2; } return 0; } function loadImage(img, imgDesc) { if (IS_NODE && loadImage.node) { loadImage.node(img, imgDesc); return; } img.src = imgDesc[0]; } var uid = 0; function UID() { return uid++; } var GUID = UID; function parseJSON(str) { if (!str || !isString(str)) { return str; } return JSON.parse(str); } function pushIn(dest) { for (var i = 1; i < arguments.length; i++) { var src = arguments[i]; if (src) { for (var ii = 0, ll = src.length; ii < ll; ii++) { dest.push(src[ii]); } } } return dest.length; } function removeFromArray(obj, array) { var i = array.indexOf(obj); if (i > -1) { array.splice(i, 1); } } function forEachCoord(arr, fn, context) { if (!Array.isArray(arr)) { return context ? fn.call(context, arr) : fn(arr); } var result = []; var p = void 0, pp = void 0; for (var i = 0, len = arr.length; i < len; i++) { p = arr[i]; if (isNil(p)) { result.push(null); continue; } if (Array.isArray(p)) { result.push(forEachCoord(p, fn, context)); } else { pp = context ? fn.call(context, p) : fn(p); result.push(pp); } } return result; } function getValueOrDefault(v, d) { return v === undefined ? d : v; } function sign(x) { if (Math.sign) { return Math.sign(x); } x = +x; if (x === 0 || isNaN(x)) { return Number(x); } return x > 0 ? 1 : -1; } function log2(x) { if (Math.log2) { return Math.log2(x); } var v = Math.log(x) * Math.LOG2E; var rounded = Math.round(v); if (Math.abs(rounded - v) < 1E-14) { return rounded; } else { return v; } } function interpolate(a, b, t) { return a * (1 - t) + b * t; } function wrap(n, min, max) { if (n === max || n === min) { return n; } var d = max - min; var w = ((n - min) % d + d) % d + min; return w; } function clamp(n, min, max) { return Math.min(max, Math.max(min, n)); } function isArrayHasData(obj) { return Array.isArray(obj) && obj.length > 0; } function isURL(url) { if (!url) { return false; } var head = url.slice(0, 6); if (head === 'http:/' || head === 'https:' || head === 'file:/') { return true; } return false; } var cssUrlReWithQuote = /^url\((['"])(.+)\1\)$/i; var cssUrlRe = /^url\(([^'"].*[^'"])\)$/i; function isCssUrl(str) { if (!isString(str)) { return 0; } var head = str.slice(0, 6); if (head === 'http:/' || head === 'https:') { return 3; } if (cssUrlRe.test(str)) { return 1; } if (cssUrlReWithQuote.test(str)) { return 2; } return 0; } function extractCssUrl(str) { var test = isCssUrl(str); var matches = void 0; if (test === 3) { return str; } if (test === 1) { matches = cssUrlRe.exec(str); return matches[1]; } else if (test === 2) { matches = cssUrlReWithQuote.exec(str); return matches[2]; } else { return str; } } var b64chrs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; function btoa(input) { if (typeof window !== 'undefined' && window.btoa) { return window.btoa(input); } var str = String(input); var output = ''; for (var block, charCode, idx = 0, map = b64chrs; str.charAt(idx | 0) || (map = '=', idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) { charCode = str.charCodeAt(idx += 3 / 4); if (charCode > 0xFF) { throw new Error('\'btoa\' failed: The string to be encoded contains characters outside of the Latin1 range.'); } block = block << 8 | charCode; } return output; } function b64toBlob(b64Data, contentType) { var byteCharacters = atob(b64Data); var arraybuffer = new ArrayBuffer(byteCharacters.length); var view = new Uint8Array(arraybuffer); for (var i = 0; i < byteCharacters.length; i++) { view[i] = byteCharacters.charCodeAt(i) & 0xff; } var blob = new Blob([arraybuffer], { type: contentType }); return blob; } function computeDegree(x0, y0, x1, y1) { var dx = x1 - x0; var dy = y1 - y0; return Math.atan2(dy, dx); } var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; function equalMapView(obj1, obj2) { if (!obj1 && !obj2) { return true; } else if (!obj1 || !obj2) { return false; } for (var p in obj1) { if (p === 'center') { if (!obj2[p] || !approx(obj1[p][0], obj2[p][0]) || !approx(obj1[p][1], obj2[p][1])) { return false; } } else if (obj1[p] !== obj2[p]) { return false; } } return true; } function approx(val, expected, delta) { if (delta == null) { delta = 1e-6; } return val >= expected - delta && val <= expected + delta; } function flash(interval, count, cb, context) { if (!interval) { interval = 100; } if (!count) { count = 4; } var me = this; count *= 2; if (this._flashTimeout) { clearTimeout(this._flashTimeout); } function flashGeo() { if (count === 0) { me.show(); if (cb) { if (context) { cb.call(context); } else { cb(); } } return; } if (count % 2 === 0) { me.hide(); } else { me.show(); } count--; me._flashTimeout = setTimeout(flashGeo, interval); } this._flashTimeout = setTimeout(flashGeo, interval); return this; } var types = ['Unknown', 'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection']; function createFilter(filter) { return new Function('f', 'var p = (f && f.properties || {}); return ' + compile(filter)); } function compile(filter) { if (!filter) return 'true'; var op = filter[0]; if (filter.length <= 1) return op === 'any' ? 'false' : 'true'; 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'; return '(' + str + ')'; } function compilePropertyReference(property) { return property[0] === '$' ? 'f.' + property.substring(1) : 'p[' + JSON.stringify(property) + ']'; } function compileComparisonOp(property, value, op, checkType) { var left = compilePropertyReference(property); var right = property === '$type' ? types.indexOf(value) : JSON.stringify(value); return (checkType ? 'typeof ' + left + '=== typeof ' + right + '&&' : '') + left + op + right; } function compileLogicalOp(expressions, op) { return expressions.map(compile).join(op); } function compileInOp(property, values) { if (property === '$type') values = values.map(function (value) { return types.indexOf(value); }); var left = JSON.stringify(values.sort(compare)); var right = compilePropertyReference(property); if (values.length <= 200) return left + '.indexOf(' + right + ') !== -1'; return '' + ('function(v, a, i, j) {' + 'while (i <= j) { var m = (i + j) >> 1;' + ' if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;' + '}' + 'return false; }(') + right + ', ' + left + ',0,' + (values.length - 1) + ')'; } function compileHasOp(property) { return property === '$id' ? '"id" in f' : JSON.stringify(property) + ' in p'; } function compileNegation(expression) { return '!(' + expression + ')'; } function compare(a, b) { return a < b ? -1 : a > b ? 1 : 0; } function getFilterFeature(geometry) { var json = geometry._toJSON(), g = json['feature']; g['type'] = types.indexOf(g['geometry']['type']); g['subType'] = json['subType']; return g; } function compileStyle(styles) { if (!Array.isArray(styles)) { return compileStyle([styles]); } var compiled = []; for (var i = 0; i < styles.length; i++) { var filter = void 0; if (styles[i]['filter'] === true) { filter = function filter() { return true; }; } else { filter = createFilter(styles[i]['filter']); } compiled.push(extend({}, styles[i], { filter: filter })); } return compiled; } function createFunction(parameters, defaultType) { var fun; if (!isFunctionDefinition(parameters)) { fun = function fun() { return parameters; }; fun.isFeatureConstant = true; fun.isZoomConstant = true; } else { var zoomAndFeatureDependent = parameters.stops && _typeof(parameters.stops[0][0]) === 'object'; var featureDependent = zoomAndFeatureDependent || parameters.property !== undefined; var zoomDependent = zoomAndFeatureDependent || !featureDependent; var type = parameters.type || defaultType || 'exponential'; var innerFun; if (type === 'exponential') { innerFun = evaluateExponentialFunction; } else if (type === 'interval') { innerFun = evaluateIntervalFunction; } else if (type === 'categorical') { innerFun = evaluateCategoricalFunction; } else if (type === 'identity') { innerFun = evaluateIdentityFunction; } else { throw new Error('Unknown function type "' + type + '"'); } if (zoomAndFeatureDependent) { var featureFunctions = {}; var featureFunctionStops = []; for (var s = 0; s < parameters.stops.length; s++) { var stop = parameters.stops[s]; if (featureFunctions[stop[0].zoom] === undefined) { featureFunctions[stop[0].zoom] = { zoom: stop[0].zoom, type: parameters.type, property: parameters.property, stops: [] }; } featureFunctions[stop[0].zoom].stops.push([stop[0].value, stop[1]]); } for (var z in featureFunctions) { featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z])]); } fun = function fun(zoom, feature) { return evaluateExponentialFunction({ stops: featureFunctionStops, base: parameters.base }, zoom)(zoom, feature); }; fun.isFeatureConstant = false; fun.isZoomConstant = false; } else if (zoomDependent) { fun = function fun(zoom) { return innerFun(parameters, zoom); }; fun.isFeatureConstant = true; fun.isZoomConstant = false; } else { fun = function fun(zoom, feature) { return innerFun(parameters, feature[parameters.property]); }; fun.isFeatureConstant = false; fun.isZoomConstant = true; } } return fun; } function evaluateCategoricalFunction(parameters, input) { for (var i = 0; i < parameters.stops.length; i++) { if (input === parameters.stops[i][0]) { return parameters.stops[i][1]; } } return parameters.stops[0][1]; } function evaluateIntervalFunction(parameters, input) { for (var i = 0; i < parameters.stops.length; i++) { if (input < parameters.stops[i][0]) break; } return parameters.stops[Math.max(i - 1, 0)][1]; } function evaluateExponentialFunction(parameters, input) { var base = parameters.base !== undefined ? parameters.base : 1; var i = 0; while (true) { if (i >= parameters.stops.length) break;else if (input <= parameters.stops[i][0]) break;else i++; } if (i === 0) { return parameters.stops[i][1]; } else if (i === parameters.stops.length) { return parameters.stops[i - 1][1]; } else { return interpolate$1(input, base, parameters.stops[i - 1][0], parameters.stops[i][0], parameters.stops[i - 1][1], parameters.stops[i][1]); } } function evaluateIdentityFunction(parameters, input) { return input; } function interpolate$1(input, base, inputLower, inputUpper, outputLower, outputUpper) { if (typeof outputLower === 'function') { return function () { var evaluatedLower = outputLower.apply(undefined, arguments); var evaluatedUpper = outputUpper.apply(undefined, arguments); return interpolate$1(input, base, inputLower, inputUpper, evaluatedLower, evaluatedUpper); }; } else if (outputLower.length) { return interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper); } else { return interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper); } } function interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper) { var difference = inputUpper - inputLower; var progress = input - inputLower; var ratio; if (base === 1) { ratio = progress / difference; } else { ratio = (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1); } return outputLower * (1 - ratio) + outputUpper * ratio; } function interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper) { var output = []; for (var i = 0; i < outputLower.length; i++) { output[i] = interpolateNumber(input, base, inputLower, inputUpper, outputLower[i], outputUpper[i]); } return output; } function isFunctionDefinition(obj) { return obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && (obj.stops || obj.property && obj.type === 'identity'); } function hasFunctionDefinition(obj) { for (var p in obj) { if (isFunctionDefinition(obj[p])) { return true; } } return false; } function interpolated(parameters) { return createFunction(parameters, 'exponential'); } function piecewiseConstant(parameters) { return createFunction(parameters, 'interval'); } function loadFunctionTypes(obj, argFn) { if (!obj) { return null; } var hit = false; if (Array.isArray(obj)) { var multResult = [], loaded; for (var i = 0; i < obj.length; i++) { loaded = loadFunctionTypes(obj[i], argFn); if (!loaded) { multResult.push(obj[i]); } else { multResult.push(loaded); hit = true; } } return hit ? multResult : obj; } var result = { '__fn_types_loaded': true }, props = [], p; for (p in obj) { if (obj.hasOwnProperty(p)) { props.push(p); } } for (var _i = 0, len = props.length; _i < len; _i++) { p = props[_i]; if (isFunctionDefinition(obj[p])) { hit = true; result['_' + p] = obj[p]; (function (_p) { Object.defineProperty(result, _p, { get: function get$$1() { if (!this['__fn_' + _p]) { this['__fn_' + _p] = interpolated(this['_' + _p]); } return this['__fn_' + _p].apply(this, argFn()); }, set: function set$$1(v) { this['_' + _p] = v; }, configurable: true, enumerable: true }); })(p); } else { result[p] = obj[p]; } } return hit ? result : obj; } function getFunctionTypeResources(t) { if (!t || !t.stops) { return []; } var res = []; for (var i = 0, l = t.stops.length; i < l; i++) { res.push(t.stops[i][1]); } return res; } var index$1 = Object.freeze({ createFilter: createFilter, getFilterFeature: getFilterFeature, compileStyle: compileStyle, isFunctionDefinition: isFunctionDefinition, hasFunctionDefinition: hasFunctionDefinition, interpolated: interpolated, piecewiseConstant: piecewiseConstant, loadFunctionTypes: loadFunctionTypes, getFunctionTypeResources: getFunctionTypeResources }); function translateToSVGStyles(s) { var result = { 'stroke': { 'stroke': s['markerLineColor'], 'stroke-width': s['markerLineWidth'], 'stroke-opacity': s['markerLineOpacity'], 'stroke-dasharray': null, 'stroke-linecap': 'butt', 'stroke-linejoin': 'round' }, 'fill': { 'fill': s['markerFill'], 'fill-opacity': s['markerFillOpacity'] } }; if (result['stroke']['stroke-linecap'] === 'butt') { if (Browser$1.vml) { result['stroke']['stroke-linecap'] = 'flat'; } } if (result['stroke']['stroke-width'] === 0) { result['stroke']['stroke-opacity'] = 0; } return result; } function getMarkerPathBase64(symbol, width, height) { if (!symbol['markerPath']) { return null; } var op = 1; var styles = translateToSVGStyles(symbol); if (isNumber(symbol['markerOpacity'])) { op = symbol['markerOpacity']; } if (isNumber(symbol['opacity'])) { op *= symbol['opacity']; } var svgStyles = {}; if (styles) { for (var p in styles['stroke']) { if (styles['stroke'].hasOwnProperty(p)) { if (!isNil(styles['stroke'][p])) { svgStyles[p] = styles['stroke'][p]; } } } for (var _p in styles['fill']) { if (styles['fill'].hasOwnProperty(_p)) { if (!isNil(styles['fill'][_p])) { svgStyles[_p] = styles['fill'][_p]; } } } } var pathes = Array.isArray(symbol['markerPath']) ? symbol['markerPath'] : [symbol['markerPath']]; var path = void 0; var pathesToRender = []; for (var i = 0; i < pathes.length; i++) { path = isString(pathes[i]) ? { 'path': pathes[i] } : pathes[i]; path = extend({}, path, svgStyles); path['d'] = path['path']; delete path['path']; pathesToRender.push(path); } var svg = ['<svg version="1.1"', 'xmlns="http://www.w3.org/2000/svg"']; if (op < 1) { svg.push('opacity="' + op + '"'); } if (symbol['markerPathWidth'] && symbol['markerPathHeight']) { svg.push('viewBox="0 0 ' + symbol['markerPathWidth'] + ' ' + symbol['markerPathHeight'] + '"'); } svg.push('preserveAspectRatio="none"'); if (width) { svg.push('width="' + width + '"'); } if (height) { svg.push('height="' + height + '"'); } svg.push('><defs></defs>'); for (var _i = 0; _i < pathesToRender.length; _i++) { var strPath = '<path '; for (var _p2 in pathesToRender[_i]) { if (pathesToRender[_i].hasOwnProperty(_p2)) { strPath += ' ' + _p2 + '="' + pathesToRender[_i][_p2] + '"'; } } strPath += '></path>'; svg.push(strPath); } svg.push('</svg>'); var b64 = 'data:image/svg+xml;base64,' + btoa(svg.join(' ')); return b64; } function getExternalResources(symbol, toAbsolute) { if (!symbol) { return []; } var symbols = symbol; if (!Array.isArray(symbol)) { symbols = [symbol]; } var resources = []; var props = RESOURCE_PROPERTIES; var res = void 0, resSizeProp = void 0; var w = void 0, h = void 0; for (var i = symbols.length - 1; i >= 0; i--) { symbol = symbols[i]; if (!symbol) { continue; } if (toAbsolute) { symbol = convertResourceUrl(symbol); } for (var ii = 0; ii < props.length; ii++) { res = symbol[props[ii]]; if (isFunctionDefinition(res)) { res = getFunctionTypeResources(res); } if (!res) { continue; } if (!Array.isArray(res)) { res = [res]; } for (var iii = 0; iii < res.length; iii++) { if (res[iii].slice(0, 4) === 'url(') { res[iii] = extractCssUrl(res[iii]); } resSizeProp = RESOURCE_SIZE_PROPERTIES[ii]; resources.push([res[iii], symbol[resSizeProp[0]], symbol[resSizeProp[1]]]); } } if (symbol['markerType'] === 'path' && symbol['markerPath']) { w = isFunctionDefinition(symbol['markerWidth']) ? 200 : symbol['markerWidth']; h = isFunctionDefinition(symbol['markerHeight']) ? 200 : symbol['markerHeight']; if (isFunctionDefinition(symbol['markerPath'])) { res = getFunctionTypeResources(symbol['markerPath']); var path = symbol['markerPath']; for (var _iii = 0; _iii < res.length; _iii++) { symbol['markerPath'] = res[_iii]; resources.push([getMarkerPathBase64(symbol), w, h]); } symbol['markerPath'] = path; } else { resources.push([getMarkerPathBase64(symbol), w, h]); } } } return resources; } function convertResourceUrl(symbol) { if (!symbol) { return null; } var s = symbol; if (IS_NODE) { return s; } var props = RESOURCE_PROPERTIES; var res = void 0; for (var ii = 0, len = props.length; ii < len; ii++) { res = s[props[ii]]; if (!res) { continue; } s[props[ii]] = _convertUrlToAbsolute(res); } return s; } function _convertUrlToAbsolute(res) { if (isFunctionDefinition(res)) { var stops = res.stops; for (var i = 0; i < stops.length; i++) { stops[i][1] = _convertUrlToAbsolute(stops[i][1]); } return res; } var embed = 'data:'; if (res.slice(0, 4) === 'url(') { res = extractCssUrl(res); } if (!isURL(res) && (res.length <= embed.length || res.substring(0, embed.length) !== embed)) { res = _absolute(location.href, res); } return res; } function _absolute(base, relative) { var stack = base.split('/'), parts = relative.split('/'); if (relative.slice(0, 1) === 0) { return stack.slice(0, 3).join('/') + relative; } else { stack.pop(); for (var i = 0; i < parts.length; i++) { if (parts[i] === '.') continue; if (parts[i] === '..') stack.pop();else stack.push(parts[i]); } return stack.join('/'); } } function isGradient(g) { return g && g['colorStops']; } function getGradientStamp(g) { var keys = [g['type']]; if (g['places']) { keys.push(g['places'].join()); } if (g['colorStops']) { var stops = []; for (var i = g['colorStops'].length - 1; i >= 0; i--) { stops.push(g['colorStops'][i].join()); } keys.push(stops.join(',')); } return keys.join('_'); } function getSymbolStamp(symbol) { var keys = []; if (Array.isArray(symbol)) { for (var i = 0; i < symbol.length; i++) { keys.push(getSymbolStamp(symbol[i])); } return '[ ' + keys.join(' , ') + ' ]'; } for (var p in symbol) { if (hasOwn(symbol, p)) { if (!isFunction(symbol[p])) { if (isGradient(symbol[p])) { keys.push(p + '=' + getGradientStamp(symbol[p])); } else { keys.push(p + '=' + symbol[p]); } } } } return keys.join(';'); } function lowerSymbolOpacity(symbol, ratio) { function s(_symbol, _ratio) { var op = _symbol['opacity']; if (isNil(op)) { _symbol['opacity'] = _ratio; } else { _symbol['opacity'] *= _ratio; } } var lower = void 0; if (Array.isArray(symbol)) { lower = []; for (var i = 0; i < symbol.length; i++) { var d = extend({}, symbol[i]); s(d, ratio); lower.push(d); } } else { lower = extend({}, symbol); s(lower, ratio); } return lower; } function extendSymbol(symbol) { var sources = Array.prototype.slice.call(arguments, 1); if (!sources || !sources.length) { sources = [{}]; } if (Array.isArray(symbol)) { var s = void 0, dest = void 0; var result = []; for (var i = 0, l = symbol.length; i < l; i++) { s = symbol[i]; dest = {}; for (var ii = 0, ll = sources.length; ii < ll; ii++) { if (!Array.isArray(sources[ii])) { extend(dest, s, sources[ii] ? sources[ii] : {}); } else if (!isNil(sources[ii][i])) { extend(dest, s, sources[ii][i]); } else { extend(dest, s ? s : {}); } } result.push(dest); } return result; } else { var args = [{}, symbol]; args.push.apply(args, sources); return extend.apply(this, args); } } var index = Object.freeze({ now: now, extend: extend, isNil: isNil, isNumber: isNumber, isInteger: isInteger, isObject: isObject, isString: isString, isFunction: isFunction, hasOwn: hasOwn, join: join, toRadian: toRadian, toDegree: toDegree, IS_NODE: IS_NODE, get requestAnimFrame () { return requestAnimFrame; }, get cancelAnimFrame () { return cancelAnimFrame; }, isSVG: isSVG, loadImage: loadImage, UID: UID, GUID: GUID, parseJSON: parseJSON, pushIn: pushIn, removeFromArray: removeFromArray, forEachCoord: forEachCoord, getValueOrDefault: getValueOrDefault, sign: sign, log2: log2, interpolate: interpolate, wrap: wrap, clamp: clamp, isArrayHasData: isArrayHasData, isURL: isURL, isCssUrl: isCssUrl, extractCssUrl: extractCssUrl, btoa: btoa, b64toBlob: b64toBlob, computeDegree: computeDegree, emptyImageUrl: emptyImageUrl, equalMapView: equalMapView, flash: flash, translateToSVGStyles: translateToSVGStyles, getMarkerPathBase64: getMarkerPathBase64, getExternalResources: getExternalResources, convertResourceUrl: convertResourceUrl, isGradient: isGradient, getGradientStamp: getGradientStamp, getSymbolStamp: getSymbolStamp, lowerSymbolOpacity: lowerSymbolOpacity, extendSymbol: extendSymbol }); var Browser = {}; if (!IS_NODE) { var ua = navigator.userAgent.toLowerCase(), doc = document.documentElement, ie = 'ActiveXObject' in window, webkit = ua.indexOf('webkit') !== -1, phantomjs = ua.indexOf('phantom') !== -1, android23 = ua.search('android [23]') !== -1, chrome = ua.indexOf('chrome') !== -1, gecko = ua.indexOf('gecko') !== -1 && !webkit && !window.opera && !ie, mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1, msPointer = !window.PointerEvent && window.MSPointerEvent, pointer = window.PointerEvent && navigator.pointerEnabled || msPointer, ie3d = ie && 'transition' in doc.style, webkit3d = 'WebKitCSSMatrix' in window && 'm11' in new window.WebKitCSSMatrix() && !android23, gecko3d = 'MozPerspective' in doc.style, opera12 = 'OTransition' in doc.style, any3d = (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs; var chromeVersion = 0; if (chrome) { chromeVersion = ua.match(/chrome\/([\d.]+)/)[1]; } var touch = !phantomjs && (pointer || 'ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch); var webgl = void 0; try { var canvas = document.createElement('canvas'); var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); webgl = gl && gl instanceof WebGLRenderingContext; } catch (err) { webgl = false; } Browser = { ie: ie, ielt9: ie && !document.addEventListener, edge: 'msLaunchUri' in navigator && !('documentMode' in document), webkit: webkit, gecko: gecko, android: ua.indexOf('android') !== -1, android23: android23, chrome: chrome, chromeVersion: chromeVersion, safari: !chrome && ua.indexOf('safari') !== -1, phantomjs: phantomjs, ie3d: ie3d, webkit3d: webkit3d, gecko3d: gecko3d, opera12: opera12, any3d: any3d, mobile: mobile, mobileWebkit: mobile && webkit, mobileWebkit3d: mobile && webkit3d, mobileOpera: mobile && window.opera, mobileGecko: mobile && gecko, touch: !!touch, msPointer: !!msPointer, pointer: !!pointer, retina: (window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI) > 1, language: navigator.browserLanguage ? navigator.browserLanguage : navigator.language, ie9: ie && document.documentMode === 9, ie10: ie && document.documentMode === 10, webgl: webgl }; } var Browser$1 = Browser; var Position = function () { function Position(x, y) { classCallCheck(this, Position); if (!isNil(x) && !isNil(y)) { this.x = +x; this.y = +y; } else if (!isNil(x.x) && !isNil(x.y)) { this.x = +x.x; this.y = +x.y; } else if (Array.isArray(x)) { this.x = +x[0]; this.y = +x[1]; } if (this._isNaN()) { throw new Error('Position is NaN'); } } Position.prototype.abs = function abs() { return new this.constructor(Math.abs(this.x), Math.abs(this.y)); }; Position.prototype._abs = function _abs() { this.x = Math.abs(this.x); this.y = Math.abs(this.y); return this; }; Position.prototype._round = function _round() { this.x = Math.round(this.x); this.y = Math.round(this.y); return this; }; Position.prototype.round = function round() { return new this.constructor(Math.round(this.x), Math.round(this.y)); }; Position.prototype._ceil = function _ceil() { this.x = Math.ceil(this.x); this.y = Math.ceil(this.y); return this; }; Position.prototype.ceil = function ceil() { return new this.constructor(Math.ceil(this.x), Math.ceil(this.y)); }; Position.prototype._floor = function _floor() { this.x = Math.floor(this.x); this.y = Math.floor(this.y); return this; }; Position.prototype.floor = function floor() { return new this.constructor(Math.floor(this.x), Math.floor(this.y)); }; Position.prototype.copy = function copy() { return new this.constructor(this.x, this.y); }; Position.prototype._add = function _add(x, y) { if (!isNil(x.x)) { this.x += x.x; this.y += x.y; } else if (!isNil(x[0])) { this.x += x[0]; this.y += x[1]; } else { this.x += x; this.y += y; } return this; }; Position.prototype.add = function add(x, y) { var nx = void 0, ny = void 0; if (!isNil(x.x)) { nx = this.x + x.x; ny = this.y + x.y; } else if (!isNil(x[0])) { nx = this.x + x[0]; ny = this.y + x[1]; } else { nx = this.x + x; ny = this.y + y; } return new this.constructor(nx, ny); }; Position.prototype._sub = function _sub(x, y) { if (!isNil(x.x)) { this.x -= x.x; this.y -= x.y; } else if (!isNil(x[0])) { this.x -= x[0]; this.y -= x[1]; } else { this.x -= x; this.y -= y; } return this; }; Position.prototype._substract = function _substract() { return this._sub.apply(this, arguments); }; Position.prototype.sub = function sub(x, y) { var nx = void 0, ny = void 0; if (!isNil(x.x)) { nx = this.x - x.x; ny = this.y - x.y; } else if (!isNil(x[0])) { nx = this.x - x[0]; ny = this.y - x[1]; } else { nx = this.x - x; ny = this.y - y; } return new this.constructor(nx, ny); }; Position.prototype.substract = function substract() { return this.sub.apply(this, arguments); }; Position.prototype.multi = function multi(ratio) { return new this.constructor(this.x * ratio, this.y * ratio); }; Position.prototype._multi = function _multi(ratio) { this.x *= ratio; this.y *= ratio; return this; }; Position.prototype.div = function div(n) { return this.multi(1 / n); }; Position.prototype._div = function _div(n) { return this._multi(1 / n); }; Position.prototype.equals = function equals(c) { if (!(c instanceof this.constructor)) { return false; } return this.x === c.x && this.y === c.y; }; Position.prototype._isNaN = function _isNaN() { return isNaN(this.x) || isNaN(this.y); }; Position.prototype.isZero = function isZero() { return this.x === 0 && this.y === 0; }; Position.prototype.toArray = function toArray$$1() { return [this.x, this.y]; }; Position.prototype.toFixed = function toFixed(n) { return new this.constructor(this.x.toFixed(n), this.y.toFixed(n)); }; Position.prototype.toJSON = function toJSON() { return { x: this.x, y: this.y }; }; return Position; }(); var Point = function (_Position) { inherits(Point, _Position); function Point() { classCallCheck(this, Point); return possibleConstructorReturn(this, _Position.apply(this, arguments)); } Point.prototype.closeTo = function closeTo(p, delta) { if (!delta) { delta = 0; } return this.x >= p.x - delta && this.x <= p.x + delta && this.y >= p.y - delta && this.y <= p.y + delta; }; Point.prototype.distanceTo = function distanceTo(point) { var x = point.x - this.x, y = point.y - this.y; return Math.sqrt(x * x + y * y); }; Point.prototype.mag = funct