@vue-start/map 0.0.8 → 0.0.9

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 CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.0.9
2
+
3
+ - feat: MapAutoComplete、MapLoc组件;
4
+
1
5
  # 0.0.7
2
6
 
3
7
  - perf: useMapApi 返回插件对象 targetRef;
package/dist/index.d.ts CHANGED
@@ -580,7 +580,7 @@ declare const useMapApi: (api: string, options: IUseMapApiOptions) => IUseMapApi
580
580
  declare const ApiNames: {
581
581
  Geocoder_getLocation: string;
582
582
  Geocoder_getAddress: string;
583
- Autocomplete_search: string;
583
+ AutoComplete_search: string;
584
584
  PlaceSearch_search: string;
585
585
  PlaceSearch_searchNearBy: string;
586
586
  PlaceSearch_searchInBounds: string;
@@ -592,4 +592,94 @@ declare const ApiNames: {
592
592
  StationSearch_searchById: string;
593
593
  };
594
594
 
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 };
595
+ declare const MapLoc: vue.DefineComponent<{
596
+ enableAuto: {
597
+ type: BooleanConstructor;
598
+ default: boolean;
599
+ };
600
+ autoProps: {
601
+ type: ObjectConstructor;
602
+ default: () => {};
603
+ };
604
+ geoOpts: {
605
+ type: ObjectConstructor;
606
+ default: () => {};
607
+ };
608
+ modelValue: {
609
+ type: PropType<[number, number] | null | undefined>;
610
+ default: null;
611
+ };
612
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("select" | "click" | "address" | "update:modelValue")[], "select" | "click" | "address" | "update:modelValue", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
613
+ enableAuto: {
614
+ type: BooleanConstructor;
615
+ default: boolean;
616
+ };
617
+ autoProps: {
618
+ type: ObjectConstructor;
619
+ default: () => {};
620
+ };
621
+ geoOpts: {
622
+ type: ObjectConstructor;
623
+ default: () => {};
624
+ };
625
+ modelValue: {
626
+ type: PropType<[number, number] | null | undefined>;
627
+ default: null;
628
+ };
629
+ }>> & {
630
+ onClick?: ((...args: any[]) => any) | undefined;
631
+ onSelect?: ((...args: any[]) => any) | undefined;
632
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
633
+ onAddress?: ((...args: any[]) => any) | undefined;
634
+ }, {
635
+ modelValue: [number, number] | null | undefined;
636
+ enableAuto: boolean;
637
+ autoProps: Record<string, any>;
638
+ geoOpts: Record<string, any>;
639
+ }>;
640
+
641
+ declare const MapAutoComplete: vue.DefineComponent<{
642
+ opts: {
643
+ type: PropType<Record<string, any>>;
644
+ default: () => {
645
+ city: string;
646
+ };
647
+ };
648
+ debounceTime: {
649
+ type: NumberConstructor;
650
+ default: number;
651
+ };
652
+ convertResult: {
653
+ type: PropType<(tip: any) => any>;
654
+ default: null;
655
+ };
656
+ renderComp: {
657
+ type: FunctionConstructor;
658
+ };
659
+ }, () => any, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "select"[], "select", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
660
+ opts: {
661
+ type: PropType<Record<string, any>>;
662
+ default: () => {
663
+ city: string;
664
+ };
665
+ };
666
+ debounceTime: {
667
+ type: NumberConstructor;
668
+ default: number;
669
+ };
670
+ convertResult: {
671
+ type: PropType<(tip: any) => any>;
672
+ default: null;
673
+ };
674
+ renderComp: {
675
+ type: FunctionConstructor;
676
+ };
677
+ }>> & {
678
+ onSelect?: ((...args: any[]) => any) | undefined;
679
+ }, {
680
+ debounceTime: number;
681
+ opts: Record<string, any>;
682
+ convertResult: (tip: any) => any;
683
+ }>;
684
+
685
+ export { ApiNames, BezierCurve, Buildings, CanvasLayer, Circle, CircleMarker, ControlBar, CustomLayer, DistrictLayerCountry, DistrictLayerProvince, DistrictLayerWorld, ElasticMarker, Ellipse, HawkEye, HeatMap, IMapProvide, IUseMapApiOptions, IUseMapApiResult, ImageLayer, InfoWindow, LabelsLayer, LayerGroup, Map, MapAutoComplete, MapEvents, MapLoc, 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 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 i, useWatch as R, createExposeObj as re, useState as ne } from "@vue-start/hooks";
4
- import { forEach as B, size as V, isFunction as h, upperFirst as oe, isNumber as z, 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
- i(() => (B(a, (n) => {
1
+ import { defineComponent as A, shallowRef as q, ref as g, createVNode as v, provide as ne, inject as oe, toRef as h, Teleport as J, mergeProps as z, computed as ce, Fragment as se, nextTick as ue } from "vue";
2
+ import le from "@amap/amap-jsapi-loader";
3
+ import { useEffect as d, useWatch as R, createExposeObj as ie, useState as pe } from "@vue-start/hooks";
4
+ import { forEach as P, size as K, isFunction as w, upperFirst as de, isNumber as _, debounce as G, isArray as B, map as Q, omit as U, isBoolean as Me, split as ye, get as fe, filter as me } from "lodash";
5
+ const X = (e, t) => {
6
+ d(() => (P(t, (n) => {
7
7
  e.on(n.type, n.handler, void 0, n.once);
8
8
  }), () => {
9
- B(a, (n) => {
9
+ P(t, (n) => {
10
10
  e.off(n.type, n.handler);
11
11
  });
12
12
  }), []);
13
- }, U = Symbol("amap-key"), j = (e) => Z(U, e), m = () => ee(U), le = () => ({
13
+ }, Y = Symbol("amap-key"), I = (e) => ne(Y, e), C = () => oe(Y), ve = () => ({
14
14
  securityJsCode: {
15
15
  type: String
16
16
  },
@@ -23,10 +23,10 @@ const Q = (e, a) => {
23
23
  events: {
24
24
  type: Array
25
25
  }
26
- }), pe = (e) => {
27
- var a;
26
+ }), Ce = (e) => {
27
+ var t;
28
28
  if (!!e) {
29
- if (!window._AMapSecurityConfig || !((a = window._AMapSecurityConfig) != null && a.securityJsCode)) {
29
+ if (!window._AMapSecurityConfig || !((t = window._AMapSecurityConfig) != null && t.securityJsCode)) {
30
30
  window._AMapSecurityConfig = {
31
31
  securityJsCode: e
32
32
  };
@@ -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
- }, de = v({
39
+ }, Z = A({
40
40
  props: {
41
41
  events: {
42
42
  type: Array
@@ -44,28 +44,28 @@ const Q = (e, a) => {
44
44
  },
45
45
  setup: (e) => {
46
46
  const {
47
- mapRef: a
48
- } = m();
49
- return Q(a.value, e.events), () => null;
47
+ mapRef: t
48
+ } = C();
49
+ return X(t.value, e.events), () => null;
50
50
  }
51
- }), be = v({
51
+ }), je = A({
52
52
  props: {
53
- ...le()
53
+ ...ve()
54
54
  },
55
55
  setup: (e, {
56
- slots: a,
56
+ slots: t,
57
57
  expose: n
58
58
  }) => {
59
- pe(e.securityJsCode);
60
- const r = x(), t = T();
59
+ Ce(e.securityJsCode);
60
+ const r = q(), a = g();
61
61
  return n({
62
62
  mapRef: r,
63
- domRef: t
64
- }), i(() => (te.load({
63
+ domRef: a
64
+ }), d(() => (le.load({
65
65
  version: "2.0",
66
66
  ...e.loadOpts
67
67
  }).then((o) => {
68
- const u = new o.Map(t.value, {
68
+ const u = new o.Map(a.value, {
69
69
  ...e.opts
70
70
  });
71
71
  u.on("complete", () => {
@@ -75,44 +75,44 @@ const Q = (e, a) => {
75
75
  console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"), console.error(o);
76
76
  }), () => {
77
77
  r.value && r.value.destroy();
78
- }), []), j({
78
+ }), []), I({
79
79
  mapRef: r
80
80
  }), () => {
81
81
  var o;
82
- return A("div", {
83
- ref: t
84
- }, [r.value && A(de, {
82
+ return v("div", {
83
+ ref: a
84
+ }, [r.value && v(Z, {
85
85
  events: e.events
86
- }, null), r.value && ((o = a.default) == null ? void 0 : o.call(a))]);
86
+ }, null), r.value && ((o = t.default) == null ? void 0 : o.call(t))]);
87
87
  };
88
88
  }
89
- }), X = (e, a) => {
90
- const { mapRef: n } = m();
91
- i(() => {
89
+ }), ee = (e, t) => {
90
+ const { mapRef: n } = C();
91
+ d(() => {
92
92
  if (!n.value) {
93
93
  console.warn("\u8BF7\u5728Map\u7EC4\u4EF6\u5185\u4F7F\u7528 useMapPlugin");
94
94
  return;
95
95
  }
96
- if (!e || V(e) <= 0) {
97
- a();
96
+ if (!e || K(e) <= 0) {
97
+ t();
98
98
  return;
99
99
  }
100
- window.AMap.plugin(e, a);
100
+ window.AMap.plugin(e, t);
101
101
  }, []);
102
- }, Me = v({
102
+ }, Ae = A({
103
103
  props: {
104
104
  plugins: Array
105
105
  },
106
- setup: (e, { slots: a }) => {
107
- const n = T(!1);
108
- return X(e.plugins, () => {
106
+ setup: (e, { slots: t }) => {
107
+ const n = g(!1);
108
+ return ee(e.plugins, () => {
109
109
  n.value = !0;
110
110
  }), () => {
111
111
  var r;
112
- return n.value ? (r = a.default) == null ? void 0 : r.call(a) : null;
112
+ return n.value ? (r = t.default) == null ? void 0 : r.call(t) : null;
113
113
  };
114
114
  }
115
- }), g = {
115
+ }), S = {
116
116
  ElasticMarker: "AMap.ElasticMarker",
117
117
  ControlBar: "AMap.ControlBar",
118
118
  ToolBar: "AMap.ToolBar",
@@ -147,70 +147,70 @@ const Q = (e, a) => {
147
147
  GraspRoad: "AMap.GraspRoad",
148
148
  HeatMap: "AMap.HeatMap",
149
149
  Weather: "AMap.Weather"
150
- }, G = (e) => {
150
+ }, N = (e) => {
151
151
  const {
152
- mapRef: a
153
- } = m();
154
- i(() => (a.value.add(e), () => {
152
+ mapRef: t
153
+ } = C();
154
+ d(() => (t.value.add(e), () => {
155
155
  try {
156
- a.value.remove(e);
156
+ t.value.remove(e);
157
157
  } catch (n) {
158
158
  console.error(n);
159
159
  }
160
160
  }), []);
161
- }, Y = (e) => {
161
+ }, te = (e) => {
162
162
  const {
163
- mapRef: a
164
- } = m();
165
- i(() => (e.setMap(a.value), () => {
163
+ mapRef: t
164
+ } = C();
165
+ d(() => (e.setMap(t.value), () => {
166
166
  try {
167
167
  e.setMap(null);
168
168
  } catch (n) {
169
169
  console.error(n);
170
170
  }
171
171
  }), []);
172
- }, F = (e) => {
172
+ }, O = (e) => {
173
173
  const {
174
- mapRef: a
175
- } = m();
176
- i(() => (a.value.addControl(e), () => {
174
+ mapRef: t
175
+ } = C();
176
+ d(() => (t.value.addControl(e), () => {
177
177
  try {
178
- a.value.removeControl(e);
178
+ t.value.removeControl(e);
179
179
  } catch (n) {
180
180
  console.error(n);
181
181
  }
182
182
  }), []);
183
- }, P = (e, a) => {
183
+ }, k = (e, t) => {
184
184
  const n = () => {
185
- e && h(e.show) && e.show();
185
+ e && w(e.show) && e.show();
186
186
  }, r = () => {
187
- e && h(e.hide) && e.hide();
187
+ e && w(e.hide) && e.hide();
188
188
  };
189
- i(() => {
190
- a.value || r();
189
+ d(() => {
190
+ t.value || r();
191
191
  }, []), R(() => {
192
- a.value ? n() : r();
193
- }, a);
194
- }, E = (e, a) => {
195
- const n = (r, t) => {
196
- const o = "set" + oe(r);
197
- if (e[o] && h(e[o]))
198
- e[o](t);
192
+ t.value ? n() : r();
193
+ }, t);
194
+ }, E = (e, t) => {
195
+ const n = (r, a) => {
196
+ const o = "set" + de(r);
197
+ if (e[o] && w(e[o]))
198
+ e[o](a);
199
199
  else {
200
200
  const u = "set" + r;
201
- e[u] && h(e[u]) && e[u](t);
201
+ e[u] && w(e[u]) && e[u](a);
202
202
  }
203
203
  };
204
- i((r, t) => {
205
- B(a.value, (o, u) => {
206
- (t == null ? void 0 : t[u]) !== o && n(u, o);
204
+ d((r, a) => {
205
+ P(t.value, (o, u) => {
206
+ (a == null ? void 0 : a[u]) !== o && n(u, o);
207
207
  });
208
- }, a);
209
- }, c = (e, {
210
- useMapConnect: a,
208
+ }, t);
209
+ }, i = (e, {
210
+ useMapConnect: t,
211
211
  createFeatureObj: n,
212
212
  needDom: r
213
- }) => v({
213
+ }) => A({
214
214
  props: {
215
215
  opts: {
216
216
  type: Object
@@ -226,71 +226,71 @@ const Q = (e, a) => {
226
226
  type: Array
227
227
  }
228
228
  },
229
- setup: (t, {
229
+ setup: (a, {
230
230
  slots: o,
231
231
  expose: u
232
232
  }) => {
233
- const s = n ? n(t.opts) : new window.AMap[e](t.opts);
234
- a(s);
235
- const p = C(t, "show");
236
- P(s, p);
237
- const d = C(t, "opts$");
238
- E(s, d), Q(s, t.events), u({
233
+ const s = n ? n(a.opts) : new window.AMap[e](a.opts);
234
+ t(s);
235
+ const l = h(a, "show");
236
+ k(s, l);
237
+ const c = h(a, "opts$");
238
+ E(s, c), X(s, a.events), u({
239
239
  getFeature: () => s
240
240
  });
241
- const M = T();
242
- return i(() => {
243
- M.value && h(s.setContent) && s.setContent(M.value);
244
- }, M), () => r && o.default ? A(J, {
241
+ const p = g();
242
+ return d(() => {
243
+ p.value && w(s.setContent) && s.setContent(p.value);
244
+ }, p), () => r && o.default ? v(J, {
245
245
  to: "body"
246
246
  }, {
247
- default: () => [A("div", {
248
- ref: M
247
+ default: () => [v("div", {
248
+ ref: p
249
249
  }, [o.default()])]
250
250
  }) : null;
251
251
  }
252
- }), S = (e, a) => v({
252
+ }), L = (e, t) => A({
253
253
  props: {
254
- ...a.props
254
+ ...t.props
255
255
  },
256
256
  setup: (n, {
257
257
  slots: r,
258
- expose: t
258
+ expose: a
259
259
  }) => {
260
- const o = T();
261
- return t(re(o, ["getFeature"])), () => A(Me, {
260
+ const o = g();
261
+ return a(ie(o, ["getFeature"])), () => v(Ae, {
262
262
  plugins: e
263
263
  }, {
264
- default: () => [A(a, ae({
264
+ default: () => [v(t, z({
265
265
  ref: o
266
266
  }, n), r)]
267
267
  });
268
268
  }
269
- }), ye = () => {
270
- const { mapRef: e, overlayGroup: a } = m();
271
- return { addToMap: (t) => {
272
- if (a) {
273
- _(t) ? a.addOverlays(t) : a.addOverlay(t);
269
+ }), he = () => {
270
+ const { mapRef: e, overlayGroup: t } = C();
271
+ return { addToMap: (a) => {
272
+ if (t) {
273
+ B(a) ? t.addOverlays(a) : t.addOverlay(a);
274
274
  return;
275
275
  }
276
- e.value.add(t);
277
- }, removeFromMap: (t) => {
278
- if (a) {
279
- _(t) ? a.removeOverlays(t) : a.removeOverlay(t);
276
+ e.value.add(a);
277
+ }, removeFromMap: (a) => {
278
+ if (t) {
279
+ B(a) ? t.removeOverlays(a) : t.removeOverlay(a);
280
280
  return;
281
281
  }
282
282
  try {
283
- e.value.remove(t);
283
+ e.value.remove(a);
284
284
  } catch (o) {
285
285
  console.error(o);
286
286
  }
287
287
  } };
288
- }, w = (e) => {
289
- const { addToMap: a, removeFromMap: n } = ye();
290
- i(() => (a(e), () => {
288
+ }, T = (e) => {
289
+ const { addToMap: t, removeFromMap: n } = he();
290
+ d(() => (t(e), () => {
291
291
  n(e);
292
292
  }), []);
293
- }, Re = v({
293
+ }, Ge = A({
294
294
  props: {
295
295
  bind: { type: Boolean, default: !1 },
296
296
  bindTime: { type: Number, default: void 0 },
@@ -298,49 +298,49 @@ const Q = (e, a) => {
298
298
  show: { type: Boolean, default: !0 },
299
299
  events: { type: Array }
300
300
  },
301
- setup: (e, { slots: a, expose: n }) => {
302
- const { mapRef: r } = m(), t = new window.AMap.OverlayGroup();
301
+ setup: (e, { slots: t, expose: n }) => {
302
+ const { mapRef: r } = C(), a = new window.AMap.OverlayGroup();
303
303
  let o = !1;
304
304
  const u = () => {
305
- o || (r.value.add(t), o = !0);
305
+ o || (r.value.add(a), o = !0);
306
306
  }, s = () => {
307
307
  try {
308
- r.value.remove(t);
309
- } catch (l) {
310
- console.error(l);
308
+ r.value.remove(a);
309
+ } catch (M) {
310
+ console.error(M);
311
311
  }
312
312
  o = !1;
313
- }, p = () => t;
314
- i(() => () => {
313
+ }, l = () => a;
314
+ d(() => () => {
315
315
  s();
316
- }, []), i(() => {
317
- if (!z(e.bindTime))
316
+ }, []), d(() => {
317
+ if (!_(e.bindTime))
318
318
  return;
319
- const l = setTimeout(() => {
319
+ const M = setTimeout(() => {
320
320
  u();
321
321
  }, e.bindTime);
322
322
  return () => {
323
- l && clearTimeout(l);
323
+ M && clearTimeout(M);
324
324
  };
325
325
  }, []);
326
- const d = q(() => {
326
+ const c = G(() => {
327
327
  u();
328
328
  }, 300);
329
329
  R(
330
330
  () => {
331
- e.bind && d();
331
+ e.bind && c();
332
332
  },
333
333
  () => e.bind
334
334
  );
335
- const M = C(e, "show");
336
- P(t, M);
337
- const L = C(e, "opts$");
338
- return E(t, L), n({ getFeature: p, addToMap: u, removeFormMap: s }), j({ mapRef: r, overlayGroup: t }), () => {
339
- var l;
340
- return (l = a.default) == null ? void 0 : l.call(a);
335
+ const p = h(e, "show");
336
+ k(a, p);
337
+ const y = h(e, "opts$");
338
+ return E(a, y), n({ getFeature: l, addToMap: u, removeFormMap: s }), I({ mapRef: r, overlayGroup: a }), () => {
339
+ var M;
340
+ return (M = t.default) == null ? void 0 : M.call(t);
341
341
  };
342
342
  }
343
- }), Fe = v({
343
+ }), Ie = A({
344
344
  props: {
345
345
  opts: {
346
346
  type: Object
@@ -354,66 +354,66 @@ const Q = (e, a) => {
354
354
  }
355
355
  },
356
356
  setup: (e, {
357
- slots: a,
357
+ slots: t,
358
358
  emit: n
359
359
  }) => {
360
360
  const {
361
361
  mapRef: r
362
- } = m(), t = new window.AMap.InfoWindow({
362
+ } = C(), a = new window.AMap.InfoWindow({
363
363
  closeWhenClickMap: !0,
364
- isCustom: !!a.default,
364
+ isCustom: !!t.default,
365
365
  ...e.opts
366
- }), o = C(e, "opts$");
367
- E(t, o);
366
+ }), o = h(e, "opts$");
367
+ E(a, o);
368
368
  const u = () => {
369
369
  n("close");
370
370
  };
371
- i(() => (t.on("close", u), () => {
372
- t.off("close", u), t.close();
373
- }), []), i(() => {
374
- var d, M;
375
- const p = ((d = e.opts$) == null ? void 0 : d.position) || ((M = e.opts) == null ? void 0 : M.position);
376
- !p || t.open(r.value, p, e.height);
371
+ d(() => (a.on("close", u), () => {
372
+ a.off("close", u), a.close();
373
+ }), []), d(() => {
374
+ var c, p;
375
+ const l = ((c = e.opts$) == null ? void 0 : c.position) || ((p = e.opts) == null ? void 0 : p.position);
376
+ !l || a.open(r.value, l, e.height);
377
377
  }, () => {
378
- var p;
379
- return (p = e.opts$) == null ? void 0 : p.position;
378
+ var l;
379
+ return (l = e.opts$) == null ? void 0 : l.position;
380
380
  });
381
- const s = T();
382
- return i(() => {
383
- s.value && h(t.setContent) && t.setContent(s.value);
384
- }, s), () => a.default ? A(J, {
381
+ const s = g();
382
+ return d(() => {
383
+ s.value && w(a.setContent) && a.setContent(s.value);
384
+ }, s), () => t.default ? v(J, {
385
385
  to: "body"
386
386
  }, {
387
- default: () => [A("div", {
387
+ default: () => [v("div", {
388
388
  ref: s
389
- }, [a.default()])]
389
+ }, [t.default()])]
390
390
  }) : null;
391
391
  }
392
- }), Oe = c("CircleMarker", { useMapConnect: G }), Be = c("Text", { useMapConnect: G }), _e = c("ElasticMarker", { useMapConnect: G }), Pe = c("Marker", { useMapConnect: w, needDom: !0 }), Ee = c("Polygon", { useMapConnect: w }), ke = 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 }), He = S([g.ToolBar], fe), me = c("Scale", { useMapConnect: F }), Ne = 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 = () => {
393
- const { mapRef: e, layerGroup: a } = m();
394
- return { addToMap: (t) => {
395
- if (a) {
396
- _(t) ? a.addLayers(t) : a.addLayer(t);
392
+ }), Ne = i("CircleMarker", { useMapConnect: N }), He = i("Text", { useMapConnect: N }), We = i("ElasticMarker", { useMapConnect: N }), we = i("Marker", { useMapConnect: T, needDom: !0 }), $e = i("Polygon", { useMapConnect: T }), xe = i("Polyline", { useMapConnect: T }), Ve = i("Circle", { useMapConnect: T }), qe = i("Rectangle", { useMapConnect: T }), Je = i("Ellipse", { useMapConnect: T }), ze = i("BezierCurve", { useMapConnect: T }), ge = i("ToolBar", { useMapConnect: O }), Ke = L([S.ToolBar], ge), Te = i("Scale", { useMapConnect: O }), Qe = L([S.Scale], Te), Se = i("HawkEye", { useMapConnect: O }), Ue = L([S.HawkEye], Se), Le = i("MapType", { useMapConnect: O }), Xe = L([S.MapType], Le), be = i("ControlBar", { useMapConnect: O }), Ye = L([S.ControlBar], be), Re = () => {
393
+ const { mapRef: e, layerGroup: t } = C();
394
+ return { addToMap: (a) => {
395
+ if (t) {
396
+ B(a) ? t.addLayers(a) : t.addLayer(a);
397
397
  return;
398
398
  }
399
- e.value.add(t);
400
- }, removeFromMap: (t) => {
401
- if (a) {
402
- _(t) ? a.removeLayers(t) : a.removeLayer(t);
399
+ e.value.add(a);
400
+ }, removeFromMap: (a) => {
401
+ if (t) {
402
+ B(a) ? t.removeLayers(a) : t.removeLayer(a);
403
403
  return;
404
404
  }
405
405
  try {
406
- e.value.remove(t);
406
+ e.value.remove(a);
407
407
  } catch (o) {
408
408
  console.error(o);
409
409
  }
410
410
  } };
411
- }, f = (e) => {
412
- const { addToMap: a, removeFromMap: n } = he();
413
- i(() => (a(e), () => {
411
+ }, m = (e) => {
412
+ const { addToMap: t, removeFromMap: n } = Re();
413
+ d(() => (t(e), () => {
414
414
  n(e);
415
415
  }), []);
416
- }, Je = v({
416
+ }, Ze = A({
417
417
  props: {
418
418
  bind: { type: Boolean, default: !1 },
419
419
  bindTime: { type: Number, default: void 0 },
@@ -421,49 +421,49 @@ const Q = (e, a) => {
421
421
  show: { type: Boolean, default: !0 },
422
422
  events: { type: Array }
423
423
  },
424
- setup: (e, { slots: a, expose: n }) => {
425
- const { mapRef: r } = m(), t = new window.AMap.LayerGroup();
424
+ setup: (e, { slots: t, expose: n }) => {
425
+ const { mapRef: r } = C(), a = new window.AMap.LayerGroup();
426
426
  let o = !1;
427
427
  const u = () => {
428
- o || (t.setMap(r.value), o = !0);
428
+ o || (a.setMap(r.value), o = !0);
429
429
  }, s = () => {
430
430
  try {
431
- t.setMap(null);
432
- } catch (l) {
433
- console.error(l);
431
+ a.setMap(null);
432
+ } catch (M) {
433
+ console.error(M);
434
434
  }
435
435
  o = !1;
436
- }, p = () => t;
437
- i(() => () => {
436
+ }, l = () => a;
437
+ d(() => () => {
438
438
  s();
439
- }, []), i(() => {
440
- if (!z(e.bindTime))
439
+ }, []), d(() => {
440
+ if (!_(e.bindTime))
441
441
  return;
442
- const l = setTimeout(() => {
442
+ const M = setTimeout(() => {
443
443
  u();
444
444
  }, e.bindTime);
445
445
  return () => {
446
- l && clearTimeout(l);
446
+ M && clearTimeout(M);
447
447
  };
448
448
  }, []);
449
- const d = q(() => {
449
+ const c = G(() => {
450
450
  u();
451
451
  }, 300);
452
452
  R(
453
453
  () => {
454
- e.bind && d();
454
+ e.bind && c();
455
455
  },
456
456
  () => e.bind
457
457
  );
458
- const M = C(e, "show");
459
- P(t, M);
460
- const L = C(e, "opts$");
461
- return E(t, L), n({ getFeature: p, addToMap: u, removeFormMap: s }), j({ mapRef: r, layerGroup: t }), () => {
462
- var l;
463
- return (l = a.default) == null ? void 0 : l.call(a);
458
+ const p = h(e, "show");
459
+ k(a, p);
460
+ const y = h(e, "opts$");
461
+ return E(a, y), n({ getFeature: l, addToMap: u, removeFormMap: s }), I({ mapRef: r, layerGroup: a }), () => {
462
+ var M;
463
+ return (M = t.default) == null ? void 0 : M.call(t);
464
464
  };
465
465
  }
466
- }), Ve = v({
466
+ }), et = A({
467
467
  props: {
468
468
  opts: { type: Object },
469
469
  itemOpts: { type: Object },
@@ -471,21 +471,21 @@ const Q = (e, a) => {
471
471
  show: { type: Boolean, default: !0 },
472
472
  events: { type: Array }
473
473
  },
474
- setup: (e, { expose: a }) => {
475
- const { mapRef: n } = m(), r = new window.AMap.LabelsLayer(e.opts), t = () => ce(e.data, (s) => {
476
- const p = new window.AMap.LabelMarker({
474
+ setup: (e, { expose: t }) => {
475
+ const { mapRef: n } = C(), r = new window.AMap.LabelsLayer(e.opts), a = () => Q(e.data, (s) => {
476
+ const l = new window.AMap.LabelMarker({
477
477
  ...e.itemOpts,
478
478
  ...s
479
479
  });
480
- return e.events && B(e.events, (d) => {
481
- p.on(d.type, d.handler, void 0, d.once);
482
- }), p;
480
+ return e.events && P(e.events, (c) => {
481
+ l.on(c.type, c.handler, void 0, c.once);
482
+ }), l;
483
483
  }), o = () => {
484
484
  r.clear();
485
- const s = t();
485
+ const s = a();
486
486
  r.add(s);
487
487
  };
488
- i(() => (V(e.data) > 0 && o(), n.value.add(r), () => {
488
+ d(() => (K(e.data) > 0 && o(), n.value.add(r), () => {
489
489
  r.clear(), n.value.remove(r);
490
490
  }), []), R(
491
491
  () => {
@@ -493,70 +493,70 @@ const Q = (e, a) => {
493
493
  },
494
494
  () => e.data
495
495
  );
496
- const u = C(e, "show");
497
- return P(r, u), a({ getFeature: () => r }), () => null;
496
+ const u = h(e, "show");
497
+ return k(r, u), t({ getFeature: () => r }), () => null;
498
498
  }
499
- }), ze = c("TileLayer", { useMapConnect: f }), qe = c("TileLayer.Satellite", {
500
- useMapConnect: f,
499
+ }), tt = i("TileLayer", { useMapConnect: m }), at = i("TileLayer.Satellite", {
500
+ useMapConnect: m,
501
501
  createFeatureObj: (e) => new window.AMap.TileLayer.Satellite(e)
502
- }), Ke = c("TileLayer.RoadNet", {
503
- useMapConnect: f,
502
+ }), rt = i("TileLayer.RoadNet", {
503
+ useMapConnect: m,
504
504
  createFeatureObj: (e) => new window.AMap.TileLayer.RoadNet(e)
505
- }), Qe = c("TileLayer.Traffic", {
506
- useMapConnect: f,
505
+ }), nt = i("TileLayer.Traffic", {
506
+ useMapConnect: m,
507
507
  createFeatureObj: (e) => new window.AMap.TileLayer.Traffic(e)
508
- }), Ue = c("Buildings", { useMapConnect: f }), Xe = c("MassMarks", {
509
- useMapConnect: Y,
510
- createFeatureObj: (e) => new window.AMap.MassMarks((e == null ? void 0 : e.data) || [], K(e, "data"))
511
- }), Ye = c("TileLayer.Flexible", {
512
- useMapConnect: f,
508
+ }), ot = i("Buildings", { useMapConnect: m }), ct = i("MassMarks", {
509
+ useMapConnect: te,
510
+ createFeatureObj: (e) => new window.AMap.MassMarks((e == null ? void 0 : e.data) || [], U(e, "data"))
511
+ }), st = i("TileLayer.Flexible", {
512
+ useMapConnect: m,
513
513
  createFeatureObj: (e) => new window.AMap.TileLayer.Flexible(e)
514
- }), Ze = c("ImageLayer", { useMapConnect: f }), ea = c("VideoLayer", { useMapConnect: f }), aa = c("CanvasLayer", { useMapConnect: f }), ta = c("CustomLayer", {
515
- useMapConnect: f,
516
- createFeatureObj: (e) => new window.AMap.CustomLayer(e == null ? void 0 : e.canvas, K(e, "canvas"))
517
- }), ra = c("DistrictLayer.World", {
518
- useMapConnect: f,
514
+ }), ut = i("ImageLayer", { useMapConnect: m }), lt = i("VideoLayer", { useMapConnect: m }), it = i("CanvasLayer", { useMapConnect: m }), pt = i("CustomLayer", {
515
+ useMapConnect: m,
516
+ createFeatureObj: (e) => new window.AMap.CustomLayer(e == null ? void 0 : e.canvas, U(e, "canvas"))
517
+ }), dt = i("DistrictLayer.World", {
518
+ useMapConnect: m,
519
519
  createFeatureObj: (e) => new window.AMap.DistrictLayer.World(e)
520
- }), na = c("DistrictLayer.Country", {
521
- useMapConnect: f,
520
+ }), Mt = i("DistrictLayer.Country", {
521
+ useMapConnect: m,
522
522
  createFeatureObj: (e) => new window.AMap.DistrictLayer.Country(e)
523
- }), oa = c("DistrictLayer.Province", {
524
- useMapConnect: f,
523
+ }), yt = i("DistrictLayer.Province", {
524
+ useMapConnect: m,
525
525
  createFeatureObj: (e) => new window.AMap.DistrictLayer.Province(e)
526
- }), we = c("HeatMap", {
527
- useMapConnect: Y,
526
+ }), Oe = i("HeatMap", {
527
+ useMapConnect: te,
528
528
  createFeatureObj: (e) => new window.AMap.HeatMap(null, e)
529
- }), ca = S([g.HeatMap], we), sa = (e, a) => {
529
+ }), ft = L([S.HeatMap], Oe), ae = (e, t) => {
530
530
  let n = !1, r = null;
531
- const t = x(), [o, u] = ne(), s = T(se(a.initEmit) ? a.initEmit : !1), p = ue(e, "_"), d = p[0], M = p[1], L = () => {
532
- const y = ie(window, d);
533
- return y ? new y({ ...a.opts, ...r == null ? void 0 : r.opts }) : null;
534
- }, l = (y) => y || (h(a.params) ? a.params() : a.params || []), I = () => {
531
+ const a = q(), [o, u] = pe(), s = g(Me(t.initEmit) ? t.initEmit : !1), l = ye(e, "_"), c = l[0], p = l[1], y = () => {
532
+ const f = fe(window, c);
533
+ return f ? new f({ ...t.opts, ...r == null ? void 0 : r.opts }) : null;
534
+ }, M = (f) => f || (w(t.params) ? t.params() : t.params || []), H = () => {
535
535
  if (!r)
536
536
  return;
537
- const y = L();
538
- if (t.value = y, !y || !h(y[M]))
537
+ const f = y();
538
+ if (a.value = f, !f || !w(f[p]))
539
539
  return;
540
- const D = l(r.params);
541
- return s.value = !0, y[M](...D, (O, b) => {
542
- var H, N, W, $;
543
- u(b), (H = a.onComplete) == null || H.call(a, O, b), O === "complete" ? (N = a.onSuccess) == null || N.call(a, b) : O === "error" ? (W = a.onFail) == null || W.call(a, b) : O === "no_data" && (($ = a.onNoData) == null || $.call(a, b)), r = null, s.value = !1;
544
- }), y;
540
+ const j = M(r.params);
541
+ return s.value = !0, f[p](...j, (F, b) => {
542
+ var W, $, x, V;
543
+ u(b), (W = t.onComplete) == null || W.call(t, F, b), F === "complete" ? ($ = t.onSuccess) == null || $.call(t, b) : F === "error" ? (x = t.onFail) == null || x.call(t, b) : F === "no_data" && ((V = t.onNoData) == null || V.call(t, b)), r = null, s.value = !1;
544
+ }), f;
545
545
  };
546
- X([d], () => {
547
- n = !0, I();
546
+ ee([c], () => {
547
+ n = !0, H();
548
548
  });
549
- const k = (y, D) => {
550
- if (r = { opts: y || a.opts, params: l(D) }, !!n)
551
- return I();
549
+ const D = (f, j) => {
550
+ if (r = { opts: f || t.opts, params: M(j) }, !!n)
551
+ return H();
552
552
  };
553
- return i(() => {
554
- a.initEmit && k();
555
- }, []), R(() => k(), a.deps || []), { data: o, request: k, requesting: s, targetRef: t };
556
- }, ua = {
553
+ return d(() => {
554
+ t.initEmit && D();
555
+ }, []), R(() => D(), t.deps || []), { data: o, request: D, requesting: s, targetRef: a };
556
+ }, re = {
557
557
  Geocoder_getLocation: "AMap.Geocoder_getLocation",
558
558
  Geocoder_getAddress: "AMap.Geocoder_getAddress",
559
- Autocomplete_search: "AMap.Autocomplete_search",
559
+ AutoComplete_search: "AMap.AutoComplete_search",
560
560
  PlaceSearch_search: "AMap.PlaceSearch_search",
561
561
  PlaceSearch_searchNearBy: "AMap.PlaceSearch_searchNearBy",
562
562
  PlaceSearch_searchInBounds: "AMap.PlaceSearch_searchInBounds",
@@ -566,59 +566,203 @@ const Q = (e, a) => {
566
566
  LineSearch_searchById: "AMap.LineSearch_searchById",
567
567
  StationSearch_search: "AMap.StationSearch_search",
568
568
  StationSearch_searchById: "AMap.StationSearch_searchById"
569
- };
569
+ }, Fe = {
570
+ opts: {
571
+ type: Object,
572
+ default: () => ({
573
+ city: "\u5168\u56FD"
574
+ })
575
+ },
576
+ debounceTime: {
577
+ type: Number,
578
+ default: 500
579
+ },
580
+ convertResult: {
581
+ type: Function,
582
+ default: null
583
+ },
584
+ renderComp: {
585
+ type: Function
586
+ }
587
+ }, Pe = A({
588
+ props: Fe,
589
+ emits: ["select"],
590
+ setup: (e, {
591
+ emit: t,
592
+ slots: n
593
+ }) => {
594
+ const r = g("");
595
+ let a;
596
+ const {
597
+ request: o
598
+ } = ae(re.AutoComplete_search, {
599
+ onSuccess: (l) => {
600
+ const c = me((l == null ? void 0 : l.tips) || [], (y) => y.location && _(y.location.lng) && _(y.location.lat)), p = e.convertResult ? e.convertResult(c) : Q(c, (y) => ({
601
+ ...y,
602
+ value: y.name
603
+ }));
604
+ a == null || a(p);
605
+ }
606
+ }), u = G((l, c) => {
607
+ a = c;
608
+ const p = (l || "").trim();
609
+ if (!p) {
610
+ c([]);
611
+ return;
612
+ }
613
+ o({
614
+ ...e.opts
615
+ }, [p]);
616
+ }, e.debounceTime), s = (l) => {
617
+ t("select", l);
618
+ };
619
+ return () => {
620
+ var l;
621
+ return e.renderComp ? e.renderComp({
622
+ query: u,
623
+ onSelect: s,
624
+ valueRef: r
625
+ }) : (l = n.default) == null ? void 0 : l.call(n, {
626
+ query: u,
627
+ onSelect: s,
628
+ valueRef: r
629
+ });
630
+ };
631
+ }
632
+ }), _e = {
633
+ enableAuto: {
634
+ type: Boolean,
635
+ default: !0
636
+ },
637
+ autoProps: {
638
+ type: Object,
639
+ default: () => ({})
640
+ },
641
+ geoOpts: {
642
+ type: Object,
643
+ default: () => ({})
644
+ },
645
+ modelValue: {
646
+ type: [Array, String, Object],
647
+ default: null
648
+ }
649
+ }, mt = A({
650
+ props: _e,
651
+ emits: ["update:modelValue", "address", "click", "select"],
652
+ setup(e, {
653
+ emit: t,
654
+ expose: n
655
+ }) {
656
+ const {
657
+ mapRef: r
658
+ } = C(), a = ce(() => e.modelValue);
659
+ d(() => {
660
+ !a.value || r.value.setCenter(a.value);
661
+ }, a);
662
+ const {
663
+ request: o
664
+ } = ae(re.Geocoder_getAddress, {
665
+ onSuccess: (c) => {
666
+ t("address", c);
667
+ }
668
+ });
669
+ n({
670
+ geoReqCurrent: () => {
671
+ ue(() => {
672
+ !a.value || o({
673
+ ...e.geoOpts
674
+ }, [a.value]);
675
+ });
676
+ },
677
+ geoReq: o
678
+ });
679
+ const s = (c) => {
680
+ if (!c || !c.location)
681
+ return;
682
+ const {
683
+ lng: p,
684
+ lat: y
685
+ } = c.location;
686
+ t("update:modelValue", [p, y]), t("select", c);
687
+ }, l = [
688
+ {
689
+ type: "click",
690
+ handler: (c) => {
691
+ if (!c || !c.lnglat)
692
+ return;
693
+ const {
694
+ lng: p,
695
+ lat: y
696
+ } = c.lnglat;
697
+ t("update:modelValue", [p, y]), t("click", c);
698
+ }
699
+ }
700
+ ];
701
+ return () => v(se, null, [v(Z, {
702
+ events: l
703
+ }, null), a.value && v(we, {
704
+ opts$: {
705
+ position: a.value
706
+ }
707
+ }, null), e.enableAuto && v(Pe, z(e.autoProps, {
708
+ onSelect: s
709
+ }), null)]);
710
+ }
711
+ });
570
712
  export {
571
- ua as ApiNames,
572
- Ie as BezierCurve,
573
- Ue as Buildings,
574
- aa as CanvasLayer,
575
- De as Circle,
576
- Oe as CircleMarker,
577
- xe as ControlBar,
578
- ta as CustomLayer,
579
- na as DistrictLayerCountry,
580
- oa as DistrictLayerProvince,
581
- ra as DistrictLayerWorld,
582
- _e as ElasticMarker,
583
- Ge as Ellipse,
584
- We as HawkEye,
585
- ca as HeatMap,
586
- Ze as ImageLayer,
587
- Fe as InfoWindow,
588
- Ve as LabelsLayer,
589
- Je as LayerGroup,
590
- be as Map,
591
- de as MapEvents,
592
- Me as MapPlugin,
593
- g as MapPluginType,
594
- $e as MapType,
595
- Pe as Marker,
596
- Xe as MassMarks,
597
- Re as OverlayGroup,
598
- Ee as Polygon,
599
- ke as Polyline,
600
- je as Rectangle,
601
- Ne as Scale,
602
- Be as Text,
603
- ze as TileLayer,
604
- Ye as TileLayerFlexible,
605
- Ke as TileLayerRoadNet,
606
- qe as TileLayerSatellite,
607
- Qe as TileLayerTraffic,
608
- He as ToolBar,
609
- ea as VideoLayer,
610
- c as createFeature,
611
- S as createPluginFeature,
612
- j as provideMap,
613
- Q as useEvents,
713
+ re as ApiNames,
714
+ ze as BezierCurve,
715
+ ot as Buildings,
716
+ it as CanvasLayer,
717
+ Ve as Circle,
718
+ Ne as CircleMarker,
719
+ Ye as ControlBar,
720
+ pt as CustomLayer,
721
+ Mt as DistrictLayerCountry,
722
+ yt as DistrictLayerProvince,
723
+ dt as DistrictLayerWorld,
724
+ We as ElasticMarker,
725
+ Je as Ellipse,
726
+ Ue as HawkEye,
727
+ ft as HeatMap,
728
+ ut as ImageLayer,
729
+ Ie as InfoWindow,
730
+ et as LabelsLayer,
731
+ Ze as LayerGroup,
732
+ je as Map,
733
+ Pe as MapAutoComplete,
734
+ Z as MapEvents,
735
+ mt as MapLoc,
736
+ Ae as MapPlugin,
737
+ S as MapPluginType,
738
+ Xe as MapType,
739
+ we as Marker,
740
+ ct as MassMarks,
741
+ Ge as OverlayGroup,
742
+ $e as Polygon,
743
+ xe as Polyline,
744
+ qe as Rectangle,
745
+ Qe as Scale,
746
+ He as Text,
747
+ tt as TileLayer,
748
+ st as TileLayerFlexible,
749
+ rt as TileLayerRoadNet,
750
+ at as TileLayerSatellite,
751
+ nt as TileLayerTraffic,
752
+ Ke as ToolBar,
753
+ lt as VideoLayer,
754
+ i as createFeature,
755
+ L as createPluginFeature,
756
+ I as provideMap,
757
+ X as useEvents,
614
758
  E as useFeatureOptMethods,
615
- m as useMap,
616
- sa as useMapApi,
617
- G as useMapConnect,
618
- Y as useMapConnect2,
619
- F as useMapControlConnect,
620
- f as useMapLayerConnect,
621
- w as useMapOverlayConnect,
622
- X as useMapPlugin,
623
- P as useShowConnect
759
+ C as useMap,
760
+ ae as useMapApi,
761
+ N as useMapConnect,
762
+ te as useMapConnect2,
763
+ O as useMapControlConnect,
764
+ m as useMapLayerConnect,
765
+ T as useMapOverlayConnect,
766
+ ee as useMapPlugin,
767
+ k as useShowConnect
624
768
  };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("vue"),x=require("@amap/amap-jsapi-loader"),l=require("@vue-start/hooks"),u=require("lodash"),$=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},J=$(x),_=(e,a)=>{l.useEffect(()=>(u.forEach(a,n=>{e.on(n.type,n.handler,void 0,n.once)}),()=>{u.forEach(a,n=>{e.off(n.type,n.handler)})}),[])},I=Symbol("amap-key"),R=e=>c.provide(I,e),h=()=>c.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=c.defineComponent({props:{events:{type:Array}},setup:e=>{const{mapRef:a}=h();return _(a.value,e.events),()=>null}}),K=c.defineComponent({props:{...q()},setup:(e,{slots:a,expose:n})=>{z(e.securityJsCode);const r=c.shallowRef(),t=c.ref();return n({mapRef:r,domRef:t}),l.useEffect(()=>(J.default.load({version:"2.0",...e.loadOpts}).then(o=>{const p=new o.Map(t.value,{...e.opts});p.on("complete",()=>{r.value=p})}).catch(o=>{console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"),console.error(o)}),()=>{r.value&&r.value.destroy()}),[]),R({mapRef:r}),()=>{var o;return c.createVNode("div",{ref:t},[r.value&&c.createVNode(H,{events:e.events},null),r.value&&((o=a.default)==null?void 0:o.call(a))])}}}),B=(e,a)=>{const{mapRef:n}=h();l.useEffect(()=>{if(!n.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=c.defineComponent({props:{plugins:Array},setup:(e,{slots:a})=>{const n=c.ref(!1);return B(e.plugins,()=>{n.value=!0}),()=>{var r;return n.value?(r=a.default)==null?void 0:r.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}=h();l.useEffect(()=>(a.value.add(e),()=>{try{a.value.remove(e)}catch(n){console.error(n)}}),[])},k=e=>{const{mapRef:a}=h();l.useEffect(()=>(e.setMap(a.value),()=>{try{e.setMap(null)}catch(n){console.error(n)}}),[])},T=e=>{const{mapRef:a}=h();l.useEffect(()=>(a.value.addControl(e),()=>{try{a.value.removeControl(e)}catch(n){console.error(n)}}),[])},S=(e,a)=>{const n=()=>{e&&u.isFunction(e.show)&&e.show()},r=()=>{e&&u.isFunction(e.hide)&&e.hide()};l.useEffect(()=>{a.value||r()},[]),l.useWatch(()=>{a.value?n():r()},a)},E=(e,a)=>{const n=(r,t)=>{const o="set"+u.upperFirst(r);if(e[o]&&u.isFunction(e[o]))e[o](t);else{const p="set"+r;e[p]&&u.isFunction(e[p])&&e[p](t)}};l.useEffect((r,t)=>{u.forEach(a.value,(o,p)=>{(t==null?void 0:t[p])!==o&&n(p,o)})},a)},s=(e,{useMapConnect:a,createFeatureObj:n,needDom:r})=>c.defineComponent({props:{opts:{type:Object},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(t,{slots:o,expose:p})=>{const i=n?n(t.opts):new window.AMap[e](t.opts);a(i);const M=c.toRef(t,"show");S(i,M);const f=c.toRef(t,"opts$");E(i,f),_(i,t.events),p({getFeature:()=>i});const y=c.ref();return l.useEffect(()=>{y.value&&u.isFunction(i.setContent)&&i.setContent(y.value)},y),()=>r&&o.default?c.createVNode(c.Teleport,{to:"body"},{default:()=>[c.createVNode("div",{ref:y},[o.default()])]}):null}}),w=(e,a)=>c.defineComponent({props:{...a.props},setup:(n,{slots:r,expose:t})=>{const o=c.ref();return t(l.createExposeObj(o,["getFeature"])),()=>c.createVNode(V,{plugins:e},{default:()=>[c.createVNode(a,c.mergeProps({ref:o},n),r)]})}}),Q=()=>{const{mapRef:e,overlayGroup:a}=h();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(o){console.error(o)}}}},v=e=>{const{addToMap:a,removeFromMap:n}=Q();l.useEffect(()=>(a(e),()=>{n(e)}),[])},U=c.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:n})=>{const{mapRef:r}=h(),t=new window.AMap.OverlayGroup;let o=!1;const p=()=>{o||(r.value.add(t),o=!0)},i=()=>{try{r.value.remove(t)}catch(d){console.error(d)}o=!1},M=()=>t;l.useEffect(()=>()=>{i()},[]),l.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);l.useWatch(()=>{e.bind&&f()},()=>e.bind);const y=c.toRef(e,"show");S(t,y);const g=c.toRef(e,"opts$");return E(t,g),n({getFeature:M,addToMap:p,removeFormMap:i}),R({mapRef:r,overlayGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),X=c.defineComponent({props:{opts:{type:Object},opts$:{type:Object},height:{type:Number,default:void 0}},setup:(e,{slots:a,emit:n})=>{const{mapRef:r}=h(),t=new window.AMap.InfoWindow({closeWhenClickMap:!0,isCustom:!!a.default,...e.opts}),o=c.toRef(e,"opts$");E(t,o);const p=()=>{n("close")};l.useEffect(()=>(t.on("close",p),()=>{t.off("close",p),t.close()}),[]),l.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(r.value,M,e.height)},()=>{var M;return(M=e.opts$)==null?void 0:M.position});const i=c.ref();return l.useEffect(()=>{i.value&&u.isFunction(t.setContent)&&t.setContent(i.value)},i),()=>a.default?c.createVNode(c.Teleport,{to:"body"},{default:()=>[c.createVNode("div",{ref:i},[a.default()])]}):null}}),Y=s("CircleMarker",{useMapConnect:F}),Z=s("Text",{useMapConnect:F}),ee=s("ElasticMarker",{useMapConnect:F}),ae=s("Marker",{useMapConnect:v,needDom:!0}),te=s("Polygon",{useMapConnect:v}),re=s("Polyline",{useMapConnect:v}),ne=s("Circle",{useMapConnect:v}),oe=s("Rectangle",{useMapConnect:v}),ce=s("Ellipse",{useMapConnect:v}),se=s("BezierCurve",{useMapConnect:v}),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),he=()=>{const{mapRef:e,layerGroup:a}=h();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(o){console.error(o)}}}},C=e=>{const{addToMap:a,removeFromMap:n}=he();l.useEffect(()=>(a(e),()=>{n(e)}),[])},ve=c.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:n})=>{const{mapRef:r}=h(),t=new window.AMap.LayerGroup;let o=!1;const p=()=>{o||(t.setMap(r.value),o=!0)},i=()=>{try{t.setMap(null)}catch(d){console.error(d)}o=!1},M=()=>t;l.useEffect(()=>()=>{i()},[]),l.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);l.useWatch(()=>{e.bind&&f()},()=>e.bind);const y=c.toRef(e,"show");S(t,y);const g=c.toRef(e,"opts$");return E(t,g),n({getFeature:M,addToMap:p,removeFormMap:i}),R({mapRef:r,layerGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),Ae=c.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:n}=h(),r=new window.AMap.LabelsLayer(e.opts),t=()=>u.map(e.data,i=>{const M=new window.AMap.LabelMarker({...e.itemOpts,...i});return e.events&&u.forEach(e.events,f=>{M.on(f.type,f.handler,void 0,f.once)}),M}),o=()=>{r.clear();const i=t();r.add(i)};l.useEffect(()=>(u.size(e.data)>0&&o(),n.value.add(r),()=>{r.clear(),n.value.remove(r)}),[]),l.useWatch(()=>{o()},()=>e.data);const p=c.toRef(e,"show");return S(r,p),a({getFeature:()=>r}),()=>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:k,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"))}),_e=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)}),ke=s("DistrictLayer.Province",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.Province(e)}),De=s("HeatMap",{useMapConnect:k,createFeatureObj:e=>new window.AMap.HeatMap(null,e)}),je=w([A.HeatMap],De),Ne=(e,a)=>{let n=!1,r=null;const t=c.shallowRef(),[o,p]=l.useState(),i=c.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,...r==null?void 0:r.opts}):null},d=m=>m||(u.isFunction(a.params)?a.params():a.params||[]),D=()=>{if(!r)return;const m=g();if(t.value=m,!m||!u.isFunction(m[y]))return;const P=d(r.params);return i.value=!0,m[y](...P,(b,L)=>{var j,N,G,W;p(L),(j=a.onComplete)==null||j.call(a,b,L),b==="complete"?(N=a.onSuccess)==null||N.call(a,L):b==="error"?(G=a.onFail)==null||G.call(a,L):b==="no_data"&&((W=a.onNoData)==null||W.call(a,L)),r=null,i.value=!1}),m};B([f],()=>{n=!0,D()});const O=(m,P)=>{if(r={opts:m||a.opts,params:d(P)},!!n)return D()};return l.useEffect(()=>{a.initEmit&&O()},[]),l.useWatch(()=>O(),a.deps||[]),{data:o,request:O,requesting:i,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=ke;exports.DistrictLayerWorld=_e;exports.ElasticMarker=ee;exports.Ellipse=ce;exports.HawkEye=Me;exports.HeatMap=je;exports.ImageLayer=Re;exports.InfoWindow=X;exports.LabelsLayer=Ae;exports.LayerGroup=ve;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=_;exports.useFeatureOptMethods=E;exports.useMap=h;exports.useMapApi=Ne;exports.useMapConnect=F;exports.useMapConnect2=k;exports.useMapControlConnect=T;exports.useMapLayerConnect=C;exports.useMapOverlayConnect=v;exports.useMapPlugin=B;exports.useShowConnect=S;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),z=require("@amap/amap-jsapi-loader"),f=require("@vue-start/hooks"),s=require("lodash"),K=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},Q=K(z),_=(e,t)=>{f.useEffect(()=>(s.forEach(t,n=>{e.on(n.type,n.handler,void 0,n.once)}),()=>{s.forEach(t,n=>{e.off(n.type,n.handler)})}),[])},q=Symbol("amap-key"),E=e=>o.provide(q,e),h=()=>o.inject(q),U=()=>({securityJsCode:{type:String},loadOpts:{type:Object},opts:{type:Object},events:{type:Array}}),X=e=>{var t;if(!!e){if(!window._AMapSecurityConfig||!((t=window._AMapSecurityConfig)!=null&&t.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"))}},k=o.defineComponent({props:{events:{type:Array}},setup:e=>{const{mapRef:t}=h();return _(t.value,e.events),()=>null}}),Y=o.defineComponent({props:{...U()},setup:(e,{slots:t,expose:n})=>{X(e.securityJsCode);const r=o.shallowRef(),a=o.ref();return n({mapRef:r,domRef:a}),f.useEffect(()=>(Q.default.load({version:"2.0",...e.loadOpts}).then(c=>{const p=new c.Map(a.value,{...e.opts});p.on("complete",()=>{r.value=p})}).catch(c=>{console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"),console.error(c)}),()=>{r.value&&r.value.destroy()}),[]),E({mapRef:r}),()=>{var c;return o.createVNode("div",{ref:a},[r.value&&o.createVNode(k,{events:e.events},null),r.value&&((c=t.default)==null?void 0:c.call(t))])}}}),B=(e,t)=>{const{mapRef:n}=h();f.useEffect(()=>{if(!n.value){console.warn("\u8BF7\u5728Map\u7EC4\u4EF6\u5185\u4F7F\u7528 useMapPlugin");return}if(!e||s.size(e)<=0){t();return}window.AMap.plugin(e,t)},[])},x=o.defineComponent({props:{plugins:Array},setup:(e,{slots:t})=>{const n=o.ref(!1);return B(e.plugins,()=>{n.value=!0}),()=>{var r;return n.value?(r=t.default)==null?void 0:r.call(t):null}}}),w={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:t}=h();f.useEffect(()=>(t.value.add(e),()=>{try{t.value.remove(e)}catch(n){console.error(n)}}),[])},D=e=>{const{mapRef:t}=h();f.useEffect(()=>(e.setMap(t.value),()=>{try{e.setMap(null)}catch(n){console.error(n)}}),[])},T=e=>{const{mapRef:t}=h();f.useEffect(()=>(t.value.addControl(e),()=>{try{t.value.removeControl(e)}catch(n){console.error(n)}}),[])},S=(e,t)=>{const n=()=>{e&&s.isFunction(e.show)&&e.show()},r=()=>{e&&s.isFunction(e.hide)&&e.hide()};f.useEffect(()=>{t.value||r()},[]),f.useWatch(()=>{t.value?n():r()},t)},b=(e,t)=>{const n=(r,a)=>{const c="set"+s.upperFirst(r);if(e[c]&&s.isFunction(e[c]))e[c](a);else{const p="set"+r;e[p]&&s.isFunction(e[p])&&e[p](a)}};f.useEffect((r,a)=>{s.forEach(t.value,(c,p)=>{(a==null?void 0:a[p])!==c&&n(p,c)})},t)},l=(e,{useMapConnect:t,createFeatureObj:n,needDom:r})=>o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(a,{slots:c,expose:p})=>{const i=n?n(a.opts):new window.AMap[e](a.opts);t(i);const d=o.toRef(a,"show");S(i,d);const u=o.toRef(a,"opts$");b(i,u),_(i,a.events),p({getFeature:()=>i});const M=o.ref();return f.useEffect(()=>{M.value&&s.isFunction(i.setContent)&&i.setContent(M.value)},M),()=>r&&c.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:M},[c.default()])]}):null}}),g=(e,t)=>o.defineComponent({props:{...t.props},setup:(n,{slots:r,expose:a})=>{const c=o.ref();return a(f.createExposeObj(c,["getFeature"])),()=>o.createVNode(x,{plugins:e},{default:()=>[o.createVNode(t,o.mergeProps({ref:c},n),r)]})}}),Z=()=>{const{mapRef:e,overlayGroup:t}=h();return{addToMap:a=>{if(t){s.isArray(a)?t.addOverlays(a):t.addOverlay(a);return}e.value.add(a)},removeFromMap:a=>{if(t){s.isArray(a)?t.removeOverlays(a):t.removeOverlay(a);return}try{e.value.remove(a)}catch(c){console.error(c)}}}},A=e=>{const{addToMap:t,removeFromMap:n}=Z();f.useEffect(()=>(t(e),()=>{n(e)}),[])},ee=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:t,expose:n})=>{const{mapRef:r}=h(),a=new window.AMap.OverlayGroup;let c=!1;const p=()=>{c||(r.value.add(a),c=!0)},i=()=>{try{r.value.remove(a)}catch(y){console.error(y)}c=!1},d=()=>a;f.useEffect(()=>()=>{i()},[]),f.useEffect(()=>{if(!s.isNumber(e.bindTime))return;const y=setTimeout(()=>{p()},e.bindTime);return()=>{y&&clearTimeout(y)}},[]);const u=s.debounce(()=>{p()},300);f.useWatch(()=>{e.bind&&u()},()=>e.bind);const M=o.toRef(e,"show");S(a,M);const m=o.toRef(e,"opts$");return b(a,m),n({getFeature:d,addToMap:p,removeFormMap:i}),E({mapRef:r,overlayGroup:a}),()=>{var y;return(y=t.default)==null?void 0:y.call(t)}}}),te=o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},height:{type:Number,default:void 0}},setup:(e,{slots:t,emit:n})=>{const{mapRef:r}=h(),a=new window.AMap.InfoWindow({closeWhenClickMap:!0,isCustom:!!t.default,...e.opts}),c=o.toRef(e,"opts$");b(a,c);const p=()=>{n("close")};f.useEffect(()=>(a.on("close",p),()=>{a.off("close",p),a.close()}),[]),f.useEffect(()=>{var u,M;const d=((u=e.opts$)==null?void 0:u.position)||((M=e.opts)==null?void 0:M.position);!d||a.open(r.value,d,e.height)},()=>{var d;return(d=e.opts$)==null?void 0:d.position});const i=o.ref();return f.useEffect(()=>{i.value&&s.isFunction(a.setContent)&&a.setContent(i.value)},i),()=>t.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:i},[t.default()])]}):null}}),ae=l("CircleMarker",{useMapConnect:F}),re=l("Text",{useMapConnect:F}),ne=l("ElasticMarker",{useMapConnect:F}),$=l("Marker",{useMapConnect:A,needDom:!0}),oe=l("Polygon",{useMapConnect:A}),ce=l("Polyline",{useMapConnect:A}),se=l("Circle",{useMapConnect:A}),ue=l("Rectangle",{useMapConnect:A}),ie=l("Ellipse",{useMapConnect:A}),le=l("BezierCurve",{useMapConnect:A}),pe=l("ToolBar",{useMapConnect:T}),de=g([w.ToolBar],pe),fe=l("Scale",{useMapConnect:T}),Me=g([w.Scale],fe),ye=l("HawkEye",{useMapConnect:T}),me=g([w.HawkEye],ye),Ce=l("MapType",{useMapConnect:T}),ve=g([w.MapType],Ce),he=l("ControlBar",{useMapConnect:T}),Ae=g([w.ControlBar],he),we=()=>{const{mapRef:e,layerGroup:t}=h();return{addToMap:a=>{if(t){s.isArray(a)?t.addLayers(a):t.addLayer(a);return}e.value.add(a)},removeFromMap:a=>{if(t){s.isArray(a)?t.removeLayers(a):t.removeLayer(a);return}try{e.value.remove(a)}catch(c){console.error(c)}}}},C=e=>{const{addToMap:t,removeFromMap:n}=we();f.useEffect(()=>(t(e),()=>{n(e)}),[])},ge=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:t,expose:n})=>{const{mapRef:r}=h(),a=new window.AMap.LayerGroup;let c=!1;const p=()=>{c||(a.setMap(r.value),c=!0)},i=()=>{try{a.setMap(null)}catch(y){console.error(y)}c=!1},d=()=>a;f.useEffect(()=>()=>{i()},[]),f.useEffect(()=>{if(!s.isNumber(e.bindTime))return;const y=setTimeout(()=>{p()},e.bindTime);return()=>{y&&clearTimeout(y)}},[]);const u=s.debounce(()=>{p()},300);f.useWatch(()=>{e.bind&&u()},()=>e.bind);const M=o.toRef(e,"show");S(a,M);const m=o.toRef(e,"opts$");return b(a,m),n({getFeature:d,addToMap:p,removeFormMap:i}),E({mapRef:r,layerGroup:a}),()=>{var y;return(y=t.default)==null?void 0:y.call(t)}}}),Te=o.defineComponent({props:{opts:{type:Object},itemOpts:{type:Object},data:{type:Array},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{expose:t})=>{const{mapRef:n}=h(),r=new window.AMap.LabelsLayer(e.opts),a=()=>s.map(e.data,i=>{const d=new window.AMap.LabelMarker({...e.itemOpts,...i});return e.events&&s.forEach(e.events,u=>{d.on(u.type,u.handler,void 0,u.once)}),d}),c=()=>{r.clear();const i=a();r.add(i)};f.useEffect(()=>(s.size(e.data)>0&&c(),n.value.add(r),()=>{r.clear(),n.value.remove(r)}),[]),f.useWatch(()=>{c()},()=>e.data);const p=o.toRef(e,"show");return S(r,p),t({getFeature:()=>r}),()=>null}}),Le=l("TileLayer",{useMapConnect:C}),Se=l("TileLayer.Satellite",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.Satellite(e)}),be=l("TileLayer.RoadNet",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.RoadNet(e)}),Re=l("TileLayer.Traffic",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.Traffic(e)}),Ee=l("Buildings",{useMapConnect:C}),Fe=l("MassMarks",{useMapConnect:D,createFeatureObj:e=>new window.AMap.MassMarks((e==null?void 0:e.data)||[],s.omit(e,"data"))}),Oe=l("TileLayer.Flexible",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.Flexible(e)}),Pe=l("ImageLayer",{useMapConnect:C}),_e=l("VideoLayer",{useMapConnect:C}),ke=l("CanvasLayer",{useMapConnect:C}),Be=l("CustomLayer",{useMapConnect:C,createFeatureObj:e=>new window.AMap.CustomLayer(e==null?void 0:e.canvas,s.omit(e,"canvas"))}),De=l("DistrictLayer.World",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.World(e)}),Ne=l("DistrictLayer.Country",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.Country(e)}),je=l("DistrictLayer.Province",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.Province(e)}),Ve=l("HeatMap",{useMapConnect:D,createFeatureObj:e=>new window.AMap.HeatMap(null,e)}),Ge=g([w.HeatMap],Ve),N=(e,t)=>{let n=!1,r=null;const a=o.shallowRef(),[c,p]=f.useState(),i=o.ref(s.isBoolean(t.initEmit)?t.initEmit:!1),d=s.split(e,"_"),u=d[0],M=d[1],m=()=>{const v=s.get(window,u);return v?new v({...t.opts,...r==null?void 0:r.opts}):null},y=v=>v||(s.isFunction(t.params)?t.params():t.params||[]),V=()=>{if(!r)return;const v=m();if(a.value=v,!v||!s.isFunction(v[M]))return;const P=y(r.params);return i.value=!0,v[M](...P,(R,L)=>{var G,W,I,H;p(L),(G=t.onComplete)==null||G.call(t,R,L),R==="complete"?(W=t.onSuccess)==null||W.call(t,L):R==="error"?(I=t.onFail)==null||I.call(t,L):R==="no_data"&&((H=t.onNoData)==null||H.call(t,L)),r=null,i.value=!1}),v};B([u],()=>{n=!0,V()});const O=(v,P)=>{if(r={opts:v||t.opts,params:y(P)},!!n)return V()};return f.useEffect(()=>{t.initEmit&&O()},[]),f.useWatch(()=>O(),t.deps||[]),{data:c,request:O,requesting:i,targetRef:a}},j={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"},We={opts:{type:Object,default:()=>({city:"\u5168\u56FD"})},debounceTime:{type:Number,default:500},convertResult:{type:Function,default:null},renderComp:{type:Function}},J=o.defineComponent({props:We,emits:["select"],setup:(e,{emit:t,slots:n})=>{const r=o.ref("");let a;const{request:c}=N(j.AutoComplete_search,{onSuccess:d=>{const u=s.filter((d==null?void 0:d.tips)||[],m=>m.location&&s.isNumber(m.location.lng)&&s.isNumber(m.location.lat)),M=e.convertResult?e.convertResult(u):s.map(u,m=>({...m,value:m.name}));a==null||a(M)}}),p=s.debounce((d,u)=>{a=u;const M=(d||"").trim();if(!M){u([]);return}c({...e.opts},[M])},e.debounceTime),i=d=>{t("select",d)};return()=>{var d;return e.renderComp?e.renderComp({query:p,onSelect:i,valueRef:r}):(d=n.default)==null?void 0:d.call(n,{query:p,onSelect:i,valueRef:r})}}}),Ie={enableAuto:{type:Boolean,default:!0},autoProps:{type:Object,default:()=>({})},geoOpts:{type:Object,default:()=>({})},modelValue:{type:[Array,String,Object],default:null}},He=o.defineComponent({props:Ie,emits:["update:modelValue","address","click","select"],setup(e,{emit:t,expose:n}){const{mapRef:r}=h(),a=o.computed(()=>e.modelValue);f.useEffect(()=>{!a.value||r.value.setCenter(a.value)},a);const{request:c}=N(j.Geocoder_getAddress,{onSuccess:u=>{t("address",u)}});n({geoReqCurrent:()=>{o.nextTick(()=>{!a.value||c({...e.geoOpts},[a.value])})},geoReq:c});const i=u=>{if(!u||!u.location)return;const{lng:M,lat:m}=u.location;t("update:modelValue",[M,m]),t("select",u)},d=[{type:"click",handler:u=>{if(!u||!u.lnglat)return;const{lng:M,lat:m}=u.lnglat;t("update:modelValue",[M,m]),t("click",u)}}];return()=>o.createVNode(o.Fragment,null,[o.createVNode(k,{events:d},null),a.value&&o.createVNode($,{opts$:{position:a.value}},null),e.enableAuto&&o.createVNode(J,o.mergeProps(e.autoProps,{onSelect:i}),null)])}});exports.ApiNames=j;exports.BezierCurve=le;exports.Buildings=Ee;exports.CanvasLayer=ke;exports.Circle=se;exports.CircleMarker=ae;exports.ControlBar=Ae;exports.CustomLayer=Be;exports.DistrictLayerCountry=Ne;exports.DistrictLayerProvince=je;exports.DistrictLayerWorld=De;exports.ElasticMarker=ne;exports.Ellipse=ie;exports.HawkEye=me;exports.HeatMap=Ge;exports.ImageLayer=Pe;exports.InfoWindow=te;exports.LabelsLayer=Te;exports.LayerGroup=ge;exports.Map=Y;exports.MapAutoComplete=J;exports.MapEvents=k;exports.MapLoc=He;exports.MapPlugin=x;exports.MapPluginType=w;exports.MapType=ve;exports.Marker=$;exports.MassMarks=Fe;exports.OverlayGroup=ee;exports.Polygon=oe;exports.Polyline=ce;exports.Rectangle=ue;exports.Scale=Me;exports.Text=re;exports.TileLayer=Le;exports.TileLayerFlexible=Oe;exports.TileLayerRoadNet=be;exports.TileLayerSatellite=Se;exports.TileLayerTraffic=Re;exports.ToolBar=de;exports.VideoLayer=_e;exports.createFeature=l;exports.createPluginFeature=g;exports.provideMap=E;exports.useEvents=_;exports.useFeatureOptMethods=b;exports.useMap=h;exports.useMapApi=N;exports.useMapConnect=F;exports.useMapConnect2=D;exports.useMapControlConnect=T;exports.useMapLayerConnect=C;exports.useMapOverlayConnect=A;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.8",
3
+ "version": "0.0.9",
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": "dd1b977211bd0db823224570b4a48892aab7c9c1"
33
+ "gitHead": "7b4fc39364352dd4c06d92e1543abf6b028fcf39"
34
34
  }