我尝试在react-native上累积maps标记。.但是我没有在我的android上获得更改标记。.在我编写类似波纹管的代码后,该应用始终会强制关闭。.请帮助..谢谢。>
render() {
return (
// <View style={styles.container}>
<MapView
ref={ref => myMap = ref}
style={{
flex: 1
}}
region={this.props.region}
showsUserLocation={true}
>
{
this.state.data.map((value, key) => {
return (
<MapView.Marker
coordinate={{ latitude: value.region.latitude, longitude: value.region.longitude }}
key={key}
title={value.title}
description={value.desc}
image={require('../../../Assets/Ruko.png')}
onPress={() => {
myMap.fitToCoordinates([{ latitude: value.region.latitude, longitude: value.region.longitude }], {
edgePadding: { top: 10, bottom: 10, left: 10, right: 10 },
animated: true
});
this.clickDetail(value.id);
}}>
</MapView.Marker>
)
})
}
</MapView>
// </View>
);
答案 0 :(得分:0)
将图像添加到标记道具。
<MapView.Marker
coordinate={{ latitude: value.region.latitude, longitude: value.region.longitude }}
key={key}
title={value.title}
description={value.desc}
onPress={() => {
myMap.fitToCoordinates([{ latitude: value.region.latitude, longitude: value.region.longitude }], {
edgePadding: { top: 10, bottom: 10, left: 10, right: 10 },
animated: true
});
this.clickDetail(value.id);
}}>
<Image source={require('../../../Assets/Ruko.png')}
style={{height: 35, width:35 }} />
</MapView.Marker>