0
我有一個iOS的反應本機應用程序在它的地圖,我試圖得到一些關於它的標記,但我不斷收到以下錯誤ReactNative添加標記到地圖中的異常標記,預計
意外令牌,預計...
任何人都知道這裏發生了什麼?
這是我的構造函數:
constructor(props) {
super(props);
this.state = {
isFirstLoad: true,
annotations: [],
mapRegion: undefined,
markers: [{
title: 'Marker1',
coordinates: {
latitude: 3.148561,
longitude: 101.652778
},
},
{
title: 'Marker2',
coordinates: {
latitude: 3.149771,
longitude: 101.655449
},
}]
};
}
我的渲染功能:
return (
<MapView
style={ styles.map }
onRegionChangeComplete={onRegionChangeComplete}
region={this.state.mapRegion}
annotations={this.state.annotations}
zoomEnabled={true}
showsUserLocation={true}
{this.state.markers.map(marker => (
<MapView.Marker
coordinate={marker.coordinates}
title={marker.title}
/>
))}
/>
);
據抱怨這一行:{this.state.markers.map(marker => (
任何幫助是非常讚賞:)
這真的幫我動態放置MapMarker動態。 BTW,marker.coordinates和marker.title僅僅是邏輯名稱。我們可以使用其他的東西,比如marker.geoposition和marker.businessname。但是在我看到的所有代碼示例中,我只能看到marker.coodinates等等。僅供參考。 –