我是react native的新手,想问一下如何在 map 中渲染多个标记.
这是我的密码
课堂内:-
constructor(props) {
super(props);
this.state = {
coordinate: ([{
latitude: 3.148561,
longitude: 101.652778,
title: 'hello'
},
{
latitude: 3.149771,
longitude: 101.655449,
title: 'hello'
}
]),
};
}
内部渲染:-
<MapView
style={styles.map}
showsUserLocation={true}
followUserLocation={true}
zoomEnabled={true}
//annotations={markers}
>
<MapView.Marker
coordinate={this.state.coordinate}
title={this.state.coordinate.title}
/>
</MapView>
我想在 map 中渲染这两个标记,但我不知道如何在react native中创建循环来渲染它.我已经try 了文档中的内容,但仍然不起作用.
提前感谢:)