- 我想在React Native中的MapView上设置一个marker,但是在 MapView 的官方文档中找不到相关信息。
- 如果不允许这样做,我如何在 React Native 中使用现有的反应模块,例如 react-googlemaps ?
原文由 ivan wang 发布,翻译遵循 CC BY-SA 4.0 许可协议
原文由 ivan wang 发布,翻译遵循 CC BY-SA 4.0 许可协议
谢谢@naoufal。最后,我能够在地图上显示标记以响应本机 IOS。
<View style={styles.container}>
<MapView style={styles.map}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0,
longitudeDelta: 0.0,
}}
>
<MapView.Marker
coordinate={{latitude: 37.78825,
longitude: -122.4324}}
title={"title"}
description={"description"}
/>
</MapView>
</View>
对于地图和容器样式,我使用了以下样式:
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
map: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}
});
我参考了以下链接: React native IOS- Display Markers on map
原文由 BK19 发布,翻译遵循 CC BY-SA 3.0 许可协议
13 回答13.1k 阅读
7 回答2.3k 阅读
3 回答2.4k 阅读✓ 已解决
3 回答1.4k 阅读✓ 已解决
6 回答1.4k 阅读✓ 已解决
2 回答1.5k 阅读✓ 已解决
3 回答1.5k 阅读✓ 已解决
您可以使用
annotations
设置标记。例如: