Android React本机自定义标记减慢应用程序速度

Android React本机自定义标记减慢应用程序速度,android,reactjs,react-native,google-maps,google-maps-markers,Android,Reactjs,React Native,Google Maps,Google Maps Markers,当我使用自定义标记时,经过几个过程后,系统开始变得沉重。但是如果我不用定制就使用它,就没有问题了。我分享了我的标记代码的截图,为什么我会遇到这样的问题 因此,如果我使用默认标记也可以。但是如果我自己设计的话,它的工作速度非常慢 标记数目:50 库:反应本机贴图、反应本机矢量图标/FontAwesome5 关闭: tracksViewChanges={false}我通过向标记添加道具解决了这个问题 tracksViewChanges:设置此标记是否应跟踪视图更改。只要有可能提高自定义标记器的性能,

当我使用自定义标记时,经过几个过程后,系统开始变得沉重。但是如果我不用定制就使用它,就没有问题了。我分享了我的标记代码的截图,为什么我会遇到这样的问题

因此,如果我使用默认标记也可以。但是如果我自己设计的话,它的工作速度非常慢

标记数目:50

库:反应本机贴图、反应本机矢量图标/FontAwesome5

关闭:


tracksViewChanges={false}
我通过向标记添加道具解决了这个问题

tracksViewChanges:设置此标记是否应跟踪视图更改。只要有可能提高自定义标记器的性能,建议将其关闭

renderListMarker = () => {
    let { markerList } = this.props;
    return (
        markerList.map((item, index) => {
            return (
                <Marker
                    onPress={() => { this.selectMarker(index) }}
                    key={item._id}
                    coordinate={{
                        latitude: item.location.coordinates[0],
                        longitude: item.location.coordinates[1],
                    }}
                >
                    <View style={{ flexDirection: 'column', justifyContent: 'center', alignItems: 'center' }}>
                        <View style={{ marginBottom: -18, flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
                            <View style={{ marginEnd: 2 }}>
                                <FontAwesome5 name="parking" size={24} color={this.state.marker === index ? "#3879f0" : "#000000"} />
                            </View>
                            {
                                item.empty !== false ? <View style={{ padding: 2, borderRadius: 2, backgroundColor: item.empty > 0 ? '#00cc96' : '#e63946', }}>
                                    <Text style={{ color: '#ffffff', fontWeight: 'bold', fontSize: 12 }}>{item.empty}</Text>
                                </View> : null
                            }
                        </View>
                        <View style={{ justifyContent: 'center' }}>
                            <FontAwesome5 name="sort-down" size={30} color={this.state.marker === index ? "#3879f0" : "#000000"} />
                        </View>
                    </View>

                </Marker>
            )
        }
        )
    )
}
renderListMarker=()=>{
设{markerList}=this.props;
返回(
markerList.map((项目,索引)=>{
返回(
{this.selectMarker(index)}
key={item.\u id}
协调={{
纬度:项目位置坐标[0],
经度:item.location.座标[1],
}}
>
{
item.empty!==false?0?'#00cc96':'#e63946',}>
{item.empty}
:null
}
)
}
)
)
}

tracksViewChanges={false}
我通过向标记tracksViewChanges添加道具解决了问题:设置此标记是否应跟踪视图更改。建议在可能提高自定义标记性能的情况下将其关闭。
tracksViewChanges={false}
I通过向标记tracksViewChanges添加道具解决了此问题:设置此标记是否应跟踪视图更改。只要有可能提高自定义标记器的性能,建议将其关闭。