@vue-start/map 0.0.1

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