【发布时间】:2021-03-21 02:59:48
【问题描述】:
通过使用这篇文章https://medium.com/@clarkjohnson_85334/adding-fetched-markers-to-my-react-native-maps-app-5f068c7be14d,我设法将观察结果整合到我的 MapView 中。
mapMarkers = () => {
return this.state.items.map((item) => <Marker
key={item.id}
coordinate={{ latitude: item.geoLocation.latitude, longitude: item.geoLocation.longitude }}
title={item.acceptedVernacularName}
description={item.scientificName}
>
</Marker >)
}
但是,我还没有设法根据鸟类的类型将不同的图像添加到标记中。是否有可能制作一个可以与需要字符串的 Marker image={} 道具一起使用的函数?我的想法是应该使用 require('../assets/xx') 将图像设置为本地,但基于 id 或鸟的名称 (acceptedVernacularName)。
【问题讨论】:
标签: javascript json react-native sorting