OGeek|极客世界-中国程序员成长平台

标题: ios - React 原生 map 集成 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:29
标题: ios - React 原生 map 集成

我正在尝试将 map 集成到 native react 中。我正在遵循以下教程。 https://github.com/airbnb/react-native-maps

我浏览了所有的安装说明。 我正在使用 react-native 版本:0.44.0react-native-map 版本:0.13.0 我确保 react-native-link 与 android 和 iOS 链接。 在 ios 模拟器中渲染 map View 时, map 没有显示,只有我能够显示带有红色轮廓的空白 map 。

请检查我下面的代码,让我知道我哪里错了。

var MapView = require('react-native-maps');
<MapView
    initialRegion={{
    latitude: 37.78825,
    longitude: -122.4324,
    latitudeDelta: 0.0922,
    longitudeDelta: 0.0421,
    }}
/>



Best Answer-推荐答案


尝试添加一个 View 和一些高度和 ...StyleSheet.absoluteFillObject

<View style={{height:400}}>
    <MapView 
         style={{ ...StyleSheet.absoluteFillObject,height:400 }}
         initialRegion={{
             latitude: 37.78825,
             longitude: -122.4324,
             latitudeDelta: 0.0922,
             longitudeDelta: 0.0421,
         }}
    />
</View>

关于ios - React 原生 map 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45622366/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4