Socket
Socket
Sign inDemoInstall

echarts-extension-gmap

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.1 to 1.4.0

426

dist/echarts-extension-gmap.js
/*!
* echarts-extension-gmap
* @version 1.3.1
* @version 1.4.0
* @author plainheart

@@ -35,4 +35,26 @@ *

function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
}
});
}
n['default'] = e;
return Object.freeze(n);
}
var echarts__namespace = /*#__PURE__*/_interopNamespace(echarts);
var name = "echarts-extension-gmap";
var version = "1.3.1";
var version = "1.4.0";

@@ -310,3 +332,3 @@ /* global google */

echarts.extendComponentModel({
echarts__namespace.extendComponentModel({
type: 'gmap',

@@ -346,2 +368,4 @@

// extension options
// since v1.4.0
roam: true,
echartsLayerZIndex: 2000,

@@ -352,385 +376,5 @@ renderOnMoving: true

var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
/**
* 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
*/
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/** `Object#toString` result references. */
var symbolTag = '[object Symbol]';
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g;
/** Used to detect bad signed hexadecimal string values. */
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
/** Used to detect binary string values. */
var reIsBinary = /^0b[01]+$/i;
/** Used to detect octal string values. */
var reIsOctal = /^0o[0-7]+$/i;
/** Built-in method references without a dependency on `root`. */
var freeParseInt = parseInt;
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
/** 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')();
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* 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();
};
/**
* 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;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
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;
lastArgs = lastThis = undefined;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
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;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime,
result = wait - timeSinceLastCall;
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime;
// 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));
}
function timerExpired() {
var time = now();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
// Restart the timer.
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = undefined;
// 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;
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
return timerId === undefined ? result : trailingEdge(now());
}
function debounced() {
var time = now(),
isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
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;
}
/**
* 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');
}
/**
* 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';
}
/**
* 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);
}
/**
* 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 */
echarts.extendComponentView({
echarts__namespace.extendComponentView({
type: 'gmap',

@@ -749,2 +393,6 @@

gmap.setOptions({
gestureHandling: gmapModel.get('roam') ? 'auto' : 'none'
});
var renderHandler = function() {

@@ -784,3 +432,3 @@ if (rendering) {

var resizeHandler = function() {
echarts.getInstanceByDom(api.getDom()).resize();
echarts__namespace.getInstanceByDom(api.getDom()).resize();
};

@@ -791,4 +439,4 @@

if (!renderOnMoving) {
renderHandler = lodash_debounce(renderHandler, 100);
resizeHandler = lodash_debounce(resizeHandler, 100);
renderHandler = echarts__namespace.throttle(renderHandler, 100, true);
resizeHandler = echarts__namespace.throttle(resizeHandler, 100, true);
}

@@ -838,6 +486,6 @@

echarts.registerCoordinateSystem('gmap', GMapCoordSys);
echarts__namespace.registerCoordinateSystem('gmap', GMapCoordSys);
// Action
echarts.registerAction(
echarts__namespace.registerAction(
{

@@ -844,0 +492,0 @@ type: 'gmapRoam',

4

dist/echarts-extension-gmap.min.js
/*!
* echarts-extension-gmap
* @version 1.3.1
* @version 1.4.0
* @author plainheart

@@ -29,2 +29,2 @@ *

*/
!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,i=n.prototype,r=["echartsLayerZIndex","renderOnMoving"];function a(e,n){return n=n||[0,0],t.util.map([0,1],(function(t){var o=n[t],i=e[t]/2,r=[],a=[];return r[t]=o-i,a[t]=o+i,r[1-t]=a[1-t]=n[1-t],Math.abs(this.dataToPoint(r)[t]-this.dataToPoint(a)[t])}),this)}function s(e,t){var n=t.__overlayProjection;return n?n.fromLatLngToContainerPixel(e):new google.maps.Point(-Infinity,-Infinity)}i.dimensions=["lng","lat"],i.setZoom=function(e){this._zoom=e},i.setCenter=function(e){var t=new google.maps.LatLng(e[1],e[0]);this._center=s(t,this._gmap)},i.setMapOffset=function(e){this._mapOffset=e},i.setGoogleMap=function(e){this._gmap=e},i.getGoogleMap=function(){return this._gmap},i.dataToPoint=function(e){var t=s(new google.maps.LatLng(e[1],e[0]),this._gmap),n=this._mapOffset;return[t.x-n[0],t.y-n[1]]},i.pointToData=function(e){var t=this._mapOffset,n=function(e,t){var n=t.__overlayProjection;if(!n)return new google.maps.Point(-Infinity,-Infinity);return n.fromContainerPixelToLatLng(e)}(new google.maps.Point(e[0]+t[0],e[1]+t[1]),this._gmap);return[n.lng(),n.lat()]},i.getViewRect=function(){var e=this._api;return new t.graphic.BoundingRect(0,0,e.getWidth(),e.getHeight())},i.getRoamTransform=function(){return t.matrix.create()},i.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=i.dimensions,n.create=function(e,i){var a,s=i.getDom();e.eachComponent("gmap",(function(e){var f=i.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")).className="ec-extension-google-map",u.style.cssText="position:absolute;top:0;left:0;right:0;bottom:0;",s.appendChild(u);var g=t.util.clone(e.get()),c=g.echartsLayerZIndex;t.util.each(r,(function(e){delete g[e]}));var d=g.center;t.util.isArray(d)&&(g.center={lng:d[0],lat:d[1]}),p=new google.maps.Map(u,g),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(c),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,i)).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,i=this.option;return n=e,o=i.center,!(n&&o&&n[0]===o[0]&&n[1]===o[1]&&t===i.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,g=/^0o[0-7]+$/i,c=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,w=function(){return h.Date.now()};function x(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(x(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=x(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(l,"");var n=u.test(e);return n||g.test(e)?c(e.slice(2),n?2:8):p.test(e)?NaN:+e}var M=function(e,t,n){var o,i,r,a,s,f,l=0,p=!1,u=!1,g=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function c(t){var n=o,r=i;return o=i=undefined,l=t,a=e.apply(r,n)}function d(e){return l=e,s=setTimeout(h,t),p?c(e):a}function m(e){var n=e-f;return f===undefined||n>=t||n<0||u&&e-l>=r}function h(){var e=w();if(m(e))return y(e);s=setTimeout(h,function(e){var n=t-(e-f);return u?_(n,r-(e-l)):n}(e))}function y(e){return s=undefined,g&&o?c(e):(o=i=undefined,a)}function M(){var e=w(),n=m(e);if(o=arguments,i=this,f=e,n){if(s===undefined)return d(f);if(u)return s=setTimeout(h,t),c(f)}return s===undefined&&(s=setTimeout(h,t)),a}return t=C(t)||0,x(n)&&(p=!!n.leading,r=(u="maxWait"in n)?v(C(n.maxWait)||0,t):r,g="trailing"in n?!!n.trailing:g),M.cancel=function(){s!==undefined&&clearTimeout(s),l=0,o=f=i=s=undefined},M.flush=function(){return s===undefined?a:y(w())},M};t.extendComponentView({type:"gmap",render:function(e,n,o){var i=!0,r=e.getGoogleMap(),a=o.getZr().painter.getViewportRoot(),s=e.coordinateSystem,f=r.getDiv(),l=e.get("renderOnMoving"),p=f.clientWidth,u=f.clientHeight,g=function(){if(!i){var t=f.clientWidth,n=f.clientHeight;if(t!==p||n!==u)return c.call(this);var r=[-parseInt(f.style.left,10)||0,-parseInt(f.style.top,10)||0];a.style.left=r[0]+"px",a.style.top=r[1]+"px",s.setMapOffset(r),e.__mapOffset=r,o.dispatchAction({type:"gmapRoam",animation:{duration:0}})}},c=function(){t.getInstanceByDom(o.getDom()).resize()};this._oldRenderHandler&&this._oldRenderHandler.remove(),l||(g=M(g,100),c=M(c,100)),this._oldRenderHandler=google.maps.event.addListener(r,"gmaprender",g),i=!1},dispose:function(e,t){this._oldRenderHandler&&this._oldRenderHandler.remove(),this._oldRenderHandler=null;var n=e.getComponent("gmap");if(n){var o=n.getGoogleMap();if(o){delete o.__overlayProjection,google.maps.event.clearInstanceListeners(o);var i=o.getDiv();i.parentNode&&i.parentNode.removeChild(i)}n.setGoogleMap(null),n.setEChartsLayer(null),n.coordinateSystem&&(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.3.1",Object.defineProperty(e,"__esModule",{value:!0})}));
!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 o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}})),t["default"]=e,Object.freeze(t)}var n=o(t);function r(e,t){this._gmap=e,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=t}var i,a=r.prototype,s=["echartsLayerZIndex","renderOnMoving"];function g(e,o){return o=o||[0,0],t.util.map([0,1],(function(t){var n=o[t],r=e[t]/2,i=[],a=[];return i[t]=n-r,a[t]=n+r,i[1-t]=a[1-t]=o[1-t],Math.abs(this.dataToPoint(i)[t]-this.dataToPoint(a)[t])}),this)}function p(e,t){var o=t.__overlayProjection;return o?o.fromLatLngToContainerPixel(e):new google.maps.Point(-Infinity,-Infinity)}a.dimensions=["lng","lat"],a.setZoom=function(e){this._zoom=e},a.setCenter=function(e){var t=new google.maps.LatLng(e[1],e[0]);this._center=p(t,this._gmap)},a.setMapOffset=function(e){this._mapOffset=e},a.setGoogleMap=function(e){this._gmap=e},a.getGoogleMap=function(){return this._gmap},a.dataToPoint=function(e){var t=p(new google.maps.LatLng(e[1],e[0]),this._gmap),o=this._mapOffset;return[t.x-o[0],t.y-o[1]]},a.pointToData=function(e){var t=this._mapOffset,o=function(e,t){var o=t.__overlayProjection;if(!o)return new google.maps.Point(-Infinity,-Infinity);return o.fromContainerPixelToLatLng(e)}(new google.maps.Point(e[0]+t[0],e[1]+t[1]),this._gmap);return[o.lng(),o.lat()]},a.getViewRect=function(){var e=this._api;return new t.graphic.BoundingRect(0,0,e.getWidth(),e.getHeight())},a.getRoamTransform=function(){return t.matrix.create()},a.prepareCustoms=function(e){var o=this.getViewRect();return{coordSys:{type:"gmap",x:o.x,y:o.y,width:o.width,height:o.height},api:{coord:t.util.bind(this.dataToPoint,this),size:t.util.bind(g,this)}}},r.dimensions=a.dimensions,r.create=function(e,o){var n,a=o.getDom();e.eachComponent("gmap",(function(e){var g=o.getZr().painter,p=g.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(i=i||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 l=e.getGoogleMap();if(!l){var c=a.querySelector(".ec-extension-google-map");c&&(p.style.left="0px",p.style.top="0px",p.style.width="100%",p.style.height="100%",a.removeChild(c)),(c=document.createElement("div")).className="ec-extension-google-map",c.style.cssText="position:absolute;top:0;left:0;right:0;bottom:0;",a.appendChild(c);var d=t.util.clone(e.get()),f=d.echartsLayerZIndex;t.util.each(s,(function(e){delete d[e]}));var m=d.center;t.util.isArray(m)&&(d.center={lng:m[0],lat:m[1]}),l=new google.maps.Map(c,d),e.setGoogleMap(l),e.__projectionChangeListener&&e.__projectionChangeListener.remove(),e.__projectionChangeListener=google.maps.event.addListener(l,"projection_changed",(function(){var t=e.getEChartsLayer();t&&t.setMap(null);var o=new i(p,l);o.setZIndex(f),e.setEChartsLayer(o)})),g.getViewportRootOffset=function(){return{offsetLeft:0,offsetTop:0}}}var u=[null!=(m=e.get("center")).lng?m.lng:m[0],null!=m.lat?m.lat:m[1]],h=e.get("zoom");if(m&&h){var y=l.getCenter(),v=l.getZoom();if(e.centerOrZoomChanged([y.lng(),y.lat()],v)){var _=new google.maps.LatLng(u[1],u[0]);l.setOptions({center:_,zoom:h})}}(n=new r(l,o)).setMapOffset(e.__mapOffset||[0,0]),n.setZoom(h),n.setCenter(u),e.coordinateSystem=n})),e.eachSeries((function(e){"gmap"===e.get("coordinateSystem")&&(e.coordinateSystem=n)}))},n.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 o,n,r=this.option;return o=e,n=r.center,!(o&&n&&o[0]===n[0]&&o[1]===n[1]&&t===r.zoom)},defaultOption:{center:{lat:39.90923,lng:116.397428},zoom:5,roam:!0,echartsLayerZIndex:2e3,renderOnMoving:!0}}),n.extendComponentView({type:"gmap",render:function(e,t,o){var r=!0,i=e.getGoogleMap(),a=o.getZr().painter.getViewportRoot(),s=e.coordinateSystem,g=i.getDiv(),p=e.get("renderOnMoving"),l=g.clientWidth,c=g.clientHeight;i.setOptions({gestureHandling:e.get("roam")?"auto":"none"});var d=function(){if(!r){var t=g.clientWidth,n=g.clientHeight;if(t!==l||n!==c)return f.call(this);var i=[-parseInt(g.style.left,10)||0,-parseInt(g.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}})}},f=function(){n.getInstanceByDom(o.getDom()).resize()};this._oldRenderHandler&&this._oldRenderHandler.remove(),p||(d=n.throttle(d,100,!0),f=n.throttle(f,100,!0)),this._oldRenderHandler=google.maps.event.addListener(i,"gmaprender",d),r=!1},dispose:function(e,t){this._oldRenderHandler&&this._oldRenderHandler.remove(),this._oldRenderHandler=null;var o=e.getComponent("gmap");if(o){var n=o.getGoogleMap();if(n){delete n.__overlayProjection,google.maps.event.clearInstanceListeners(n);var r=n.getDiv();r.parentNode&&r.parentNode.removeChild(r)}o.setGoogleMap(null),o.setEChartsLayer(null),o.coordinateSystem&&(o.coordinateSystem.setGoogleMap(null),o.coordinateSystem=null)}}}),n.registerCoordinateSystem("gmap",r),n.registerAction({type:"gmapRoam",event:"gmapRoam",update:"updateLayout"},(function(e,t){t.eachComponent("gmap",(function(e){var t=e.getGoogleMap(),o=t.getCenter();e.setCenterAndZoom([o.lng(),o.lat()],t.getZoom())}))})),e.name="echarts-extension-gmap",e.version="1.4.0",Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "echarts-extension-gmap",
"version": "1.3.1",
"version": "1.4.0",
"description": "A Google Map(https://www.google.com/maps) extension for Apache ECharts (https://github.com/apache/echarts)",

@@ -50,6 +50,3 @@ "main": "dist/echarts-extension-gmap.min.js",

"rollup-plugin-terser": "^7.0.2"
},
"dependencies": {
"lodash.debounce": "^4.0.8"
}
}
[![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)
[![Build Status](https://github.com/plainheart/echarts-extension-gmap/actions/workflows/ci.yml/badge.svg)](https://github.com/plainheart/echarts-extension-gmap/actions/workflows/ci.yml)
[![NPM Downloads](https://img.shields.io/npm/dm/echarts-extension-gmap.svg)](https://npmcharts.com/compare/echarts-extension-gmap?minimal=true)

@@ -75,10 +75,15 @@ [![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/echarts-extension-gmap/badge?style=rounded)](https://www.jsdelivr.com/package/npm/echarts-extension-gmap)

center: [108.39, 39.9],
// center: { lng: 108.39, lat: 39.9 },
// initial map zoom
zoom: 4,
// whether echarts layer should be rendered when the map is moving. Default is true.
// whether echarts layer should be rendered when the map is moving. `true` by default.
// if false, it will only be re-rendered after the map `moveend`.
// It's better to set this option to false if data is large.
renderOnMoving: true,
// the zIndex of echarts layer for Google Map, default value is 2000.
echartsLayerZIndex: 2019
// the zIndex of echarts layer for Google Map. `2000` by default.
echartsLayerZIndex: 2019,
// whether to enable gesture handling. `true` by default.
// since v1.4.0
roam: false

@@ -85,0 +90,0 @@ // More initial options...

[![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)
[![Build Status](https://github.com/plainheart/echarts-extension-gmap/actions/workflows/ci.yml/badge.svg)](https://github.com/plainheart/echarts-extension-gmap/actions/workflows/ci.yml)
[![NPM Downloads](https://img.shields.io/npm/dm/echarts-extension-gmap.svg)](https://npmcharts.com/compare/echarts-extension-gmap?minimal=true)

@@ -79,4 +79,9 @@ [![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/echarts-extension-gmap/badge?style=rounded)](https://www.jsdelivr.com/package/npm/echarts-extension-gmap)

// 移动过程中实时渲染 默认为true 如数据量较大 建议置为false
renderOnMoving: true
// 移动过程中实时渲染。默认为 true。如数据量较大,建议置为 false。
renderOnMoving: true,
// 谷歌地图 ECharts 图层的 zIndex。默认为 2000。
echartsLayerZIndex: 2019,
// 是否启用手势事件处理,如拖拽等。默认为 true。
// 此配置项从 v1.4.0 起支持
roam: true
},

@@ -83,0 +88,0 @@ series: [

@@ -42,2 +42,4 @@ import * as echarts from 'echarts';

// extension options
// since v1.4.0
roam: true,
echartsLayerZIndex: 2000,

@@ -44,0 +46,0 @@ renderOnMoving: true

/* global google */
import * as echarts from 'echarts';
import debounce from 'lodash.debounce';

@@ -20,2 +19,6 @@ export default echarts.extendComponentView({

gmap.setOptions({
gestureHandling: gmapModel.get('roam') ? 'auto' : 'none'
});
var renderHandler = function() {

@@ -61,4 +64,4 @@ if (rendering) {

if (!renderOnMoving) {
renderHandler = debounce(renderHandler, 100);
resizeHandler = debounce(resizeHandler, 100);
renderHandler = echarts.throttle(renderHandler, 100, true)
resizeHandler = echarts.throttle(resizeHandler, 100, true)
}

@@ -65,0 +68,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc