我想将我的自定义图像显示为react-native-maps中的标记,如下所示,但它没有在地图上显示任何内容
<MapView
style={{ flex: 1 }}
region={this.state.region}
ref={ref => { this.map = ref; }}
zoomControlEnabled={true}
>
<MapView.Marker
identifier="destination"
coordinate={direction.destination}
anchor={{ x: 0.5, y: 0.5 }}
>
<View style={{ width: 10, height: 10 }}>
<Image source={require('../assets/images/destination-3.png')} style={{ width: 10, height: 10 }}/>
</View>
</MapView.Marker>
</MapView>我可以看到<MapView.Marker>中的任何元素,除了<Image/>和<ImageBackground>。这正成为一个麻烦。
发布于 2018-12-23 13:24:19
对我来说唯一可行的解决方案是使用svg方法在svg中呈现图像,而不是通过直接反应本地图像来呈现。
<Svg
height="50"
width="50"
key={2000}
>
<Image
key={200}
width="90%"
height="90%"
href={require('../assets/images/destination-3.png')}
/>
</Svg>如果我想在第一次看到它的话,我已经在页面中显示了这个svg超过两次!(并且给出负的顶部和左边的绝对位置来隐藏它)
发布于 2019-04-17 12:52:46
我已经使用GIMP ()将我的图像最小化为一个图标大小(在GIMP中打开的图像->图像->刻度->给出了您想要的大小。)我的代码是这样的
<MapView
initialRegion={this.state.loc}
region={this.state.loc}
style={styles.map}
>
<Marker coordinate={{
latitude: 7.093546,
longitude: 79.993703,}}
image={require('./img/icon.png')} >
</Marker>
</MapView>希望这有帮助..。

https://stackoverflow.com/questions/53828626
复制相似问题