@opentinyvue/vue-huicharts-amap 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 - present TinyVue Authors.
4
+ Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import AutonaviMap from './src/autonavi-map.vue';
2
+ export { AutonaviMap };
3
+ export default AutonaviMap;
package/lib/index.js ADDED
@@ -0,0 +1,388 @@
1
+ import Core from '@opentinyvue/vue-huicharts-core';
2
+ import * as echarts from 'echarts';
3
+ import { $prefix } from '@opentinyvue/vue-common';
4
+
5
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
6
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
7
+ if (render) {
8
+ options.render = render;
9
+ options.staticRenderFns = staticRenderFns;
10
+ options._compiled = true;
11
+ }
12
+ var hook;
13
+ if (injectStyles) {
14
+ hook = injectStyles;
15
+ }
16
+ if (hook) {
17
+ if (options.functional) {
18
+ options._injectStyles = hook;
19
+ var originalRender = options.render;
20
+ options.render = function renderWithStyleInjection(h, context) {
21
+ hook.call(context);
22
+ return originalRender(h, context);
23
+ };
24
+ } else {
25
+ var existing = options.beforeCreate;
26
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
27
+ }
28
+ }
29
+ return {
30
+ exports: scriptExports,
31
+ options
32
+ };
33
+ }
34
+
35
+ function _extends() {
36
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
37
+ for (var e = 1; e < arguments.length; e++) {
38
+ var t = arguments[e];
39
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
40
+ }
41
+ return n;
42
+ }, _extends.apply(null, arguments);
43
+ }
44
+ var AMapCoordSys = /* @__PURE__ */ function() {
45
+ function AMapCoordSys2(amap, api) {
46
+ this._amap = amap;
47
+ this.dimensions = ["lng", "lat"];
48
+ this._mapOffset = [0, 0];
49
+ this._api = api;
50
+ }
51
+ AMapCoordSys2.create = function create(ecModel, api) {
52
+ var tinySys;
53
+ var root = api.getDom();
54
+ ecModel.eachComponent("amap", function(tinyModel) {
55
+ var viewportRoot = api.getZr().painter.getViewportRoot();
56
+ if (typeof window.AMap === "undefined") {
57
+ throw new TypeError("AMap api is not loaded");
58
+ }
59
+ if (tinySys) {
60
+ throw new Error("Only one amap component can exist");
61
+ }
62
+ if (!tinyModel.__amap) {
63
+ var amapRoot = root.querySelector(".ec-extension-amap");
64
+ if (amapRoot) {
65
+ viewportRoot.style.left = "0px";
66
+ viewportRoot.style.top = "0px";
67
+ root.removeChild(amapRoot);
68
+ }
69
+ amapRoot = document.createElement("div");
70
+ amapRoot.style.cssText = "width:100%;height:100%";
71
+ amapRoot.classList.add("ec-extension-amap");
72
+ root.appendChild(amapRoot);
73
+ var options = tinyModel.get() || {};
74
+ options = tinyModel.__options = echarts.util.clone(options);
75
+ var amap = tinyModel.__amap = new window.AMap.Map(amapRoot, options);
76
+ var layer = tinyModel.__layer = new window.AMap.CustomLayer(viewportRoot);
77
+ layer.setMap(amap);
78
+ }
79
+ var tinyApm = tinyModel.getAMap();
80
+ var tinyOut = tinyModel.getLayer();
81
+ tinyOut.hide();
82
+ var tinyZoom = tinyApm.getZoom();
83
+ var tinyCenter = tinyApm.getCenter();
84
+ tinySys = new AMapCoordSys2(tinyApm, api);
85
+ tinySys.setMapOffset(tinyModel.__mapOffset || [0, 0]);
86
+ tinySys.setZoom(tinyZoom);
87
+ tinySys.setCenter([tinyCenter.lng, tinyCenter.lat]);
88
+ tinyModel.coordinateSystem = tinySys;
89
+ tinyOut.show();
90
+ });
91
+ ecModel.eachSeries(function(seriesModel) {
92
+ if (seriesModel.get("coordinateSystem") === "amap") {
93
+ seriesModel.coordinateSystem = tinySys;
94
+ }
95
+ });
96
+ };
97
+ var _proto = AMapCoordSys2.prototype;
98
+ _proto.setZoom = function setZoom(zoom) {
99
+ this._zoom = zoom;
100
+ };
101
+ _proto.setCenter = function setCenter(center) {
102
+ this._center = this._amap.lnglatToPixel(center);
103
+ };
104
+ _proto.setMapOffset = function setMapOffset(mapOffset) {
105
+ this._mapOffset = mapOffset;
106
+ };
107
+ _proto.getAMap = function getAMap() {
108
+ return this._amap;
109
+ };
110
+ _proto.dataToPoint = function dataToPoint(data2) {
111
+ var point = new window.AMap.LngLat(data2[0], data2[1]);
112
+ var px = this._amap.lngLatToContainer(point);
113
+ var mapOffset = this._mapOffset;
114
+ return [px.x - mapOffset[0], px.y - mapOffset[1]];
115
+ };
116
+ _proto.pointToData = function pointToData(pt) {
117
+ var mapOffset = this._mapOffset;
118
+ pt = this._amap.containerToLngLat({
119
+ x: pt[0] + mapOffset[0],
120
+ y: pt[1] + mapOffset[1]
121
+ });
122
+ return [pt.lng, pt.lat];
123
+ };
124
+ _proto.getViewRect = function getViewRect() {
125
+ var api = this._api;
126
+ return new echarts.graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight());
127
+ };
128
+ _proto.getRoamTransform = function getRoamTransform() {
129
+ return echarts.matrix.create();
130
+ };
131
+ return AMapCoordSys2;
132
+ }();
133
+ var equal = function equal2(x, y) {
134
+ return x && y && x[0] === y[0] && x[1] === y[1];
135
+ };
136
+ function extendComponentModel() {
137
+ echarts.extendComponentModel({
138
+ type: "amap",
139
+ getAMap: function getAMap() {
140
+ return this.__amap;
141
+ },
142
+ getLayer: function getLayer() {
143
+ return this.__layer;
144
+ },
145
+ getMapOptions: function getMapOptions() {
146
+ return this.__options;
147
+ },
148
+ setCenterAndZoom: function setCenterAndZoom(center, zoom) {
149
+ this.huiChartOption.center = center;
150
+ this.huiChartOption.zoom = zoom;
151
+ },
152
+ centerOrZoomChanged: function centerOrZoomChanged(center, zoom) {
153
+ var option = this.huiChartOption;
154
+ return !(equal(center, option.center) && zoom === option.zoom);
155
+ },
156
+ defaultOption: {
157
+ center: [116.397475, 39.908695],
158
+ zoom: 4
159
+ }
160
+ });
161
+ }
162
+ var setLaterFunc = function setLaterFunc2(ctx) {
163
+ ctx.later = function() {
164
+ ctx.lock = false;
165
+ if (ctx.args) {
166
+ ctx.wrapperFn.apply(ctx.context, ctx.args);
167
+ ctx.args = false;
168
+ }
169
+ };
170
+ };
171
+ var setWrapperFunc = function setWrapperFunc2(ctx) {
172
+ ctx.wrapperFn = function() {
173
+ if (ctx.lock) {
174
+ ctx.args = arguments;
175
+ } else {
176
+ ctx.fn.apply(ctx.context, arguments);
177
+ setTimeout(ctx.later, ctx.time);
178
+ ctx.lock = true;
179
+ }
180
+ };
181
+ };
182
+ var throttle = function throttle2(fn, time, context) {
183
+ var ctx = {
184
+ fn,
185
+ time,
186
+ context,
187
+ lock: void 0,
188
+ args: void 0,
189
+ wrapperFn: void 0,
190
+ later: void 0
191
+ };
192
+ setLaterFunc(ctx);
193
+ setWrapperFunc(ctx);
194
+ return ctx.wrapperFn;
195
+ };
196
+ var backupListener = function backupListener2(_ref) {
197
+ var _vm = _ref._vm, throttledResizeHandler = _ref.throttledResizeHandler, zoomEndHandler = _ref.zoomEndHandler;
198
+ _vm._oldZoomEndHandler = zoomEndHandler;
199
+ _vm._oldResizeHandler = throttledResizeHandler;
200
+ };
201
+ var addListener = function addListener2(_ref2) {
202
+ var aMapModel = _ref2.aMapModel, amap = _ref2.amap, throttledResizeHandler = _ref2.throttledResizeHandler, zoomEndHandler = _ref2.zoomEndHandler;
203
+ amap.on("zoomend", zoomEndHandler);
204
+ amap.on("moveend", zoomEndHandler);
205
+ amap.on("complete", zoomEndHandler);
206
+ aMapModel.get("resizeEnable") && amap.on("resize", throttledResizeHandler);
207
+ };
208
+ var removeListener = function removeListener2(_ref3) {
209
+ var _vm = _ref3._vm, aMapModel = _ref3.aMapModel, amap = _ref3.amap;
210
+ amap.off("zoomend", _vm._oldZoomEndHandler);
211
+ amap.off("moveend", _vm._oldZoomEndHandler);
212
+ amap.off("complete", _vm._oldZoomEndHandler);
213
+ aMapModel.get("resizeEnable") && amap.off("resize", _vm._oldResizeHandler);
214
+ };
215
+ var getResizeHandler = function getResizeHandler2(_ref4) {
216
+ var _vm = _ref4._vm, api = _ref4.api, moveHandler = _ref4.moveHandler;
217
+ return function(e) {
218
+ echarts.getInstanceByDom(api.getDom()).resize();
219
+ moveHandler.call(_vm, e);
220
+ };
221
+ };
222
+ var getZoomEndHandler = function getZoomEndHandler2(_ref5) {
223
+ var api = _ref5.api, rendering = _ref5.rendering;
224
+ return function() {
225
+ if (rendering) {
226
+ return;
227
+ }
228
+ api.dispatchAction({
229
+ type: "amapRoam"
230
+ });
231
+ };
232
+ };
233
+ var getMoveHandler = function getMoveHandler2(_ref6) {
234
+ var aMapModel = _ref6.aMapModel, api = _ref6.api, coordSys = _ref6.coordSys, rendering = _ref6.rendering, viewportRoot = _ref6.viewportRoot;
235
+ return function() {
236
+ if (rendering) {
237
+ return;
238
+ }
239
+ var offsetEl = viewportRoot.parentNode.parentNode.parentNode;
240
+ var mapOffset = [-parseInt(offsetEl.style.left, 10) || 0, -parseInt(offsetEl.style.top, 10) || 0];
241
+ aMapModel.__mapOffset = mapOffset;
242
+ coordSys.setMapOffset(mapOffset);
243
+ viewportRoot.style.left = mapOffset[0] + "px";
244
+ viewportRoot.style.top = mapOffset[1] + "px";
245
+ api.dispatchAction({
246
+ type: "amapRoam"
247
+ });
248
+ };
249
+ };
250
+ function extendComponentView() {
251
+ echarts.extendComponentView({
252
+ type: "amap",
253
+ render: function render3(aMapModel, ecModel, api) {
254
+ var rendering = true;
255
+ var amap = aMapModel.getAMap();
256
+ var viewportRoot = api.getZr().painter.getViewportRoot();
257
+ var coordSys = aMapModel.coordinateSystem;
258
+ var moveHandler = getMoveHandler({
259
+ aMapModel,
260
+ api,
261
+ coordSys,
262
+ rendering,
263
+ viewportRoot
264
+ });
265
+ var zoomEndHandler = getZoomEndHandler({
266
+ api,
267
+ rendering
268
+ });
269
+ var resizeHandler = getResizeHandler({
270
+ _vm: this,
271
+ api,
272
+ moveHandler
273
+ });
274
+ var throttledResizeHandler = throttle(resizeHandler, 300, amap);
275
+ removeListener({
276
+ _vm: this,
277
+ aMapModel,
278
+ amap
279
+ });
280
+ addListener({
281
+ aMapModel,
282
+ amap,
283
+ throttledResizeHandler,
284
+ zoomEndHandler
285
+ });
286
+ backupListener({
287
+ _vm: this,
288
+ throttledResizeHandler,
289
+ zoomEndHandler
290
+ });
291
+ rendering = false;
292
+ }
293
+ });
294
+ }
295
+ function registerAmap() {
296
+ echarts.registerCoordinateSystem("amap", AMapCoordSys);
297
+ extendComponentModel();
298
+ extendComponentView();
299
+ echarts.registerAction({
300
+ type: "amapRoam",
301
+ event: "amapRoam",
302
+ update: "updateLayout"
303
+ }, function(payload, ecModel) {
304
+ ecModel.eachComponent("amap", function(aMapModel) {
305
+ var amap = aMapModel.getAMap();
306
+ var center = amap.getCenter();
307
+ aMapModel.setCenterAndZoom([center.lng, center.lat], amap.getZoom());
308
+ });
309
+ });
310
+ }
311
+ var render = function render2() {
312
+ var _vm = this;
313
+ var _h = _vm.$createElement;
314
+ var _c = _vm._self._c || _h;
315
+ return _c("div", {
316
+ staticClass: "hui-chart chart-box"
317
+ }, [_c("div", {
318
+ ref: "chartRef",
319
+ style: {
320
+ width: _vm.width,
321
+ height: _vm.height
322
+ }
323
+ }), _vm._t("default")], 2);
324
+ };
325
+ var staticRenderFns = [];
326
+ var __vue2_script = {
327
+ name: $prefix + "ChartAutonaviMap",
328
+ mixins: [Core],
329
+ data: function data() {
330
+ return {
331
+ iChartName: "AutonaviMapChart"
332
+ };
333
+ },
334
+ mounted: function mounted() {
335
+ registerAmap();
336
+ },
337
+ methods: {
338
+ updateChart: function updateChart() {
339
+ var _this = this;
340
+ if (this.options && Object.keys(this.options).length) {
341
+ this.huiChartOption = _extends({}, this.options, this.settings);
342
+ if (!this.tooltipVisible) {
343
+ this.huiChartOption.tooltip = {
344
+ show: false
345
+ };
346
+ }
347
+ if (!this.legendVisible) {
348
+ this.huiChartOption.legend = {
349
+ show: false
350
+ };
351
+ }
352
+ return;
353
+ }
354
+ var echartsSettings = ["grid", "dataZoom", "visualMap", "toolbox", "title", "legend", "xAxis", "yAxis", "radar", "axisPointer", "brush", "geo", "timeline", "graphic", "backgroundColor", "textStyle"];
355
+ this.huiChartOption = _extends({}, this.settings, {
356
+ tooltip: this.tooltipVisible ? this.tooltip : {
357
+ show: false
358
+ },
359
+ series: this.series
360
+ });
361
+ echartsSettings.forEach(function(prop) {
362
+ if (_this[prop]) {
363
+ _this.huiChartOption[prop] = _this[prop];
364
+ }
365
+ });
366
+ if (!this.legendVisible) {
367
+ this.huiChartOption.legend = {
368
+ show: false
369
+ };
370
+ }
371
+ }
372
+ }
373
+ };
374
+ var __cssModules = {};
375
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
376
+ function __vue2_injectStyles(context) {
377
+ for (var o in __cssModules) {
378
+ this[o] = __cssModules[o];
379
+ }
380
+ }
381
+ var AutonaviMap = /* @__PURE__ */ function() {
382
+ return __component__.exports;
383
+ }();
384
+ AutonaviMap.install = function(Vue) {
385
+ Vue.component(AutonaviMap.name, AutonaviMap);
386
+ };
387
+
388
+ export { AutonaviMap, AutonaviMap as default };
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@opentinyvue/vue-huicharts-amap",
3
+ "version": "2.21.0",
4
+ "description": "",
5
+ "main": "./lib/index.js",
6
+ "module": "./lib/index.js",
7
+ "sideEffects": false,
8
+ "type": "module",
9
+ "dependencies": {
10
+ "@opentinyvue/vue-huicharts-core": "~2.21.0",
11
+ "@opentinyvue/vue-common": "~2.21.0"
12
+ },
13
+ "license": "MIT",
14
+ "types": "index.d.ts",
15
+ "scripts": {
16
+ "build": "pnpm -w build:ui $npm_package_name",
17
+ "//postversion": "pnpm build"
18
+ }
19
+ }
@@ -0,0 +1,12 @@
1
+ export default class AMapCoordSys {
2
+ constructor(amap: any, api: any);
3
+ static create(ecModel: any, api: any): void;
4
+ setZoom(zoom: any): void;
5
+ setCenter(center: any): void;
6
+ setMapOffset(mapOffset: any): void;
7
+ getAMap(): any;
8
+ dataToPoint(data: any): number[];
9
+ pointToData(pt: any): any[];
10
+ getViewRect(): any;
11
+ getRoamTransform(): number[];
12
+ }
@@ -0,0 +1 @@
1
+ export default function extendComponentModel(): void;
@@ -0,0 +1 @@
1
+ export default function extendComponentView(): void;
package/src/amap.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function registerAmap(): void;
@@ -0,0 +1,6 @@
1
+ declare const _default: import("vue/types/vue").ExtendedVue<import("vue").default, {
2
+ iChartName: string;
3
+ }, {
4
+ updateChart(): void;
5
+ }, any, Record<never, any>>;
6
+ export default _default;