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