离子 5 谷歌地图标记在缩放时闪烁

最大限度

我的 Ionic 5 项目中存在 Google 地图标记问题,该项目仅与原生 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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章