[英]Markers move when zooming with Google Maps Android API v2
[英]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.