首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在react-native-maps MapView中使用远程图像uri

在react-native-maps MapView中使用远程图像uri
EN

Stack Overflow用户
提问于 2017-09-10 22:56:45
回答 2查看 1.5K关注 0票数 0

我为我的react-native应用程序使用了react-native-map。我需要在地图上的MapView上张贴图像。但是,我从网络上得到了图片。然而,据我所知,只有本地图像可以添加到react-native-map中的Mapview。你知道在react-native-maps MapView中从uri上传图片的方法吗?

我试着用

代码语言:javascript
复制
<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/>

代码语言:javascript
复制
<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>

结果就是

EN

回答 2

Stack Overflow用户

发布于 2017-09-10 23:02:44

你可以试试custom marker view

代码语言:javascript
复制
<MapView.Marker coordinate={marker.latlng}>
  <Image source={{uri: 'http://someCustomImageURL' }} />
</MapView.Marker>
票数 0
EN

Stack Overflow用户

发布于 2017-09-11 05:37:15

我找到路了。

实际上,我在我的应用程序中使用了Native-Base。因此,组件Thumbnail是从Native-base导入的。

我的代码是这样的

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46142065

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档