3
Hye,Im新的反應本地化並想問我如何在地圖中渲染多個標記。在react-native-maps中渲染多個標記
這是我的代碼
內部類: -
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>
我想渲染裏面的地圖和我這兩個標記不知道如何在原生反應中做出循環來渲染它。我已經嘗試了文檔中的內容,但仍然無法工作。
預先感謝您:)
謝謝!在此之前,我誤解了如何構建座標的屬性,因爲我遵循react-native的MapView。再次感謝。你真的幫助我很多:)有一個美好的一天^ _^ –
出於某種原因,這個確切的代碼不適合我。 –
對我來說,我不得不添加一個'index'和'key'。 '{this.state.markers.map((標記指數)=>( \t \t \t \t \t \t \t \t \t \t))}'' –