繁体   English   中英

不会渲染循环中的react-native-maps标记

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM