【发布时间】:2018-06-25 10:03:48
【问题描述】:
我正在使用 React-Native 为 Android 开发一个应用程序,它使用 react-native-maps 包。
在标记组件(react-native-maps)中有一个名为“image”的道具,它只能用于本地图像。但在我的情况下,我需要渲染远程图像 Url
<Marker
coordinate={marker.latlng}
image={require('../images/pin.png')}
/>
上面的代码工作正常,因为图像是静态的,但我需要渲染一个远程图像而不是 pin.jpg 那么有没有办法我可以这样做。
- 将远程网址下载到图像文件夹。
- 在标记组件中使用保存的图像 uri。
这是我想要实现的 - 类似于下面的代码
let path_to_save_image = '../images/'
some_package.fetch('http://www.example.com/image/new_image.png',
path_to_save_image, {
//some headers ..
})
.then((res) => {
console.log('The file saved ')
})
render (){
return (
<Marker
coordinate={marker.latlng}
image={require('../images/new_image.png')}
/>)
}
有什么办法可以做到吗?
我尝试过创建自定义标记,但没有成功。 #issue
【问题讨论】:
标签: javascript react-native react-native-maps