簡體   English   中英

Ionic 5 Google Maps 標記在縮放時閃爍

[英]Ionic 5 Google Maps markers flickering when zooming

我的 Ionic 5 項目中存在 Google Maps 標記問題,該項目僅與本地 Android 構建隔離。

放大或縮小時,我的自定義標記閃爍/閃爍。
閃爍在其他平台上不是問題。 僅在本機 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM