[英]react-native-maps markers in loop are not rendered
我正在尝试学习如何为iOS创建React本机应用程序。 我使用react-native-maps
包,当我静态渲染MapView.Marker
,它会正确渲染到地图。 但是,当我要渲染标记数组时,什么也没发生。
export default (props) => {
return (
<MapView
initialRegion={{
latitude: 48.99568000,
longitude: 21.24220000,
latitudeDelta: 0.001,
longitudeDelta: 0.01
}}>
{/* this works */}
<MapView.Marker
coordinate={{
latitude: 48.98975,
longitude: 21.24697
}}
/>
{/* this doesn't */}
{
props.points.nearby.map(point => {
<MapView.Marker
coordinate={{
latitude: point.lat,
longitude: point.lng
}}
/>
})
}
</MapView>
);
}
props.points.nearby
数组还可以,有三项
解:
正如我意识到的那样, 带有块体的ES6箭头函数不会隐式return ,所以我在map
回调中添加了return
语句,现在一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.