@vue-start/map 0.0.7 → 0.0.8

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/dist/index.es.js CHANGED
@@ -1,13 +1,13 @@
1
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
2
  import te from "@amap/amap-jsapi-loader";
3
- import { useEffect as u, useWatch as R, createExposeObj as re, useState as ne } from "@vue-start/hooks";
4
- import { forEach as B, size as z, upperFirst as oe, isFunction as h, isNumber as V, debounce as q, isArray as _, map as ce, omit as K, isBoolean as se, split as ue, get as ie } from "lodash";
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
5
  const Q = (e, a) => {
6
- u(() => (B(a, (r) => {
7
- e.on(r.type, r.handler, void 0, r.once);
6
+ i(() => (B(a, (n) => {
7
+ e.on(n.type, n.handler, void 0, n.once);
8
8
  }), () => {
9
- B(a, (r) => {
10
- e.off(r.type, r.handler);
9
+ B(a, (n) => {
10
+ e.off(n.type, n.handler);
11
11
  });
12
12
  }), []);
13
13
  }, U = Symbol("amap-key"), j = (e) => Z(U, e), m = () => ee(U), le = () => ({
@@ -54,46 +54,46 @@ const Q = (e, a) => {
54
54
  },
55
55
  setup: (e, {
56
56
  slots: a,
57
- expose: r
57
+ expose: n
58
58
  }) => {
59
59
  pe(e.securityJsCode);
60
- const n = x(), t = T();
61
- return r({
62
- mapRef: n,
60
+ const r = x(), t = T();
61
+ return n({
62
+ mapRef: r,
63
63
  domRef: t
64
- }), u(() => (te.load({
64
+ }), i(() => (te.load({
65
65
  version: "2.0",
66
66
  ...e.loadOpts
67
67
  }).then((o) => {
68
- const i = new o.Map(t.value, {
68
+ const u = new o.Map(t.value, {
69
69
  ...e.opts
70
70
  });
71
- i.on("complete", () => {
72
- n.value = i;
71
+ u.on("complete", () => {
72
+ r.value = u;
73
73
  });
74
74
  }).catch((o) => {
75
75
  console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"), console.error(o);
76
76
  }), () => {
77
- n.value && n.value.destroy();
77
+ r.value && r.value.destroy();
78
78
  }), []), j({
79
- mapRef: n
79
+ mapRef: r
80
80
  }), () => {
81
81
  var o;
82
82
  return A("div", {
83
83
  ref: t
84
- }, [n.value && A(de, {
84
+ }, [r.value && A(de, {
85
85
  events: e.events
86
- }, null), n.value && ((o = a.default) == null ? void 0 : o.call(a))]);
86
+ }, null), r.value && ((o = a.default) == null ? void 0 : o.call(a))]);
87
87
  };
88
88
  }
89
89
  }), X = (e, a) => {
90
- const { mapRef: r } = m();
91
- u(() => {
92
- if (!r.value) {
90
+ const { mapRef: n } = m();
91
+ i(() => {
92
+ if (!n.value) {
93
93
  console.warn("\u8BF7\u5728Map\u7EC4\u4EF6\u5185\u4F7F\u7528 useMapPlugin");
94
94
  return;
95
95
  }
96
- if (!e || z(e) <= 0) {
96
+ if (!e || V(e) <= 0) {
97
97
  a();
98
98
  return;
99
99
  }
@@ -104,12 +104,12 @@ const Q = (e, a) => {
104
104
  plugins: Array
105
105
  },
106
106
  setup: (e, { slots: a }) => {
107
- const r = T(!1);
107
+ const n = T(!1);
108
108
  return X(e.plugins, () => {
109
- r.value = !0;
109
+ n.value = !0;
110
110
  }), () => {
111
- var n;
112
- return r.value ? (n = a.default) == null ? void 0 : n.call(a) : null;
111
+ var r;
112
+ return n.value ? (r = a.default) == null ? void 0 : r.call(a) : null;
113
113
  };
114
114
  }
115
115
  }), g = {
@@ -151,57 +151,65 @@ const Q = (e, a) => {
151
151
  const {
152
152
  mapRef: a
153
153
  } = m();
154
- u(() => (a.value.add(e), () => {
154
+ i(() => (a.value.add(e), () => {
155
155
  try {
156
156
  a.value.remove(e);
157
- } catch (r) {
158
- console.error(r);
157
+ } catch (n) {
158
+ console.error(n);
159
159
  }
160
160
  }), []);
161
161
  }, Y = (e) => {
162
162
  const {
163
163
  mapRef: a
164
164
  } = m();
165
- u(() => (e.setMap(a.value), () => {
165
+ i(() => (e.setMap(a.value), () => {
166
166
  try {
167
167
  e.setMap(null);
168
- } catch (r) {
169
- console.error(r);
168
+ } catch (n) {
169
+ console.error(n);
170
170
  }
171
171
  }), []);
172
172
  }, F = (e) => {
173
173
  const {
174
174
  mapRef: a
175
175
  } = m();
176
- u(() => (a.value.addControl(e), () => {
176
+ i(() => (a.value.addControl(e), () => {
177
177
  try {
178
178
  a.value.removeControl(e);
179
- } catch (r) {
180
- console.error(r);
179
+ } catch (n) {
180
+ console.error(n);
181
181
  }
182
182
  }), []);
183
183
  }, P = (e, a) => {
184
- const r = () => {
184
+ const n = () => {
185
185
  e && h(e.show) && e.show();
186
- }, n = () => {
186
+ }, r = () => {
187
187
  e && h(e.hide) && e.hide();
188
188
  };
189
- u(() => {
190
- a.value || n();
189
+ i(() => {
190
+ a.value || r();
191
191
  }, []), R(() => {
192
- a.value ? r() : n();
192
+ a.value ? n() : r();
193
193
  }, a);
194
- }, k = (e, a) => {
195
- u(() => {
196
- B(a.value, (r, n) => {
197
- const t = "set" + oe(n);
198
- e[t] && h(e[t]) && e[t](r);
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);
199
+ else {
200
+ const u = "set" + r;
201
+ e[u] && h(e[u]) && e[u](t);
202
+ }
203
+ };
204
+ i((r, t) => {
205
+ B(a.value, (o, u) => {
206
+ (t == null ? void 0 : t[u]) !== o && n(u, o);
199
207
  });
200
208
  }, a);
201
209
  }, c = (e, {
202
210
  useMapConnect: a,
203
- createFeatureObj: r,
204
- needDom: n
211
+ createFeatureObj: n,
212
+ needDom: r
205
213
  }) => v({
206
214
  props: {
207
215
  opts: {
@@ -220,20 +228,20 @@ const Q = (e, a) => {
220
228
  },
221
229
  setup: (t, {
222
230
  slots: o,
223
- expose: i
231
+ expose: u
224
232
  }) => {
225
- const s = r ? r(t.opts) : new window.AMap[e](t.opts);
233
+ const s = n ? n(t.opts) : new window.AMap[e](t.opts);
226
234
  a(s);
227
235
  const p = C(t, "show");
228
236
  P(s, p);
229
237
  const d = C(t, "opts$");
230
- k(s, d), Q(s, t.events), i({
238
+ E(s, d), Q(s, t.events), u({
231
239
  getFeature: () => s
232
240
  });
233
241
  const M = T();
234
- return u(() => {
242
+ return i(() => {
235
243
  M.value && h(s.setContent) && s.setContent(M.value);
236
- }, M), () => n && o.default ? A(J, {
244
+ }, M), () => r && o.default ? A(J, {
237
245
  to: "body"
238
246
  }, {
239
247
  default: () => [A("div", {
@@ -245,8 +253,8 @@ const Q = (e, a) => {
245
253
  props: {
246
254
  ...a.props
247
255
  },
248
- setup: (r, {
249
- slots: n,
256
+ setup: (n, {
257
+ slots: r,
250
258
  expose: t
251
259
  }) => {
252
260
  const o = T();
@@ -255,7 +263,7 @@ const Q = (e, a) => {
255
263
  }, {
256
264
  default: () => [A(a, ae({
257
265
  ref: o
258
- }, r), n)]
266
+ }, n), r)]
259
267
  });
260
268
  }
261
269
  }), ye = () => {
@@ -278,9 +286,9 @@ const Q = (e, a) => {
278
286
  }
279
287
  } };
280
288
  }, w = (e) => {
281
- const { addToMap: a, removeFromMap: r } = ye();
282
- u(() => (a(e), () => {
283
- r(e);
289
+ const { addToMap: a, removeFromMap: n } = ye();
290
+ i(() => (a(e), () => {
291
+ n(e);
284
292
  }), []);
285
293
  }, Re = v({
286
294
  props: {
@@ -290,33 +298,33 @@ const Q = (e, a) => {
290
298
  show: { type: Boolean, default: !0 },
291
299
  events: { type: Array }
292
300
  },
293
- setup: (e, { slots: a, expose: r }) => {
294
- const { mapRef: n } = m(), t = new window.AMap.OverlayGroup();
301
+ setup: (e, { slots: a, expose: n }) => {
302
+ const { mapRef: r } = m(), t = new window.AMap.OverlayGroup();
295
303
  let o = !1;
296
- const i = () => {
297
- o || (n.value.add(t), o = !0);
304
+ const u = () => {
305
+ o || (r.value.add(t), o = !0);
298
306
  }, s = () => {
299
307
  try {
300
- n.value.remove(t);
308
+ r.value.remove(t);
301
309
  } catch (l) {
302
310
  console.error(l);
303
311
  }
304
312
  o = !1;
305
313
  }, p = () => t;
306
- u(() => () => {
314
+ i(() => () => {
307
315
  s();
308
- }, []), u(() => {
309
- if (!V(e.bindTime))
316
+ }, []), i(() => {
317
+ if (!z(e.bindTime))
310
318
  return;
311
319
  const l = setTimeout(() => {
312
- i();
320
+ u();
313
321
  }, e.bindTime);
314
322
  return () => {
315
323
  l && clearTimeout(l);
316
324
  };
317
325
  }, []);
318
326
  const d = q(() => {
319
- i();
327
+ u();
320
328
  }, 300);
321
329
  R(
322
330
  () => {
@@ -327,7 +335,7 @@ const Q = (e, a) => {
327
335
  const M = C(e, "show");
328
336
  P(t, M);
329
337
  const L = C(e, "opts$");
330
- return k(t, L), r({ getFeature: p, addToMap: i, removeFormMap: s }), j({ mapRef: n, overlayGroup: t }), () => {
338
+ return E(t, L), n({ getFeature: p, addToMap: u, removeFormMap: s }), j({ mapRef: r, overlayGroup: t }), () => {
331
339
  var l;
332
340
  return (l = a.default) == null ? void 0 : l.call(a);
333
341
  };
@@ -347,31 +355,31 @@ const Q = (e, a) => {
347
355
  },
348
356
  setup: (e, {
349
357
  slots: a,
350
- emit: r
358
+ emit: n
351
359
  }) => {
352
360
  const {
353
- mapRef: n
361
+ mapRef: r
354
362
  } = m(), t = new window.AMap.InfoWindow({
355
363
  closeWhenClickMap: !0,
356
364
  isCustom: !!a.default,
357
365
  ...e.opts
358
366
  }), o = C(e, "opts$");
359
- k(t, o);
360
- const i = () => {
361
- r("close");
367
+ E(t, o);
368
+ const u = () => {
369
+ n("close");
362
370
  };
363
- u(() => (t.on("close", i), () => {
364
- t.off("close", i), t.close();
365
- }), []), u(() => {
371
+ i(() => (t.on("close", u), () => {
372
+ t.off("close", u), t.close();
373
+ }), []), i(() => {
366
374
  var d, M;
367
375
  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);
376
+ !p || t.open(r.value, p, e.height);
369
377
  }, () => {
370
378
  var p;
371
379
  return (p = e.opts$) == null ? void 0 : p.position;
372
380
  });
373
381
  const s = T();
374
- return u(() => {
382
+ return i(() => {
375
383
  s.value && h(t.setContent) && t.setContent(s.value);
376
384
  }, s), () => a.default ? A(J, {
377
385
  to: "body"
@@ -381,7 +389,7 @@ const Q = (e, a) => {
381
389
  }, [a.default()])]
382
390
  }) : null;
383
391
  }
384
- }), Oe = c("CircleMarker", { useMapConnect: G }), Be = c("Text", { useMapConnect: G }), _e = c("ElasticMarker", { useMapConnect: G }), Pe = c("Marker", { useMapConnect: w, needDom: !0 }), ke = c("Polygon", { useMapConnect: w }), Ee = c("Polyline", { useMapConnect: w }), De = c("Circle", { useMapConnect: w }), je = c("Rectangle", { useMapConnect: w }), Ge = c("Ellipse", { useMapConnect: w }), Ie = c("BezierCurve", { useMapConnect: w }), fe = c("ToolBar", { useMapConnect: F }), Ne = S([g.ToolBar], fe), me = c("Scale", { useMapConnect: F }), He = S([g.Scale], me), ve = c("HawkEye", { useMapConnect: F }), We = S([g.HawkEye], ve), Ae = c("MapType", { useMapConnect: F }), $e = S([g.MapType], Ae), Ce = c("ControlBar", { useMapConnect: F }), xe = S([g.ControlBar], Ce), he = () => {
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 = () => {
385
393
  const { mapRef: e, layerGroup: a } = m();
386
394
  return { addToMap: (t) => {
387
395
  if (a) {
@@ -401,9 +409,9 @@ const Q = (e, a) => {
401
409
  }
402
410
  } };
403
411
  }, f = (e) => {
404
- const { addToMap: a, removeFromMap: r } = he();
405
- u(() => (a(e), () => {
406
- r(e);
412
+ const { addToMap: a, removeFromMap: n } = he();
413
+ i(() => (a(e), () => {
414
+ n(e);
407
415
  }), []);
408
416
  }, Je = v({
409
417
  props: {
@@ -413,11 +421,11 @@ const Q = (e, a) => {
413
421
  show: { type: Boolean, default: !0 },
414
422
  events: { type: Array }
415
423
  },
416
- setup: (e, { slots: a, expose: r }) => {
417
- const { mapRef: n } = m(), t = new window.AMap.LayerGroup();
424
+ setup: (e, { slots: a, expose: n }) => {
425
+ const { mapRef: r } = m(), t = new window.AMap.LayerGroup();
418
426
  let o = !1;
419
- const i = () => {
420
- o || (t.setMap(n.value), o = !0);
427
+ const u = () => {
428
+ o || (t.setMap(r.value), o = !0);
421
429
  }, s = () => {
422
430
  try {
423
431
  t.setMap(null);
@@ -426,20 +434,20 @@ const Q = (e, a) => {
426
434
  }
427
435
  o = !1;
428
436
  }, p = () => t;
429
- u(() => () => {
437
+ i(() => () => {
430
438
  s();
431
- }, []), u(() => {
432
- if (!V(e.bindTime))
439
+ }, []), i(() => {
440
+ if (!z(e.bindTime))
433
441
  return;
434
442
  const l = setTimeout(() => {
435
- i();
443
+ u();
436
444
  }, e.bindTime);
437
445
  return () => {
438
446
  l && clearTimeout(l);
439
447
  };
440
448
  }, []);
441
449
  const d = q(() => {
442
- i();
450
+ u();
443
451
  }, 300);
444
452
  R(
445
453
  () => {
@@ -450,12 +458,12 @@ const Q = (e, a) => {
450
458
  const M = C(e, "show");
451
459
  P(t, M);
452
460
  const L = C(e, "opts$");
453
- return k(t, L), r({ getFeature: p, addToMap: i, removeFormMap: s }), j({ mapRef: n, layerGroup: t }), () => {
461
+ return E(t, L), n({ getFeature: p, addToMap: u, removeFormMap: s }), j({ mapRef: r, layerGroup: t }), () => {
454
462
  var l;
455
463
  return (l = a.default) == null ? void 0 : l.call(a);
456
464
  };
457
465
  }
458
- }), ze = v({
466
+ }), Ve = v({
459
467
  props: {
460
468
  opts: { type: Object },
461
469
  itemOpts: { type: Object },
@@ -464,7 +472,7 @@ const Q = (e, a) => {
464
472
  events: { type: Array }
465
473
  },
466
474
  setup: (e, { expose: a }) => {
467
- const { mapRef: r } = m(), n = new window.AMap.LabelsLayer(e.opts), t = () => ce(e.data, (s) => {
475
+ const { mapRef: n } = m(), r = new window.AMap.LabelsLayer(e.opts), t = () => ce(e.data, (s) => {
468
476
  const p = new window.AMap.LabelMarker({
469
477
  ...e.itemOpts,
470
478
  ...s
@@ -473,22 +481,22 @@ const Q = (e, a) => {
473
481
  p.on(d.type, d.handler, void 0, d.once);
474
482
  }), p;
475
483
  }), o = () => {
476
- n.clear();
484
+ r.clear();
477
485
  const s = t();
478
- n.add(s);
486
+ r.add(s);
479
487
  };
480
- u(() => (z(e.data) > 0 && o(), r.value.add(n), () => {
481
- n.clear(), r.value.remove(n);
488
+ i(() => (V(e.data) > 0 && o(), n.value.add(r), () => {
489
+ r.clear(), n.value.remove(r);
482
490
  }), []), R(
483
491
  () => {
484
492
  o();
485
493
  },
486
494
  () => e.data
487
495
  );
488
- const i = C(e, "show");
489
- return P(n, i), a({ getFeature: () => n }), () => null;
496
+ const u = C(e, "show");
497
+ return P(r, u), a({ getFeature: () => r }), () => null;
490
498
  }
491
- }), Ve = c("TileLayer", { useMapConnect: f }), qe = c("TileLayer.Satellite", {
499
+ }), ze = c("TileLayer", { useMapConnect: f }), qe = c("TileLayer.Satellite", {
492
500
  useMapConnect: f,
493
501
  createFeatureObj: (e) => new window.AMap.TileLayer.Satellite(e)
494
502
  }), Ke = c("TileLayer.RoadNet", {
@@ -519,32 +527,32 @@ const Q = (e, a) => {
519
527
  useMapConnect: Y,
520
528
  createFeatureObj: (e) => new window.AMap.HeatMap(null, e)
521
529
  }), ca = S([g.HeatMap], we), sa = (e, a) => {
522
- let r = !1, n = null;
523
- const t = x(), [o, i] = ne(), s = T(se(a.initEmit) ? a.initEmit : !1), p = ue(e, "_"), d = p[0], M = p[1], L = () => {
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 = () => {
524
532
  const y = ie(window, d);
525
- return y ? new y({ ...a.opts, ...n == null ? void 0 : n.opts }) : null;
533
+ return y ? new y({ ...a.opts, ...r == null ? void 0 : r.opts }) : null;
526
534
  }, l = (y) => y || (h(a.params) ? a.params() : a.params || []), I = () => {
527
- if (!n)
535
+ if (!r)
528
536
  return;
529
537
  const y = L();
530
538
  if (t.value = y, !y || !h(y[M]))
531
539
  return;
532
- const D = l(n.params);
540
+ const D = l(r.params);
533
541
  return s.value = !0, y[M](...D, (O, b) => {
534
- var N, H, W, $;
535
- i(b), (N = a.onComplete) == null || N.call(a, O, b), O === "complete" ? (H = a.onSuccess) == null || H.call(a, b) : O === "error" ? (W = a.onFail) == null || W.call(a, b) : O === "no_data" && (($ = a.onNoData) == null || $.call(a, b)), n = null, s.value = !1;
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;
536
544
  }), y;
537
545
  };
538
546
  X([d], () => {
539
- r = !0, I();
547
+ n = !0, I();
540
548
  });
541
- const E = (y, D) => {
542
- if (n = { opts: y || a.opts, params: l(D) }, !!r)
549
+ const k = (y, D) => {
550
+ if (r = { opts: y || a.opts, params: l(D) }, !!n)
543
551
  return I();
544
552
  };
545
- return u(() => {
546
- a.initEmit && E();
547
- }, []), R(() => E(), a.deps || []), { data: o, request: E, requesting: s, targetRef: t };
553
+ return i(() => {
554
+ a.initEmit && k();
555
+ }, []), R(() => k(), a.deps || []), { data: o, request: k, requesting: s, targetRef: t };
548
556
  }, ua = {
549
557
  Geocoder_getLocation: "AMap.Geocoder_getLocation",
550
558
  Geocoder_getAddress: "AMap.Geocoder_getAddress",
@@ -577,7 +585,7 @@ export {
577
585
  ca as HeatMap,
578
586
  Ze as ImageLayer,
579
587
  Fe as InfoWindow,
580
- ze as LabelsLayer,
588
+ Ve as LabelsLayer,
581
589
  Je as LayerGroup,
582
590
  be as Map,
583
591
  de as MapEvents,
@@ -587,23 +595,23 @@ export {
587
595
  Pe as Marker,
588
596
  Xe as MassMarks,
589
597
  Re as OverlayGroup,
590
- ke as Polygon,
591
- Ee as Polyline,
598
+ Ee as Polygon,
599
+ ke as Polyline,
592
600
  je as Rectangle,
593
- He as Scale,
601
+ Ne as Scale,
594
602
  Be as Text,
595
- Ve as TileLayer,
603
+ ze as TileLayer,
596
604
  Ye as TileLayerFlexible,
597
605
  Ke as TileLayerRoadNet,
598
606
  qe as TileLayerSatellite,
599
607
  Qe as TileLayerTraffic,
600
- Ne as ToolBar,
608
+ He as ToolBar,
601
609
  ea as VideoLayer,
602
610
  c as createFeature,
603
611
  S as createPluginFeature,
604
612
  j as provideMap,
605
613
  Q as useEvents,
606
- k as useFeatureOptMethods,
614
+ E as useFeatureOptMethods,
607
615
  m as useMap,
608
616
  sa as useMapApi,
609
617
  G as useMapConnect,
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),$=require("@amap/amap-jsapi-loader"),i=require("@vue-start/hooks"),u=require("lodash"),x=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},J=x($),k=(e,a)=>{i.useEffect(()=>(u.forEach(a,r=>{e.on(r.type,r.handler,void 0,r.once)}),()=>{u.forEach(a,r=>{e.off(r.type,r.handler)})}),[])},I=Symbol("amap-key"),R=e=>o.provide(I,e),v=()=>o.inject(I),q=()=>({securityJsCode:{type:String},loadOpts:{type:Object},opts:{type:Object},events:{type:Array}}),z=e=>{var a;if(!!e){if(!window._AMapSecurityConfig||!((a=window._AMapSecurityConfig)!=null&&a.securityJsCode)){window._AMapSecurityConfig={securityJsCode:e};return}window._AMapSecurityConfig.securityJsCode!==e&&(window._AMapSecurityConfig={securityJsCode:e},console.warn("\u5F53\u524Dwindow\u5BF9\u8C61\u5DF2\u7ECF\u6CE8\u5165\u8FC7securityJsCode\u503C\uFF0C\u53EF\u80FD\u9020\u6210\u95EE\u9898"))}},H=o.defineComponent({props:{events:{type:Array}},setup:e=>{const{mapRef:a}=v();return k(a.value,e.events),()=>null}}),K=o.defineComponent({props:{...q()},setup:(e,{slots:a,expose:r})=>{z(e.securityJsCode);const n=o.shallowRef(),t=o.ref();return r({mapRef:n,domRef:t}),i.useEffect(()=>(J.default.load({version:"2.0",...e.loadOpts}).then(c=>{const p=new c.Map(t.value,{...e.opts});p.on("complete",()=>{n.value=p})}).catch(c=>{console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"),console.error(c)}),()=>{n.value&&n.value.destroy()}),[]),R({mapRef:n}),()=>{var c;return o.createVNode("div",{ref:t},[n.value&&o.createVNode(H,{events:e.events},null),n.value&&((c=a.default)==null?void 0:c.call(a))])}}}),B=(e,a)=>{const{mapRef:r}=v();i.useEffect(()=>{if(!r.value){console.warn("\u8BF7\u5728Map\u7EC4\u4EF6\u5185\u4F7F\u7528 useMapPlugin");return}if(!e||u.size(e)<=0){a();return}window.AMap.plugin(e,a)},[])},V=o.defineComponent({props:{plugins:Array},setup:(e,{slots:a})=>{const r=o.ref(!1);return B(e.plugins,()=>{r.value=!0}),()=>{var n;return r.value?(n=a.default)==null?void 0:n.call(a):null}}}),A={ElasticMarker:"AMap.ElasticMarker",ControlBar:"AMap.ControlBar",ToolBar:"AMap.ToolBar",Scale:"AMap.Scale",HawkEye:"AMap.HawkEye",MapType:"AMap.MapType",AdvancedInfoWindow:"AMap.AdvancedInfoWindow",DragRoute:"AMap.DragRoute",IndoorMap:"AMap.IndoorMap",MouseTool:"AMap.MouseTool",CircleEditor:"AMap.CircleEditor",PolygonEditor:"AMap.PolygonEditor",PolylineEditor:"AMap.PolylineEditor",MarkerCluster:"AMap.MarkerCluster",RangingTool:"AMap.RangingTool",Geolocation:"AMap.Geolocation",Geocoder:"AMap.Geocoder",AutoComplete:"AMap.AutoComplete",PlaceSearch:"AMap.PlaceSearch",LineSearch:"AMap.LineSearch",DistrictSearch:"AMap.DistrictSearch",StationSearch:"AMap.StationSearch",CitySearch:"AMap.CitySearch",CloudDataSearch:"AMap.CloudDataSearch",RoadInfoSearch:"AMap.RoadInfoSearch",Driving:"AMap.Driving",TruckDriving:"AMap.TruckDriving",Transfer:"AMap.Transfer",Walking:"AMap.Walking",Riding:"AMap.Riding",ArrivalRange:"AMap.ArrivalRange",GraspRoad:"AMap.GraspRoad",HeatMap:"AMap.HeatMap",Weather:"AMap.Weather"},F=e=>{const{mapRef:a}=v();i.useEffect(()=>(a.value.add(e),()=>{try{a.value.remove(e)}catch(r){console.error(r)}}),[])},_=e=>{const{mapRef:a}=v();i.useEffect(()=>(e.setMap(a.value),()=>{try{e.setMap(null)}catch(r){console.error(r)}}),[])},T=e=>{const{mapRef:a}=v();i.useEffect(()=>(a.value.addControl(e),()=>{try{a.value.removeControl(e)}catch(r){console.error(r)}}),[])},S=(e,a)=>{const r=()=>{e&&u.isFunction(e.show)&&e.show()},n=()=>{e&&u.isFunction(e.hide)&&e.hide()};i.useEffect(()=>{a.value||n()},[]),i.useWatch(()=>{a.value?r():n()},a)},E=(e,a)=>{i.useEffect(()=>{u.forEach(a.value,(r,n)=>{const t="set"+u.upperFirst(n);e[t]&&u.isFunction(e[t])&&e[t](r)})},a)},s=(e,{useMapConnect:a,createFeatureObj:r,needDom:n})=>o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(t,{slots:c,expose:p})=>{const l=r?r(t.opts):new window.AMap[e](t.opts);a(l);const M=o.toRef(t,"show");S(l,M);const f=o.toRef(t,"opts$");E(l,f),k(l,t.events),p({getFeature:()=>l});const y=o.ref();return i.useEffect(()=>{y.value&&u.isFunction(l.setContent)&&l.setContent(y.value)},y),()=>n&&c.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:y},[c.default()])]}):null}}),w=(e,a)=>o.defineComponent({props:{...a.props},setup:(r,{slots:n,expose:t})=>{const c=o.ref();return t(i.createExposeObj(c,["getFeature"])),()=>o.createVNode(V,{plugins:e},{default:()=>[o.createVNode(a,o.mergeProps({ref:c},r),n)]})}}),Q=()=>{const{mapRef:e,overlayGroup:a}=v();return{addToMap:t=>{if(a){u.isArray(t)?a.addOverlays(t):a.addOverlay(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeOverlays(t):a.removeOverlay(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},h=e=>{const{addToMap:a,removeFromMap:r}=Q();i.useEffect(()=>(a(e),()=>{r(e)}),[])},U=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=v(),t=new window.AMap.OverlayGroup;let c=!1;const p=()=>{c||(n.value.add(t),c=!0)},l=()=>{try{n.value.remove(t)}catch(d){console.error(d)}c=!1},M=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&f()},()=>e.bind);const y=o.toRef(e,"show");S(t,y);const g=o.toRef(e,"opts$");return E(t,g),r({getFeature:M,addToMap:p,removeFormMap:l}),R({mapRef:n,overlayGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),X=o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},height:{type:Number,default:void 0}},setup:(e,{slots:a,emit:r})=>{const{mapRef:n}=v(),t=new window.AMap.InfoWindow({closeWhenClickMap:!0,isCustom:!!a.default,...e.opts}),c=o.toRef(e,"opts$");E(t,c);const p=()=>{r("close")};i.useEffect(()=>(t.on("close",p),()=>{t.off("close",p),t.close()}),[]),i.useEffect(()=>{var f,y;const M=((f=e.opts$)==null?void 0:f.position)||((y=e.opts)==null?void 0:y.position);!M||t.open(n.value,M,e.height)},()=>{var M;return(M=e.opts$)==null?void 0:M.position});const l=o.ref();return i.useEffect(()=>{l.value&&u.isFunction(t.setContent)&&t.setContent(l.value)},l),()=>a.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:l},[a.default()])]}):null}}),Y=s("CircleMarker",{useMapConnect:F}),Z=s("Text",{useMapConnect:F}),ee=s("ElasticMarker",{useMapConnect:F}),ae=s("Marker",{useMapConnect:h,needDom:!0}),te=s("Polygon",{useMapConnect:h}),re=s("Polyline",{useMapConnect:h}),ne=s("Circle",{useMapConnect:h}),oe=s("Rectangle",{useMapConnect:h}),ce=s("Ellipse",{useMapConnect:h}),se=s("BezierCurve",{useMapConnect:h}),ue=s("ToolBar",{useMapConnect:T}),ie=w([A.ToolBar],ue),le=s("Scale",{useMapConnect:T}),pe=w([A.Scale],le),de=s("HawkEye",{useMapConnect:T}),Me=w([A.HawkEye],de),fe=s("MapType",{useMapConnect:T}),ye=w([A.MapType],fe),Ce=s("ControlBar",{useMapConnect:T}),me=w([A.ControlBar],Ce),ve=()=>{const{mapRef:e,layerGroup:a}=v();return{addToMap:t=>{if(a){u.isArray(t)?a.addLayers(t):a.addLayer(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeLayers(t):a.removeLayer(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},C=e=>{const{addToMap:a,removeFromMap:r}=ve();i.useEffect(()=>(a(e),()=>{r(e)}),[])},he=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=v(),t=new window.AMap.LayerGroup;let c=!1;const p=()=>{c||(t.setMap(n.value),c=!0)},l=()=>{try{t.setMap(null)}catch(d){console.error(d)}c=!1},M=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&f()},()=>e.bind);const y=o.toRef(e,"show");S(t,y);const g=o.toRef(e,"opts$");return E(t,g),r({getFeature:M,addToMap:p,removeFormMap:l}),R({mapRef:n,layerGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),Ae=o.defineComponent({props:{opts:{type:Object},itemOpts:{type:Object},data:{type:Array},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{expose:a})=>{const{mapRef:r}=v(),n=new window.AMap.LabelsLayer(e.opts),t=()=>u.map(e.data,l=>{const M=new window.AMap.LabelMarker({...e.itemOpts,...l});return e.events&&u.forEach(e.events,f=>{M.on(f.type,f.handler,void 0,f.once)}),M}),c=()=>{n.clear();const l=t();n.add(l)};i.useEffect(()=>(u.size(e.data)>0&&c(),r.value.add(n),()=>{n.clear(),r.value.remove(n)}),[]),i.useWatch(()=>{c()},()=>e.data);const p=o.toRef(e,"show");return S(n,p),a({getFeature:()=>n}),()=>null}}),we=s("TileLayer",{useMapConnect:C}),Te=s("TileLayer.Satellite",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.Satellite(e)}),ge=s("TileLayer.RoadNet",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.RoadNet(e)}),Le=s("TileLayer.Traffic",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.Traffic(e)}),Se=s("Buildings",{useMapConnect:C}),Ee=s("MassMarks",{useMapConnect:_,createFeatureObj:e=>new window.AMap.MassMarks((e==null?void 0:e.data)||[],u.omit(e,"data"))}),be=s("TileLayer.Flexible",{useMapConnect:C,createFeatureObj:e=>new window.AMap.TileLayer.Flexible(e)}),Re=s("ImageLayer",{useMapConnect:C}),Fe=s("VideoLayer",{useMapConnect:C}),Oe=s("CanvasLayer",{useMapConnect:C}),Pe=s("CustomLayer",{useMapConnect:C,createFeatureObj:e=>new window.AMap.CustomLayer(e==null?void 0:e.canvas,u.omit(e,"canvas"))}),ke=s("DistrictLayer.World",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.World(e)}),Be=s("DistrictLayer.Country",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.Country(e)}),_e=s("DistrictLayer.Province",{useMapConnect:C,createFeatureObj:e=>new window.AMap.DistrictLayer.Province(e)}),De=s("HeatMap",{useMapConnect:_,createFeatureObj:e=>new window.AMap.HeatMap(null,e)}),Ne=w([A.HeatMap],De),je=(e,a)=>{let r=!1,n=null;const t=o.shallowRef(),[c,p]=i.useState(),l=o.ref(u.isBoolean(a.initEmit)?a.initEmit:!1),M=u.split(e,"_"),f=M[0],y=M[1],g=()=>{const m=u.get(window,f);return m?new m({...a.opts,...n==null?void 0:n.opts}):null},d=m=>m||(u.isFunction(a.params)?a.params():a.params||[]),D=()=>{if(!n)return;const m=g();if(t.value=m,!m||!u.isFunction(m[y]))return;const P=d(n.params);return l.value=!0,m[y](...P,(b,L)=>{var N,j,G,W;p(L),(N=a.onComplete)==null||N.call(a,b,L),b==="complete"?(j=a.onSuccess)==null||j.call(a,L):b==="error"?(G=a.onFail)==null||G.call(a,L):b==="no_data"&&((W=a.onNoData)==null||W.call(a,L)),n=null,l.value=!1}),m};B([f],()=>{r=!0,D()});const O=(m,P)=>{if(n={opts:m||a.opts,params:d(P)},!!r)return D()};return i.useEffect(()=>{a.initEmit&&O()},[]),i.useWatch(()=>O(),a.deps||[]),{data:c,request:O,requesting:l,targetRef:t}},Ge={Geocoder_getLocation:"AMap.Geocoder_getLocation",Geocoder_getAddress:"AMap.Geocoder_getAddress",Autocomplete_search:"AMap.Autocomplete_search",PlaceSearch_search:"AMap.PlaceSearch_search",PlaceSearch_searchNearBy:"AMap.PlaceSearch_searchNearBy",PlaceSearch_searchInBounds:"AMap.PlaceSearch_searchInBounds",PlaceSearch_getDetails:"AMap.PlaceSearch_getDetails",DistrictSearch_search:"AMap.DistrictSearch_search",LineSearch_search:"AMap.LineSearch_search",LineSearch_searchById:"AMap.LineSearch_searchById",StationSearch_search:"AMap.StationSearch_search",StationSearch_searchById:"AMap.StationSearch_searchById"};exports.ApiNames=Ge;exports.BezierCurve=se;exports.Buildings=Se;exports.CanvasLayer=Oe;exports.Circle=ne;exports.CircleMarker=Y;exports.ControlBar=me;exports.CustomLayer=Pe;exports.DistrictLayerCountry=Be;exports.DistrictLayerProvince=_e;exports.DistrictLayerWorld=ke;exports.ElasticMarker=ee;exports.Ellipse=ce;exports.HawkEye=Me;exports.HeatMap=Ne;exports.ImageLayer=Re;exports.InfoWindow=X;exports.LabelsLayer=Ae;exports.LayerGroup=he;exports.Map=K;exports.MapEvents=H;exports.MapPlugin=V;exports.MapPluginType=A;exports.MapType=ye;exports.Marker=ae;exports.MassMarks=Ee;exports.OverlayGroup=U;exports.Polygon=te;exports.Polyline=re;exports.Rectangle=oe;exports.Scale=pe;exports.Text=Z;exports.TileLayer=we;exports.TileLayerFlexible=be;exports.TileLayerRoadNet=ge;exports.TileLayerSatellite=Te;exports.TileLayerTraffic=Le;exports.ToolBar=ie;exports.VideoLayer=Fe;exports.createFeature=s;exports.createPluginFeature=w;exports.provideMap=R;exports.useEvents=k;exports.useFeatureOptMethods=E;exports.useMap=v;exports.useMapApi=je;exports.useMapConnect=F;exports.useMapConnect2=_;exports.useMapControlConnect=T;exports.useMapLayerConnect=C;exports.useMapOverlayConnect=h;exports.useMapPlugin=B;exports.useShowConnect=S;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-start/map",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
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": "1a871319b5d0c292f0733a062e67688bed52ee44"
33
+ "gitHead": "dd1b977211bd0db823224570b4a48892aab7c9c1"
34
34
  }