Ionic 5 Google 地图标记在缩放时闪烁

Ionic 5 Google Maps markers flickering when zooming

我的 Ionic 5 项目中有 Google 地图标记问题,该项目仅与原生 Android 构建隔离。

放大或缩小时,我的自定义标记是flickering/blinking。
闪烁在其他平台上不是问题。仅限本机 Android.

如有任何想法,我们将不胜感激。

这里是标记代码的片段

  addMarker(station: StationModel, showMemberDiscount: boolean, index: number) {
    let selectedPrice = showMemberDiscount? station.selectedFuelTypePrice.discountedPrice : station.selectedFuelTypePrice.price;

    this.getMarkerIcons(station, showMemberDiscount).pipe(takeUntil(this.destroyed$)).subscribe(
      icons => {
        let marker = new google.maps.Marker({
          position: { lat: station.location.position.latitude, lng: station.location.position.longitude },
          label: {
            text:  selectedPrice.toFixed(1) + '',
            color: '#FFFFFF',
            fontSize: '20px',
            fontWeight: 'bold',
          },
          icon: icons.iconDefault,
          zIndex: index,
          map: this.map,
        });
        marker.addListener('click', () => {
          this.ngZone.run(() => {
            // reset previous active marker if there's one
            this.clearActiveMarker(true);
            this.map.panTo(marker.getPosition());
            // store the default icon for selected marker
            this.activeMarkerDefaultIcon = {marker: marker, icon: icons.iconDefault, zIndex: marker.getZIndex()};
            this.selectedStation.next(station);
            marker.setZIndex(google.maps.Marker.MAX_ZINDEX + 1);
            marker.setIcon(icons.iconSelected);
          });
        });
        this.markers.push(marker);
      });
  }

将硬件加速设置为 false 解决了闪烁标记问题

<application android:hardwareAccelerated="false" ...>

https://developer.android.com/guide/topics/graphics/hardware-accel