在 React 本机映射中裁剪快照仅路由



我想知道是否有人知道如何在反应原生地图中拍摄路线快照,这是拼车公司在用户查看以前的行程时所拥有的。我能够使用以下代码拍摄快照,尽管我注意到高度、宽度、区域属性没有。

takeLocationSnapshot() {
const { location: { longitude, latitude, } } = this.state;
const snapshot = this.mapView.takeSnapshot({
width: 300,      // optional, when omitted the view-width is used
height: 300,     // optional, when omitted the view-height is used
region: {
latitude,
longitude,
LONGITUDEDELTA,
LATITUDEDELTA,
},
// iOS only, optional region to render
format: 'jpg',   // image formats: 'png', 'jpg' (default: 'png')
quality: 0.7,    // image quality: 0..1 (only relevant for jpg, default: 1)
result: 'file'   // result types: 'file', 'base64' (default: 'file')
});
snapshot.then((uri) => {
this.props.locationSnapshotChange(uri);
});
}

<View style={styles.imageContentWrap}>
<Image
source={imageSource}
style={styles.imageStyle}
/>
</View>
imageContentWrap: {
flexWrap: 'wrap',
backgroundColor: 'green',
flex: 0.58,
},
imageStyle: {
flexWrap: 'wrap',
width: '100%',
height: '100%',
resizeMode: 'cover',
overflow: 'hidden',
},

只需使用固定高度和溢出隐藏的包装器,并为图像样式添加绝对位置的顶部属性

最新更新