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



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

最新更新