gpt4 book ai didi

react-native - React Native Maps - takeSnapshot 不捕获标记

转载 作者:行者123 更新时间:2023-12-04 11:38:55 31 4
gpt4 key购买 nike

react 原生:https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz
react :16.13.1
react 原生 map :0.28.0
我想将标记作为快照的一部分。当我们使用 takeSnapshot方法所有标记都被忽略。

const snapshot = this.viewRefTest.takeSnapshot({
format: 'png', // image formats: 'png', 'jpg' (default: 'png')
quality: 0.5, // image quality: 0..1 (only relevant for jpg, default: 1)
result: 'file', // result types: 'file', 'base64' (default: 'file')
});

<MapView
ref={(viewRefTest) => {
this.viewRefTest = viewRefTest;
}}
showsUserLocation={true}
followUserLocation={true}>
<MapView.Marker coordinate={item.location}>
<Image
style={{ width: 30, height: 30 }}
source={require('../../assets/images/trophy.png')}
/>
<Callout style={{ width: 250, flexDirection: 'row', alignItems: 'center' }}>
<Text>$23</Text>
<View>
<Text style={{ fontSize: 12 }}>Custom Text!</Text>
</View>
</Callout>
</MapView.Marker>
</MapView>;
请让我知道这种可能性。

最佳答案

您可以尝试使用宽度和高度吗?

const snapshot = this.viewRefTest.takeSnapshot({
width: 500,
height: 500,
format: 'png',
quality: 0.5,
result: 'file',
});

snapshot.then((uri) => {
console.log(uri);
});

关于react-native - React Native Maps - takeSnapshot 不捕获标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69095346/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com