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

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