如何提高具有大量标记的 react-native-map 的性能?
How can I improve the performance of a react-native-map with a large number of markers?
我使用的是反应式原生地图。在地图上使用标记会大大降低性能。如何提高具有大量标记的地图的性能?
ShouldComponentUpdate - 没有帮助。
事实证明,通过执行 2 个步骤可以很好地提高性能:
- 为 MapView.Marker
添加 tracksViewChanges={false}
- 标记的组件应该更新
<MapView.Marker
coordinate={{ latitude, longitude }}
tracksViewChanges={false}
>
<View> ... </View>
</MapView.Marker>
shouldComponentUpdate(nextProps) {
return nextProps.latitude !== this.props.latitude && nextProps.longitude !== this.props.longitude;
}
我使用的是反应式原生地图。在地图上使用标记会大大降低性能。如何提高具有大量标记的地图的性能?
ShouldComponentUpdate - 没有帮助。
事实证明,通过执行 2 个步骤可以很好地提高性能:
- 为 MapView.Marker 添加 tracksViewChanges={false}
- 标记的组件应该更新
<MapView.Marker
coordinate={{ latitude, longitude }}
tracksViewChanges={false}
>
<View> ... </View>
</MapView.Marker>
shouldComponentUpdate(nextProps) {
return nextProps.latitude !== this.props.latitude && nextProps.longitude !== this.props.longitude;
}