我想将我的自定义图像显示为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>。这正成为一个麻烦。
发布于 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
复制相似问题