diff --git a/dist/echarts-extension-gmap.js b/dist/echarts-extension-gmap.js index 824cd5a..5f75bea 100644 --- a/dist/echarts-extension-gmap.js +++ b/dist/echarts-extension-gmap.js @@ -1,6 +1,6 @@ /*! * echarts-extension-gmap - * @version 1.2.0 + * @version 1.2.1 * @author plainheart * * MIT License @@ -33,7 +33,7 @@ }(this, (function (exports, echarts) { 'use strict'; var name = "echarts-extension-gmap"; - var version = "1.2.0"; + var version = "1.2.1"; /* global google */ diff --git a/dist/echarts-extension-gmap.min.js b/dist/echarts-extension-gmap.min.js index bd06ff6..ab4b3b8 100644 --- a/dist/echarts-extension-gmap.min.js +++ b/dist/echarts-extension-gmap.min.js @@ -1,6 +1,6 @@ /*! * echarts-extension-gmap - * @version 1.2.0 + * @version 1.2.1 * @author plainheart * * MIT License @@ -26,4 +26,4 @@ * 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.0",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 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})})); diff --git a/package.json b/package.json index 6a74c20..7818b3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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": {