【发布时间】:2019-12-11 12:24:48
【问题描述】:
我对原生和 firebase 的反应相对较新,如果有人能帮助我解决这个问题,那就太棒了。目前,当我向我的 firebase 收藏添加新帖子时,我会使用平面列表显示所有帖子,并且效果很好。但是是否可以只获取我的标记的 currentLatitude 和 currentLongitude ?我的目标是为每个帖子生成一个新标记。
Events = []
this.firestore.collection("Events").get().then(snapshot => {
snapshot.forEach(doc => {
Events.push(doc.data())
})
})
render() {
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
<MapView
provider={PROVIDER_GOOGLE}
mapType='hybrid'
showsUserLocation style={{flex: 1}}>
<MapView.Marker
coordinate={{latitude: //currentLatitude,
longitude: //currntLongitude}}
title={("Test")}
description={("Test")}
/>
</MapView>
</View>
</SafeAreaView>
);
}
}
【问题讨论】:
-
你的意思是“是否有可能只为我的标记获取 currentLatitude 和 currentLongitude?”你的应用程序中应该有什么最终结果?
-
感谢您回复@DevAS!我需要从我的 Firestore 文档中获取经纬度坐标,以将它们放入标记组件中。最终结果应该是存储在我的 Firestore 中的每个文档/帖子的标记。例如 airbnb。
-
那么问题出在哪里?正如我在最后一张图片中看到的那样,你得到了经纬度,然后你将它传递给标记!您在地图上看到的应该是位置标记
-
如果你有一些最终结果的 gif 或图像,这将有助于理解你想要实现的目标
标签: firebase react-native google-cloud-firestore react-native-maps