Try*_*rog 3 reactjs react-native react-native-maps
我有一个带有标记的地图屏幕,我尝试将图像添加到标注中,并且使用<image source = .. /> 与在其他有效地方相同的方法,但在地图上它不会向我显示图片。
{
this.state.markers.map(marker => (
<MapView.Marker
key={marker.id}
coordinate={{longitude: marker.longitude, latitude: marker.latitude}}>
<MapView.Callout>
<View>
<View>
{marker.imageUri && <Image source = {{uri: marker.imageUri}}
style = {{ width: '90%', height: 100, justifyContent: 'center', flex: 1, alignContent: 'center', resizeMode: 'stretch'}}
/> }
</View>
<Text>Lat: {marker.latitude}, Lon: {marker.longitude}</Text>
<Text>{marker.email}</Text>
</View>
</MapView.Callout>
</MapView.Marker>
))
}
Run Code Online (Sandbox Code Playgroud)
它给了我一个空白视图而不是图像。我有做错什么吗?
小智 5
在文本组件中使用图像,这很奇怪,但它有效:)
<Text> <Image style={{ height: 100, width:100 }} source={{ ... }} resizeMode="cover" /> </Text>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1737 次 |
| 最近记录: |