@heycar/heycars-map 0.9.8-fix2 → 0.9.8-memory2

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.cjs CHANGED
@@ -8,8 +8,11 @@ var __publicField = (obj, key, value) => {
8
8
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
9
  const Vue = require("vue");
10
10
  const style_css_ts_vanilla = "";
11
+ if (window !== void 0 && typeof globalThis === void 0) {
12
+ window.globalThis = window;
13
+ }
11
14
  const name = "@heycar/heycars-map";
12
- const version = "0.9.8-fix2";
15
+ const version = "0.9.8-memory2";
13
16
  const type = "module";
14
17
  const bin = {
15
18
  checkVersion: "./bin/checkVersion.js"
@@ -1218,7 +1221,7 @@ const pipeDefer = (fn) => (...args) => {
1218
1221
  setTimeout(() => {
1219
1222
  const result = fn == null ? void 0 : fn(...args);
1220
1223
  resolve(result);
1221
- }, 1e3);
1224
+ }, 50);
1222
1225
  });
1223
1226
  };
1224
1227
  const pipeOnlyLastEffect = (fn) => {
@@ -1387,14 +1390,13 @@ function watchPostEffectForMapProperty(targetRef, props, nameOptions, watchOptio
1387
1390
  Vue.watch(
1388
1391
  deps,
1389
1392
  (values, prevValues) => {
1390
- const target = targetRef.value;
1391
- if (!target)
1393
+ if (!targetRef.value)
1392
1394
  return;
1393
1395
  for (const [idx, value] of values.entries()) {
1394
1396
  const { name: name2, defaultValue } = nameOptions[idx];
1395
1397
  const prev = prevValues[idx];
1396
1398
  if (!deepCompareEqualsForMaps(value, prev)) {
1397
- target[name2setterName(name2)](value != null ? value : defaultValue);
1399
+ targetRef.value[name2setterName(name2)](value != null ? value : defaultValue);
1398
1400
  }
1399
1401
  }
1400
1402
  },
@@ -1413,16 +1415,18 @@ function watchNoneImmediatePostEffectForMapProperty(targetRef, props, nameOption
1413
1415
  }
1414
1416
  function watchPostEffectForAMapEvent(targetRef, props, emit, propertyNames) {
1415
1417
  Vue.watchPostEffect((onCleanup) => {
1416
- const target = targetRef == null ? void 0 : targetRef.value;
1417
- if (!target)
1418
+ if (!(targetRef == null ? void 0 : targetRef.value))
1418
1419
  return;
1419
1420
  const cleanList = [];
1420
1421
  for (const name2 of propertyNames) {
1421
1422
  const emitEventName = property2emitEventName(name2);
1422
1423
  const eventName = property2mapEventName(name2);
1423
1424
  const handler = (e) => emit(emitEventName, e);
1424
- target.on(eventName, handler);
1425
- cleanList.push(() => target == null ? void 0 : target.off(eventName, handler));
1425
+ targetRef == null ? void 0 : targetRef.value.on(eventName, handler);
1426
+ cleanList.push(() => {
1427
+ var _a;
1428
+ return (_a = targetRef == null ? void 0 : targetRef.value) == null ? void 0 : _a.off(eventName, handler);
1429
+ });
1426
1430
  }
1427
1431
  onCleanup(() => {
1428
1432
  for (const clean of cleanList)
@@ -1452,24 +1456,49 @@ function watchPostEffectForGMapEvent(targetRef, props, emit, propertyNames) {
1452
1456
  const watchPostEffectOnce = (callback) => {
1453
1457
  Vue.watch(() => 0, callback, { immediate: true, flush: "post" });
1454
1458
  };
1459
+ class ReferenceCount {
1460
+ constructor() {
1461
+ __publicField(this, "count", 0);
1462
+ }
1463
+ log() {
1464
+ console.log(`ReferenceCount count = ${this.count}`);
1465
+ }
1466
+ add() {
1467
+ this.count += 1;
1468
+ this.log();
1469
+ }
1470
+ remove() {
1471
+ this.count -= 1;
1472
+ this.log();
1473
+ }
1474
+ }
1475
+ const referenceCount = new ReferenceCount();
1455
1476
  const AmapMarker = defineSetup(function AmapMarker2(props, { emit }) {
1456
1477
  const { registerOverlay } = props;
1457
1478
  const markerRef = Vue.shallowRef();
1458
1479
  const mapRef = useAmap();
1459
1480
  Vue.onMounted(() => {
1481
+ referenceCount.add();
1460
1482
  markerRef.value = new AMap.Marker({ ...props });
1461
1483
  });
1462
1484
  Vue.onUnmounted(() => {
1463
- var _a;
1485
+ var _a, _b;
1486
+ referenceCount.remove();
1464
1487
  (_a = markerRef.value) == null ? void 0 : _a.setMap(null);
1488
+ (_b = markerRef.value) == null ? void 0 : _b.destroy();
1489
+ markerRef.value = void 0;
1465
1490
  });
1466
1491
  useMapOverlay({ registerOverlay, overlayRef: markerRef });
1467
- Vue.watchPostEffect(() => {
1492
+ Vue.watchPostEffect((onCleanup) => {
1468
1493
  var _a;
1469
1494
  const map = mapRef == null ? void 0 : mapRef.value;
1470
- if (!map)
1495
+ if (!(map == null ? void 0 : map.amap))
1471
1496
  return;
1472
- (_a = markerRef.value) == null ? void 0 : _a.setMap(map);
1497
+ (_a = markerRef.value) == null ? void 0 : _a.setMap(map.amap);
1498
+ onCleanup(() => {
1499
+ var _a2;
1500
+ return (_a2 = markerRef.value) == null ? void 0 : _a2.setMap(null);
1501
+ });
1473
1502
  });
1474
1503
  watchNoneImmediatePostEffectForMapProperty(markerRef, props, [
1475
1504
  { name: "anchor", defaultValue: "" },
@@ -2317,6 +2346,8 @@ function detectWebGL() {
2317
2346
  const useAmapLngLatToVw = (props) => {
2318
2347
  const apiMapLngLatToVw = (point) => {
2319
2348
  const amap2 = props.mapRef.value;
2349
+ if (!(amap2 == null ? void 0 : amap2.amap))
2350
+ return [0, 0];
2320
2351
  const sw = innerWidth;
2321
2352
  const [x, y] = amap2 == null ? void 0 : amap2.lngLatToContainer(point).toArray();
2322
2353
  return [100 * x / sw, 100 * y / sw];
@@ -2381,6 +2412,316 @@ const useAmapWheelZoomCenter = (props) => {
2381
2412
  };
2382
2413
  const Amap_css_ts_vanilla = "";
2383
2414
  var amap = "_1d8ur7t0";
2415
+ class SafeAmap {
2416
+ constructor(elm, options) {
2417
+ __publicField(this, "containerElm");
2418
+ __publicField(this, "amap");
2419
+ this.containerElm = document.createElement("div");
2420
+ this.containerElm.style.position = "absolute";
2421
+ this.containerElm.style.top = "0";
2422
+ this.containerElm.style.left = "0";
2423
+ this.containerElm.style.right = "0";
2424
+ this.containerElm.style.bottom = "0";
2425
+ elm.appendChild(this.containerElm);
2426
+ this.amap = new AMap.Map(this.containerElm, options);
2427
+ }
2428
+ destroy() {
2429
+ var _a, _b, _c;
2430
+ (_b = (_a = this.containerElm) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.removeChild(this.containerElm);
2431
+ (_c = this.amap) == null ? void 0 : _c.destroy();
2432
+ this.containerElm = void 0;
2433
+ this.amap = void 0;
2434
+ }
2435
+ getContainer() {
2436
+ var _a;
2437
+ return (_a = this.containerElm) == null ? void 0 : _a.parentElement;
2438
+ }
2439
+ setCenter(center, immediately, duration) {
2440
+ var _a;
2441
+ return (_a = this.amap) == null ? void 0 : _a.setCenter(center, immediately, duration);
2442
+ }
2443
+ getStyleByUserId(id, zoom) {
2444
+ var _a;
2445
+ return (_a = this.amap) == null ? void 0 : _a.getStyleByUserId(id, zoom);
2446
+ }
2447
+ getCustomTypeByContainerPos(lnglat) {
2448
+ var _a;
2449
+ return (_a = this.amap) == null ? void 0 : _a.getCustomTypeByContainerPos(lnglat);
2450
+ }
2451
+ getScreenShot(width, height) {
2452
+ var _a;
2453
+ return (_a = this.amap) == null ? void 0 : _a.getScreenShot(width, height);
2454
+ }
2455
+ setZoomAndCenter(zoom, center, immediately, duration) {
2456
+ var _a;
2457
+ (_a = this.amap) == null ? void 0 : _a.setZoomAndCenter(zoom, center, immediately, duration);
2458
+ }
2459
+ getBounds() {
2460
+ var _a;
2461
+ return (_a = this.amap) == null ? void 0 : _a.getBounds();
2462
+ }
2463
+ getCenter() {
2464
+ var _a;
2465
+ return (_a = this.amap) == null ? void 0 : _a.getCenter();
2466
+ }
2467
+ getGraphicInfo() {
2468
+ var _a;
2469
+ return (_a = this.amap) == null ? void 0 : _a.getGraphicInfo();
2470
+ }
2471
+ setZoom(zoom, immediately, duration) {
2472
+ var _a;
2473
+ (_a = this.amap) == null ? void 0 : _a.setZoom(zoom, immediately, duration);
2474
+ }
2475
+ getZoom(digits) {
2476
+ var _a;
2477
+ return (_a = this.amap) == null ? void 0 : _a.getZoom(digits);
2478
+ }
2479
+ zoomIn() {
2480
+ var _a;
2481
+ (_a = this.amap) == null ? void 0 : _a.zoomIn();
2482
+ }
2483
+ zoomOut() {
2484
+ var _a;
2485
+ (_a = this.amap) == null ? void 0 : _a.zoomOut();
2486
+ }
2487
+ getPitch() {
2488
+ var _a;
2489
+ return (_a = this.amap) == null ? void 0 : _a.getPitch();
2490
+ }
2491
+ setPitch(pitch, immediately, duration) {
2492
+ var _a;
2493
+ (_a = this.amap) == null ? void 0 : _a.setPitch(pitch, immediately, duration);
2494
+ }
2495
+ getRotation() {
2496
+ var _a;
2497
+ return (_a = this.amap) == null ? void 0 : _a.getRotation();
2498
+ }
2499
+ setRotation(rotation, immediately, duration) {
2500
+ var _a;
2501
+ (_a = this.amap) == null ? void 0 : _a.setRotation(rotation, immediately, duration);
2502
+ }
2503
+ setBounds(bounds, immediately, avoid) {
2504
+ var _a;
2505
+ (_a = this.amap) == null ? void 0 : _a.setBounds(bounds, immediately, avoid);
2506
+ }
2507
+ panTo(lnglat, duration) {
2508
+ var _a;
2509
+ (_a = this.amap) == null ? void 0 : _a.panTo(lnglat, duration);
2510
+ }
2511
+ panBy(x, y, duration) {
2512
+ var _a;
2513
+ (_a = this.amap) == null ? void 0 : _a.panBy(x, y, duration);
2514
+ }
2515
+ add(features) {
2516
+ var _a;
2517
+ (_a = this.amap) == null ? void 0 : _a.add(features);
2518
+ }
2519
+ remove(features) {
2520
+ var _a;
2521
+ (_a = this.amap) == null ? void 0 : _a.remove(features);
2522
+ }
2523
+ lngLatToCoords(lnglat) {
2524
+ var _a;
2525
+ return (_a = this.amap) == null ? void 0 : _a.lngLatToCoords(lnglat);
2526
+ }
2527
+ coordsToLngLat(coords) {
2528
+ var _a;
2529
+ return (_a = this.amap) == null ? void 0 : _a.coordsToLngLat(coords);
2530
+ }
2531
+ lngLatToContainer(lnglat) {
2532
+ var _a;
2533
+ return (_a = this.amap) == null ? void 0 : _a.lngLatToContainer(lnglat);
2534
+ }
2535
+ containerToLngLat(pixel) {
2536
+ var _a;
2537
+ return (_a = this.amap) == null ? void 0 : _a.containerToLngLat(pixel);
2538
+ }
2539
+ coordToContainer(coord) {
2540
+ var _a;
2541
+ return (_a = this.amap) == null ? void 0 : _a.coordToContainer(coord);
2542
+ }
2543
+ containerToCoord(pixel) {
2544
+ var _a;
2545
+ return (_a = this.amap) == null ? void 0 : _a.containerToCoord(pixel);
2546
+ }
2547
+ pixelToLngLat(pixel, z) {
2548
+ var _a;
2549
+ return (_a = this.amap) == null ? void 0 : _a.pixelToLngLat(pixel, z);
2550
+ }
2551
+ lngLatToPixel(lnglat, z) {
2552
+ var _a;
2553
+ return (_a = this.amap) == null ? void 0 : _a.lngLatToPixel(lnglat, z);
2554
+ }
2555
+ getResolution(point) {
2556
+ var _a;
2557
+ return (_a = this.amap) == null ? void 0 : _a.getResolution(point);
2558
+ }
2559
+ getScale(dpi) {
2560
+ var _a;
2561
+ return (_a = this.amap) == null ? void 0 : _a.getScale(dpi);
2562
+ }
2563
+ getCity(cbk, lnglat) {
2564
+ var _a;
2565
+ (_a = this.amap) == null ? void 0 : _a.getCity(cbk, lnglat);
2566
+ }
2567
+ setCity(cityName, cbk) {
2568
+ var _a;
2569
+ (_a = this.amap) == null ? void 0 : _a.setCity(cityName, cbk);
2570
+ }
2571
+ setFitView(overlays, immediately, avoid, maxZoom) {
2572
+ var _a;
2573
+ return (_a = this.amap) == null ? void 0 : _a.setFitView(overlays, immediately, avoid, maxZoom);
2574
+ }
2575
+ getFitZoomAndCenterByOverlays(overlayList, avoid, maxZoom) {
2576
+ var _a;
2577
+ return (_a = this.amap) == null ? void 0 : _a.getFitZoomAndCenterByOverlays(overlayList, avoid, maxZoom);
2578
+ }
2579
+ getFitZoomAndCenterByBounds(bounds, avoid, maxZoom) {
2580
+ var _a;
2581
+ return (_a = this.amap) == null ? void 0 : _a.getFitZoomAndCenterByBounds(bounds, avoid, maxZoom);
2582
+ }
2583
+ addControl(control) {
2584
+ var _a;
2585
+ (_a = this.amap) == null ? void 0 : _a.addControl(control);
2586
+ }
2587
+ removeControl(control) {
2588
+ var _a;
2589
+ (_a = this.amap) == null ? void 0 : _a.removeControl(control);
2590
+ }
2591
+ setMapStyle(value) {
2592
+ var _a;
2593
+ (_a = this.amap) == null ? void 0 : _a.setMapStyle(value);
2594
+ }
2595
+ getMapStyle() {
2596
+ var _a;
2597
+ return (_a = this.amap) == null ? void 0 : _a.getMapStyle();
2598
+ }
2599
+ getAllOverlays(type2) {
2600
+ var _a;
2601
+ return (_a = this.amap) == null ? void 0 : _a.getAllOverlays(type2);
2602
+ }
2603
+ clearMap() {
2604
+ var _a;
2605
+ (_a = this.amap) == null ? void 0 : _a.clearMap();
2606
+ }
2607
+ clearInfoWindow() {
2608
+ var _a;
2609
+ (_a = this.amap) == null ? void 0 : _a.clearInfoWindow();
2610
+ }
2611
+ getFeatures() {
2612
+ var _a;
2613
+ return (_a = this.amap) == null ? void 0 : _a.getFeatures();
2614
+ }
2615
+ setFeatures(features) {
2616
+ var _a;
2617
+ (_a = this.amap) == null ? void 0 : _a.setFeatures(features);
2618
+ }
2619
+ getMapApprovalNumber() {
2620
+ var _a;
2621
+ return (_a = this.amap) == null ? void 0 : _a.getMapApprovalNumber();
2622
+ }
2623
+ setMask(maskPath) {
2624
+ var _a;
2625
+ (_a = this.amap) == null ? void 0 : _a.setMask(maskPath);
2626
+ }
2627
+ setLabelRejectMask(reject) {
2628
+ var _a;
2629
+ (_a = this.amap) == null ? void 0 : _a.setLabelRejectMask(reject);
2630
+ }
2631
+ /**
2632
+ * AMap.coreMap
2633
+ */
2634
+ getSize() {
2635
+ var _a;
2636
+ return (_a = this.amap) == null ? void 0 : _a.getSize();
2637
+ }
2638
+ addLayer(layer) {
2639
+ var _a;
2640
+ (_a = this.amap) == null ? void 0 : _a.addLayer(layer);
2641
+ }
2642
+ removeLayer(layer) {
2643
+ var _a;
2644
+ (_a = this.amap) == null ? void 0 : _a.removeLayer(layer);
2645
+ }
2646
+ setLayers(layers) {
2647
+ var _a;
2648
+ (_a = this.amap) == null ? void 0 : _a.setLayers(layers);
2649
+ }
2650
+ getLayers() {
2651
+ var _a;
2652
+ return (_a = this.amap) == null ? void 0 : _a.getLayers();
2653
+ }
2654
+ getLayersDangerous() {
2655
+ var _a;
2656
+ return (_a = this.amap) == null ? void 0 : _a.getLayersDangerous();
2657
+ }
2658
+ getStatus() {
2659
+ var _a;
2660
+ return (_a = this.amap) == null ? void 0 : _a.getStatus();
2661
+ }
2662
+ setStatus(status) {
2663
+ var _a;
2664
+ (_a = this.amap) == null ? void 0 : _a.setStatus(status);
2665
+ }
2666
+ getDefaultCursor() {
2667
+ var _a;
2668
+ return (_a = this.amap) == null ? void 0 : _a.getDefaultCursor();
2669
+ }
2670
+ setDefaultCursor(cursor) {
2671
+ var _a;
2672
+ (_a = this.amap) == null ? void 0 : _a.setDefaultCursor(cursor);
2673
+ }
2674
+ getLimitBounds() {
2675
+ var _a;
2676
+ return (_a = this.amap) == null ? void 0 : _a.getLimitBounds();
2677
+ }
2678
+ setLimitBounds(bounds) {
2679
+ var _a;
2680
+ (_a = this.amap) == null ? void 0 : _a.setLimitBounds(bounds);
2681
+ }
2682
+ clearLimitBounds() {
2683
+ var _a;
2684
+ (_a = this.amap) == null ? void 0 : _a.clearLimitBounds();
2685
+ }
2686
+ getZooms() {
2687
+ var _a;
2688
+ return (_a = this.amap) == null ? void 0 : _a.getZooms();
2689
+ }
2690
+ setZooms(zooms) {
2691
+ var _a;
2692
+ (_a = this.amap) == null ? void 0 : _a.setZooms(zooms);
2693
+ }
2694
+ /**
2695
+ * AMap.Event
2696
+ */
2697
+ on(type2, fn, context2, once) {
2698
+ var _a;
2699
+ (_a = this.amap) == null ? void 0 : _a.on(type2, fn, context2, once);
2700
+ return this;
2701
+ }
2702
+ off(type2, fn, context2) {
2703
+ var _a;
2704
+ (_a = this.amap) == null ? void 0 : _a.off(type2, fn, context2);
2705
+ return this;
2706
+ }
2707
+ hasEvents(type2, fn, context2) {
2708
+ var _a;
2709
+ return !!((_a = this.amap) == null ? void 0 : _a.hasEvents(type2, fn, context2));
2710
+ }
2711
+ clearEvents(type2) {
2712
+ var _a;
2713
+ (_a = this.amap) == null ? void 0 : _a.clearEvents(type2);
2714
+ return this;
2715
+ }
2716
+ emit(type2, data) {
2717
+ var _a;
2718
+ (_a = this.amap) == null ? void 0 : _a.emit(type2, data);
2719
+ return this;
2720
+ }
2721
+ getEvents() {
2722
+ return this.amap.getEvents();
2723
+ }
2724
+ }
2384
2725
  const Amap = defineSetup(function Amap2(props, { slots, emit }) {
2385
2726
  const {
2386
2727
  onDragStart,
@@ -2424,10 +2765,11 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
2424
2765
  provideAmap(mapRef);
2425
2766
  const { apiMapDistanceVwOfPoints } = useMapLngLatToVw({ mapRef });
2426
2767
  useAmapWheelZoomCenter({ mapRef, enableRef: Vue.computed(() => !!props.touchZoomCenter) });
2427
- Vue.watchPostEffect(() => {
2768
+ Vue.watchPostEffect((onCleanup) => {
2428
2769
  if (mapRef.value || !elementRef.value)
2429
2770
  return;
2430
- const map = new AMap.Map(elementRef.value, {
2771
+ referenceCount.add();
2772
+ const map = new SafeAmap(elementRef.value, {
2431
2773
  ...defaultOptions,
2432
2774
  scrollWheel: defaultOptions.touchZoomCenter ? false : defaultOptions.scrollWheel,
2433
2775
  vectorMapForeign
@@ -2435,6 +2777,13 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
2435
2777
  window.GlobalAmap = map;
2436
2778
  mapRef.value = map;
2437
2779
  setMap == null ? void 0 : setMap(map);
2780
+ onCleanup(() => {
2781
+ window.GlobalAmap = void 0;
2782
+ mapRef.value = void 0;
2783
+ setMap == null ? void 0 : setMap(void 0);
2784
+ map == null ? void 0 : map.destroy();
2785
+ referenceCount.remove();
2786
+ });
2438
2787
  });
2439
2788
  watchNoneImmediatePostEffectForDeepOption(
2440
2789
  () => statusOptions.value,
@@ -2738,18 +3087,26 @@ const AmapPolyline = defineSetup(function AmapPolyline2(props) {
2738
3087
  const polylineRef = Vue.shallowRef();
2739
3088
  const mapRef = useAmap();
2740
3089
  Vue.onMounted(() => {
3090
+ referenceCount.add();
2741
3091
  polylineRef.value = new AMap.Polyline({ ...props });
2742
3092
  });
2743
3093
  Vue.onUnmounted(() => {
2744
- var _a;
3094
+ var _a, _b;
3095
+ referenceCount.remove();
2745
3096
  (_a = polylineRef.value) == null ? void 0 : _a.setMap(null);
3097
+ (_b = polylineRef.value) == null ? void 0 : _b.destroy();
3098
+ polylineRef.value = void 0;
2746
3099
  });
2747
- Vue.watchPostEffect(() => {
3100
+ Vue.watchPostEffect((onCleanup) => {
2748
3101
  var _a;
2749
3102
  const map = mapRef == null ? void 0 : mapRef.value;
2750
- if (!map)
3103
+ if (!(map == null ? void 0 : map.amap))
2751
3104
  return;
2752
- (_a = polylineRef.value) == null ? void 0 : _a.setMap(map);
3105
+ (_a = polylineRef.value) == null ? void 0 : _a.setMap(map.amap);
3106
+ onCleanup(() => {
3107
+ var _a2;
3108
+ return (_a2 = polylineRef.value) == null ? void 0 : _a2.setMap(null);
3109
+ });
2753
3110
  });
2754
3111
  watchNoneImmediatePostEffectForMapProperty(polylineRef, props, [
2755
3112
  { name: "path", defaultValue: [[0, 0]] },
@@ -3029,7 +3386,7 @@ const useDrivingRoute = (props) => {
3029
3386
  return supplier === "gmap" ? useGDrivingRoute(props) : useADrivingRoute(props);
3030
3387
  };
3031
3388
  const amapComputeHeading = (from, to, map) => {
3032
- if (!map)
3389
+ if (!(map == null ? void 0 : map.amap))
3033
3390
  return 0;
3034
3391
  const { x: xFrom, y: yFrom } = map.lngLatToContainer(from);
3035
3392
  const { x: xTo, y: yTo } = map.lngLatToContainer(to);
@@ -3121,15 +3478,15 @@ const useAmapFitView = (props) => {
3121
3478
  const { mapRef, autoFitTimeout } = props;
3122
3479
  const overlayGroup = /* @__PURE__ */ new Set();
3123
3480
  let timer = void 0;
3124
- const setFitView = () => {
3481
+ const setFitView = (immediate = false) => {
3125
3482
  var _a, _b;
3126
3483
  const map = mapRef.value;
3127
- if (!map)
3484
+ if (!(map == null ? void 0 : map.amap))
3128
3485
  return;
3129
3486
  const vw = window.innerWidth / 100;
3130
3487
  const [top, right, bottom, left] = (_a = props.padding) != null ? _a : [0, 0, 0, 0];
3131
3488
  spaceLog("setFitView", "overlayGroup = ", overlayGroup);
3132
- map.setFitView([...overlayGroup], false, [top * vw, bottom * vw, left * vw, right * vw]);
3489
+ map.setFitView([...overlayGroup], immediate, [top * vw, bottom * vw, left * vw, right * vw]);
3133
3490
  if (overlayGroup.size === 1) {
3134
3491
  const [overlay] = [...overlayGroup];
3135
3492
  const position = (_b = overlay.getPosition) == null ? void 0 : _b.call(overlay);
@@ -3309,7 +3666,7 @@ const FitViewOnce = defineSetup(function FitViewOnce2(props, {
3309
3666
  } = registerOverlay;
3310
3667
  Vue.onMounted(async () => {
3311
3668
  await mapMountedPromise;
3312
- setFitView();
3669
+ setFitView(!!props.immediate);
3313
3670
  });
3314
3671
  return () => {
3315
3672
  var _a;
@@ -3391,7 +3748,7 @@ const InterruptableIntervalFitView = defineSetup(function InterruptableIntervalF
3391
3748
  } = pausableSleep(props.interval));
3392
3749
  await sleepPromise;
3393
3750
  console.log("InterruptableIntervalFitView setFitView");
3394
- registerOverlay.setFitView();
3751
+ registerOverlay.setFitView(!!props.immediate);
3395
3752
  }
3396
3753
  }, {
3397
3754
  immediate: true,
@@ -3578,7 +3935,7 @@ const BusinessQuotingMap = defineLagecySetup(function BusinessQuotingMap2(props,
3578
3935
  language
3579
3936
  } = useMapSupplier();
3580
3937
  const fittableRegistryOverlay = createFittableRegisterOverlay(registerOverlay);
3581
- const deferedSetFitView = pipeDefer(registerOverlay.setFitView);
3938
+ const deferedSetFitView = pipeDefer(() => registerOverlay.setFitView(true));
3582
3939
  return () => {
3583
3940
  const {
3584
3941
  from: inputFromPlace,
@@ -4092,11 +4449,11 @@ const useHeycarAmap = () => {
4092
4449
  const { apiMapDistanceVwOfPoints } = useMapLngLatToVw({ mapRef: amapRef });
4093
4450
  const setMap = (map) => {
4094
4451
  amapRef.value = map;
4095
- amapElementRef.value = map.getContainer();
4452
+ amapElementRef.value = map == null ? void 0 : map.getContainer();
4096
4453
  };
4097
4454
  const panTo = async (value) => {
4098
4455
  const amap2 = amapRef.value;
4099
- if (!amap2)
4456
+ if (!(amap2 == null ? void 0 : amap2.amap))
4100
4457
  return;
4101
4458
  const { lng, lat } = amap2.getCenter();
4102
4459
  const distanceVw = apiMapDistanceVwOfPoints(value, [lng, lat]);
@@ -4116,7 +4473,7 @@ const useHeycarGamp = () => {
4116
4473
  const gmapElementRef = Vue.shallowRef();
4117
4474
  const setMap = (map) => {
4118
4475
  gmapRef.value = map;
4119
- gmapElementRef.value = map.getDiv();
4476
+ gmapElementRef.value = map == null ? void 0 : map.getDiv();
4120
4477
  };
4121
4478
  const panTo = (value) => {
4122
4479
  var _a;
@@ -6059,7 +6416,7 @@ const useAmapZoom = (props) => {
6059
6416
  Vue.watch(
6060
6417
  () => mapRef.value,
6061
6418
  (map) => {
6062
- if (!map)
6419
+ if (!(map == null ? void 0 : map.amap))
6063
6420
  return;
6064
6421
  zoomRef.value = map.getZoom();
6065
6422
  }
@@ -6107,20 +6464,28 @@ const AmapPolygon = defineSetup(function AmapPolygon2(props) {
6107
6464
  const polygonRef = Vue.shallowRef();
6108
6465
  const mapRef = useAmap();
6109
6466
  Vue.onMounted(() => {
6467
+ referenceCount.add();
6110
6468
  polygonRef.value = new AMap.Polygon();
6111
6469
  polygonRef.value.setOptions(props);
6112
6470
  });
6113
6471
  Vue.onUnmounted(() => {
6114
- var _a;
6472
+ var _a, _b;
6473
+ referenceCount.remove();
6115
6474
  (_a = polygonRef.value) == null ? void 0 : _a.setMap(null);
6475
+ (_b = polygonRef.value) == null ? void 0 : _b.destroy();
6476
+ polygonRef.value = void 0;
6116
6477
  });
6117
6478
  useAmapFixBugPolygonDrag(polygonRef);
6118
- Vue.watchPostEffect(() => {
6479
+ Vue.watchPostEffect((onCleanup) => {
6119
6480
  var _a;
6120
6481
  const map = mapRef == null ? void 0 : mapRef.value;
6121
- if (!map)
6482
+ if (!(map == null ? void 0 : map.amap))
6122
6483
  return;
6123
- (_a = polygonRef.value) == null ? void 0 : _a.setMap(map);
6484
+ (_a = polygonRef.value) == null ? void 0 : _a.setMap(map.amap);
6485
+ onCleanup(() => {
6486
+ var _a2;
6487
+ return (_a2 = polygonRef.value) == null ? void 0 : _a2.setMap(null);
6488
+ });
6124
6489
  });
6125
6490
  watchNoneImmediatePostEffectForMapProperty(polygonRef, props, [
6126
6491
  { name: "path", defaultValue: [[0, 0]] },
@@ -7598,10 +7963,12 @@ const SectionDispatching = defineSetup(function SectionDispatching2(props) {
7598
7963
  }
7599
7964
  }), Vue.h(FitViewOnce, {
7600
7965
  "attrs": {
7601
- "registerOverlay": registerOverlay
7966
+ "registerOverlay": registerOverlay,
7967
+ "immediate": true
7602
7968
  }
7603
7969
  }), Vue.h(InterruptableIntervalFitView, {
7604
7970
  "attrs": {
7971
+ "immediate": true,
7605
7972
  "interval": AUTO_FIT_VIEW_INTERVAL,
7606
7973
  "registerOverlay": registerOverlay
7607
7974
  }
@@ -7673,7 +8040,8 @@ const SectionConfirmed = defineSetup(function SectionConfirmed2(props) {
7673
8040
  }
7674
8041
  }), Vue.h(FitViewOnce, {
7675
8042
  "attrs": {
7676
- "registerOverlay": registerOverlay
8043
+ "registerOverlay": registerOverlay,
8044
+ "immediate": true
7677
8045
  }
7678
8046
  }), Vue.h(InterruptableIntervalFitView, {
7679
8047
  "attrs": {
@@ -7779,7 +8147,8 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
7779
8147
  }
7780
8148
  }), Vue.h(FitViewOnce, {
7781
8149
  "attrs": {
7782
- "registerOverlay": registerOverlay
8150
+ "registerOverlay": registerOverlay,
8151
+ "immediate": true
7783
8152
  }
7784
8153
  }), Vue.h(InterruptableIntervalFitView, {
7785
8154
  "attrs": {
@@ -7866,7 +8235,8 @@ const SectionBookDispatched = defineSetup(function SectionBookDispatched2(props)
7866
8235
  }
7867
8236
  }), Vue.h(FitViewOnce, {
7868
8237
  "attrs": {
7869
- "registerOverlay": registerOverlay
8238
+ "registerOverlay": registerOverlay,
8239
+ "immediate": true
7870
8240
  }
7871
8241
  }), Vue.h(InterruptableIntervalFitView, {
7872
8242
  "attrs": {
@@ -7939,7 +8309,8 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
7939
8309
  }
7940
8310
  }), Vue.h(FitViewOnce, {
7941
8311
  "attrs": {
7942
- "registerOverlay": registerOverlay
8312
+ "registerOverlay": registerOverlay,
8313
+ "immediate": true
7943
8314
  }
7944
8315
  }), Vue.h(InterruptableIntervalFitView, {
7945
8316
  "attrs": {
@@ -8023,7 +8394,8 @@ const SectionInService = defineSetup(function SectionInService2(props) {
8023
8394
  }
8024
8395
  }), Vue.h(FitViewOnce, {
8025
8396
  "attrs": {
8026
- "registerOverlay": registerOverlay
8397
+ "registerOverlay": registerOverlay,
8398
+ "immediate": true
8027
8399
  }
8028
8400
  }), Vue.h(InterruptableIntervalFitView, {
8029
8401
  "attrs": {
@@ -8073,10 +8445,12 @@ const SectionCanceled = defineSetup(function SectionCanceled2(props) {
8073
8445
  }
8074
8446
  }), Vue.h(FitViewOnce, {
8075
8447
  "attrs": {
8076
- "registerOverlay": registerOverlay
8448
+ "registerOverlay": registerOverlay,
8449
+ "immediate": true
8077
8450
  }
8078
8451
  }), Vue.h(InterruptableIntervalFitView, {
8079
8452
  "attrs": {
8453
+ "immediate": true,
8080
8454
  "interval": AUTO_FIT_VIEW_INTERVAL,
8081
8455
  "registerOverlay": registerOverlay
8082
8456
  }
@@ -8136,11 +8510,13 @@ const SectionEndService = defineSetup(function SectionEndService2(props) {
8136
8510
  }
8137
8511
  }), Vue.h(FitViewOnce, {
8138
8512
  "attrs": {
8139
- "registerOverlay": registerOverlay
8513
+ "registerOverlay": registerOverlay,
8514
+ "immediate": true
8140
8515
  }
8141
8516
  }), Vue.h(InterruptableIntervalFitView, {
8142
8517
  "attrs": {
8143
8518
  "interval": AUTO_FIT_VIEW_INTERVAL,
8519
+ "immediate": true,
8144
8520
  "registerOverlay": registerOverlay
8145
8521
  }
8146
8522
  })]);
@@ -8158,7 +8534,7 @@ const BusinessTaxiEndMap = defineSetup(function BusinessTaxiEndMap2(props) {
8158
8534
  autoFitTimeout: 5e3,
8159
8535
  padding: [19, 36, 19, 26]
8160
8536
  });
8161
- const deferedSetFitView = pipeDefer(registerFitVeiw.setFitView);
8537
+ const deferedSetFitView = pipeDefer(() => registerFitVeiw.setFitView(true));
8162
8538
  return () => {
8163
8539
  const {
8164
8540
  from: inputFrom,
@@ -8197,7 +8573,7 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
8197
8573
  renderStartSerivceTitle,
8198
8574
  renderInServiceTitle
8199
8575
  } = props;
8200
- const deferedSetFitView = pipeDefer(registerOverlay.setFitView);
8576
+ const deferedSetFitView = pipeDefer(() => registerOverlay.setFitView(true));
8201
8577
  const {
8202
8578
  setMap,
8203
8579
  mapElementRef