我一直在使用来自https://github.com/lelandrichardson/react-native-maps/blob/master/docs/installation.md的React-Native-Maps库
我已经完成所有灌输步骤,但是仍然收到空白屏幕(整个反应屏幕都是白色的,就像什么都没有渲染一样)。
但是,当我尝试在react中渲染元素时,会弹出文本。因此,我的地图未显示是我实施该库的结果,而不是react问题。
这是我的index.android.js页面代码
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import MapView from 'react-native-maps';
class roads extends Component {
render() {
return (
<View style={styles.container}>
<MapView
style={styles.map}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
map: {
position: 'absolute',
top: 0,
left: 0,
},
});
AppRegistry.registerComponent('roads', () => roads);
我也在手机上收到此错误消息
warning encountered 4 times.
Show Stacktrace
Unable to symbolicate stack trace: The stack is null
这是我找到的有关错误的最接近的线程,但应将其修复... https://github.com/facebook/react-native/issues/8311
我还检查了我在Google Developers Console上的API密钥的权限,但仍然无法显示我的地图(它表示它正在接收API请求)。那么,有谁知道如何在我的应用程序中实现google maps?
Map组件没有任何可用于确定其大小的属性。因此,它是0x0像素大而看不见。为了解决此问题,您需要将以下属性之一添加到styles.map
:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句