echarts-extension-gmap
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -1,1054 +0,849 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(require("echarts")); | ||
else if(typeof define === 'function' && define.amd) | ||
define("gmap", ["echarts"], factory); | ||
else if(typeof exports === 'object') | ||
exports["gmap"] = factory(require("echarts")); | ||
else | ||
root["echarts"] = root["echarts"] || {}, root["echarts"]["gmap"] = factory(root["echarts"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_echarts__) { | ||
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, { enumerable: true, get: getter }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // 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 = "./src/index.js"); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ({ | ||
/***/ "./node_modules/lodash.debounce/index.js": | ||
/*!***********************************************!*\ | ||
!*** ./node_modules/lodash.debounce/index.js ***! | ||
\***********************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(global) {/** | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
/*! | ||
* echarts-extension-gmap | ||
* @version 1.2.1 | ||
* @author plainheart | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Zhongxiang.Wang | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('echarts')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'echarts'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.echarts = global.echarts || {}, global.echarts.gmap = {}), global.echarts)); | ||
}(this, (function (exports, echarts) { 'use strict'; | ||
/** Used as the `TypeError` message for "Functions" methods. */ | ||
var FUNC_ERROR_TEXT = 'Expected a function'; | ||
var name = "echarts-extension-gmap"; | ||
var version = "1.2.1"; | ||
/** Used as references for various `Number` constants. */ | ||
var NAN = 0 / 0; | ||
/* global google */ | ||
/** `Object#toString` result references. */ | ||
var symbolTag = '[object Symbol]'; | ||
function GMapCoordSys(gmap, api) { | ||
this._gmap = gmap; | ||
this.dimensions = ['lng', 'lat']; | ||
this._mapOffset = [0, 0]; | ||
this._api = api; | ||
} | ||
/** Used to match leading and trailing whitespace. */ | ||
var reTrim = /^\s+|\s+$/g; | ||
var GMapCoordSysProto = GMapCoordSys.prototype; | ||
/** Used to detect bad signed hexadecimal string values. */ | ||
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; | ||
// exclude private and unsupported options | ||
var excludedOptions = [ | ||
'echartsLayerZIndex', | ||
'renderOnMoving' | ||
]; | ||
/** Used to detect binary string values. */ | ||
var reIsBinary = /^0b[01]+$/i; | ||
GMapCoordSysProto.dimensions = ['lng', 'lat']; | ||
/** Used to detect octal string values. */ | ||
var reIsOctal = /^0o[0-7]+$/i; | ||
GMapCoordSysProto.setZoom = function(zoom) { | ||
this._zoom = zoom; | ||
}; | ||
/** Built-in method references without a dependency on `root`. */ | ||
var freeParseInt = parseInt; | ||
GMapCoordSysProto.setCenter = function(center) { | ||
var latlng = new google.maps.LatLng(center[1], center[0]); | ||
this._center = latLngToPixel(latlng, this._gmap); | ||
}; | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; | ||
GMapCoordSysProto.setMapOffset = function(mapOffset) { | ||
this._mapOffset = mapOffset; | ||
}; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
GMapCoordSysProto.setGoogleMap = function(gmap) { | ||
this._gmap = gmap; | ||
}; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
GMapCoordSysProto.getGoogleMap = function() { | ||
return this._gmap; | ||
}; | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
GMapCoordSysProto.dataToPoint = function(data) { | ||
var latlng = new google.maps.LatLng(data[1], data[0]); | ||
var px = latLngToPixel(latlng, this._gmap); | ||
if (px) { | ||
var mapOffset = this._mapOffset; | ||
return [px.x - mapOffset[0], px.y - mapOffset[1]]; | ||
} | ||
}; | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
GMapCoordSysProto.pointToData = function(pt) { | ||
var mapOffset = this._mapOffset; | ||
var latlng = pixelToLatLng( | ||
new google.maps.Point(pt[0] + mapOffset[0], pt[1] + mapOffset[1]), | ||
this._gmap | ||
); | ||
return [latlng.lng(), latlng.lat()]; | ||
}; | ||
/* Built-in method references for those with the same name as other `lodash` methods. */ | ||
var nativeMax = Math.max, | ||
nativeMin = Math.min; | ||
GMapCoordSysProto.getViewRect = function() { | ||
var api = this._api; | ||
return new echarts.graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight()); | ||
}; | ||
/** | ||
* Gets the timestamp of the number of milliseconds that have elapsed since | ||
* the Unix epoch (1 January 1970 00:00:00 UTC). | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 2.4.0 | ||
* @category Date | ||
* @returns {number} Returns the timestamp. | ||
* @example | ||
* | ||
* _.defer(function(stamp) { | ||
* console.log(_.now() - stamp); | ||
* }, _.now()); | ||
* // => Logs the number of milliseconds it took for the deferred invocation. | ||
*/ | ||
var now = function() { | ||
return root.Date.now(); | ||
}; | ||
GMapCoordSysProto.getRoamTransform = function() { | ||
return echarts.matrix.create(); | ||
}; | ||
/** | ||
* Creates a debounced function that delays invoking `func` until after `wait` | ||
* milliseconds have elapsed since the last time the debounced function was | ||
* invoked. The debounced function comes with a `cancel` method to cancel | ||
* delayed `func` invocations and a `flush` method to immediately invoke them. | ||
* Provide `options` to indicate whether `func` should be invoked on the | ||
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked | ||
* with the last arguments provided to the debounced function. Subsequent | ||
* calls to the debounced function return the result of the last `func` | ||
* invocation. | ||
* | ||
* **Note:** If `leading` and `trailing` options are `true`, `func` is | ||
* invoked on the trailing edge of the timeout only if the debounced function | ||
* is invoked more than once during the `wait` timeout. | ||
* | ||
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred | ||
* until to the next tick, similar to `setTimeout` with a timeout of `0`. | ||
* | ||
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) | ||
* for details over the differences between `_.debounce` and `_.throttle`. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @category Function | ||
* @param {Function} func The function to debounce. | ||
* @param {number} [wait=0] The number of milliseconds to delay. | ||
* @param {Object} [options={}] The options object. | ||
* @param {boolean} [options.leading=false] | ||
* Specify invoking on the leading edge of the timeout. | ||
* @param {number} [options.maxWait] | ||
* The maximum time `func` is allowed to be delayed before it's invoked. | ||
* @param {boolean} [options.trailing=true] | ||
* Specify invoking on the trailing edge of the timeout. | ||
* @returns {Function} Returns the new debounced function. | ||
* @example | ||
* | ||
* // Avoid costly calculations while the window size is in flux. | ||
* jQuery(window).on('resize', _.debounce(calculateLayout, 150)); | ||
* | ||
* // Invoke `sendMail` when clicked, debouncing subsequent calls. | ||
* jQuery(element).on('click', _.debounce(sendMail, 300, { | ||
* 'leading': true, | ||
* 'trailing': false | ||
* })); | ||
* | ||
* // Ensure `batchLog` is invoked once after 1 second of debounced calls. | ||
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); | ||
* var source = new EventSource('/stream'); | ||
* jQuery(source).on('message', debounced); | ||
* | ||
* // Cancel the trailing debounced invocation. | ||
* jQuery(window).on('popstate', debounced.cancel); | ||
*/ | ||
function debounce(func, wait, options) { | ||
var lastArgs, | ||
lastThis, | ||
maxWait, | ||
result, | ||
timerId, | ||
lastCallTime, | ||
lastInvokeTime = 0, | ||
leading = false, | ||
maxing = false, | ||
trailing = true; | ||
GMapCoordSysProto.prepareCustoms = function(data) { | ||
var rect = this.getViewRect(); | ||
return { | ||
coordSys: { | ||
// The name exposed to user is always 'cartesian2d' but not 'grid'. | ||
type: 'gmap', | ||
x: rect.x, | ||
y: rect.y, | ||
width: rect.width, | ||
height: rect.height | ||
}, | ||
api: { | ||
coord: echarts.util.bind(this.dataToPoint, this), | ||
size: echarts.util.bind(dataToCoordSize, this) | ||
} | ||
}; | ||
}; | ||
if (typeof func != 'function') { | ||
throw new TypeError(FUNC_ERROR_TEXT); | ||
function dataToCoordSize(dataSize, dataItem) { | ||
dataItem = dataItem || [0, 0]; | ||
return echarts.util.map( | ||
[0, 1], | ||
function(dimIdx) { | ||
var val = dataItem[dimIdx]; | ||
var halfSize = dataSize[dimIdx] / 2; | ||
var p1 = []; | ||
var p2 = []; | ||
p1[dimIdx] = val - halfSize; | ||
p2[dimIdx] = val + halfSize; | ||
p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx]; | ||
return Math.abs( | ||
this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx] | ||
); | ||
}, | ||
this | ||
); | ||
} | ||
wait = toNumber(wait) || 0; | ||
if (isObject(options)) { | ||
leading = !!options.leading; | ||
maxing = 'maxWait' in options; | ||
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; | ||
trailing = 'trailing' in options ? !!options.trailing : trailing; | ||
} | ||
function invokeFunc(time) { | ||
var args = lastArgs, | ||
thisArg = lastThis; | ||
// For deciding which dimensions to use when creating list data | ||
GMapCoordSys.dimensions = GMapCoordSysProto.dimensions; | ||
lastArgs = lastThis = undefined; | ||
lastInvokeTime = time; | ||
result = func.apply(thisArg, args); | ||
return result; | ||
} | ||
GMapCoordSys.create = function(ecModel, api) { | ||
var gmapCoordSys; | ||
var root = api.getDom(); | ||
function leadingEdge(time) { | ||
// Reset any `maxWait` timer. | ||
lastInvokeTime = time; | ||
// Start the timer for the trailing edge. | ||
timerId = setTimeout(timerExpired, wait); | ||
// Invoke the leading edge. | ||
return leading ? invokeFunc(time) : result; | ||
} | ||
ecModel.eachComponent('gmap', function(gmapModel) { | ||
var painter = api.getZr().painter; | ||
var viewportRoot = painter.getViewportRoot(); | ||
if (typeof google === 'undefined' | ||
|| typeof google.maps === 'undefined' | ||
|| typeof google.maps.Map === 'undefined') { | ||
throw new Error('It seems that Google Map API has not been loaded completely yet.'); | ||
} | ||
Overlay = Overlay || createOverlayCtor(); | ||
if (gmapCoordSys) { | ||
throw new Error('Only one google map component can exist'); | ||
} | ||
var gmap = gmapModel.getGoogleMap(); | ||
if (!gmap) { | ||
// Not support IE8 | ||
var gmapRoot = root.querySelector('.ec-extension-google-map'); | ||
if (gmapRoot) { | ||
// Reset viewport left and top, which will be changed | ||
// in moving handler in GMapView | ||
viewportRoot.style.left = '0px'; | ||
viewportRoot.style.top = '0px'; | ||
viewportRoot.style.width = '100%'; | ||
viewportRoot.style.height = '100%'; | ||
root.removeChild(gmapRoot); | ||
} | ||
gmapRoot = document.createElement('div'); | ||
gmapRoot.style.cssText = 'width:100%;height:100%'; | ||
// Not support IE8 | ||
gmapRoot.classList.add('ec-extension-google-map'); | ||
root.appendChild(gmapRoot); | ||
function remainingWait(time) { | ||
var timeSinceLastCall = time - lastCallTime, | ||
timeSinceLastInvoke = time - lastInvokeTime, | ||
result = wait - timeSinceLastCall; | ||
var options = echarts.util.clone(gmapModel.get()); | ||
var echartsLayerZIndex = options.echartsLayerZIndex; | ||
// delete excluded options | ||
echarts.util.each(excludedOptions, function(key) { | ||
delete options[key]; | ||
}); | ||
var center = options.center; | ||
// normalize center | ||
if (echarts.util.isArray(center)) { | ||
options.center = { | ||
lng: center[0], | ||
lat: center[1] | ||
}; | ||
} | ||
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; | ||
} | ||
gmap = new google.maps.Map(gmapRoot, options); | ||
gmapModel.setGoogleMap(gmap); | ||
function shouldInvoke(time) { | ||
var timeSinceLastCall = time - lastCallTime, | ||
timeSinceLastInvoke = time - lastInvokeTime; | ||
gmapModel.__projectionChangeListener && gmapModel.__projectionChangeListener.remove(); | ||
gmapModel.__projectionChangeListener = google.maps.event.addListener(gmap, 'projection_changed', | ||
function() { | ||
var layer = gmapModel.getEChartsLayer(); | ||
layer && layer.setMap(null); | ||
// Either this is the first call, activity has stopped and we're at the | ||
// trailing edge, the system time has gone backwards and we're treating | ||
// it as the trailing edge, or we've hit the `maxWait` limit. | ||
return (lastCallTime === undefined || (timeSinceLastCall >= wait) || | ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); | ||
} | ||
var overlay = new Overlay(viewportRoot, gmap); | ||
overlay.setZIndex(echartsLayerZIndex); | ||
gmapModel.setEChartsLayer(overlay); | ||
} | ||
); | ||
function timerExpired() { | ||
var time = now(); | ||
if (shouldInvoke(time)) { | ||
return trailingEdge(time); | ||
} | ||
// Restart the timer. | ||
timerId = setTimeout(timerExpired, remainingWait(time)); | ||
} | ||
// Override | ||
painter.getViewportRootOffset = function() { | ||
return { offsetLeft: 0, offsetTop: 0 }; | ||
}; | ||
} | ||
function trailingEdge(time) { | ||
timerId = undefined; | ||
var center = gmapModel.get('center'); | ||
var normalizedCenter = [ | ||
center.lng != null ? center.lng : center[0], | ||
center.lat != null ? center.lat : center[1] | ||
]; | ||
var zoom = gmapModel.get('zoom'); | ||
if (center && zoom) { | ||
var gmapCenter = gmap.getCenter(); | ||
var gmapZoom = gmap.getZoom(); | ||
var centerOrZoomChanged = gmapModel.centerOrZoomChanged([gmapCenter.lng(), gmapCenter.lat()], gmapZoom); | ||
if (centerOrZoomChanged) { | ||
var pt = new google.maps.LatLng(normalizedCenter[1], normalizedCenter[0]); | ||
gmap.setOptions({ | ||
center: pt, | ||
zoom: zoom | ||
}); | ||
} | ||
} | ||
// Only invoke if we have `lastArgs` which means `func` has been | ||
// debounced at least once. | ||
if (trailing && lastArgs) { | ||
return invokeFunc(time); | ||
} | ||
lastArgs = lastThis = undefined; | ||
return result; | ||
} | ||
gmapCoordSys = new GMapCoordSys(gmap, api); | ||
gmapCoordSys.setMapOffset(gmapModel.__mapOffset || [0, 0]); | ||
gmapCoordSys.setZoom(zoom); | ||
gmapCoordSys.setCenter(normalizedCenter); | ||
function cancel() { | ||
if (timerId !== undefined) { | ||
clearTimeout(timerId); | ||
} | ||
lastInvokeTime = 0; | ||
lastArgs = lastCallTime = lastThis = timerId = undefined; | ||
} | ||
gmapModel.coordinateSystem = gmapCoordSys; | ||
}); | ||
function flush() { | ||
return timerId === undefined ? result : trailingEdge(now()); | ||
} | ||
ecModel.eachSeries(function(seriesModel) { | ||
if (seriesModel.get('coordinateSystem') === 'gmap') { | ||
seriesModel.coordinateSystem = gmapCoordSys; | ||
} | ||
}); | ||
}; | ||
function debounced() { | ||
var time = now(), | ||
isInvoking = shouldInvoke(time); | ||
var Overlay; | ||
lastArgs = arguments; | ||
lastThis = this; | ||
lastCallTime = time; | ||
if (isInvoking) { | ||
if (timerId === undefined) { | ||
return leadingEdge(lastCallTime); | ||
function createOverlayCtor() { | ||
function Overlay(root, gmap) { | ||
this._root = root; | ||
this.setMap(gmap); | ||
} | ||
if (maxing) { | ||
// Handle invocations in a tight loop. | ||
timerId = setTimeout(timerExpired, wait); | ||
return invokeFunc(lastCallTime); | ||
} | ||
} | ||
if (timerId === undefined) { | ||
timerId = setTimeout(timerExpired, wait); | ||
} | ||
return result; | ||
} | ||
debounced.cancel = cancel; | ||
debounced.flush = flush; | ||
return debounced; | ||
} | ||
/** | ||
* 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 && (type == 'object' || type == 'function'); | ||
} | ||
Overlay.prototype = new google.maps.OverlayView(); | ||
/** | ||
* 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 && typeof value == 'object'; | ||
} | ||
Overlay.prototype.onAdd = function() { | ||
var gmap = this.getMap(); | ||
gmap.__overlayProjection = this.getProjection(); | ||
gmap.getDiv().querySelector('.gm-style > div').appendChild(this._root); | ||
}; | ||
/** | ||
* Checks if `value` is classified as a `Symbol` primitive or object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`. | ||
* @example | ||
* | ||
* _.isSymbol(Symbol.iterator); | ||
* // => true | ||
* | ||
* _.isSymbol('abc'); | ||
* // => false | ||
*/ | ||
function isSymbol(value) { | ||
return typeof value == 'symbol' || | ||
(isObjectLike(value) && objectToString.call(value) == symbolTag); | ||
} | ||
/** | ||
* @override | ||
*/ | ||
Overlay.prototype.draw = function() { | ||
google.maps.event.trigger(this.getMap(), 'gmaprender'); | ||
}; | ||
/** | ||
* Converts `value` to a number. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to process. | ||
* @returns {number} Returns the number. | ||
* @example | ||
* | ||
* _.toNumber(3.2); | ||
* // => 3.2 | ||
* | ||
* _.toNumber(Number.MIN_VALUE); | ||
* // => 5e-324 | ||
* | ||
* _.toNumber(Infinity); | ||
* // => Infinity | ||
* | ||
* _.toNumber('3.2'); | ||
* // => 3.2 | ||
*/ | ||
function toNumber(value) { | ||
if (typeof value == 'number') { | ||
return value; | ||
} | ||
if (isSymbol(value)) { | ||
return NAN; | ||
} | ||
if (isObject(value)) { | ||
var other = typeof value.valueOf == 'function' ? value.valueOf() : value; | ||
value = isObject(other) ? (other + '') : other; | ||
} | ||
if (typeof value != 'string') { | ||
return value === 0 ? value : +value; | ||
} | ||
value = value.replace(reTrim, ''); | ||
var isBinary = reIsBinary.test(value); | ||
return (isBinary || reIsOctal.test(value)) | ||
? freeParseInt(value.slice(2), isBinary ? 2 : 8) | ||
: (reIsBadHex.test(value) ? NAN : +value); | ||
} | ||
Overlay.prototype.onRemove = function() { | ||
this._root.parentNode.removeChild(this._root); | ||
this._root = null; | ||
}; | ||
module.exports = debounce; | ||
Overlay.prototype.setZIndex = function(zIndex) { | ||
this._root.style.zIndex = zIndex; | ||
}; | ||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) | ||
Overlay.prototype.getZIndex = function() { | ||
return this._root.style.zIndex; | ||
}; | ||
/***/ }), | ||
return Overlay; | ||
} | ||
/***/ "./node_modules/webpack/buildin/global.js": | ||
/*!***********************************!*\ | ||
!*** (webpack)/buildin/global.js ***! | ||
\***********************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
function latLngToPixel(latLng, map) { | ||
var projection = map.__overlayProjection; | ||
if (!projection) { | ||
return; | ||
} | ||
var g; | ||
return projection.fromLatLngToContainerPixel(latLng); | ||
} | ||
// This works in non-strict mode | ||
g = (function() { | ||
return this; | ||
})(); | ||
function pixelToLatLng(pixel, map) { | ||
var projection = map.__overlayProjection; | ||
if (!projection) { | ||
return; | ||
} | ||
try { | ||
// This works if eval is allowed (see CSP) | ||
g = g || new Function("return this")(); | ||
} catch (e) { | ||
// This works if the window reference is available | ||
if (typeof window === "object") g = window; | ||
} | ||
return projection.fromContainerPixelToLatLng(pixel); | ||
} | ||
// 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) { ...} | ||
function v2Equal(a, b) { | ||
return a && b && a[0] === b[0] && a[1] === b[1]; | ||
} | ||
module.exports = g; | ||
echarts.extendComponentModel({ | ||
type: 'gmap', | ||
setGoogleMap: function(gmap) { | ||
this.__gmap = gmap; | ||
}, | ||
/***/ }), | ||
getGoogleMap: function() { | ||
// __gmap is set when creating GMapCoordSys | ||
return this.__gmap; | ||
}, | ||
/***/ "./package.json": | ||
/*!**********************!*\ | ||
!*** ./package.json ***! | ||
\**********************/ | ||
/*! exports provided: name, version, description, main, scripts, repository, keywords, author, license, bugs, homepage, devDependencies, dependencies, default */ | ||
/***/ (function(module) { | ||
setEChartsLayer: function(layer) { | ||
this.__echartsLayer = layer; | ||
}, | ||
module.exports = JSON.parse("{\"name\":\"echarts-extension-gmap\",\"version\":\"1.2.0\",\"description\":\"An Google Map(https://www.google.com/maps) extension for Apache ECharts (incubating) (https://github.com/apache/incubator-echarts)\",\"main\":\"dist/echarts-extension-gmap.min.js\",\"scripts\":{\"build\":\"webpack --env=production --optimize-minimize --progress --colors\",\"dev\":\"webpack --env=development\",\"watch\":\"webpack --env=development --watch\",\"test\":\"echo \\\"Error: no test specified\\\" && exit 1\"},\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/plainheart/echarts-extension-gmap.git\"},\"keywords\":[\"echarts\",\"google-maps\",\"google\",\"echarts-extention\",\"data-visualization\",\"map\",\"echarts-gmap\",\"echarts-google-map\",\"echarts4\",\"echarts5\",\"gmap\"],\"author\":\"plainheart\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://github.com/plainheart/echarts-extension-gmap/issues\"},\"homepage\":\"https://github.com/plainheart/echarts-extension-gmap#readme\",\"devDependencies\":{\"webpack\":\"^4.29.5\",\"webpack-cli\":\"^3.2.3\"},\"dependencies\":{\"lodash.debounce\":\"^4.0.8\"}}"); | ||
getEChartsLayer: function() { | ||
return this.__echartsLayer; | ||
}, | ||
/***/ }), | ||
setCenterAndZoom: function(center, zoom) { | ||
this.option.center = center; | ||
this.option.zoom = zoom; | ||
}, | ||
/***/ "./src/GMapCoordSys.js": | ||
/*!*****************************!*\ | ||
!*** ./src/GMapCoordSys.js ***! | ||
\*****************************/ | ||
/*! exports provided: default */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
centerOrZoomChanged: function(center, zoom) { | ||
var option = this.option; | ||
return !(v2Equal(center, option.center) && zoom === option.zoom); | ||
}, | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */ var echarts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! echarts */ "echarts"); | ||
/* harmony import */ var echarts__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(echarts__WEBPACK_IMPORTED_MODULE_0__); | ||
/* global google */ | ||
defaultOption: { | ||
center: { lat: 39.90923, lng: 116.397428 }, | ||
zoom: 5, | ||
// extension options | ||
echartsLayerZIndex: 2000, | ||
renderOnMoving: true | ||
} | ||
}); | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function GMapCoordSys(gmap, api) { | ||
this._gmap = gmap; | ||
this.dimensions = ['lng', 'lat']; | ||
this._mapOffset = [0, 0]; | ||
this._api = api; | ||
} | ||
/** | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
var GMapCoordSysProto = GMapCoordSys.prototype; | ||
/** Used as the `TypeError` message for "Functions" methods. */ | ||
var FUNC_ERROR_TEXT = 'Expected a function'; | ||
// exclude private and unsupported options | ||
var excludedOptions = [ | ||
'echartsLayerZIndex', | ||
'renderOnMoving' | ||
]; | ||
/** Used as references for various `Number` constants. */ | ||
var NAN = 0 / 0; | ||
GMapCoordSysProto.dimensions = ['lng', 'lat']; | ||
/** `Object#toString` result references. */ | ||
var symbolTag = '[object Symbol]'; | ||
GMapCoordSysProto.setZoom = function(zoom) { | ||
this._zoom = zoom; | ||
}; | ||
/** Used to match leading and trailing whitespace. */ | ||
var reTrim = /^\s+|\s+$/g; | ||
GMapCoordSysProto.setCenter = function(center) { | ||
var latlng = new google.maps.LatLng(center[1], center[0]); | ||
this._center = latLngToPixel(latlng, this._gmap); | ||
}; | ||
/** Used to detect bad signed hexadecimal string values. */ | ||
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; | ||
GMapCoordSysProto.setMapOffset = function(mapOffset) { | ||
this._mapOffset = mapOffset; | ||
}; | ||
/** Used to detect binary string values. */ | ||
var reIsBinary = /^0b[01]+$/i; | ||
GMapCoordSysProto.setGoogleMap = function(gmap) { | ||
this._gmap = gmap; | ||
}; | ||
/** Used to detect octal string values. */ | ||
var reIsOctal = /^0o[0-7]+$/i; | ||
GMapCoordSysProto.getGoogleMap = function() { | ||
return this._gmap; | ||
}; | ||
/** Built-in method references without a dependency on `root`. */ | ||
var freeParseInt = parseInt; | ||
GMapCoordSysProto.dataToPoint = function(data) { | ||
var latlng = new google.maps.LatLng(data[1], data[0]); | ||
var px = latLngToPixel(latlng, this._gmap); | ||
if (px) { | ||
var mapOffset = this._mapOffset; | ||
return [px.x - mapOffset[0], px.y - mapOffset[1]]; | ||
} | ||
}; | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; | ||
GMapCoordSysProto.pointToData = function(pt) { | ||
var mapOffset = this._mapOffset; | ||
var latlng = pixelToLatLng( | ||
new google.maps.Point(pt[0] + mapOffset[0], pt[1] + mapOffset[1]), | ||
this._gmap | ||
); | ||
return [latlng.lng(), latlng.lat()]; | ||
}; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
GMapCoordSysProto.getViewRect = function() { | ||
var api = this._api; | ||
return new echarts__WEBPACK_IMPORTED_MODULE_0__["graphic"].BoundingRect(0, 0, api.getWidth(), api.getHeight()); | ||
}; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
GMapCoordSysProto.getRoamTransform = function() { | ||
return echarts__WEBPACK_IMPORTED_MODULE_0__["matrix"].create(); | ||
}; | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
GMapCoordSysProto.prepareCustoms = function(data) { | ||
var rect = this.getViewRect(); | ||
return { | ||
coordSys: { | ||
// The name exposed to user is always 'cartesian2d' but not 'grid'. | ||
type: 'gmap', | ||
x: rect.x, | ||
y: rect.y, | ||
width: rect.width, | ||
height: rect.height | ||
}, | ||
api: { | ||
coord: echarts__WEBPACK_IMPORTED_MODULE_0__["util"].bind(this.dataToPoint, this), | ||
size: echarts__WEBPACK_IMPORTED_MODULE_0__["util"].bind(dataToCoordSize, this) | ||
} | ||
}; | ||
}; | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
function dataToCoordSize(dataSize, dataItem) { | ||
dataItem = dataItem || [0, 0]; | ||
return echarts__WEBPACK_IMPORTED_MODULE_0__["util"].map( | ||
[0, 1], | ||
function(dimIdx) { | ||
var val = dataItem[dimIdx]; | ||
var halfSize = dataSize[dimIdx] / 2; | ||
var p1 = []; | ||
var p2 = []; | ||
p1[dimIdx] = val - halfSize; | ||
p2[dimIdx] = val + halfSize; | ||
p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx]; | ||
return Math.abs( | ||
this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx] | ||
); | ||
}, | ||
this | ||
); | ||
} | ||
/* Built-in method references for those with the same name as other `lodash` methods. */ | ||
var nativeMax = Math.max, | ||
nativeMin = Math.min; | ||
// For deciding which dimensions to use when creating list data | ||
GMapCoordSys.dimensions = GMapCoordSysProto.dimensions; | ||
/** | ||
* Gets the timestamp of the number of milliseconds that have elapsed since | ||
* the Unix epoch (1 January 1970 00:00:00 UTC). | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 2.4.0 | ||
* @category Date | ||
* @returns {number} Returns the timestamp. | ||
* @example | ||
* | ||
* _.defer(function(stamp) { | ||
* console.log(_.now() - stamp); | ||
* }, _.now()); | ||
* // => Logs the number of milliseconds it took for the deferred invocation. | ||
*/ | ||
var now = function() { | ||
return root.Date.now(); | ||
}; | ||
GMapCoordSys.create = function(ecModel, api) { | ||
var gmapCoordSys; | ||
var root = api.getDom(); | ||
/** | ||
* Creates a debounced function that delays invoking `func` until after `wait` | ||
* milliseconds have elapsed since the last time the debounced function was | ||
* invoked. The debounced function comes with a `cancel` method to cancel | ||
* delayed `func` invocations and a `flush` method to immediately invoke them. | ||
* Provide `options` to indicate whether `func` should be invoked on the | ||
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked | ||
* with the last arguments provided to the debounced function. Subsequent | ||
* calls to the debounced function return the result of the last `func` | ||
* invocation. | ||
* | ||
* **Note:** If `leading` and `trailing` options are `true`, `func` is | ||
* invoked on the trailing edge of the timeout only if the debounced function | ||
* is invoked more than once during the `wait` timeout. | ||
* | ||
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred | ||
* until to the next tick, similar to `setTimeout` with a timeout of `0`. | ||
* | ||
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) | ||
* for details over the differences between `_.debounce` and `_.throttle`. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @category Function | ||
* @param {Function} func The function to debounce. | ||
* @param {number} [wait=0] The number of milliseconds to delay. | ||
* @param {Object} [options={}] The options object. | ||
* @param {boolean} [options.leading=false] | ||
* Specify invoking on the leading edge of the timeout. | ||
* @param {number} [options.maxWait] | ||
* The maximum time `func` is allowed to be delayed before it's invoked. | ||
* @param {boolean} [options.trailing=true] | ||
* Specify invoking on the trailing edge of the timeout. | ||
* @returns {Function} Returns the new debounced function. | ||
* @example | ||
* | ||
* // Avoid costly calculations while the window size is in flux. | ||
* jQuery(window).on('resize', _.debounce(calculateLayout, 150)); | ||
* | ||
* // Invoke `sendMail` when clicked, debouncing subsequent calls. | ||
* jQuery(element).on('click', _.debounce(sendMail, 300, { | ||
* 'leading': true, | ||
* 'trailing': false | ||
* })); | ||
* | ||
* // Ensure `batchLog` is invoked once after 1 second of debounced calls. | ||
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); | ||
* var source = new EventSource('/stream'); | ||
* jQuery(source).on('message', debounced); | ||
* | ||
* // Cancel the trailing debounced invocation. | ||
* jQuery(window).on('popstate', debounced.cancel); | ||
*/ | ||
function debounce(func, wait, options) { | ||
var lastArgs, | ||
lastThis, | ||
maxWait, | ||
result, | ||
timerId, | ||
lastCallTime, | ||
lastInvokeTime = 0, | ||
leading = false, | ||
maxing = false, | ||
trailing = true; | ||
ecModel.eachComponent('gmap', function(gmapModel) { | ||
var painter = api.getZr().painter; | ||
var viewportRoot = painter.getViewportRoot(); | ||
if (typeof google === 'undefined' | ||
|| typeof google.maps === 'undefined' | ||
|| typeof google.maps.Map === 'undefined') { | ||
throw new Error('It seems that Google Map API has not been loaded completely yet.'); | ||
if (typeof func != 'function') { | ||
throw new TypeError(FUNC_ERROR_TEXT); | ||
} | ||
Overlay = Overlay || createOverlayCtor(); | ||
if (gmapCoordSys) { | ||
throw new Error('Only one google map component can exist'); | ||
wait = toNumber(wait) || 0; | ||
if (isObject(options)) { | ||
leading = !!options.leading; | ||
maxing = 'maxWait' in options; | ||
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; | ||
trailing = 'trailing' in options ? !!options.trailing : trailing; | ||
} | ||
var gmap = gmapModel.getGoogleMap(); | ||
if (!gmap) { | ||
// Not support IE8 | ||
var gmapRoot = root.querySelector('.ec-extension-google-map'); | ||
if (gmapRoot) { | ||
// Reset viewport left and top, which will be changed | ||
// in moving handler in GMapView | ||
viewportRoot.style.left = '0px'; | ||
viewportRoot.style.top = '0px'; | ||
viewportRoot.style.width = '100%'; | ||
viewportRoot.style.height = '100%'; | ||
root.removeChild(gmapRoot); | ||
} | ||
gmapRoot = document.createElement('div'); | ||
gmapRoot.style.cssText = 'width:100%;height:100%'; | ||
// Not support IE8 | ||
gmapRoot.classList.add('ec-extension-google-map'); | ||
root.appendChild(gmapRoot); | ||
var options = echarts__WEBPACK_IMPORTED_MODULE_0__["util"].clone(gmapModel.get()); | ||
var echartsLayerZIndex = options.echartsLayerZIndex; | ||
// delete excluded options | ||
echarts__WEBPACK_IMPORTED_MODULE_0__["util"].each(excludedOptions, function(key) { | ||
delete options[key]; | ||
}); | ||
var center = options.center; | ||
// normalize center | ||
if (echarts__WEBPACK_IMPORTED_MODULE_0__["util"].isArray(center)) { | ||
options.center = { | ||
lng: center[0], | ||
lat: center[1] | ||
}; | ||
} | ||
function invokeFunc(time) { | ||
var args = lastArgs, | ||
thisArg = lastThis; | ||
gmap = new google.maps.Map(gmapRoot, options); | ||
gmapModel.setGoogleMap(gmap); | ||
gmapModel.__projectionChangeListener && gmapModel.__projectionChangeListener.remove(); | ||
gmapModel.__projectionChangeListener = google.maps.event.addListener(gmap, 'projection_changed', | ||
function() { | ||
var layer = gmapModel.getEChartsLayer(); | ||
layer && layer.setMap(null); | ||
var overlay = new Overlay(viewportRoot, gmap); | ||
overlay.setZIndex(echartsLayerZIndex); | ||
gmapModel.setEChartsLayer(overlay); | ||
} | ||
); | ||
// Override | ||
painter.getViewportRootOffset = function() { | ||
return { offsetLeft: 0, offsetTop: 0 }; | ||
}; | ||
lastArgs = lastThis = undefined; | ||
lastInvokeTime = time; | ||
result = func.apply(thisArg, args); | ||
return result; | ||
} | ||
var center = gmapModel.get('center'); | ||
var normalizedCenter = [ | ||
center.lng != null ? center.lng : center[0], | ||
center.lat != null ? center.lat : center[1] | ||
]; | ||
var zoom = gmapModel.get('zoom'); | ||
if (center && zoom) { | ||
var gmapCenter = gmap.getCenter(); | ||
var gmapZoom = gmap.getZoom(); | ||
var centerOrZoomChanged = gmapModel.centerOrZoomChanged([gmapCenter.lng(), gmapCenter.lat()], gmapZoom); | ||
if (centerOrZoomChanged) { | ||
var pt = new google.maps.LatLng(normalizedCenter[1], normalizedCenter[0]); | ||
gmap.setOptions({ | ||
center: pt, | ||
zoom: zoom | ||
}); | ||
} | ||
function leadingEdge(time) { | ||
// Reset any `maxWait` timer. | ||
lastInvokeTime = time; | ||
// Start the timer for the trailing edge. | ||
timerId = setTimeout(timerExpired, wait); | ||
// Invoke the leading edge. | ||
return leading ? invokeFunc(time) : result; | ||
} | ||
gmapCoordSys = new GMapCoordSys(gmap, api); | ||
gmapCoordSys.setMapOffset(gmapModel.__mapOffset || [0, 0]); | ||
gmapCoordSys.setZoom(zoom); | ||
gmapCoordSys.setCenter(normalizedCenter); | ||
function remainingWait(time) { | ||
var timeSinceLastCall = time - lastCallTime, | ||
timeSinceLastInvoke = time - lastInvokeTime, | ||
result = wait - timeSinceLastCall; | ||
gmapModel.coordinateSystem = gmapCoordSys; | ||
}); | ||
ecModel.eachSeries(function(seriesModel) { | ||
if (seriesModel.get('coordinateSystem') === 'gmap') { | ||
seriesModel.coordinateSystem = gmapCoordSys; | ||
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result; | ||
} | ||
}); | ||
}; | ||
var Overlay; | ||
function shouldInvoke(time) { | ||
var timeSinceLastCall = time - lastCallTime, | ||
timeSinceLastInvoke = time - lastInvokeTime; | ||
function createOverlayCtor() { | ||
function Overlay(root, gmap) { | ||
this._root = root; | ||
this.setMap(gmap); | ||
// Either this is the first call, activity has stopped and we're at the | ||
// trailing edge, the system time has gone backwards and we're treating | ||
// it as the trailing edge, or we've hit the `maxWait` limit. | ||
return (lastCallTime === undefined || (timeSinceLastCall >= wait) || | ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); | ||
} | ||
Overlay.prototype = new google.maps.OverlayView(); | ||
function timerExpired() { | ||
var time = now(); | ||
if (shouldInvoke(time)) { | ||
return trailingEdge(time); | ||
} | ||
// Restart the timer. | ||
timerId = setTimeout(timerExpired, remainingWait(time)); | ||
} | ||
Overlay.prototype.onAdd = function() { | ||
var gmap = this.getMap(); | ||
gmap.__overlayProjection = this.getProjection(); | ||
gmap.getDiv().querySelector('.gm-style > div').appendChild(this._root); | ||
}; | ||
function trailingEdge(time) { | ||
timerId = undefined; | ||
/** | ||
* @override | ||
*/ | ||
Overlay.prototype.draw = function() { | ||
google.maps.event.trigger(this.getMap(), 'gmaprender'); | ||
}; | ||
// Only invoke if we have `lastArgs` which means `func` has been | ||
// debounced at least once. | ||
if (trailing && lastArgs) { | ||
return invokeFunc(time); | ||
} | ||
lastArgs = lastThis = undefined; | ||
return result; | ||
} | ||
Overlay.prototype.onRemove = function() { | ||
this._root.parentNode.removeChild(this._root); | ||
this._root = null; | ||
}; | ||
function cancel() { | ||
if (timerId !== undefined) { | ||
clearTimeout(timerId); | ||
} | ||
lastInvokeTime = 0; | ||
lastArgs = lastCallTime = lastThis = timerId = undefined; | ||
} | ||
Overlay.prototype.setZIndex = function(zIndex) { | ||
this._root.style.zIndex = zIndex; | ||
}; | ||
function flush() { | ||
return timerId === undefined ? result : trailingEdge(now()); | ||
} | ||
Overlay.prototype.getZIndex = function() { | ||
return this._root.style.zIndex; | ||
}; | ||
function debounced() { | ||
var time = now(), | ||
isInvoking = shouldInvoke(time); | ||
return Overlay; | ||
} | ||
lastArgs = arguments; | ||
lastThis = this; | ||
lastCallTime = time; | ||
function latLngToPixel(latLng, map) { | ||
var projection = map.__overlayProjection; | ||
if (!projection) { | ||
return; | ||
if (isInvoking) { | ||
if (timerId === undefined) { | ||
return leadingEdge(lastCallTime); | ||
} | ||
if (maxing) { | ||
// Handle invocations in a tight loop. | ||
timerId = setTimeout(timerExpired, wait); | ||
return invokeFunc(lastCallTime); | ||
} | ||
} | ||
if (timerId === undefined) { | ||
timerId = setTimeout(timerExpired, wait); | ||
} | ||
return result; | ||
} | ||
debounced.cancel = cancel; | ||
debounced.flush = flush; | ||
return debounced; | ||
} | ||
return projection.fromLatLngToContainerPixel(latLng); | ||
} | ||
/** | ||
* 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 && (type == 'object' || type == 'function'); | ||
} | ||
function pixelToLatLng(pixel, map) { | ||
var projection = map.__overlayProjection; | ||
if (!projection) { | ||
return; | ||
/** | ||
* 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 && typeof value == 'object'; | ||
} | ||
return projection.fromContainerPixelToLatLng(pixel); | ||
} | ||
/** | ||
* Checks if `value` is classified as a `Symbol` primitive or object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`. | ||
* @example | ||
* | ||
* _.isSymbol(Symbol.iterator); | ||
* // => true | ||
* | ||
* _.isSymbol('abc'); | ||
* // => false | ||
*/ | ||
function isSymbol(value) { | ||
return typeof value == 'symbol' || | ||
(isObjectLike(value) && objectToString.call(value) == symbolTag); | ||
} | ||
/* harmony default export */ __webpack_exports__["default"] = (GMapCoordSys); | ||
/** | ||
* Converts `value` to a number. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to process. | ||
* @returns {number} Returns the number. | ||
* @example | ||
* | ||
* _.toNumber(3.2); | ||
* // => 3.2 | ||
* | ||
* _.toNumber(Number.MIN_VALUE); | ||
* // => 5e-324 | ||
* | ||
* _.toNumber(Infinity); | ||
* // => Infinity | ||
* | ||
* _.toNumber('3.2'); | ||
* // => 3.2 | ||
*/ | ||
function toNumber(value) { | ||
if (typeof value == 'number') { | ||
return value; | ||
} | ||
if (isSymbol(value)) { | ||
return NAN; | ||
} | ||
if (isObject(value)) { | ||
var other = typeof value.valueOf == 'function' ? value.valueOf() : value; | ||
value = isObject(other) ? (other + '') : other; | ||
} | ||
if (typeof value != 'string') { | ||
return value === 0 ? value : +value; | ||
} | ||
value = value.replace(reTrim, ''); | ||
var isBinary = reIsBinary.test(value); | ||
return (isBinary || reIsOctal.test(value)) | ||
? freeParseInt(value.slice(2), isBinary ? 2 : 8) | ||
: (reIsBadHex.test(value) ? NAN : +value); | ||
} | ||
var lodash_debounce = debounce; | ||
/***/ }), | ||
/* global google */ | ||
/***/ "./src/GMapModel.js": | ||
/*!**************************!*\ | ||
!*** ./src/GMapModel.js ***! | ||
\**************************/ | ||
/*! exports provided: default */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
echarts.extendComponentView({ | ||
type: 'gmap', | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */ var echarts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! echarts */ "echarts"); | ||
/* harmony import */ var echarts__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(echarts__WEBPACK_IMPORTED_MODULE_0__); | ||
render: function(gmapModel, ecModel, api) { | ||
var rendering = true; | ||
var gmap = gmapModel.getGoogleMap(); | ||
var viewportRoot = api.getZr().painter.getViewportRoot(); | ||
var coordSys = gmapModel.coordinateSystem; | ||
var offsetEl = gmap.getDiv(); | ||
var renderOnMoving = gmapModel.get('renderOnMoving'); | ||
var oldWidth = offsetEl.clientWidth; | ||
var oldHeight = offsetEl.clientHeight; | ||
function v2Equal(a, b) { | ||
return a && b && a[0] === b[0] && a[1] === b[1]; | ||
} | ||
var renderHandler = function() { | ||
if (rendering) { | ||
return; | ||
} | ||
/* harmony default export */ __webpack_exports__["default"] = (echarts__WEBPACK_IMPORTED_MODULE_0__["extendComponentModel"]({ | ||
type: 'gmap', | ||
// need resize? | ||
var width = offsetEl.clientWidth; | ||
var height = offsetEl.clientHeight; | ||
if (width !== oldWidth || height !== oldHeight) { | ||
return resizeHandler.call(this); | ||
} | ||
setGoogleMap: function(gmap) { | ||
this.__gmap = gmap; | ||
}, | ||
var mapOffset = [ | ||
-parseInt(offsetEl.style.left, 10) || 0, | ||
-parseInt(offsetEl.style.top, 10) || 0 | ||
]; | ||
viewportRoot.style.left = mapOffset[0] + 'px'; | ||
viewportRoot.style.top = mapOffset[1] + 'px'; | ||
getGoogleMap: function() { | ||
// __gmap is set when creating GMapCoordSys | ||
return this.__gmap; | ||
}, | ||
coordSys.setMapOffset(mapOffset); | ||
gmapModel.__mapOffset = mapOffset; | ||
setEChartsLayer: function(layer) { | ||
this.__echartsLayer = layer; | ||
}, | ||
api.dispatchAction({ | ||
type: 'gmapRoam', | ||
animation: { | ||
// in ECharts 5.x, | ||
// we can set animation duration as 0 | ||
// to ensure no delay when moving or zooming | ||
duration: 0 | ||
} | ||
}); | ||
}; | ||
getEChartsLayer: function() { | ||
return this.__echartsLayer; | ||
}, | ||
var resizeHandler = function() { | ||
echarts.getInstanceByDom(api.getDom()).resize(); | ||
}; | ||
setCenterAndZoom: function(center, zoom) { | ||
this.option.center = center; | ||
this.option.zoom = zoom; | ||
}, | ||
this._oldRenderHandler && this._oldRenderHandler.remove(); | ||
centerOrZoomChanged: function(center, zoom) { | ||
var option = this.option; | ||
return !(v2Equal(center, option.center) && zoom === option.zoom); | ||
}, | ||
if (!renderOnMoving) { | ||
renderHandler = lodash_debounce(renderHandler, 100); | ||
resizeHandler = lodash_debounce(resizeHandler, 100); | ||
} | ||
defaultOption: { | ||
center: { lat: 39.90923, lng: 116.397428 }, | ||
zoom: 5, | ||
this._oldRenderHandler = google.maps.event.addListener(gmap, 'gmaprender', renderHandler); | ||
// extension options | ||
echartsLayerZIndex: 2000, | ||
renderOnMoving: true | ||
} | ||
})); | ||
rendering = false; | ||
}, | ||
dispose: function(ecModel, api) { | ||
this._oldRenderHandler && this._oldRenderHandler.remove(); | ||
this._oldRenderHandler = null; | ||
/***/ }), | ||
var component = ecModel.getComponent('gmap'); | ||
var gmapInstance = component.getGoogleMap(); | ||
/***/ "./src/GMapView.js": | ||
/*!*************************!*\ | ||
!*** ./src/GMapView.js ***! | ||
\*************************/ | ||
/*! exports provided: default */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
// remove injected projection | ||
delete gmapInstance.__overlayProjection; | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */ var echarts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! echarts */ "echarts"); | ||
/* harmony import */ var echarts__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(echarts__WEBPACK_IMPORTED_MODULE_0__); | ||
/* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash.debounce */ "./node_modules/lodash.debounce/index.js"); | ||
/* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_debounce__WEBPACK_IMPORTED_MODULE_1__); | ||
/* global google */ | ||
// clear all listeners of map instance | ||
google.maps.event.clearInstanceListeners(gmapInstance); | ||
// remove DOM of map instance | ||
var mapDiv = gmapInstance.getDiv(); | ||
mapDiv.parentNode.removeChild(mapDiv); | ||
component.setGoogleMap(null); | ||
component.setEChartsLayer(null); | ||
component.coordinateSystem.setGoogleMap(null); | ||
component.coordinateSystem = null; | ||
} | ||
}); | ||
/** | ||
* Google Map component extension | ||
*/ | ||
/* harmony default export */ __webpack_exports__["default"] = (echarts__WEBPACK_IMPORTED_MODULE_0__["extendComponentView"]({ | ||
type: 'gmap', | ||
echarts.registerCoordinateSystem('gmap', GMapCoordSys); | ||
render: function(gmapModel, ecModel, api) { | ||
var rendering = true; | ||
var gmap = gmapModel.getGoogleMap(); | ||
var viewportRoot = api.getZr().painter.getViewportRoot(); | ||
var coordSys = gmapModel.coordinateSystem; | ||
var offsetEl = gmap.getDiv(); | ||
var renderOnMoving = gmapModel.get('renderOnMoving'); | ||
var oldWidth = offsetEl.clientWidth; | ||
var oldHeight = offsetEl.clientHeight; | ||
var renderHandler = function() { | ||
if (rendering) { | ||
return; | ||
} | ||
// need resize? | ||
var width = offsetEl.clientWidth; | ||
var height = offsetEl.clientHeight; | ||
if (width !== oldWidth || height !== oldHeight) { | ||
return resizeHandler.call(this); | ||
} | ||
var mapOffset = [ | ||
-parseInt(offsetEl.style.left, 10) || 0, | ||
-parseInt(offsetEl.style.top, 10) || 0 | ||
]; | ||
viewportRoot.style.left = mapOffset[0] + 'px'; | ||
viewportRoot.style.top = mapOffset[1] + 'px'; | ||
coordSys.setMapOffset(mapOffset); | ||
gmapModel.__mapOffset = mapOffset; | ||
api.dispatchAction({ | ||
type: 'gmapRoam', | ||
animation: { | ||
// in ECharts 5.x, | ||
// we can set animation duration as 0 | ||
// to ensure no delay when moving or zooming | ||
duration: 0 | ||
} | ||
// Action | ||
echarts.registerAction( | ||
{ | ||
type: 'gmapRoam', | ||
event: 'gmapRoam', | ||
update: 'updateLayout' | ||
}, | ||
function(payload, ecModel) { | ||
ecModel.eachComponent('gmap', function(gmapModel) { | ||
var gmap = gmapModel.getGoogleMap(); | ||
var center = gmap.getCenter(); | ||
gmapModel.setCenterAndZoom([center.lng(), center.lat()], gmap.getZoom()); | ||
}); | ||
}; | ||
var resizeHandler = function() { | ||
echarts__WEBPACK_IMPORTED_MODULE_0__["getInstanceByDom"](api.getDom()).resize(); | ||
}; | ||
this._oldRenderHandler && this._oldRenderHandler.remove(); | ||
if (!renderOnMoving) { | ||
renderHandler = lodash_debounce__WEBPACK_IMPORTED_MODULE_1___default()(renderHandler, 100); | ||
resizeHandler = lodash_debounce__WEBPACK_IMPORTED_MODULE_1___default()(resizeHandler, 100); | ||
} | ||
); | ||
this._oldRenderHandler = google.maps.event.addListener(gmap, 'gmaprender', renderHandler); | ||
exports.name = name; | ||
exports.version = version; | ||
rendering = false; | ||
}, | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
dispose: function(ecModel, api) { | ||
this._oldRenderHandler && this._oldRenderHandler.remove(); | ||
this._oldRenderHandler = null; | ||
var component = ecModel.getComponent('gmap'); | ||
var gmapInstance = component.getGoogleMap(); | ||
// remove injected projection | ||
delete gmapInstance.__overlayProjection; | ||
// clear all listeners of map instance | ||
google.maps.event.clearInstanceListeners(gmapInstance); | ||
// remove DOM of map instance | ||
var mapDiv = gmapInstance.getDiv(); | ||
mapDiv.parentNode.removeChild(mapDiv); | ||
component.setGoogleMap(null); | ||
component.setEChartsLayer(null); | ||
component.coordinateSystem.setGoogleMap(null); | ||
component.coordinateSystem = null; | ||
} | ||
})); | ||
/***/ }), | ||
/***/ "./src/index.js": | ||
/*!**********************!*\ | ||
!*** ./src/index.js ***! | ||
\**********************/ | ||
/*! exports provided: version, name */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */ var _package_json__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../package.json */ "./package.json"); | ||
var _package_json__WEBPACK_IMPORTED_MODULE_0___namespace = /*#__PURE__*/__webpack_require__.t(/*! ../package.json */ "./package.json", 1); | ||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "version", function() { return _package_json__WEBPACK_IMPORTED_MODULE_0__["version"]; }); | ||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _package_json__WEBPACK_IMPORTED_MODULE_0__["name"]; }); | ||
/* harmony import */ var echarts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! echarts */ "echarts"); | ||
/* harmony import */ var echarts__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(echarts__WEBPACK_IMPORTED_MODULE_1__); | ||
/* harmony import */ var _GMapCoordSys__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./GMapCoordSys */ "./src/GMapCoordSys.js"); | ||
/* harmony import */ var _GMapModel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./GMapModel */ "./src/GMapModel.js"); | ||
/* harmony import */ var _GMapView__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./GMapView */ "./src/GMapView.js"); | ||
/** | ||
* Google Map component extension | ||
*/ | ||
echarts__WEBPACK_IMPORTED_MODULE_1__["registerCoordinateSystem"]('gmap', _GMapCoordSys__WEBPACK_IMPORTED_MODULE_2__["default"]); | ||
// Action | ||
echarts__WEBPACK_IMPORTED_MODULE_1__["registerAction"]( | ||
{ | ||
type: 'gmapRoam', | ||
event: 'gmapRoam', | ||
update: 'updateLayout' | ||
}, | ||
function(payload, ecModel) { | ||
ecModel.eachComponent('gmap', function(gmapModel) { | ||
var gmap = gmapModel.getGoogleMap(); | ||
var center = gmap.getCenter(); | ||
gmapModel.setCenterAndZoom([center.lng(), center.lat()], gmap.getZoom()); | ||
}); | ||
} | ||
); | ||
/***/ }), | ||
/***/ "echarts": | ||
/*!**************************!*\ | ||
!*** external "echarts" ***! | ||
\**************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_echarts__; | ||
/***/ }) | ||
/******/ }); | ||
}); | ||
//# sourceMappingURL=echarts-extension-gmap.js.map | ||
}))); | ||
//# sourceMappingURL=echarts-extension-gmap.js.map |
@@ -1,1 +0,29 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("echarts")):"function"==typeof define&&define.amd?define("gmap",["echarts"],t):"object"==typeof exports?exports.gmap=t(require("echarts")):(e.echarts=e.echarts||{},e.echarts.gmap=t(e.echarts))}(this,(function(e){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(t,n){t.exports=e},function(e){e.exports=JSON.parse('{"a":"echarts-extension-gmap","b":"1.2.0"}')},function(e,t,n){(function(t){var n=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,i=/^0o[0-7]+$/i,a=parseInt,s="object"==typeof t&&t&&t.Object===Object&&t,c="object"==typeof self&&self&&self.Object===Object&&self,u=s||c||Function("return this")(),p=Object.prototype.toString,l=Math.max,f=Math.min,g=function(){return u.Date.now()};function d(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function m(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==p.call(e)}(e))return NaN;if(d(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=d(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var s=r.test(e);return s||i.test(e)?a(e.slice(2),s?2:8):o.test(e)?NaN:+e}e.exports=function(e,t,n){var o,r,i,a,s,c,u=0,p=!1,h=!1,y=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(t){var n=o,i=r;return o=r=void 0,u=t,a=e.apply(i,n)}function _(e){return u=e,s=setTimeout(b,t),p?v(e):a}function x(e){var n=e-c;return void 0===c||n>=t||n<0||h&&e-u>=i}function b(){var e=g();if(x(e))return w(e);s=setTimeout(b,function(e){var n=t-(e-c);return h?f(n,i-(e-u)):n}(e))}function w(e){return s=void 0,y&&o?v(e):(o=r=void 0,a)}function O(){var e=g(),n=x(e);if(o=arguments,r=this,c=e,n){if(void 0===s)return _(c);if(h)return s=setTimeout(b,t),v(c)}return void 0===s&&(s=setTimeout(b,t)),a}return t=m(t)||0,d(n)&&(p=!!n.leading,i=(h="maxWait"in n)?l(m(n.maxWait)||0,t):i,y="trailing"in n?!!n.trailing:y),O.cancel=function(){void 0!==s&&clearTimeout(s),u=0,o=c=r=s=void 0},O.flush=function(){return void 0===s?a:w(g())},O}}).call(this,n(3))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t),n.d(t,"version",(function(){return o.b})),n.d(t,"name",(function(){return o.a}));var o=n(1),r=n(0);function i(e,t){this._gmap=e,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=t}var a,s=i.prototype,c=["echartsLayerZIndex","renderOnMoving"];function u(e,t){return t=t||[0,0],r.util.map([0,1],(function(n){var o=t[n],r=e[n]/2,i=[],a=[];return i[n]=o-r,a[n]=o+r,i[1-n]=a[1-n]=t[1-n],Math.abs(this.dataToPoint(i)[n]-this.dataToPoint(a)[n])}),this)}function p(e,t){var n=t.__overlayProjection;if(n)return n.fromLatLngToContainerPixel(e)}s.dimensions=["lng","lat"],s.setZoom=function(e){this._zoom=e},s.setCenter=function(e){var t=new google.maps.LatLng(e[1],e[0]);this._center=p(t,this._gmap)},s.setMapOffset=function(e){this._mapOffset=e},s.setGoogleMap=function(e){this._gmap=e},s.getGoogleMap=function(){return this._gmap},s.dataToPoint=function(e){var t=p(new google.maps.LatLng(e[1],e[0]),this._gmap);if(t){var n=this._mapOffset;return[t.x-n[0],t.y-n[1]]}},s.pointToData=function(e){var t=this._mapOffset,n=function(e,t){var n=t.__overlayProjection;if(!n)return;return n.fromContainerPixelToLatLng(e)}(new google.maps.Point(e[0]+t[0],e[1]+t[1]),this._gmap);return[n.lng(),n.lat()]},s.getViewRect=function(){var e=this._api;return new r.graphic.BoundingRect(0,0,e.getWidth(),e.getHeight())},s.getRoamTransform=function(){return r.matrix.create()},s.prepareCustoms=function(e){var t=this.getViewRect();return{coordSys:{type:"gmap",x:t.x,y:t.y,width:t.width,height:t.height},api:{coord:r.util.bind(this.dataToPoint,this),size:r.util.bind(u,this)}}},i.dimensions=s.dimensions,i.create=function(e,t){var n,o=t.getDom();e.eachComponent("gmap",(function(e){var s=t.getZr().painter,u=s.getViewportRoot();if("undefined"==typeof google||void 0===google.maps||void 0===google.maps.Map)throw new Error("It seems that Google Map API has not been loaded completely yet.");if(a=a||function(){function e(e,t){this._root=e,this.setMap(t)}return e.prototype=new google.maps.OverlayView,e.prototype.onAdd=function(){var e=this.getMap();e.__overlayProjection=this.getProjection(),e.getDiv().querySelector(".gm-style > div").appendChild(this._root)},e.prototype.draw=function(){google.maps.event.trigger(this.getMap(),"gmaprender")},e.prototype.onRemove=function(){this._root.parentNode.removeChild(this._root),this._root=null},e.prototype.setZIndex=function(e){this._root.style.zIndex=e},e.prototype.getZIndex=function(){return this._root.style.zIndex},e}(),n)throw new Error("Only one google map component can exist");var p=e.getGoogleMap();if(!p){var l=o.querySelector(".ec-extension-google-map");l&&(u.style.left="0px",u.style.top="0px",u.style.width="100%",u.style.height="100%",o.removeChild(l)),(l=document.createElement("div")).style.cssText="width:100%;height:100%",l.classList.add("ec-extension-google-map"),o.appendChild(l);var f=r.util.clone(e.get()),g=f.echartsLayerZIndex;r.util.each(c,(function(e){delete f[e]}));var d=f.center;r.util.isArray(d)&&(f.center={lng:d[0],lat:d[1]}),p=new google.maps.Map(l,f),e.setGoogleMap(p),e.__projectionChangeListener&&e.__projectionChangeListener.remove(),e.__projectionChangeListener=google.maps.event.addListener(p,"projection_changed",(function(){var t=e.getEChartsLayer();t&&t.setMap(null);var n=new a(u,p);n.setZIndex(g),e.setEChartsLayer(n)})),s.getViewportRootOffset=function(){return{offsetLeft:0,offsetTop:0}}}var m=[null!=(d=e.get("center")).lng?d.lng:d[0],null!=d.lat?d.lat:d[1]],h=e.get("zoom");if(d&&h){var y=p.getCenter(),v=p.getZoom();if(e.centerOrZoomChanged([y.lng(),y.lat()],v)){var _=new google.maps.LatLng(m[1],m[0]);p.setOptions({center:_,zoom:h})}}(n=new i(p,t)).setMapOffset(e.__mapOffset||[0,0]),n.setZoom(h),n.setCenter(m),e.coordinateSystem=n})),e.eachSeries((function(e){"gmap"===e.get("coordinateSystem")&&(e.coordinateSystem=n)}))};var l=i;r.extendComponentModel({type:"gmap",setGoogleMap:function(e){this.__gmap=e},getGoogleMap:function(){return this.__gmap},setEChartsLayer:function(e){this.__echartsLayer=e},getEChartsLayer:function(){return this.__echartsLayer},setCenterAndZoom:function(e,t){this.option.center=e,this.option.zoom=t},centerOrZoomChanged:function(e,t){var n,o,r=this.option;return n=e,o=r.center,!(n&&o&&n[0]===o[0]&&n[1]===o[1]&&t===r.zoom)},defaultOption:{center:{lat:39.90923,lng:116.397428},zoom:5,echartsLayerZIndex:2e3,renderOnMoving:!0}});var f=n(2),g=n.n(f);r.extendComponentView({type:"gmap",render:function(e,t,n){var o=!0,i=e.getGoogleMap(),a=n.getZr().painter.getViewportRoot(),s=e.coordinateSystem,c=i.getDiv(),u=e.get("renderOnMoving"),p=c.clientWidth,l=c.clientHeight,f=function(){if(!o){var t=c.clientWidth,r=c.clientHeight;if(t!==p||r!==l)return d.call(this);var i=[-parseInt(c.style.left,10)||0,-parseInt(c.style.top,10)||0];a.style.left=i[0]+"px",a.style.top=i[1]+"px",s.setMapOffset(i),e.__mapOffset=i,n.dispatchAction({type:"gmapRoam",animation:{duration:0}})}},d=function(){r.getInstanceByDom(n.getDom()).resize()};this._oldRenderHandler&&this._oldRenderHandler.remove(),u||(f=g()(f,100),d=g()(d,100)),this._oldRenderHandler=google.maps.event.addListener(i,"gmaprender",f),o=!1},dispose:function(e,t){this._oldRenderHandler&&this._oldRenderHandler.remove(),this._oldRenderHandler=null;var n=e.getComponent("gmap"),o=n.getGoogleMap();delete o.__overlayProjection,google.maps.event.clearInstanceListeners(o);var r=o.getDiv();r.parentNode.removeChild(r),n.setGoogleMap(null),n.setEChartsLayer(null),n.coordinateSystem.setGoogleMap(null),n.coordinateSystem=null}});r.registerCoordinateSystem("gmap",l),r.registerAction({type:"gmapRoam",event:"gmapRoam",update:"updateLayout"},(function(e,t){t.eachComponent("gmap",(function(e){var t=e.getGoogleMap(),n=t.getCenter();e.setCenterAndZoom([n.lng(),n.lat()],t.getZoom())}))}))}])})); | ||
/*! | ||
* echarts-extension-gmap | ||
* @version 1.2.1 | ||
* @author plainheart | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Zhongxiang.Wang | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("echarts")):"function"==typeof define&&define.amd?define(["exports","echarts"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).echarts=e.echarts||{},e.echarts.gmap={}),e.echarts)}(this,(function(e,t){"use strict";function n(e,t){this._gmap=e,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=t}var o,r=n.prototype,i=["echartsLayerZIndex","renderOnMoving"];function a(e,n){return n=n||[0,0],t.util.map([0,1],(function(t){var o=n[t],r=e[t]/2,i=[],a=[];return i[t]=o-r,a[t]=o+r,i[1-t]=a[1-t]=n[1-t],Math.abs(this.dataToPoint(i)[t]-this.dataToPoint(a)[t])}),this)}function s(e,t){var n=t.__overlayProjection;if(n)return n.fromLatLngToContainerPixel(e)}r.dimensions=["lng","lat"],r.setZoom=function(e){this._zoom=e},r.setCenter=function(e){var t=new google.maps.LatLng(e[1],e[0]);this._center=s(t,this._gmap)},r.setMapOffset=function(e){this._mapOffset=e},r.setGoogleMap=function(e){this._gmap=e},r.getGoogleMap=function(){return this._gmap},r.dataToPoint=function(e){var t=s(new google.maps.LatLng(e[1],e[0]),this._gmap);if(t){var n=this._mapOffset;return[t.x-n[0],t.y-n[1]]}},r.pointToData=function(e){var t=this._mapOffset,n=function(e,t){var n=t.__overlayProjection;if(!n)return;return n.fromContainerPixelToLatLng(e)}(new google.maps.Point(e[0]+t[0],e[1]+t[1]),this._gmap);return[n.lng(),n.lat()]},r.getViewRect=function(){var e=this._api;return new t.graphic.BoundingRect(0,0,e.getWidth(),e.getHeight())},r.getRoamTransform=function(){return t.matrix.create()},r.prepareCustoms=function(e){var n=this.getViewRect();return{coordSys:{type:"gmap",x:n.x,y:n.y,width:n.width,height:n.height},api:{coord:t.util.bind(this.dataToPoint,this),size:t.util.bind(a,this)}}},n.dimensions=r.dimensions,n.create=function(e,r){var a,s=r.getDom();e.eachComponent("gmap",(function(e){var f=r.getZr().painter,l=f.getViewportRoot();if("undefined"==typeof google||"undefined"==typeof google.maps||"undefined"==typeof google.maps.Map)throw new Error("It seems that Google Map API has not been loaded completely yet.");if(o=o||function(){function e(e,t){this._root=e,this.setMap(t)}return e.prototype=new google.maps.OverlayView,e.prototype.onAdd=function(){var e=this.getMap();e.__overlayProjection=this.getProjection(),e.getDiv().querySelector(".gm-style > div").appendChild(this._root)},e.prototype.draw=function(){google.maps.event.trigger(this.getMap(),"gmaprender")},e.prototype.onRemove=function(){this._root.parentNode.removeChild(this._root),this._root=null},e.prototype.setZIndex=function(e){this._root.style.zIndex=e},e.prototype.getZIndex=function(){return this._root.style.zIndex},e}(),a)throw new Error("Only one google map component can exist");var p=e.getGoogleMap();if(!p){var u=s.querySelector(".ec-extension-google-map");u&&(l.style.left="0px",l.style.top="0px",l.style.width="100%",l.style.height="100%",s.removeChild(u)),(u=document.createElement("div")).style.cssText="width:100%;height:100%",u.classList.add("ec-extension-google-map"),s.appendChild(u);var c=t.util.clone(e.get()),g=c.echartsLayerZIndex;t.util.each(i,(function(e){delete c[e]}));var d=c.center;t.util.isArray(d)&&(c.center={lng:d[0],lat:d[1]}),p=new google.maps.Map(u,c),e.setGoogleMap(p),e.__projectionChangeListener&&e.__projectionChangeListener.remove(),e.__projectionChangeListener=google.maps.event.addListener(p,"projection_changed",(function(){var t=e.getEChartsLayer();t&&t.setMap(null);var n=new o(l,p);n.setZIndex(g),e.setEChartsLayer(n)})),f.getViewportRootOffset=function(){return{offsetLeft:0,offsetTop:0}}}var m=[null!=(d=e.get("center")).lng?d.lng:d[0],null!=d.lat?d.lat:d[1]],h=e.get("zoom");if(d&&h){var y=p.getCenter(),v=p.getZoom();if(e.centerOrZoomChanged([y.lng(),y.lat()],v)){var _=new google.maps.LatLng(m[1],m[0]);p.setOptions({center:_,zoom:h})}}(a=new n(p,r)).setMapOffset(e.__mapOffset||[0,0]),a.setZoom(h),a.setCenter(m),e.coordinateSystem=a})),e.eachSeries((function(e){"gmap"===e.get("coordinateSystem")&&(e.coordinateSystem=a)}))},t.extendComponentModel({type:"gmap",setGoogleMap:function(e){this.__gmap=e},getGoogleMap:function(){return this.__gmap},setEChartsLayer:function(e){this.__echartsLayer=e},getEChartsLayer:function(){return this.__echartsLayer},setCenterAndZoom:function(e,t){this.option.center=e,this.option.zoom=t},centerOrZoomChanged:function(e,t){var n,o,r=this.option;return n=e,o=r.center,!(n&&o&&n[0]===o[0]&&n[1]===o[1]&&t===r.zoom)},defaultOption:{center:{lat:39.90923,lng:116.397428},zoom:5,echartsLayerZIndex:2e3,renderOnMoving:!0}});var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},l=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,c=/^0o[0-7]+$/i,g=parseInt,d="object"==typeof f&&f&&f.Object===Object&&f,m="object"==typeof self&&self&&self.Object===Object&&self,h=d||m||Function("return this")(),y=Object.prototype.toString,v=Math.max,_=Math.min,x=function(){return h.Date.now()};function w(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function C(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==y.call(e)}(e))return NaN;if(w(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=w(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(l,"");var n=u.test(e);return n||c.test(e)?g(e.slice(2),n?2:8):p.test(e)?NaN:+e}var L=function(e,t,n){var o,r,i,a,s,f,l=0,p=!1,u=!1,c=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function g(t){var n=o,i=r;return o=r=undefined,l=t,a=e.apply(i,n)}function d(e){return l=e,s=setTimeout(h,t),p?g(e):a}function m(e){var n=e-f;return f===undefined||n>=t||n<0||u&&e-l>=i}function h(){var e=x();if(m(e))return y(e);s=setTimeout(h,function(e){var n=t-(e-f);return u?_(n,i-(e-l)):n}(e))}function y(e){return s=undefined,c&&o?g(e):(o=r=undefined,a)}function L(){var e=x(),n=m(e);if(o=arguments,r=this,f=e,n){if(s===undefined)return d(f);if(u)return s=setTimeout(h,t),g(f)}return s===undefined&&(s=setTimeout(h,t)),a}return t=C(t)||0,w(n)&&(p=!!n.leading,i=(u="maxWait"in n)?v(C(n.maxWait)||0,t):i,c="trailing"in n?!!n.trailing:c),L.cancel=function(){s!==undefined&&clearTimeout(s),l=0,o=f=r=s=undefined},L.flush=function(){return s===undefined?a:y(x())},L};t.extendComponentView({type:"gmap",render:function(e,n,o){var r=!0,i=e.getGoogleMap(),a=o.getZr().painter.getViewportRoot(),s=e.coordinateSystem,f=i.getDiv(),l=e.get("renderOnMoving"),p=f.clientWidth,u=f.clientHeight,c=function(){if(!r){var t=f.clientWidth,n=f.clientHeight;if(t!==p||n!==u)return g.call(this);var i=[-parseInt(f.style.left,10)||0,-parseInt(f.style.top,10)||0];a.style.left=i[0]+"px",a.style.top=i[1]+"px",s.setMapOffset(i),e.__mapOffset=i,o.dispatchAction({type:"gmapRoam",animation:{duration:0}})}},g=function(){t.getInstanceByDom(o.getDom()).resize()};this._oldRenderHandler&&this._oldRenderHandler.remove(),l||(c=L(c,100),g=L(g,100)),this._oldRenderHandler=google.maps.event.addListener(i,"gmaprender",c),r=!1},dispose:function(e,t){this._oldRenderHandler&&this._oldRenderHandler.remove(),this._oldRenderHandler=null;var n=e.getComponent("gmap"),o=n.getGoogleMap();delete o.__overlayProjection,google.maps.event.clearInstanceListeners(o);var r=o.getDiv();r.parentNode.removeChild(r),n.setGoogleMap(null),n.setEChartsLayer(null),n.coordinateSystem.setGoogleMap(null),n.coordinateSystem=null}}),t.registerCoordinateSystem("gmap",n),t.registerAction({type:"gmapRoam",event:"gmapRoam",update:"updateLayout"},(function(e,t){t.eachComponent("gmap",(function(e){var t=e.getGoogleMap(),n=t.getCenter();e.setCenterAndZoom([n.lng(),n.lat()],t.getZoom())}))})),e.name="echarts-extension-gmap",e.version="1.2.1",Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "echarts-extension-gmap", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "An Google Map(https://www.google.com/maps) extension for Apache ECharts (incubating) (https://github.com/apache/incubator-echarts)", | ||
"main": "dist/echarts-extension-gmap.min.js", | ||
"scripts": { | ||
"build": "webpack --env=production --optimize-minimize --progress --colors", | ||
"dev": "webpack --env=development", | ||
"watch": "webpack --env=development --watch", | ||
"dev": "node build/build.js", | ||
"watch": "node build/build.js -w", | ||
"build": "node build/build.js --min", | ||
"release": "node build/build.js --release", | ||
"help": "node build/build.js --help", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -36,4 +38,9 @@ }, | ||
"devDependencies": { | ||
"webpack": "^4.29.5", | ||
"webpack-cli": "^3.2.3" | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"commander": "^6.1.0", | ||
"fs-extra": "^9.0.1", | ||
"rollup": "^2.28.2", | ||
"rollup-plugin-terser": "^7.0.2" | ||
}, | ||
@@ -40,0 +47,0 @@ "dependencies": { |
[![NPM version](https://img.shields.io/npm/v/echarts-extension-gmap.svg?style=flat)](https://www.npmjs.org/package/echarts-extension-gmap) | ||
[![Build Status](https://travis-ci.org/plainheart/echarts-extension-gmap.svg?branch=master)](https://travis-ci.org/plainheart/echarts-extension-gmap) | ||
[![Downloads](https://img.shields.io/npm/dm/echarts-extension-gmap.svg)](https://npmcharts.com/compare/echarts-extension-gmap?minimal=true) | ||
[![NPM Downloads](https://img.shields.io/npm/dm/echarts-extension-gmap.svg)](https://npmcharts.com/compare/echarts-extension-gmap?minimal=true) | ||
[![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/echarts-extension-gmap/badge)](https://www.jsdelivr.com/package/npm/echarts-extension-gmap) | ||
[![License](https://img.shields.io/npm/l/echarts-extension-gmap.svg)](https://www.npmjs.com/package/echarts-extension-gmap) | ||
@@ -5,0 +6,0 @@ |
[![NPM version](https://img.shields.io/npm/v/echarts-extension-gmap.svg?style=flat)](https://www.npmjs.org/package/echarts-extension-gmap) | ||
[![Build Status](https://travis-ci.org/plainheart/echarts-extension-gmap.svg?branch=master)](https://travis-ci.org/plainheart/echarts-extension-gmap) | ||
[![Downloads](https://img.shields.io/npm/dm/echarts-extension-gmap.svg)](https://npmcharts.com/compare/echarts-extension-gmap?minimal=true) | ||
[![NPM Downloads](https://img.shields.io/npm/dm/echarts-extension-gmap.svg)](https://npmcharts.com/compare/echarts-extension-gmap?minimal=true) | ||
[![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/echarts-extension-gmap/badge)](https://www.jsdelivr.com/package/npm/echarts-extension-gmap) | ||
[![License](https://img.shields.io/npm/l/echarts-extension-gmap.svg)](https://www.npmjs.com/package/echarts-extension-gmap) | ||
@@ -5,0 +6,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
143996
18
1443
107
2
7
2