@vue-start/map 0.0.5 → 0.0.7
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/CHANGELOG.md +7 -0
- package/dist/index.d.ts +25 -14
- package/dist/index.es.js +169 -166
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare type TEvents = {
|
|
|
6
6
|
handler: (...args: any[]) => void;
|
|
7
7
|
once?: boolean;
|
|
8
8
|
}[];
|
|
9
|
+
declare const useEvents: (eventObj: AMap.Event, events: TEvents) => void;
|
|
9
10
|
|
|
10
11
|
interface IMapProvide {
|
|
11
12
|
mapRef: ShallowRef<AMap.Map>;
|
|
@@ -48,6 +49,15 @@ declare global {
|
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
}
|
|
52
|
+
declare const MapEvents: vue.DefineComponent<{
|
|
53
|
+
events: {
|
|
54
|
+
type: PropType<TEvents>;
|
|
55
|
+
};
|
|
56
|
+
}, () => null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
57
|
+
events: {
|
|
58
|
+
type: PropType<TEvents>;
|
|
59
|
+
};
|
|
60
|
+
}>>, {}>;
|
|
51
61
|
declare const Map: vue.DefineComponent<Partial<ExtractPropTypes<{
|
|
52
62
|
securityJsCode: {
|
|
53
63
|
type: StringConstructor;
|
|
@@ -61,7 +71,7 @@ declare const Map: vue.DefineComponent<Partial<ExtractPropTypes<{
|
|
|
61
71
|
events: {
|
|
62
72
|
type: PropType<TEvents>;
|
|
63
73
|
};
|
|
64
|
-
}>>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
74
|
+
}>>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<Partial<ExtractPropTypes<{
|
|
65
75
|
securityJsCode: {
|
|
66
76
|
type: StringConstructor;
|
|
67
77
|
};
|
|
@@ -81,7 +91,7 @@ declare const MapPlugin: vue.DefineComponent<{
|
|
|
81
91
|
plugins: PropType<string[]>;
|
|
82
92
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
83
93
|
[key: string]: any;
|
|
84
|
-
}>[] | null | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
94
|
+
}>[] | null | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
85
95
|
plugins: PropType<string[]>;
|
|
86
96
|
}>>, {}>;
|
|
87
97
|
declare const MapPluginType: {
|
|
@@ -263,7 +273,7 @@ declare const createFeature: <T extends keyof TFeature>(name: T, { useMapConnect
|
|
|
263
273
|
createFeatureObj?: ((opts: TFeature[T]["opts"]) => TFeature[T]["type"]) | undefined;
|
|
264
274
|
needDom?: boolean | undefined;
|
|
265
275
|
}) => DefineComponent<any, any, any>;
|
|
266
|
-
declare const createPluginFeature: (plugins: string[], Feature: any) => DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
276
|
+
declare const createPluginFeature: (plugins: string[], Feature: any) => DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
267
277
|
[x: string]: any;
|
|
268
278
|
}>;
|
|
269
279
|
|
|
@@ -302,7 +312,7 @@ declare const OverlayGroup: vue.DefineComponent<{
|
|
|
302
312
|
};
|
|
303
313
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
304
314
|
[key: string]: any;
|
|
305
|
-
}>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
315
|
+
}>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
306
316
|
/**
|
|
307
317
|
* 首次添加到地图中的标识;
|
|
308
318
|
* 值为true时,将OverlayGroup对象添加到地图中;
|
|
@@ -344,7 +354,7 @@ declare const InfoWindow: vue.DefineComponent<{
|
|
|
344
354
|
type: NumberConstructor;
|
|
345
355
|
default: undefined;
|
|
346
356
|
};
|
|
347
|
-
}, () => JSX.Element | null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
357
|
+
}, () => JSX.Element | null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
348
358
|
opts: {
|
|
349
359
|
type: PropType<AMap.InfoOptions>;
|
|
350
360
|
};
|
|
@@ -391,19 +401,19 @@ declare const Ellipse: vue.DefineComponent<any, any, any, vue.ComputedOptions, v
|
|
|
391
401
|
declare const BezierCurve: vue.DefineComponent<any, any, any, vue.ComputedOptions, vue.MethodOptions, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
392
402
|
[x: string]: any;
|
|
393
403
|
}>;
|
|
394
|
-
declare const ToolBar: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
404
|
+
declare const ToolBar: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
395
405
|
[x: string]: any;
|
|
396
406
|
}>;
|
|
397
|
-
declare const Scale: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
407
|
+
declare const Scale: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
398
408
|
[x: string]: any;
|
|
399
409
|
}>;
|
|
400
|
-
declare const HawkEye: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
410
|
+
declare const HawkEye: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
401
411
|
[x: string]: any;
|
|
402
412
|
}>;
|
|
403
|
-
declare const MapType: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
413
|
+
declare const MapType: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
404
414
|
[x: string]: any;
|
|
405
415
|
}>;
|
|
406
|
-
declare const ControlBar: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
416
|
+
declare const ControlBar: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
407
417
|
[x: string]: any;
|
|
408
418
|
}>;
|
|
409
419
|
|
|
@@ -431,7 +441,7 @@ declare const LayerGroup: vue.DefineComponent<{
|
|
|
431
441
|
};
|
|
432
442
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
433
443
|
[key: string]: any;
|
|
434
|
-
}>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
444
|
+
}>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
435
445
|
bind: {
|
|
436
446
|
type: BooleanConstructor;
|
|
437
447
|
default: boolean;
|
|
@@ -475,7 +485,7 @@ declare const LabelsLayer: vue.DefineComponent<{
|
|
|
475
485
|
events: {
|
|
476
486
|
type: PropType<TEvents>;
|
|
477
487
|
};
|
|
478
|
-
}, () => null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
488
|
+
}, () => null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
479
489
|
opts: {
|
|
480
490
|
type: PropType<AMap.LabelsLayerOptions>;
|
|
481
491
|
};
|
|
@@ -538,7 +548,7 @@ declare const DistrictLayerCountry: vue.DefineComponent<any, any, any, vue.Compu
|
|
|
538
548
|
declare const DistrictLayerProvince: vue.DefineComponent<any, any, any, vue.ComputedOptions, vue.MethodOptions, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
539
549
|
[x: string]: any;
|
|
540
550
|
}>;
|
|
541
|
-
declare const HeatMap: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
551
|
+
declare const HeatMap: vue.DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
542
552
|
[x: string]: any;
|
|
543
553
|
}>;
|
|
544
554
|
|
|
@@ -556,6 +566,7 @@ interface IUseMapApiResult {
|
|
|
556
566
|
data: UnwrapNestedRefs<any>;
|
|
557
567
|
requesting: Ref<UnwrapRef<boolean>>;
|
|
558
568
|
request: (opts?: Record<string, any>, params?: any[]) => void;
|
|
569
|
+
targetRef: ShallowRef<any>;
|
|
559
570
|
}
|
|
560
571
|
/**
|
|
561
572
|
* api组成说明 `AMap.${PluginName}_MethodName`
|
|
@@ -581,4 +592,4 @@ declare const ApiNames: {
|
|
|
581
592
|
StationSearch_searchById: string;
|
|
582
593
|
};
|
|
583
594
|
|
|
584
|
-
export { ApiNames, BezierCurve, Buildings, CanvasLayer, Circle, CircleMarker, ControlBar, CustomLayer, DistrictLayerCountry, DistrictLayerProvince, DistrictLayerWorld, ElasticMarker, Ellipse, HawkEye, HeatMap, IMapProvide, IUseMapApiOptions, IUseMapApiResult, ImageLayer, InfoWindow, LabelsLayer, LayerGroup, Map, MapPlugin, MapPluginType, MapProps, MapType, Marker, MassMarks, OverlayGroup, Polygon, Polyline, Rectangle, Scale, TLoadOpts, Text, TileLayer, TileLayerFlexible, TileLayerRoadNet, TileLayerSatellite, TileLayerTraffic, ToolBar, VideoLayer, createFeature, createPluginFeature, provideMap, useFeatureOptMethods, useMap, useMapApi, useMapConnect, useMapConnect2, useMapControlConnect, useMapLayerConnect, useMapOverlayConnect, useMapPlugin, useShowConnect };
|
|
595
|
+
export { ApiNames, BezierCurve, Buildings, CanvasLayer, Circle, CircleMarker, ControlBar, CustomLayer, DistrictLayerCountry, DistrictLayerProvince, DistrictLayerWorld, ElasticMarker, Ellipse, HawkEye, HeatMap, IMapProvide, IUseMapApiOptions, IUseMapApiResult, ImageLayer, InfoWindow, LabelsLayer, LayerGroup, Map, MapEvents, MapPlugin, MapPluginType, MapProps, MapType, Marker, MassMarks, OverlayGroup, Polygon, Polyline, Rectangle, Scale, TEvents, TLoadOpts, Text, TileLayer, TileLayerFlexible, TileLayerRoadNet, TileLayerSatellite, TileLayerTraffic, ToolBar, VideoLayer, createFeature, createPluginFeature, provideMap, useEvents, useFeatureOptMethods, useMap, useMapApi, useMapConnect, useMapConnect2, useMapControlConnect, useMapLayerConnect, useMapOverlayConnect, useMapPlugin, useShowConnect };
|
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { defineComponent as v, shallowRef as
|
|
2
|
-
import
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { forEach as B, size as
|
|
5
|
-
const
|
|
6
|
-
|
|
1
|
+
import { defineComponent as v, shallowRef as x, ref as T, createVNode as A, provide as Z, inject as ee, toRef as C, Teleport as J, mergeProps as ae } from "vue";
|
|
2
|
+
import te from "@amap/amap-jsapi-loader";
|
|
3
|
+
import { useEffect as u, useWatch as R, createExposeObj as re, useState as ne } from "@vue-start/hooks";
|
|
4
|
+
import { forEach as B, size as z, upperFirst as oe, isFunction as h, isNumber as V, debounce as q, isArray as _, map as ce, omit as K, isBoolean as se, split as ue, get as ie } from "lodash";
|
|
5
|
+
const Q = (e, a) => {
|
|
6
|
+
u(() => (B(a, (r) => {
|
|
7
7
|
e.on(r.type, r.handler, void 0, r.once);
|
|
8
8
|
}), () => {
|
|
9
9
|
B(a, (r) => {
|
|
10
10
|
e.off(r.type, r.handler);
|
|
11
11
|
});
|
|
12
12
|
}), []);
|
|
13
|
-
},
|
|
13
|
+
}, U = Symbol("amap-key"), j = (e) => Z(U, e), m = () => ee(U), le = () => ({
|
|
14
14
|
securityJsCode: {
|
|
15
15
|
type: String
|
|
16
16
|
},
|
|
@@ -23,7 +23,7 @@ const q = (e, a) => {
|
|
|
23
23
|
events: {
|
|
24
24
|
type: Array
|
|
25
25
|
}
|
|
26
|
-
}),
|
|
26
|
+
}), pe = (e) => {
|
|
27
27
|
var a;
|
|
28
28
|
if (!!e) {
|
|
29
29
|
if (!window._AMapSecurityConfig || !((a = window._AMapSecurityConfig) != null && a.securityJsCode)) {
|
|
@@ -36,7 +36,7 @@ const q = (e, a) => {
|
|
|
36
36
|
securityJsCode: e
|
|
37
37
|
}, console.warn("\u5F53\u524Dwindow\u5BF9\u8C61\u5DF2\u7ECF\u6CE8\u5165\u8FC7securityJsCode\u503C\uFF0C\u53EF\u80FD\u9020\u6210\u95EE\u9898"));
|
|
38
38
|
}
|
|
39
|
-
},
|
|
39
|
+
}, de = v({
|
|
40
40
|
props: {
|
|
41
41
|
events: {
|
|
42
42
|
type: Array
|
|
@@ -46,30 +46,30 @@ const q = (e, a) => {
|
|
|
46
46
|
const {
|
|
47
47
|
mapRef: a
|
|
48
48
|
} = m();
|
|
49
|
-
return
|
|
49
|
+
return Q(a.value, e.events), () => null;
|
|
50
50
|
}
|
|
51
|
-
}),
|
|
51
|
+
}), be = v({
|
|
52
52
|
props: {
|
|
53
|
-
...
|
|
53
|
+
...le()
|
|
54
54
|
},
|
|
55
55
|
setup: (e, {
|
|
56
56
|
slots: a,
|
|
57
57
|
expose: r
|
|
58
58
|
}) => {
|
|
59
|
-
|
|
60
|
-
const n =
|
|
59
|
+
pe(e.securityJsCode);
|
|
60
|
+
const n = x(), t = T();
|
|
61
61
|
return r({
|
|
62
62
|
mapRef: n,
|
|
63
63
|
domRef: t
|
|
64
|
-
}),
|
|
64
|
+
}), u(() => (te.load({
|
|
65
65
|
version: "2.0",
|
|
66
66
|
...e.loadOpts
|
|
67
67
|
}).then((o) => {
|
|
68
|
-
const
|
|
68
|
+
const i = new o.Map(t.value, {
|
|
69
69
|
...e.opts
|
|
70
70
|
});
|
|
71
|
-
|
|
72
|
-
n.value =
|
|
71
|
+
i.on("complete", () => {
|
|
72
|
+
n.value = i;
|
|
73
73
|
});
|
|
74
74
|
}).catch((o) => {
|
|
75
75
|
console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"), console.error(o);
|
|
@@ -81,38 +81,38 @@ const q = (e, a) => {
|
|
|
81
81
|
var o;
|
|
82
82
|
return A("div", {
|
|
83
83
|
ref: t
|
|
84
|
-
}, [n.value && A(
|
|
84
|
+
}, [n.value && A(de, {
|
|
85
85
|
events: e.events
|
|
86
86
|
}, null), n.value && ((o = a.default) == null ? void 0 : o.call(a))]);
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
}),
|
|
89
|
+
}), X = (e, a) => {
|
|
90
90
|
const { mapRef: r } = m();
|
|
91
|
-
|
|
91
|
+
u(() => {
|
|
92
92
|
if (!r.value) {
|
|
93
93
|
console.warn("\u8BF7\u5728Map\u7EC4\u4EF6\u5185\u4F7F\u7528 useMapPlugin");
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
if (!e ||
|
|
96
|
+
if (!e || z(e) <= 0) {
|
|
97
97
|
a();
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
window.AMap.plugin(e, a);
|
|
101
101
|
}, []);
|
|
102
|
-
},
|
|
102
|
+
}, Me = v({
|
|
103
103
|
props: {
|
|
104
104
|
plugins: Array
|
|
105
105
|
},
|
|
106
106
|
setup: (e, { slots: a }) => {
|
|
107
|
-
const r =
|
|
108
|
-
return
|
|
107
|
+
const r = T(!1);
|
|
108
|
+
return X(e.plugins, () => {
|
|
109
109
|
r.value = !0;
|
|
110
110
|
}), () => {
|
|
111
111
|
var n;
|
|
112
112
|
return r.value ? (n = a.default) == null ? void 0 : n.call(a) : null;
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
}),
|
|
115
|
+
}), g = {
|
|
116
116
|
ElasticMarker: "AMap.ElasticMarker",
|
|
117
117
|
ControlBar: "AMap.ControlBar",
|
|
118
118
|
ToolBar: "AMap.ToolBar",
|
|
@@ -151,18 +151,18 @@ const q = (e, a) => {
|
|
|
151
151
|
const {
|
|
152
152
|
mapRef: a
|
|
153
153
|
} = m();
|
|
154
|
-
|
|
154
|
+
u(() => (a.value.add(e), () => {
|
|
155
155
|
try {
|
|
156
156
|
a.value.remove(e);
|
|
157
157
|
} catch (r) {
|
|
158
158
|
console.error(r);
|
|
159
159
|
}
|
|
160
160
|
}), []);
|
|
161
|
-
},
|
|
161
|
+
}, Y = (e) => {
|
|
162
162
|
const {
|
|
163
163
|
mapRef: a
|
|
164
164
|
} = m();
|
|
165
|
-
|
|
165
|
+
u(() => (e.setMap(a.value), () => {
|
|
166
166
|
try {
|
|
167
167
|
e.setMap(null);
|
|
168
168
|
} catch (r) {
|
|
@@ -173,7 +173,7 @@ const q = (e, a) => {
|
|
|
173
173
|
const {
|
|
174
174
|
mapRef: a
|
|
175
175
|
} = m();
|
|
176
|
-
|
|
176
|
+
u(() => (a.value.addControl(e), () => {
|
|
177
177
|
try {
|
|
178
178
|
a.value.removeControl(e);
|
|
179
179
|
} catch (r) {
|
|
@@ -186,15 +186,15 @@ const q = (e, a) => {
|
|
|
186
186
|
}, n = () => {
|
|
187
187
|
e && h(e.hide) && e.hide();
|
|
188
188
|
};
|
|
189
|
-
|
|
189
|
+
u(() => {
|
|
190
190
|
a.value || n();
|
|
191
191
|
}, []), R(() => {
|
|
192
192
|
a.value ? r() : n();
|
|
193
193
|
}, a);
|
|
194
194
|
}, k = (e, a) => {
|
|
195
|
-
|
|
195
|
+
u(() => {
|
|
196
196
|
B(a.value, (r, n) => {
|
|
197
|
-
const t = "set" +
|
|
197
|
+
const t = "set" + oe(n);
|
|
198
198
|
e[t] && h(e[t]) && e[t](r);
|
|
199
199
|
});
|
|
200
200
|
}, a);
|
|
@@ -220,20 +220,20 @@ const q = (e, a) => {
|
|
|
220
220
|
},
|
|
221
221
|
setup: (t, {
|
|
222
222
|
slots: o,
|
|
223
|
-
expose:
|
|
223
|
+
expose: i
|
|
224
224
|
}) => {
|
|
225
225
|
const s = r ? r(t.opts) : new window.AMap[e](t.opts);
|
|
226
226
|
a(s);
|
|
227
227
|
const p = C(t, "show");
|
|
228
228
|
P(s, p);
|
|
229
229
|
const d = C(t, "opts$");
|
|
230
|
-
k(s, d),
|
|
230
|
+
k(s, d), Q(s, t.events), i({
|
|
231
231
|
getFeature: () => s
|
|
232
232
|
});
|
|
233
|
-
const M =
|
|
234
|
-
return
|
|
233
|
+
const M = T();
|
|
234
|
+
return u(() => {
|
|
235
235
|
M.value && h(s.setContent) && s.setContent(M.value);
|
|
236
|
-
}, M), () => n && o.default ? A(
|
|
236
|
+
}, M), () => n && o.default ? A(J, {
|
|
237
237
|
to: "body"
|
|
238
238
|
}, {
|
|
239
239
|
default: () => [A("div", {
|
|
@@ -241,7 +241,7 @@ const q = (e, a) => {
|
|
|
241
241
|
}, [o.default()])]
|
|
242
242
|
}) : null;
|
|
243
243
|
}
|
|
244
|
-
}),
|
|
244
|
+
}), S = (e, a) => v({
|
|
245
245
|
props: {
|
|
246
246
|
...a.props
|
|
247
247
|
},
|
|
@@ -249,16 +249,16 @@ const q = (e, a) => {
|
|
|
249
249
|
slots: n,
|
|
250
250
|
expose: t
|
|
251
251
|
}) => {
|
|
252
|
-
const o =
|
|
253
|
-
return t(
|
|
252
|
+
const o = T();
|
|
253
|
+
return t(re(o, ["getFeature"])), () => A(Me, {
|
|
254
254
|
plugins: e
|
|
255
255
|
}, {
|
|
256
|
-
default: () => [A(a,
|
|
256
|
+
default: () => [A(a, ae({
|
|
257
257
|
ref: o
|
|
258
258
|
}, r), n)]
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
|
-
}),
|
|
261
|
+
}), ye = () => {
|
|
262
262
|
const { mapRef: e, overlayGroup: a } = m();
|
|
263
263
|
return { addToMap: (t) => {
|
|
264
264
|
if (a) {
|
|
@@ -278,11 +278,11 @@ const q = (e, a) => {
|
|
|
278
278
|
}
|
|
279
279
|
} };
|
|
280
280
|
}, w = (e) => {
|
|
281
|
-
const { addToMap: a, removeFromMap: r } =
|
|
282
|
-
|
|
281
|
+
const { addToMap: a, removeFromMap: r } = ye();
|
|
282
|
+
u(() => (a(e), () => {
|
|
283
283
|
r(e);
|
|
284
284
|
}), []);
|
|
285
|
-
},
|
|
285
|
+
}, Re = v({
|
|
286
286
|
props: {
|
|
287
287
|
bind: { type: Boolean, default: !1 },
|
|
288
288
|
bindTime: { type: Number, default: void 0 },
|
|
@@ -293,7 +293,7 @@ const q = (e, a) => {
|
|
|
293
293
|
setup: (e, { slots: a, expose: r }) => {
|
|
294
294
|
const { mapRef: n } = m(), t = new window.AMap.OverlayGroup();
|
|
295
295
|
let o = !1;
|
|
296
|
-
const
|
|
296
|
+
const i = () => {
|
|
297
297
|
o || (n.value.add(t), o = !0);
|
|
298
298
|
}, s = () => {
|
|
299
299
|
try {
|
|
@@ -303,20 +303,20 @@ const q = (e, a) => {
|
|
|
303
303
|
}
|
|
304
304
|
o = !1;
|
|
305
305
|
}, p = () => t;
|
|
306
|
-
|
|
306
|
+
u(() => () => {
|
|
307
307
|
s();
|
|
308
|
-
}, []),
|
|
309
|
-
if (!
|
|
308
|
+
}, []), u(() => {
|
|
309
|
+
if (!V(e.bindTime))
|
|
310
310
|
return;
|
|
311
311
|
const l = setTimeout(() => {
|
|
312
|
-
|
|
312
|
+
i();
|
|
313
313
|
}, e.bindTime);
|
|
314
314
|
return () => {
|
|
315
315
|
l && clearTimeout(l);
|
|
316
316
|
};
|
|
317
317
|
}, []);
|
|
318
|
-
const d =
|
|
319
|
-
|
|
318
|
+
const d = q(() => {
|
|
319
|
+
i();
|
|
320
320
|
}, 300);
|
|
321
321
|
R(
|
|
322
322
|
() => {
|
|
@@ -326,13 +326,13 @@ const q = (e, a) => {
|
|
|
326
326
|
);
|
|
327
327
|
const M = C(e, "show");
|
|
328
328
|
P(t, M);
|
|
329
|
-
const
|
|
330
|
-
return k(t,
|
|
329
|
+
const L = C(e, "opts$");
|
|
330
|
+
return k(t, L), r({ getFeature: p, addToMap: i, removeFormMap: s }), j({ mapRef: n, overlayGroup: t }), () => {
|
|
331
331
|
var l;
|
|
332
332
|
return (l = a.default) == null ? void 0 : l.call(a);
|
|
333
333
|
};
|
|
334
334
|
}
|
|
335
|
-
}),
|
|
335
|
+
}), Fe = v({
|
|
336
336
|
props: {
|
|
337
337
|
opts: {
|
|
338
338
|
type: Object
|
|
@@ -357,12 +357,12 @@ const q = (e, a) => {
|
|
|
357
357
|
...e.opts
|
|
358
358
|
}), o = C(e, "opts$");
|
|
359
359
|
k(t, o);
|
|
360
|
-
const
|
|
360
|
+
const i = () => {
|
|
361
361
|
r("close");
|
|
362
362
|
};
|
|
363
|
-
|
|
364
|
-
t.off("close",
|
|
365
|
-
}), []),
|
|
363
|
+
u(() => (t.on("close", i), () => {
|
|
364
|
+
t.off("close", i), t.close();
|
|
365
|
+
}), []), u(() => {
|
|
366
366
|
var d, M;
|
|
367
367
|
const p = ((d = e.opts$) == null ? void 0 : d.position) || ((M = e.opts) == null ? void 0 : M.position);
|
|
368
368
|
!p || t.open(n.value, p, e.height);
|
|
@@ -370,10 +370,10 @@ const q = (e, a) => {
|
|
|
370
370
|
var p;
|
|
371
371
|
return (p = e.opts$) == null ? void 0 : p.position;
|
|
372
372
|
});
|
|
373
|
-
const s =
|
|
374
|
-
return
|
|
373
|
+
const s = T();
|
|
374
|
+
return u(() => {
|
|
375
375
|
s.value && h(t.setContent) && t.setContent(s.value);
|
|
376
|
-
}, s), () => a.default ? A(
|
|
376
|
+
}, s), () => a.default ? A(J, {
|
|
377
377
|
to: "body"
|
|
378
378
|
}, {
|
|
379
379
|
default: () => [A("div", {
|
|
@@ -381,7 +381,7 @@ const q = (e, a) => {
|
|
|
381
381
|
}, [a.default()])]
|
|
382
382
|
}) : null;
|
|
383
383
|
}
|
|
384
|
-
}),
|
|
384
|
+
}), Oe = c("CircleMarker", { useMapConnect: G }), Be = c("Text", { useMapConnect: G }), _e = c("ElasticMarker", { useMapConnect: G }), Pe = c("Marker", { useMapConnect: w, needDom: !0 }), ke = c("Polygon", { useMapConnect: w }), Ee = c("Polyline", { useMapConnect: w }), De = c("Circle", { useMapConnect: w }), je = c("Rectangle", { useMapConnect: w }), Ge = c("Ellipse", { useMapConnect: w }), Ie = c("BezierCurve", { useMapConnect: w }), fe = c("ToolBar", { useMapConnect: F }), Ne = S([g.ToolBar], fe), me = c("Scale", { useMapConnect: F }), He = S([g.Scale], me), ve = c("HawkEye", { useMapConnect: F }), We = S([g.HawkEye], ve), Ae = c("MapType", { useMapConnect: F }), $e = S([g.MapType], Ae), Ce = c("ControlBar", { useMapConnect: F }), xe = S([g.ControlBar], Ce), he = () => {
|
|
385
385
|
const { mapRef: e, layerGroup: a } = m();
|
|
386
386
|
return { addToMap: (t) => {
|
|
387
387
|
if (a) {
|
|
@@ -400,12 +400,12 @@ const q = (e, a) => {
|
|
|
400
400
|
console.error(o);
|
|
401
401
|
}
|
|
402
402
|
} };
|
|
403
|
-
},
|
|
404
|
-
const { addToMap: a, removeFromMap: r } =
|
|
405
|
-
|
|
403
|
+
}, f = (e) => {
|
|
404
|
+
const { addToMap: a, removeFromMap: r } = he();
|
|
405
|
+
u(() => (a(e), () => {
|
|
406
406
|
r(e);
|
|
407
407
|
}), []);
|
|
408
|
-
},
|
|
408
|
+
}, Je = v({
|
|
409
409
|
props: {
|
|
410
410
|
bind: { type: Boolean, default: !1 },
|
|
411
411
|
bindTime: { type: Number, default: void 0 },
|
|
@@ -416,7 +416,7 @@ const q = (e, a) => {
|
|
|
416
416
|
setup: (e, { slots: a, expose: r }) => {
|
|
417
417
|
const { mapRef: n } = m(), t = new window.AMap.LayerGroup();
|
|
418
418
|
let o = !1;
|
|
419
|
-
const
|
|
419
|
+
const i = () => {
|
|
420
420
|
o || (t.setMap(n.value), o = !0);
|
|
421
421
|
}, s = () => {
|
|
422
422
|
try {
|
|
@@ -426,20 +426,20 @@ const q = (e, a) => {
|
|
|
426
426
|
}
|
|
427
427
|
o = !1;
|
|
428
428
|
}, p = () => t;
|
|
429
|
-
|
|
429
|
+
u(() => () => {
|
|
430
430
|
s();
|
|
431
|
-
}, []),
|
|
432
|
-
if (!
|
|
431
|
+
}, []), u(() => {
|
|
432
|
+
if (!V(e.bindTime))
|
|
433
433
|
return;
|
|
434
434
|
const l = setTimeout(() => {
|
|
435
|
-
|
|
435
|
+
i();
|
|
436
436
|
}, e.bindTime);
|
|
437
437
|
return () => {
|
|
438
438
|
l && clearTimeout(l);
|
|
439
439
|
};
|
|
440
440
|
}, []);
|
|
441
|
-
const d =
|
|
442
|
-
|
|
441
|
+
const d = q(() => {
|
|
442
|
+
i();
|
|
443
443
|
}, 300);
|
|
444
444
|
R(
|
|
445
445
|
() => {
|
|
@@ -449,13 +449,13 @@ const q = (e, a) => {
|
|
|
449
449
|
);
|
|
450
450
|
const M = C(e, "show");
|
|
451
451
|
P(t, M);
|
|
452
|
-
const
|
|
453
|
-
return k(t,
|
|
452
|
+
const L = C(e, "opts$");
|
|
453
|
+
return k(t, L), r({ getFeature: p, addToMap: i, removeFormMap: s }), j({ mapRef: n, layerGroup: t }), () => {
|
|
454
454
|
var l;
|
|
455
455
|
return (l = a.default) == null ? void 0 : l.call(a);
|
|
456
456
|
};
|
|
457
457
|
}
|
|
458
|
-
}),
|
|
458
|
+
}), ze = v({
|
|
459
459
|
props: {
|
|
460
460
|
opts: { type: Object },
|
|
461
461
|
itemOpts: { type: Object },
|
|
@@ -464,7 +464,7 @@ const q = (e, a) => {
|
|
|
464
464
|
events: { type: Array }
|
|
465
465
|
},
|
|
466
466
|
setup: (e, { expose: a }) => {
|
|
467
|
-
const { mapRef: r } = m(), n = new window.AMap.LabelsLayer(e.opts), t = () =>
|
|
467
|
+
const { mapRef: r } = m(), n = new window.AMap.LabelsLayer(e.opts), t = () => ce(e.data, (s) => {
|
|
468
468
|
const p = new window.AMap.LabelMarker({
|
|
469
469
|
...e.itemOpts,
|
|
470
470
|
...s
|
|
@@ -477,7 +477,7 @@ const q = (e, a) => {
|
|
|
477
477
|
const s = t();
|
|
478
478
|
n.add(s);
|
|
479
479
|
};
|
|
480
|
-
|
|
480
|
+
u(() => (z(e.data) > 0 && o(), r.value.add(n), () => {
|
|
481
481
|
n.clear(), r.value.remove(n);
|
|
482
482
|
}), []), R(
|
|
483
483
|
() => {
|
|
@@ -485,66 +485,67 @@ const q = (e, a) => {
|
|
|
485
485
|
},
|
|
486
486
|
() => e.data
|
|
487
487
|
);
|
|
488
|
-
const
|
|
489
|
-
return P(n,
|
|
488
|
+
const i = C(e, "show");
|
|
489
|
+
return P(n, i), a({ getFeature: () => n }), () => null;
|
|
490
490
|
}
|
|
491
|
-
}),
|
|
492
|
-
useMapConnect:
|
|
491
|
+
}), Ve = c("TileLayer", { useMapConnect: f }), qe = c("TileLayer.Satellite", {
|
|
492
|
+
useMapConnect: f,
|
|
493
493
|
createFeatureObj: (e) => new window.AMap.TileLayer.Satellite(e)
|
|
494
|
-
}),
|
|
495
|
-
useMapConnect:
|
|
494
|
+
}), Ke = c("TileLayer.RoadNet", {
|
|
495
|
+
useMapConnect: f,
|
|
496
496
|
createFeatureObj: (e) => new window.AMap.TileLayer.RoadNet(e)
|
|
497
|
-
}),
|
|
498
|
-
useMapConnect:
|
|
497
|
+
}), Qe = c("TileLayer.Traffic", {
|
|
498
|
+
useMapConnect: f,
|
|
499
499
|
createFeatureObj: (e) => new window.AMap.TileLayer.Traffic(e)
|
|
500
|
-
}),
|
|
501
|
-
useMapConnect:
|
|
502
|
-
createFeatureObj: (e) => new window.AMap.MassMarks((e == null ? void 0 : e.data) || [],
|
|
503
|
-
}),
|
|
504
|
-
useMapConnect:
|
|
500
|
+
}), Ue = c("Buildings", { useMapConnect: f }), Xe = c("MassMarks", {
|
|
501
|
+
useMapConnect: Y,
|
|
502
|
+
createFeatureObj: (e) => new window.AMap.MassMarks((e == null ? void 0 : e.data) || [], K(e, "data"))
|
|
503
|
+
}), Ye = c("TileLayer.Flexible", {
|
|
504
|
+
useMapConnect: f,
|
|
505
505
|
createFeatureObj: (e) => new window.AMap.TileLayer.Flexible(e)
|
|
506
|
-
}),
|
|
507
|
-
useMapConnect:
|
|
508
|
-
createFeatureObj: (e) => new window.AMap.CustomLayer(e == null ? void 0 : e.canvas,
|
|
509
|
-
}),
|
|
510
|
-
useMapConnect:
|
|
506
|
+
}), Ze = c("ImageLayer", { useMapConnect: f }), ea = c("VideoLayer", { useMapConnect: f }), aa = c("CanvasLayer", { useMapConnect: f }), ta = c("CustomLayer", {
|
|
507
|
+
useMapConnect: f,
|
|
508
|
+
createFeatureObj: (e) => new window.AMap.CustomLayer(e == null ? void 0 : e.canvas, K(e, "canvas"))
|
|
509
|
+
}), ra = c("DistrictLayer.World", {
|
|
510
|
+
useMapConnect: f,
|
|
511
511
|
createFeatureObj: (e) => new window.AMap.DistrictLayer.World(e)
|
|
512
|
-
}),
|
|
513
|
-
useMapConnect:
|
|
512
|
+
}), na = c("DistrictLayer.Country", {
|
|
513
|
+
useMapConnect: f,
|
|
514
514
|
createFeatureObj: (e) => new window.AMap.DistrictLayer.Country(e)
|
|
515
|
-
}),
|
|
516
|
-
useMapConnect:
|
|
515
|
+
}), oa = c("DistrictLayer.Province", {
|
|
516
|
+
useMapConnect: f,
|
|
517
517
|
createFeatureObj: (e) => new window.AMap.DistrictLayer.Province(e)
|
|
518
|
-
}),
|
|
519
|
-
useMapConnect:
|
|
518
|
+
}), we = c("HeatMap", {
|
|
519
|
+
useMapConnect: Y,
|
|
520
520
|
createFeatureObj: (e) => new window.AMap.HeatMap(null, e)
|
|
521
|
-
}),
|
|
521
|
+
}), ca = S([g.HeatMap], we), sa = (e, a) => {
|
|
522
522
|
let r = !1, n = null;
|
|
523
|
-
const
|
|
524
|
-
const
|
|
525
|
-
return
|
|
526
|
-
},
|
|
523
|
+
const t = x(), [o, i] = ne(), s = T(se(a.initEmit) ? a.initEmit : !1), p = ue(e, "_"), d = p[0], M = p[1], L = () => {
|
|
524
|
+
const y = ie(window, d);
|
|
525
|
+
return y ? new y({ ...a.opts, ...n == null ? void 0 : n.opts }) : null;
|
|
526
|
+
}, l = (y) => y || (h(a.params) ? a.params() : a.params || []), I = () => {
|
|
527
527
|
if (!n)
|
|
528
528
|
return;
|
|
529
|
-
const
|
|
530
|
-
if (!
|
|
529
|
+
const y = L();
|
|
530
|
+
if (t.value = y, !y || !h(y[M]))
|
|
531
531
|
return;
|
|
532
|
-
const D =
|
|
533
|
-
|
|
534
|
-
var
|
|
535
|
-
|
|
536
|
-
});
|
|
532
|
+
const D = l(n.params);
|
|
533
|
+
return s.value = !0, y[M](...D, (O, b) => {
|
|
534
|
+
var N, H, W, $;
|
|
535
|
+
i(b), (N = a.onComplete) == null || N.call(a, O, b), O === "complete" ? (H = a.onSuccess) == null || H.call(a, b) : O === "error" ? (W = a.onFail) == null || W.call(a, b) : O === "no_data" && (($ = a.onNoData) == null || $.call(a, b)), n = null, s.value = !1;
|
|
536
|
+
}), y;
|
|
537
537
|
};
|
|
538
|
-
|
|
539
|
-
r = !0,
|
|
538
|
+
X([d], () => {
|
|
539
|
+
r = !0, I();
|
|
540
540
|
});
|
|
541
|
-
const E = (
|
|
542
|
-
n = { opts:
|
|
541
|
+
const E = (y, D) => {
|
|
542
|
+
if (n = { opts: y || a.opts, params: l(D) }, !!r)
|
|
543
|
+
return I();
|
|
543
544
|
};
|
|
544
|
-
return
|
|
545
|
+
return u(() => {
|
|
545
546
|
a.initEmit && E();
|
|
546
|
-
}, []), R(() => E(), a.deps || []), { data:
|
|
547
|
-
},
|
|
547
|
+
}, []), R(() => E(), a.deps || []), { data: o, request: E, requesting: s, targetRef: t };
|
|
548
|
+
}, ua = {
|
|
548
549
|
Geocoder_getLocation: "AMap.Geocoder_getLocation",
|
|
549
550
|
Geocoder_getAddress: "AMap.Geocoder_getAddress",
|
|
550
551
|
Autocomplete_search: "AMap.Autocomplete_search",
|
|
@@ -559,55 +560,57 @@ const q = (e, a) => {
|
|
|
559
560
|
StationSearch_searchById: "AMap.StationSearch_searchById"
|
|
560
561
|
};
|
|
561
562
|
export {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
de as
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
ke as
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
563
|
+
ua as ApiNames,
|
|
564
|
+
Ie as BezierCurve,
|
|
565
|
+
Ue as Buildings,
|
|
566
|
+
aa as CanvasLayer,
|
|
567
|
+
De as Circle,
|
|
568
|
+
Oe as CircleMarker,
|
|
569
|
+
xe as ControlBar,
|
|
570
|
+
ta as CustomLayer,
|
|
571
|
+
na as DistrictLayerCountry,
|
|
572
|
+
oa as DistrictLayerProvince,
|
|
573
|
+
ra as DistrictLayerWorld,
|
|
574
|
+
_e as ElasticMarker,
|
|
575
|
+
Ge as Ellipse,
|
|
576
|
+
We as HawkEye,
|
|
577
|
+
ca as HeatMap,
|
|
578
|
+
Ze as ImageLayer,
|
|
579
|
+
Fe as InfoWindow,
|
|
580
|
+
ze as LabelsLayer,
|
|
581
|
+
Je as LayerGroup,
|
|
582
|
+
be as Map,
|
|
583
|
+
de as MapEvents,
|
|
584
|
+
Me as MapPlugin,
|
|
585
|
+
g as MapPluginType,
|
|
586
|
+
$e as MapType,
|
|
587
|
+
Pe as Marker,
|
|
588
|
+
Xe as MassMarks,
|
|
589
|
+
Re as OverlayGroup,
|
|
590
|
+
ke as Polygon,
|
|
591
|
+
Ee as Polyline,
|
|
592
|
+
je as Rectangle,
|
|
593
|
+
He as Scale,
|
|
594
|
+
Be as Text,
|
|
595
|
+
Ve as TileLayer,
|
|
596
|
+
Ye as TileLayerFlexible,
|
|
597
|
+
Ke as TileLayerRoadNet,
|
|
598
|
+
qe as TileLayerSatellite,
|
|
599
|
+
Qe as TileLayerTraffic,
|
|
600
|
+
Ne as ToolBar,
|
|
601
|
+
ea as VideoLayer,
|
|
600
602
|
c as createFeature,
|
|
601
|
-
|
|
603
|
+
S as createPluginFeature,
|
|
602
604
|
j as provideMap,
|
|
605
|
+
Q as useEvents,
|
|
603
606
|
k as useFeatureOptMethods,
|
|
604
607
|
m as useMap,
|
|
605
|
-
|
|
608
|
+
sa as useMapApi,
|
|
606
609
|
G as useMapConnect,
|
|
607
|
-
|
|
610
|
+
Y as useMapConnect2,
|
|
608
611
|
F as useMapControlConnect,
|
|
609
|
-
|
|
612
|
+
f as useMapLayerConnect,
|
|
610
613
|
w as useMapOverlayConnect,
|
|
611
|
-
|
|
614
|
+
X as useMapPlugin,
|
|
612
615
|
P as useShowConnect
|
|
613
616
|
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),H=require("@amap/amap-jsapi-loader"),i=require("@vue-start/hooks"),u=require("lodash"),V=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},$=V(H),G=(e,a)=>{i.useEffect(()=>(u.forEach(a,r=>{e.on(r.type,r.handler,void 0,r.once)}),()=>{u.forEach(a,r=>{e.off(r.type,r.handler)})}),[])},W=Symbol("amap-key"),R=e=>o.provide(W,e),m=()=>o.inject(W),x=()=>({securityJsCode:{type:String},loadOpts:{type:Object},opts:{type:Object},events:{type:Array}}),J=e=>{var a;if(!!e){if(!window._AMapSecurityConfig||!((a=window._AMapSecurityConfig)!=null&&a.securityJsCode)){window._AMapSecurityConfig={securityJsCode:e};return}window._AMapSecurityConfig.securityJsCode!==e&&(window._AMapSecurityConfig={securityJsCode:e},console.warn("\u5F53\u524Dwindow\u5BF9\u8C61\u5DF2\u7ECF\u6CE8\u5165\u8FC7securityJsCode\u503C\uFF0C\u53EF\u80FD\u9020\u6210\u95EE\u9898"))}},q=o.defineComponent({props:{events:{type:Array}},setup:e=>{const{mapRef:a}=m();return G(a.value,e.events),()=>null}}),z=o.defineComponent({props:{...x()},setup:(e,{slots:a,expose:r})=>{J(e.securityJsCode);const n=o.shallowRef(),t=o.ref();return r({mapRef:n,domRef:t}),i.useEffect(()=>($.default.load({version:"2.0",...e.loadOpts}).then(c=>{const p=new c.Map(t.value,{...e.opts});p.on("complete",()=>{n.value=p})}).catch(c=>{console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"),console.error(c)}),()=>{n.value&&n.value.destroy()}),[]),R({mapRef:n}),()=>{var c;return o.createVNode("div",{ref:t},[n.value&&o.createVNode(q,{events:e.events},null),n.value&&((c=a.default)==null?void 0:c.call(a))])}}}),k=(e,a)=>{const{mapRef:r}=m();i.useEffect(()=>{if(!r.value){console.warn("\u8BF7\u5728Map\u7EC4\u4EF6\u5185\u4F7F\u7528 useMapPlugin");return}if(!e||u.size(e)<=0){a();return}window.AMap.plugin(e,a)},[])},I=o.defineComponent({props:{plugins:Array},setup:(e,{slots:a})=>{const r=o.ref(!1);return k(e.plugins,()=>{r.value=!0}),()=>{var n;return r.value?(n=a.default)==null?void 0:n.call(a):null}}}),A={ElasticMarker:"AMap.ElasticMarker",ControlBar:"AMap.ControlBar",ToolBar:"AMap.ToolBar",Scale:"AMap.Scale",HawkEye:"AMap.HawkEye",MapType:"AMap.MapType",AdvancedInfoWindow:"AMap.AdvancedInfoWindow",DragRoute:"AMap.DragRoute",IndoorMap:"AMap.IndoorMap",MouseTool:"AMap.MouseTool",CircleEditor:"AMap.CircleEditor",PolygonEditor:"AMap.PolygonEditor",PolylineEditor:"AMap.PolylineEditor",MarkerCluster:"AMap.MarkerCluster",RangingTool:"AMap.RangingTool",Geolocation:"AMap.Geolocation",Geocoder:"AMap.Geocoder",AutoComplete:"AMap.AutoComplete",PlaceSearch:"AMap.PlaceSearch",LineSearch:"AMap.LineSearch",DistrictSearch:"AMap.DistrictSearch",StationSearch:"AMap.StationSearch",CitySearch:"AMap.CitySearch",CloudDataSearch:"AMap.CloudDataSearch",RoadInfoSearch:"AMap.RoadInfoSearch",Driving:"AMap.Driving",TruckDriving:"AMap.TruckDriving",Transfer:"AMap.Transfer",Walking:"AMap.Walking",Riding:"AMap.Riding",ArrivalRange:"AMap.ArrivalRange",GraspRoad:"AMap.GraspRoad",HeatMap:"AMap.HeatMap",Weather:"AMap.Weather"},F=e=>{const{mapRef:a}=m();i.useEffect(()=>(a.value.add(e),()=>{try{a.value.remove(e)}catch(r){console.error(r)}}),[])},B=e=>{const{mapRef:a}=m();i.useEffect(()=>(e.setMap(a.value),()=>{try{e.setMap(null)}catch(r){console.error(r)}}),[])},g=e=>{const{mapRef:a}=m();i.useEffect(()=>(a.value.addControl(e),()=>{try{a.value.removeControl(e)}catch(r){console.error(r)}}),[])},S=(e,a)=>{const r=()=>{e&&u.isFunction(e.show)&&e.show()},n=()=>{e&&u.isFunction(e.hide)&&e.hide()};i.useEffect(()=>{a.value||n()},[]),i.useWatch(()=>{a.value?r():n()},a)},b=(e,a)=>{i.useEffect(()=>{u.forEach(a.value,(r,n)=>{const t="set"+u.upperFirst(n);e[t]&&u.isFunction(e[t])&&e[t](r)})},a)},s=(e,{useMapConnect:a,createFeatureObj:r,needDom:n})=>o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(t,{slots:c,expose:p})=>{const l=r?r(t.opts):new window.AMap[e](t.opts);a(l);const M=o.toRef(t,"show");S(l,M);const f=o.toRef(t,"opts$");b(l,f),G(l,t.events),p({getFeature:()=>l});const C=o.ref();return i.useEffect(()=>{C.value&&u.isFunction(l.setContent)&&l.setContent(C.value)},C),()=>n&&c.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:C},[c.default()])]}):null}}),w=(e,a)=>o.defineComponent({props:{...a.props},setup:(r,{slots:n,expose:t})=>{const c=o.ref();return t(i.createExposeObj(c,["getFeature"])),()=>o.createVNode(I,{plugins:e},{default:()=>[o.createVNode(a,o.mergeProps({ref:c},r),n)]})}}),K=()=>{const{mapRef:e,overlayGroup:a}=m();return{addToMap:t=>{if(a){u.isArray(t)?a.addOverlays(t):a.addOverlay(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeOverlays(t):a.removeOverlay(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},h=e=>{const{addToMap:a,removeFromMap:r}=K();i.useEffect(()=>(a(e),()=>{r(e)}),[])},Q=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=m(),t=new window.AMap.OverlayGroup;let c=!1;const p=()=>{c||(n.value.add(t),c=!0)},l=()=>{try{n.value.remove(t)}catch(d){console.error(d)}c=!1},M=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&f()},()=>e.bind);const C=o.toRef(e,"show");S(t,C);const T=o.toRef(e,"opts$");return b(t,T),r({getFeature:M,addToMap:p,removeFormMap:l}),R({mapRef:n,overlayGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),U=o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},height:{type:Number,default:void 0}},setup:(e,{slots:a,emit:r})=>{const{mapRef:n}=m(),t=new window.AMap.InfoWindow({closeWhenClickMap:!0,isCustom:!!a.default,...e.opts}),c=o.toRef(e,"opts$");b(t,c);const p=()=>{r("close")};i.useEffect(()=>(t.on("close",p),()=>{t.off("close",p),t.close()}),[]),i.useEffect(()=>{var f,C;const M=((f=e.opts$)==null?void 0:f.position)||((C=e.opts)==null?void 0:C.position);!M||t.open(n.value,M,e.height)},()=>{var M;return(M=e.opts$)==null?void 0:M.position});const l=o.ref();return i.useEffect(()=>{l.value&&u.isFunction(t.setContent)&&t.setContent(l.value)},l),()=>a.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:l},[a.default()])]}):null}}),X=s("CircleMarker",{useMapConnect:F}),Y=s("Text",{useMapConnect:F}),Z=s("ElasticMarker",{useMapConnect:F}),ee=s("Marker",{useMapConnect:h,needDom:!0}),ae=s("Polygon",{useMapConnect:h}),te=s("Polyline",{useMapConnect:h}),re=s("Circle",{useMapConnect:h}),ne=s("Rectangle",{useMapConnect:h}),oe=s("Ellipse",{useMapConnect:h}),ce=s("BezierCurve",{useMapConnect:h}),se=s("ToolBar",{useMapConnect:g}),ue=w([A.ToolBar],se),ie=s("Scale",{useMapConnect:g}),le=w([A.Scale],ie),pe=s("HawkEye",{useMapConnect:g}),de=w([A.HawkEye],pe),Me=s("MapType",{useMapConnect:g}),fe=w([A.MapType],Me),ye=s("ControlBar",{useMapConnect:g}),Ce=w([A.ControlBar],ye),me=()=>{const{mapRef:e,layerGroup:a}=m();return{addToMap:t=>{if(a){u.isArray(t)?a.addLayers(t):a.addLayer(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeLayers(t):a.removeLayer(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},y=e=>{const{addToMap:a,removeFromMap:r}=me();i.useEffect(()=>(a(e),()=>{r(e)}),[])},ve=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=m(),t=new window.AMap.LayerGroup;let c=!1;const p=()=>{c||(t.setMap(n.value),c=!0)},l=()=>{try{t.setMap(null)}catch(d){console.error(d)}c=!1},M=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&f()},()=>e.bind);const C=o.toRef(e,"show");S(t,C);const T=o.toRef(e,"opts$");return b(t,T),r({getFeature:M,addToMap:p,removeFormMap:l}),R({mapRef:n,layerGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),he=o.defineComponent({props:{opts:{type:Object},itemOpts:{type:Object},data:{type:Array},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{expose:a})=>{const{mapRef:r}=m(),n=new window.AMap.LabelsLayer(e.opts),t=()=>u.map(e.data,l=>{const M=new window.AMap.LabelMarker({...e.itemOpts,...l});return e.events&&u.forEach(e.events,f=>{M.on(f.type,f.handler,void 0,f.once)}),M}),c=()=>{n.clear();const l=t();n.add(l)};i.useEffect(()=>(u.size(e.data)>0&&c(),r.value.add(n),()=>{n.clear(),r.value.remove(n)}),[]),i.useWatch(()=>{c()},()=>e.data);const p=o.toRef(e,"show");return S(n,p),a({getFeature:()=>n}),()=>null}}),Ae=s("TileLayer",{useMapConnect:y}),we=s("TileLayer.Satellite",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.Satellite(e)}),Te=s("TileLayer.RoadNet",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.RoadNet(e)}),ge=s("TileLayer.Traffic",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.Traffic(e)}),Le=s("Buildings",{useMapConnect:y}),Se=s("MassMarks",{useMapConnect:B,createFeatureObj:e=>new window.AMap.MassMarks((e==null?void 0:e.data)||[],u.omit(e,"data"))}),be=s("TileLayer.Flexible",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.Flexible(e)}),Ee=s("ImageLayer",{useMapConnect:y}),Re=s("VideoLayer",{useMapConnect:y}),Fe=s("CanvasLayer",{useMapConnect:y}),Oe=s("CustomLayer",{useMapConnect:y,createFeatureObj:e=>new window.AMap.CustomLayer(e==null?void 0:e.canvas,u.omit(e,"canvas"))}),Pe=s("DistrictLayer.World",{useMapConnect:y,createFeatureObj:e=>new window.AMap.DistrictLayer.World(e)}),ke=s("DistrictLayer.Country",{useMapConnect:y,createFeatureObj:e=>new window.AMap.DistrictLayer.Country(e)}),Be=s("DistrictLayer.Province",{useMapConnect:y,createFeatureObj:e=>new window.AMap.DistrictLayer.Province(e)}),_e=s("HeatMap",{useMapConnect:B,createFeatureObj:e=>new window.AMap.HeatMap(null,e)}),De=w([A.HeatMap],_e),Ne=(e,a)=>{let r=!1,n=null;const[t,c]=i.useState(),p=o.ref(u.isBoolean(a.initEmit)?a.initEmit:!1),l=u.split(e,"_"),M=l[0],f=l[1],C=()=>{const v=u.get(window,M);return v?new v({...a.opts,...n==null?void 0:n.opts}):null},T=v=>v||(u.isFunction(a.params)?a.params():a.params||[]),d=()=>{if(!n)return;const v=C();if(!v||!u.isFunction(v[f]))return;const P=T(n.params);p.value=!0,v[f](...P,(E,L)=>{var _,D,N,j;c(L),(_=a.onComplete)==null||_.call(a,E,L),E==="complete"?(D=a.onSuccess)==null||D.call(a,L):E==="error"?(N=a.onFail)==null||N.call(a,L):E==="no_data"&&((j=a.onNoData)==null||j.call(a,L)),n=null,p.value=!1})};k([M],()=>{r=!0,d()});const O=(v,P)=>{n={opts:v||a.opts,params:T(P)},r&&d()};return i.useEffect(()=>{a.initEmit&&O()},[]),i.useWatch(()=>O(),a.deps||[]),{data:t,request:O,requesting:p}},je={Geocoder_getLocation:"AMap.Geocoder_getLocation",Geocoder_getAddress:"AMap.Geocoder_getAddress",Autocomplete_search:"AMap.Autocomplete_search",PlaceSearch_search:"AMap.PlaceSearch_search",PlaceSearch_searchNearBy:"AMap.PlaceSearch_searchNearBy",PlaceSearch_searchInBounds:"AMap.PlaceSearch_searchInBounds",PlaceSearch_getDetails:"AMap.PlaceSearch_getDetails",DistrictSearch_search:"AMap.DistrictSearch_search",LineSearch_search:"AMap.LineSearch_search",LineSearch_searchById:"AMap.LineSearch_searchById",StationSearch_search:"AMap.StationSearch_search",StationSearch_searchById:"AMap.StationSearch_searchById"};exports.ApiNames=je;exports.BezierCurve=ce;exports.Buildings=Le;exports.CanvasLayer=Fe;exports.Circle=re;exports.CircleMarker=X;exports.ControlBar=Ce;exports.CustomLayer=Oe;exports.DistrictLayerCountry=ke;exports.DistrictLayerProvince=Be;exports.DistrictLayerWorld=Pe;exports.ElasticMarker=Z;exports.Ellipse=oe;exports.HawkEye=de;exports.HeatMap=De;exports.ImageLayer=Ee;exports.InfoWindow=U;exports.LabelsLayer=he;exports.LayerGroup=ve;exports.Map=z;exports.MapPlugin=I;exports.MapPluginType=A;exports.MapType=fe;exports.Marker=ee;exports.MassMarks=Se;exports.OverlayGroup=Q;exports.Polygon=ae;exports.Polyline=te;exports.Rectangle=ne;exports.Scale=le;exports.Text=Y;exports.TileLayer=Ae;exports.TileLayerFlexible=be;exports.TileLayerRoadNet=Te;exports.TileLayerSatellite=we;exports.TileLayerTraffic=ge;exports.ToolBar=ue;exports.VideoLayer=Re;exports.createFeature=s;exports.createPluginFeature=w;exports.provideMap=R;exports.useFeatureOptMethods=b;exports.useMap=m;exports.useMapApi=Ne;exports.useMapConnect=F;exports.useMapConnect2=B;exports.useMapControlConnect=g;exports.useMapLayerConnect=y;exports.useMapOverlayConnect=h;exports.useMapPlugin=k;exports.useShowConnect=S;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),$=require("@amap/amap-jsapi-loader"),i=require("@vue-start/hooks"),u=require("lodash"),x=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},J=x($),k=(e,a)=>{i.useEffect(()=>(u.forEach(a,r=>{e.on(r.type,r.handler,void 0,r.once)}),()=>{u.forEach(a,r=>{e.off(r.type,r.handler)})}),[])},I=Symbol("amap-key"),R=e=>o.provide(I,e),v=()=>o.inject(I),q=()=>({securityJsCode:{type:String},loadOpts:{type:Object},opts:{type:Object},events:{type:Array}}),z=e=>{var a;if(!!e){if(!window._AMapSecurityConfig||!((a=window._AMapSecurityConfig)!=null&&a.securityJsCode)){window._AMapSecurityConfig={securityJsCode:e};return}window._AMapSecurityConfig.securityJsCode!==e&&(window._AMapSecurityConfig={securityJsCode:e},console.warn("\u5F53\u524Dwindow\u5BF9\u8C61\u5DF2\u7ECF\u6CE8\u5165\u8FC7securityJsCode\u503C\uFF0C\u53EF\u80FD\u9020\u6210\u95EE\u9898"))}},H=o.defineComponent({props:{events:{type:Array}},setup:e=>{const{mapRef:a}=v();return k(a.value,e.events),()=>null}}),K=o.defineComponent({props:{...q()},setup:(e,{slots:a,expose:r})=>{z(e.securityJsCode);const n=o.shallowRef(),t=o.ref();return r({mapRef:n,domRef:t}),i.useEffect(()=>(J.default.load({version:"2.0",...e.loadOpts}).then(c=>{const p=new c.Map(t.value,{...e.opts});p.on("complete",()=>{n.value=p})}).catch(c=>{console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"),console.error(c)}),()=>{n.value&&n.value.destroy()}),[]),R({mapRef:n}),()=>{var c;return o.createVNode("div",{ref:t},[n.value&&o.createVNode(H,{events:e.events},null),n.value&&((c=a.default)==null?void 0:c.call(a))])}}}),B=(e,a)=>{const{mapRef:r}=v();i.useEffect(()=>{if(!r.value){console.warn("\u8BF7\u5728Map\u7EC4\u4EF6\u5185\u4F7F\u7528 useMapPlugin");return}if(!e||u.size(e)<=0){a();return}window.AMap.plugin(e,a)},[])},V=o.defineComponent({props:{plugins:Array},setup:(e,{slots:a})=>{const r=o.ref(!1);return B(e.plugins,()=>{r.value=!0}),()=>{var n;return r.value?(n=a.default)==null?void 0:n.call(a):null}}}),A={ElasticMarker:"AMap.ElasticMarker",ControlBar:"AMap.ControlBar",ToolBar:"AMap.ToolBar",Scale:"AMap.Scale",HawkEye:"AMap.HawkEye",MapType:"AMap.MapType",AdvancedInfoWindow:"AMap.AdvancedInfoWindow",DragRoute:"AMap.DragRoute",IndoorMap:"AMap.IndoorMap",MouseTool:"AMap.MouseTool",CircleEditor:"AMap.CircleEditor",PolygonEditor:"AMap.PolygonEditor",PolylineEditor:"AMap.PolylineEditor",MarkerCluster:"AMap.MarkerCluster",RangingTool:"AMap.RangingTool",Geolocation:"AMap.Geolocation",Geocoder:"AMap.Geocoder",AutoComplete:"AMap.AutoComplete",PlaceSearch:"AMap.PlaceSearch",LineSearch:"AMap.LineSearch",DistrictSearch:"AMap.DistrictSearch",StationSearch:"AMap.StationSearch",CitySearch:"AMap.CitySearch",CloudDataSearch:"AMap.CloudDataSearch",RoadInfoSearch:"AMap.RoadInfoSearch",Driving:"AMap.Driving",TruckDriving:"AMap.TruckDriving",Transfer:"AMap.Transfer",Walking:"AMap.Walking",Riding:"AMap.Riding",ArrivalRange:"AMap.ArrivalRange",GraspRoad:"AMap.GraspRoad",HeatMap:"AMap.HeatMap",Weather:"AMap.Weather"},F=e=>{const{mapRef:a}=v();i.useEffect(()=>(a.value.add(e),()=>{try{a.value.remove(e)}catch(r){console.error(r)}}),[])},_=e=>{const{mapRef:a}=v();i.useEffect(()=>(e.setMap(a.value),()=>{try{e.setMap(null)}catch(r){console.error(r)}}),[])},T=e=>{const{mapRef:a}=v();i.useEffect(()=>(a.value.addControl(e),()=>{try{a.value.removeControl(e)}catch(r){console.error(r)}}),[])},S=(e,a)=>{const r=()=>{e&&u.isFunction(e.show)&&e.show()},n=()=>{e&&u.isFunction(e.hide)&&e.hide()};i.useEffect(()=>{a.value||n()},[]),i.useWatch(()=>{a.value?r():n()},a)},E=(e,a)=>{i.useEffect(()=>{u.forEach(a.value,(r,n)=>{const t="set"+u.upperFirst(n);e[t]&&u.isFunction(e[t])&&e[t](r)})},a)},s=(e,{useMapConnect:a,createFeatureObj:r,needDom:n})=>o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(t,{slots:c,expose:p})=>{const l=r?r(t.opts):new window.AMap[e](t.opts);a(l);const M=o.toRef(t,"show");S(l,M);const f=o.toRef(t,"opts$");E(l,f),k(l,t.events),p({getFeature:()=>l});const y=o.ref();return i.useEffect(()=>{y.value&&u.isFunction(l.setContent)&&l.setContent(y.value)},y),()=>n&&c.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:y},[c.default()])]}):null}}),w=(e,a)=>o.defineComponent({props:{...a.props},setup:(r,{slots:n,expose:t})=>{const c=o.ref();return t(i.createExposeObj(c,["getFeature"])),()=>o.createVNode(V,{plugins:e},{default:()=>[o.createVNode(a,o.mergeProps({ref:c},r),n)]})}}),Q=()=>{const{mapRef:e,overlayGroup:a}=v();return{addToMap:t=>{if(a){u.isArray(t)?a.addOverlays(t):a.addOverlay(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeOverlays(t):a.removeOverlay(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},h=e=>{const{addToMap:a,removeFromMap:r}=Q();i.useEffect(()=>(a(e),()=>{r(e)}),[])},U=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=v(),t=new window.AMap.OverlayGroup;let c=!1;const p=()=>{c||(n.value.add(t),c=!0)},l=()=>{try{n.value.remove(t)}catch(d){console.error(d)}c=!1},M=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&f()},()=>e.bind);const y=o.toRef(e,"show");S(t,y);const g=o.toRef(e,"opts$");return E(t,g),r({getFeature:M,addToMap:p,removeFormMap:l}),R({mapRef:n,overlayGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),X=o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},height:{type:Number,default:void 0}},setup:(e,{slots:a,emit:r})=>{const{mapRef:n}=v(),t=new window.AMap.InfoWindow({closeWhenClickMap:!0,isCustom:!!a.default,...e.opts}),c=o.toRef(e,"opts$");E(t,c);const p=()=>{r("close")};i.useEffect(()=>(t.on("close",p),()=>{t.off("close",p),t.close()}),[]),i.useEffect(()=>{var f,y;const M=((f=e.opts$)==null?void 0:f.position)||((y=e.opts)==null?void 0:y.position);!M||t.open(n.value,M,e.height)},()=>{var M;return(M=e.opts$)==null?void 0:M.position});const l=o.ref();return i.useEffect(()=>{l.value&&u.isFunction(t.setContent)&&t.setContent(l.value)},l),()=>a.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:l},[a.default()])]}):null}}),Y=s("CircleMarker",{useMapConnect:F}),Z=s("Text",{useMapConnect:F}),ee=s("ElasticMarker",{useMapConnect:F}),ae=s("Marker",{useMapConnect:h,needDom:!0}),te=s("Polygon",{useMapConnect:h}),re=s("Polyline",{useMapConnect:h}),ne=s("Circle",{useMapConnect:h}),oe=s("Rectangle",{useMapConnect:h}),ce=s("Ellipse",{useMapConnect:h}),se=s("BezierCurve",{useMapConnect:h}),ue=s("ToolBar",{useMapConnect:T}),ie=w([A.ToolBar],ue),le=s("Scale",{useMapConnect:T}),pe=w([A.Scale],le),de=s("HawkEye",{useMapConnect:T}),Me=w([A.HawkEye],de),fe=s("MapType",{useMapConnect:T}),ye=w([A.MapType],fe),Ce=s("ControlBar",{useMapConnect:T}),me=w([A.ControlBar],Ce),ve=()=>{const{mapRef:e,layerGroup:a}=v();return{addToMap:t=>{if(a){u.isArray(t)?a.addLayers(t):a.addLayer(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeLayers(t):a.removeLayer(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},C=e=>{const{addToMap:a,removeFromMap:r}=ve();i.useEffect(()=>(a(e),()=>{r(e)}),[])},he=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=v(),t=new window.AMap.LayerGroup;let c=!1;const p=()=>{c||(t.setMap(n.value),c=!0)},l=()=>{try{t.setMap(null)}catch(d){console.error(d)}c=!1},M=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&f()},()=>e.bind);const y=o.toRef(e,"show");S(t,y);const g=o.toRef(e,"opts$");return E(t,g),r({getFeature:M,addToMap:p,removeFormMap:l}),R({mapRef:n,layerGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),Ae=o.defineComponent({props:{opts:{type:Object},itemOpts:{type:Object},data:{type:Array},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{expose:a})=>{const{mapRef:r}=v(),n=new window.AMap.LabelsLayer(e.opts),t=()=>u.map(e.data,l=>{const M=new window.AMap.LabelMarker({...e.itemOpts,...l});return e.events&&u.forEach(e.events,f=>{M.on(f.type,f.handler,void 0,f.once)}),M}),c=()=>{n.clear();const l=t();n.add(l)};i.useEffect(()=>(u.size(e.data)>0&&c(),r.value.add(n),()=>{n.clear(),r.value.remove(n)}),[]),i.useWatch(()=>{c()},()=>e.data);const p=o.toRef(e,"show");return S(n,p),a({getFeature:()=>n}),()=>null}}),we=s("TileLayer",{useMapConnect:C}),Te=s("TileLayer.Satellite",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.Satellite(e)}),ge=s("TileLayer.RoadNet",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.RoadNet(e)}),Le=s("TileLayer.Traffic",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.Traffic(e)}),Se=s("Buildings",{useMapConnect:C}),Ee=s("MassMarks",{useMapConnect:_,createFeatureObj:e=>new window.AMap.MassMarks((e==null?void 0:e.data)||[],u.omit(e,"data"))}),be=s("TileLayer.Flexible",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.Flexible(e)}),Re=s("ImageLayer",{useMapConnect:C}),Fe=s("VideoLayer",{useMapConnect:C}),Oe=s("CanvasLayer",{useMapConnect:C}),Pe=s("CustomLayer",{useMapConnect:C,createFeatureObj:e=>new window.AMap.CustomLayer(e==null?void 0:e.canvas,u.omit(e,"canvas"))}),ke=s("DistrictLayer.World",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.World(e)}),Be=s("DistrictLayer.Country",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.Country(e)}),_e=s("DistrictLayer.Province",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.Province(e)}),De=s("HeatMap",{useMapConnect:_,createFeatureObj:e=>new window.AMap.HeatMap(null,e)}),Ne=w([A.HeatMap],De),je=(e,a)=>{let r=!1,n=null;const t=o.shallowRef(),[c,p]=i.useState(),l=o.ref(u.isBoolean(a.initEmit)?a.initEmit:!1),M=u.split(e,"_"),f=M[0],y=M[1],g=()=>{const m=u.get(window,f);return m?new m({...a.opts,...n==null?void 0:n.opts}):null},d=m=>m||(u.isFunction(a.params)?a.params():a.params||[]),D=()=>{if(!n)return;const m=g();if(t.value=m,!m||!u.isFunction(m[y]))return;const P=d(n.params);return l.value=!0,m[y](...P,(b,L)=>{var N,j,G,W;p(L),(N=a.onComplete)==null||N.call(a,b,L),b==="complete"?(j=a.onSuccess)==null||j.call(a,L):b==="error"?(G=a.onFail)==null||G.call(a,L):b==="no_data"&&((W=a.onNoData)==null||W.call(a,L)),n=null,l.value=!1}),m};B([f],()=>{r=!0,D()});const O=(m,P)=>{if(n={opts:m||a.opts,params:d(P)},!!r)return D()};return i.useEffect(()=>{a.initEmit&&O()},[]),i.useWatch(()=>O(),a.deps||[]),{data:c,request:O,requesting:l,targetRef:t}},Ge={Geocoder_getLocation:"AMap.Geocoder_getLocation",Geocoder_getAddress:"AMap.Geocoder_getAddress",Autocomplete_search:"AMap.Autocomplete_search",PlaceSearch_search:"AMap.PlaceSearch_search",PlaceSearch_searchNearBy:"AMap.PlaceSearch_searchNearBy",PlaceSearch_searchInBounds:"AMap.PlaceSearch_searchInBounds",PlaceSearch_getDetails:"AMap.PlaceSearch_getDetails",DistrictSearch_search:"AMap.DistrictSearch_search",LineSearch_search:"AMap.LineSearch_search",LineSearch_searchById:"AMap.LineSearch_searchById",StationSearch_search:"AMap.StationSearch_search",StationSearch_searchById:"AMap.StationSearch_searchById"};exports.ApiNames=Ge;exports.BezierCurve=se;exports.Buildings=Se;exports.CanvasLayer=Oe;exports.Circle=ne;exports.CircleMarker=Y;exports.ControlBar=me;exports.CustomLayer=Pe;exports.DistrictLayerCountry=Be;exports.DistrictLayerProvince=_e;exports.DistrictLayerWorld=ke;exports.ElasticMarker=ee;exports.Ellipse=ce;exports.HawkEye=Me;exports.HeatMap=Ne;exports.ImageLayer=Re;exports.InfoWindow=X;exports.LabelsLayer=Ae;exports.LayerGroup=he;exports.Map=K;exports.MapEvents=H;exports.MapPlugin=V;exports.MapPluginType=A;exports.MapType=ye;exports.Marker=ae;exports.MassMarks=Ee;exports.OverlayGroup=U;exports.Polygon=te;exports.Polyline=re;exports.Rectangle=oe;exports.Scale=pe;exports.Text=Z;exports.TileLayer=we;exports.TileLayerFlexible=be;exports.TileLayerRoadNet=ge;exports.TileLayerSatellite=Te;exports.TileLayerTraffic=Le;exports.ToolBar=ie;exports.VideoLayer=Fe;exports.createFeature=s;exports.createPluginFeature=w;exports.provideMap=R;exports.useEvents=k;exports.useFeatureOptMethods=E;exports.useMap=v;exports.useMapApi=je;exports.useMapConnect=F;exports.useMapConnect2=_;exports.useMapControlConnect=T;exports.useMapLayerConnect=C;exports.useMapOverlayConnect=h;exports.useMapPlugin=B;exports.useShowConnect=S;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-start/map",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "amap wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amap"
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@amap/amap-jsapi-loader": "^1.0.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "1a871319b5d0c292f0733a062e67688bed52ee44"
|
|
34
34
|
}
|