UNPKG

@sakitam-gis/react-map

Version:
1,631 lines (1,319 loc) 1.05 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/ */ module.exports = /******/ (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 = 24); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { var freeGlobal = __webpack_require__(14); /** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function('return this')(); module.exports = root; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { var baseIsNative = __webpack_require__(38), getValue = __webpack_require__(43); /** * Gets the native function at `key` of `object`. * * @private * @param {Object} object The object to query. * @param {string} key The key of the method to get. * @returns {*} Returns the function if it's native, else `undefined`. */ function getNative(object, key) { var value = getValue(object, key); return baseIsNative(value) ? value : undefined; } module.exports = getNative; /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { var listCacheClear = __webpack_require__(28), listCacheDelete = __webpack_require__(29), listCacheGet = __webpack_require__(30), listCacheHas = __webpack_require__(31), listCacheSet = __webpack_require__(32); /** * Creates an list cache object. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function ListCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `ListCache`. ListCache.prototype.clear = listCacheClear; ListCache.prototype['delete'] = listCacheDelete; ListCache.prototype.get = listCacheGet; ListCache.prototype.has = listCacheHas; ListCache.prototype.set = listCacheSet; module.exports = ListCache; /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { var eq = __webpack_require__(12); /** * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private * @param {Array} array The array to inspect. * @param {*} key The key to search for. * @returns {number} Returns the index of the matched value, else `-1`. */ function assocIndexOf(array, key) { var length = array.length; while (length--) { if (eq(array[length][0], key)) { return length; } } return -1; } module.exports = assocIndexOf; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { var Symbol = __webpack_require__(9), getRawTag = __webpack_require__(39), objectToString = __webpack_require__(40); /** `Object#toString` result references. */ var nullTag = '[object Null]', undefinedTag = '[object Undefined]'; /** Built-in value references. */ var symToStringTag = Symbol ? Symbol.toStringTag : undefined; /** * The base implementation of `getTag` without fallbacks for buggy environments. * * @private * @param {*} value The value to query. * @returns {string} Returns the `toStringTag`. */ function baseGetTag(value) { if (value == null) { return value === undefined ? undefinedTag : nullTag; } return (symToStringTag && symToStringTag in Object(value)) ? getRawTag(value) : objectToString(value); } module.exports = baseGetTag; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { var getNative = __webpack_require__(1); /* Built-in method references that are verified to be native. */ var nativeCreate = getNative(Object, 'create'); module.exports = nativeCreate; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { var isKeyable = __webpack_require__(52); /** * Gets the data for `map`. * * @private * @param {Object} map The map to query. * @param {string} key The reference key. * @returns {*} Returns the map data. */ function getMapData(map, key) { var data = map.__data__; return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map; } module.exports = getMapData; /***/ }), /* 7 */ /***/ (function(module, exports) { /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. * @example * * _.isObjectLike({}); * // => true * * _.isObjectLike([1, 2, 3]); * // => true * * _.isObjectLike(_.noop); * // => false * * _.isObjectLike(null); * // => false */ function isObjectLike(value) { return value != null && typeof value == 'object'; } module.exports = isObjectLike; /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { var getNative = __webpack_require__(1), root = __webpack_require__(0); /* Built-in method references that are verified to be native. */ var Map = getNative(root, 'Map'); module.exports = Map; /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { var root = __webpack_require__(0); /** Built-in value references. */ var Symbol = root.Symbol; module.exports = Symbol; /***/ }), /* 10 */ /***/ (function(module, exports) { /** * Checks if `value` is classified as an `Array` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array, else `false`. * @example * * _.isArray([1, 2, 3]); * // => true * * _.isArray(document.body.children); * // => false * * _.isArray('abc'); * // => false * * _.isArray(_.noop); * // => false */ var isArray = Array.isArray; module.exports = isArray; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * 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. */ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; module.exports = ReactPropTypesSecret; /***/ }), /* 12 */ /***/ (function(module, exports) { /** * Performs a * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * var object = { 'a': 1 }; * var other = { 'a': 1 }; * * _.eq(object, object); * // => true * * _.eq(object, other); * // => false * * _.eq('a', 'a'); * // => true * * _.eq('a', Object('a')); * // => false * * _.eq(NaN, NaN); * // => true */ function eq(value, other) { return value === other || (value !== value && other !== other); } module.exports = eq; /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(4), isObject = __webpack_require__(16); /** `Object#toString` result references. */ var asyncTag = '[object AsyncFunction]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', proxyTag = '[object Proxy]'; /** * Checks if `value` is classified as a `Function` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a function, else `false`. * @example * * _.isFunction(_); * // => true * * _.isFunction(/abc/); * // => false */ function isFunction(value) { if (!isObject(value)) { return false; } // The use of `Object#toString` avoids issues with the `typeof` operator // in Safari 9 which returns 'object' for typed arrays and other constructors. var tag = baseGetTag(value); return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } module.exports = isFunction; /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {/** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; module.exports = freeGlobal; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(15))) /***/ }), /* 15 */ /***/ (function(module, exports) { var g; // This works in non-strict mode g = (function() { return this; })(); try { // This works if eval is allowed (see CSP) g = g || Function("return this")() || (1,eval)("this"); } catch(e) { // This works if the window reference is available if(typeof window === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /* 16 */ /***/ (function(module, exports) { /** * Checks if `value` is the * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an object, else `false`. * @example * * _.isObject({}); * // => true * * _.isObject([1, 2, 3]); * // => true * * _.isObject(_.noop); * // => true * * _.isObject(null); * // => false */ function isObject(value) { var type = typeof value; return value != null && (type == 'object' || type == 'function'); } module.exports = isObject; /***/ }), /* 17 */ /***/ (function(module, exports) { /** Used for built-in method references. */ var funcProto = Function.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** * Converts `func` to its source code. * * @private * @param {Function} func The function to convert. * @returns {string} Returns the source code. */ function toSource(func) { if (func != null) { try { return funcToString.call(func); } catch (e) {} try { return (func + ''); } catch (e) {} } return ''; } module.exports = toSource; /***/ }), /* 18 */ /***/ (function(module, exports, __webpack_require__) { var mapCacheClear = __webpack_require__(44), mapCacheDelete = __webpack_require__(51), mapCacheGet = __webpack_require__(53), mapCacheHas = __webpack_require__(54), mapCacheSet = __webpack_require__(55); /** * Creates a map cache object to store key-value pairs. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function MapCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `MapCache`. MapCache.prototype.clear = mapCacheClear; MapCache.prototype['delete'] = mapCacheDelete; MapCache.prototype.get = mapCacheGet; MapCache.prototype.has = mapCacheHas; MapCache.prototype.set = mapCacheSet; module.exports = MapCache; /***/ }), /* 19 */ /***/ (function(module, exports, __webpack_require__) { var SetCache = __webpack_require__(56), arraySome = __webpack_require__(59), cacheHas = __webpack_require__(60); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** * A specialized version of `baseIsEqualDeep` for arrays with support for * partial deep comparisons. * * @private * @param {Array} array The array to compare. * @param {Array} other The other array to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `array` and `other` objects. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length; if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } // Assume cyclic values are equal. var stacked = stack.get(array); if (stacked && stack.get(other)) { return stacked == other; } var index = -1, result = true, seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; stack.set(array, other); stack.set(other, array); // Ignore non-index properties. while (++index < arrLength) { var arrValue = array[index], othValue = other[index]; if (customizer) { var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); } if (compared !== undefined) { if (compared) { continue; } result = false; break; } // Recursively compare arrays (susceptible to call stack limits). if (seen) { if (!arraySome(other, function(othValue, othIndex) { if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { return seen.push(othIndex); } })) { result = false; break; } } else if (!( arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack) )) { result = false; break; } } stack['delete'](array); stack['delete'](other); return result; } module.exports = equalArrays; /***/ }), /* 20 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(module) {var root = __webpack_require__(0), stubFalse = __webpack_require__(77); /** Detect free variable `exports`. */ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; /** * Checks if `value` is a buffer. * * @static * @memberOf _ * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. * @example * * _.isBuffer(new Buffer(2)); * // => true * * _.isBuffer(new Uint8Array(2)); * // => false */ var isBuffer = nativeIsBuffer || stubFalse; module.exports = isBuffer; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(21)(module))) /***/ }), /* 21 */ /***/ (function(module, exports) { module.exports = function(module) { if(!module.webpackPolyfill) { module.deprecate = function() {}; module.paths = []; // module.parent = undefined by default if(!module.children) module.children = []; Object.defineProperty(module, "loaded", { enumerable: true, get: function() { return module.l; } }); Object.defineProperty(module, "id", { enumerable: true, get: function() { return module.i; } }); module.webpackPolyfill = 1; } return module; }; /***/ }), /* 22 */ /***/ (function(module, exports, __webpack_require__) { var baseIsTypedArray = __webpack_require__(79), baseUnary = __webpack_require__(80), nodeUtil = __webpack_require__(81); /* Node.js helper references. */ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; /** * Checks if `value` is classified as a typed array. * * @static * @memberOf _ * @since 3.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. * @example * * _.isTypedArray(new Uint8Array); * // => true * * _.isTypedArray([]); * // => false */ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; module.exports = isTypedArray; /***/ }), /* 23 */ /***/ (function(module, exports) { /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; /** * Checks if `value` is a valid array-like length. * * **Note:** This method is loosely based on * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. * @example * * _.isLength(3); * // => true * * _.isLength(Number.MIN_VALUE); * // => false * * _.isLength(Infinity); * // => false * * _.isLength('3'); * // => false */ function isLength(value) { return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } module.exports = isLength; /***/ }), /* 24 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); // EXTERNAL MODULE: ./node_modules/maptalks/dist/maptalks.css var maptalks = __webpack_require__(97); var maptalks_default = /*#__PURE__*/__webpack_require__.n(maptalks); // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"} var external___root___React___commonjs2___react___commonjs___react___amd___react__ = __webpack_require__(98); var external___root___React___commonjs2___react___commonjs___react___amd___react___default = /*#__PURE__*/__webpack_require__.n(external___root___React___commonjs2___react___commonjs___react___amd___react__); // EXTERNAL MODULE: ./node_modules/lodash/isEqual.js var isEqual = __webpack_require__(99); var isEqual_default = /*#__PURE__*/__webpack_require__.n(isEqual); // EXTERNAL MODULE: ./node_modules/prop-types/index.js var prop_types = __webpack_require__(100); var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types); // EXTERNAL MODULE: ./node_modules/maptalks/dist/maptalks.es.js var maptalks_es = __webpack_require__(101); // CONCATENATED MODULE: ./src/map/index.js var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var map_Map = function (_React$Component) { _inherits(Map, _React$Component); function Map(props) { _classCallCheck(this, Map); var _this = _possibleConstructorReturn(this, (Map.__proto__ || Object.getPrototypeOf(Map)).call(this, props)); _this.setRef = function () { var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; _this.container = x; }; _this.state = { isLoad: false, isMounted: false }; /** * map * @type {null} */ _this.map = null; _this.container = null; _this.events = {}; return _this; } _createClass(Map, [{ key: 'getChildContext', value: function getChildContext() { return { map: this.map }; } // shouldComponentUpdate (nextProps) { // // const { isMounted } = this.state; // const { children } = nextProps; // return children.length > 0; // } // componentWillUpdate(nextProps, nextState) // componentDidUpdate(prevProps, prevState) }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { var _props = this.props, center = _props.center, zoom = _props.zoom, spatialReference = _props.spatialReference, cursor = _props.cursor, maxExtent = _props.maxExtent, maxZoom = _props.maxZoom, minZoom = _props.minZoom, pitch = _props.pitch, bearing = _props.bearing, fov = _props.fov; if (!this.map) { return null; } if (!isEqual_default()(nextProps.center, center) || !isEqual_default()(nextProps.zoom, zoom)) { if (!isEqual_default()(nextProps.center, center) && isEqual_default()(nextProps.zoom, zoom)) { this.map.setCenter(nextProps.center); } if (isEqual_default()(nextProps.center, center) && !isEqual_default()(nextProps.zoom, zoom)) { this.map.setZoom(nextProps.zoom); } if (!isEqual_default()(nextProps.center, center) && !isEqual_default()(nextProps.zoom, zoom)) { this.map.setCenterAndZoom(nextProps.center, nextProps.zoom); } } if (!isEqual_default()(nextProps.spatialReference, spatialReference)) { this.map.setSpatialReference(nextProps.zoom); } if (!isEqual_default()(nextProps.cursor, cursor)) { this.map.setCursor(nextProps.cursor); } if (!isEqual_default()(nextProps.maxExtent, maxExtent)) { this.map.setMaxExtent(nextProps.maxExtent); } if (!isEqual_default()(nextProps.maxZoom, maxZoom)) { this.map.setMaxZoom(nextProps.maxZoom); } if (!isEqual_default()(nextProps.minZoom, minZoom)) { this.map.setMinZoom(nextProps.minZoom); } if (!isEqual_default()(nextProps.fov, fov)) { this.map.setFov(nextProps.fov); } if (!isEqual_default()(nextProps.bearing, bearing)) { this.map.setBearing(nextProps.bearing); } if (!isEqual_default()(nextProps.pitch, pitch)) { this.map.setPitch(nextProps.pitch); } return null; } /** * set base layers * @param layers * @returns {null} */ }, { key: 'setBaseLayer', value: function setBaseLayer(layers) { if (!this.map) { return null; } if (layers && layers.length > 0) { this.map.setBaseLayer(); } } /** * set layers * @param layers * @returns {null} */ }, { key: 'setLayers', value: function setLayers(layers) { if (!this.map) { return null; } if (layers && layers.length > 0) { // map.addLayer(); } } }, { key: 'componentDidMount', value: function componentDidMount() { var _props2 = this.props, center = _props2.center, zoom = _props2.zoom, events = _props2.events, fov = _props2.fov, bearing = _props2.bearing, pitch = _props2.pitch; var options = { zoom: zoom, center: center, fov: Math.max(0.01, Math.min(59, fov)), bearing: bearing, pitch: pitch }; this.map = new maptalks_es["e" /* Map */](this.container, options); if (this.map.isLoaded()) { this.setState({ isLoad: true }); for (var key in events) { if (key === 'onload') { events[key](this.map, this); } else { this.map.on(key, events[key], this); } } } this.setState({ isMounted: true }); } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { if (this.map) { this.map = null; this.setState({ isMounted: false }); } } }, { key: 'render', value: function render() { var _state = this.state, isMounted = _state.isMounted, isLoad = _state.isLoad; var _props3 = this.props, className = _props3.className, children = _props3.children; return external___root___React___commonjs2___react___commonjs___react___amd___react___default.a.createElement( 'div', { ref: this.setRef, className: className }, isMounted && isLoad ? children : null ); } }]); return Map; }(external___root___React___commonjs2___react___commonjs___react___amd___react___default.a.Component); map_Map.defaultProps = {}; map_Map.childContextTypes = { map: prop_types_default.a.instanceOf(maptalks_es["e" /* Map */]) }; /* harmony default export */ var src_map = (map_Map); // CONCATENATED MODULE: ./src/layers/Layer.js var Layer__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function Layer__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function Layer__possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function Layer__inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Layer_TileLayer = function (_React$Component) { Layer__inherits(TileLayer, _React$Component); function TileLayer(props, context) { Layer__classCallCheck(this, TileLayer); var _this = Layer__possibleConstructorReturn(this, (TileLayer.__proto__ || Object.getPrototypeOf(TileLayer)).call(this, props, context)); _this.layer = null; return _this; } Layer__createClass(TileLayer, [{ key: 'render', value: function render() { return null; } /** * create layer * @param nextProps */ }, { key: 'createLayer', value: function createLayer(nextProps) { if (nextProps) { var map = this.context.map; if (!map) return; if (this.layer) { map.removeLayer(this.layer); } var id = nextProps.id; this.layer = new maptalks_es["c" /* Layer */](id, nextProps); map.addLayer(this.layer); } } }, { key: 'componentDidMount', value: function componentDidMount() { this.createLayer(this.props); } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { this.createLayer(nextProps); return null; } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { var map = this.context.map; if (!map || !this.layer) return; map.removeLayer(this.layer); } }]); return TileLayer; }(external___root___React___commonjs2___react___commonjs___react___amd___react___default.a.Component); Layer_TileLayer.defaultProps = { attribution: null, minZoom: null, maxZoom: null, visible: true, opacity: 1, globalCompositeOperation: null, renderer: 'canvas', debugOutline: '#0f0', cssFilter: null, forceRenderOnMoving: false, forceRenderOnZooming: false, forceRenderOnRotating: false }; Layer_TileLayer.contextTypes = { map: prop_types_default.a.instanceOf(maptalks_es["e" /* Map */]) }; /* harmony default export */ var Layer = (Layer_TileLayer); // CONCATENATED MODULE: ./src/layers/tile/TileLayer.js var TileLayer__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function TileLayer__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function TileLayer__possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function TileLayer__inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var TileLayer_TileLayer = function (_Layer) { TileLayer__inherits(TileLayer, _Layer); function TileLayer(props, context) { TileLayer__classCallCheck(this, TileLayer); /** * layer state * @type {{isAdd: boolean}} */ var _this = TileLayer__possibleConstructorReturn(this, (TileLayer.__proto__ || Object.getPrototypeOf(TileLayer)).call(this, props, context)); _this.state = { isAdd: false }; _this.layer = null; return _this; } /** * create layer * @param nextProps */ TileLayer__createClass(TileLayer, [{ key: 'createLayer', value: function createLayer(nextProps) { var _this2 = this; if (nextProps) { var map = this.context.map; if (!map) return; if (this.layer) { map.removeLayer(this.layer); } var id = nextProps.id; this.layer = new maptalks_es["l" /* TileLayer */](id, nextProps); this.layer.on('add', function () { _this2.setState({ isAdd: true }); }); map.addLayer(this.layer); } } }]); return TileLayer; }(Layer); TileLayer_TileLayer.defaultProps = { subdomains: null, repeatWorld: true, background: true, backgroundZoomDiff: 6, loadingLimitOnInteracting: 3, placeholder: false, crossOrigin: null, tileSize: [256, 256], offset: [0, 0], tileSystem: null, fadeAnimation: true, debug: false, spatialReference: null, maxCacheSize: 256, clipByPitch: true, maxAvailableZoom: null, cascadeTiles: true, minPitchToCascade: 35 }; TileLayer_TileLayer.propTypes = { urlTemplate: prop_types_default.a.oneOfType([prop_types_default.a.string, prop_types_default.a.func]).isRequired, subdomains: prop_types_default.a.oneOfType([prop_types_default.a.arrayOf(prop_types_default.a.string), prop_types_default.a.arrayOf(prop_types_default.a.number)]), repeatWorld: prop_types_default.a.bool, background: prop_types_default.a.bool, backgroundZoomDiff: prop_types_default.a.number, loadingLimitOnInteracting: prop_types_default.a.number, placeholder: prop_types_default.a.bool, crossOrigin: prop_types_default.a.string, tileSize: prop_types_default.a.arrayOf(prop_types_default.a.number), offset: prop_types_default.a.arrayOf(prop_types_default.a.number), tileSystem: prop_types_default.a.arrayOf(prop_types_default.a.number), fadeAnimation: prop_types_default.a.bool, debug: prop_types_default.a.bool, spatialReference: prop_types_default.a.object, maxCacheSize: prop_types_default.a.number, clipByPitch: prop_types_default.a.bool, maxAvailableZoom: prop_types_default.a.number, cascadeTiles: prop_types_default.a.bool, minPitchToCascade: prop_types_default.a.number }; /* harmony default export */ var tile_TileLayer = (TileLayer_TileLayer); // CONCATENATED MODULE: ./src/layers/OverlayLayer.js var OverlayLayer__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function OverlayLayer__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function OverlayLayer__possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function OverlayLayer__inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var OverlayLayer_OverlayLayer = function (_Layer) { OverlayLayer__inherits(OverlayLayer, _Layer); function OverlayLayer(props, context) { OverlayLayer__classCallCheck(this, OverlayLayer); var _this = OverlayLayer__possibleConstructorReturn(this, (OverlayLayer.__proto__ || Object.getPrototypeOf(OverlayLayer)).call(this, props, context)); _this.layer = null; return _this; } /** * create layer * @param nextProps */ OverlayLayer__createClass(OverlayLayer, [{ key: 'createLayer', value: function createLayer(nextProps) { if (nextProps) { var map = this.context.map; if (!map) return; if (this.layer) { map.removeLayer(this.layer); } var id = nextProps.id, geometries = nextProps.geometries; this.layer = new maptalks_es["j" /* OverlayLayer */](id, geometries, nextProps); map.addLayer(this.layer); } } }]); return OverlayLayer; }(Layer); OverlayLayer_OverlayLayer.defaultProps = { drawImmediate: false }; OverlayLayer_OverlayLayer.propTypes = { drawImmediate: prop_types_default.a.bool }; /* harmony default export */ var layers_OverlayLayer = (OverlayLayer_OverlayLayer); // CONCATENATED MODULE: ./src/layers/VectorLayer.js var VectorLayer__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function VectorLayer__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function VectorLayer__possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function VectorLayer__inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var VectorLayer_VectorLayer = function (_OverlayLayer) { VectorLayer__inherits(VectorLayer, _OverlayLayer); function VectorLayer(props, context) { VectorLayer__classCallCheck(this, VectorLayer); var _this = VectorLayer__possibleConstructorReturn(this, (VectorLayer.__proto__ || Object.getPrototypeOf(VectorLayer)).call(this, props, context)); _this.layer = null; /** * layer state * @type {{isAdd: boolean}} */ _this.state = { isAdd: false }; return _this; } /** * create layer * @param nextProps */ VectorLayer__createClass(VectorLayer, [{ key: 'createLayer', value: function createLayer(nextProps) { var _this2 = this; if (nextProps) { var map = this.context.map; if (!map) return; if (this.layer) { map.removeLayer(this.layer); } var id = nextProps.id, geometries = nextProps.geometries; this.layer = new maptalks_es["m" /* VectorLayer */](id, geometries, nextProps); this.layer.on('add', function () { _this2.setState({ isAdd: true }); }); map.addLayer(this.layer); } } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { this.createLayer(nextProps); } }, { key: 'getChildContext', value: function getChildContext() { return { layer: this.layer }; } /** * render * @returns {*} */ }, { key: 'render', value: function render() { var isAdd = this.state.isAdd; console.log(isAdd); var children = this.props.children; return isAdd ? children : null; } }]); return VectorLayer; }(layers_OverlayLayer); VectorLayer_VectorLayer.defaultProps = { cursor: 'default', enableSimplify: true, geometryEvents: true, defaultIconSize: [20, 20], cacheVectorOnCanvas: true, cacheSvgOnCanvas: true, enableAltitude: false, altitudeProperty: 'altitude', drawAltitude: false }; VectorLayer_VectorLayer.propTypes = { cursor: prop_types_default.a.string, enableSimplify: prop_types_default.a.bool, geometryEvents: prop_types_default.a.bool, defaultIconSize: prop_types_default.a.arrayOf(prop_types_default.a.number), cacheVectorOnCanvas: prop_types_default.a.bool, cacheSvgOnCanvas: prop_types_default.a.bool, enableAltitude: prop_types_default.a.bool, altitudeProperty: prop_types_default.a.string, drawAltitude: prop_types_default.a.bool }; VectorLayer_VectorLayer.childContextTypes = { layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */]) }; /* harmony default export */ var layers_VectorLayer = (VectorLayer_VectorLayer); // CONCATENATED MODULE: ./src/layers/index.js // import Layer from './Layer'; // import GroupTileLayer from './tile/GroupTileLayer'; // import WMSTileLayer from './tile/WMSTileLayer'; // import CanvasTileLayer from './tile/CanvasTileLayer'; // import ImageLayer from './ImageLayer'; // import CanvasLayer from './CanvasLayer'; // import ParticleLayer from './ParticleLayer'; // import TileSystem from './tile/tileinfo/TileSystem'; // import TileConfig from './tile/tileinfo/TileConfig'; // CONCATENATED MODULE: ./src/geometry/Geometry.js var Geometry__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function Geometry__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function Geometry__possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function Geometry__inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Geometry_Geometry = function (_React$Component) { Geometry__inherits(Geometry, _React$Component); /** * super class * @param props * @param context */ function Geometry(props, context) { Geometry__classCallCheck(this, Geometry); /** * geometry * @type {null} */ var _this = Geometry__possibleConstructorReturn(this, (Geometry.__proto__ || Object.getPrototypeOf(Geometry)).call(this, props, context)); _this.geometry = null; return _this; } /** * create geometry * @param nextProps */ Geometry__createClass(Geometry, [{ key: 'createGeometry', value: function createGeometry(nextProps) { if (nextProps) { var layer = this.context.layer; if (!layer) return; this.geometry = new maptalks_es["b" /* Geometry */](); layer.addGeometry(this.geometry); } } }, { key: 'componentDidMount', value: function componentDidMount() { this.createGeometry(this.props); } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { this.createGeometry(nextProps); return null; } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { var layer = this.context.layer; if (!layer) return; layer.removeGeometry(this.geometry); } /** * render * @returns {null} */ }, { key: 'render', value: function render() { return null; } }]); return Geometry; }(external___root___React___commonjs2___react___commonjs___react___amd___react___default.a.Component); Geometry_Geometry.contextTypes = { layer: prop_types_default.a.instanceOf(maptalks_es["c" /* Layer */]) }; /* harmony default export */ var geometry_Geometry = (Geometry_Geometry); // CONCATENATED MODULE: ./src/geometry/Marker.js var Marker__createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function Marker__classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function Marker__possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function Marker__inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Marker_Marker = function (_Geometry) { Marker__inherits(Marker, _Geometry); /** * super class * @param props * @param context */ function Marker(props, context) { Marker__classCallCheck(this, Marker); /** * geometry * @type {null} */ var _this = Marker__possibleConstructorReturn(this, (Marker.__proto__ || Object.getPrototypeOf(Marker)).call(this, props, context)); _this.geometry = null; return _this; } /** * create geometry * @param nextProps */ Marker__createClass(Marker, [{ key: 'createGeometry', value: function createGeometry(nextProps) { if (nextProps) { var layer = this.context.layer; if (!layer) return; var id = nextProps.id, coordinates = nextProps.coordinates, options = nextProps.options; this.geometry = new maptalks_es["f" /* Marker */](coordinates, options); this.geometry.setId(id);