我为我的react-native应用程序使用了react-native-map。我需要在地图上的MapView上张贴图像。但是,我从网络上得到了图片。然而,据我所知,只有本地图像可以添加到react-native-map中的Mapview。你知道在react-native-maps MapView
中从uri
上传图片的方法吗?
我试着用
<MapView style={{flex: 1}}
loadingEnabled={true}
region={this.state.region}
onRegionChangeComplete={this.onRegionChangeComplete}>
<MapView.Marker
coordinate={{latitude: this.props.user_location[0], longitude: this.props.user_location[1]}}
title={this.props.user_name}
description={this.props.user_desc}>
<Image source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}} />
</MapView.Marker>
</MapView>
结果就是
然后我用下面的命令删除了<Image/>
<MapView style={{flex: 1}}
loadingEnabled={true}
region={this.state.region}
onRegionChangeComplete={this.onRegionChangeComplete}>
<MapView.Marker
coordinate={{latitude: this.props.user_location[0], longitude: this.props.user_location[1]}}
title={this.props.user_name}
description={this.props.user_desc}>
</MapView.Marker>
</MapView>
结果就是
发布于 2017-09-10 23:02:44
你可以试试custom marker view
<MapView.Marker coordinate={marker.latlng}>
<Image source={{uri: 'http://someCustomImageURL' }} />
</MapView.Marker>
发布于 2017-09-11 05:37:15
我找到路了。
实际上,我在我的应用程序中使用了Native-Base。因此,组件Thumbnail
是从Native-base导入的。
我的代码是这样的
<MapView style={{flex: 1, justifyContent: 'space-between'}}
loadingEnabled={true}
region={this.state.region}
onRegionChangeComplete={this.onRegionChangeComplete}>
<MapView.Marker
coordinate={{latitude: this.props.user_location[0], longitude: this.props.user_location[1]}}
title={this.props.user_name}
description={this.props.user_desc}>
<View>
<Thumbnail source={{uri: this.props.user_photo}} />
</View>
</MapView.Marker>
</MapView>
https://stackoverflow.com/questions/46142065
复制相似问题