Теперь я хотел бы установить несколько маркеров на реактивных картах, но мой код ниже не работает.
Я искал эту проблему и пробовал и ошибку. Однако я не смог.
class Map extends React.Component {
constructor(props) {
super(props);
this.state = {
markers: [
{
coordinates:
{
latitude: this.props.latitude,
longitude: this.props.longitude,
},
}
],
};
}
/* eslint no-unused-expressions: "off" */
renderMapMarker() {
return this.state.markers.map((value, index) => {
<MapView.Marker
index={index}
coordinate={value.coordinates}
>
<Icon name="map-marker" size={40} color="red" />
</MapView.Marker>;
});
}
render() {
const { style } = this.props;
const { latitude, longitude } = this.props;
return (
<MapView
style={style}
initialRegion={{
latitude,
longitude,
latitudeDelta: 0.005,
longitudeDelta: 0.005,
}}
>
{this.renderMapMarker()}
</MapView>
);
}
}
Не могли бы вы дать мне совет?