我刚开始使用react-native-maps,当我运行我的代码时,我的iPhone6 Plus模拟器上出现了空白屏幕。
我经历了Blank Map #118问题。我执行npm link
命令,但我仍面临同样的问题。
下面是我的代码:
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
View,
} from 'react-native';
import Api from './src/api';
import MapView from 'react-native-maps';
const styles = StyleSheet.create({
container: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
},
});
class weather extends Component {
constructor() {
super();
}
render() {
return (
<MapView
style={ styles.map }
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
);
}
}
以下是我运行npm link
Ashok$ npm link
weather@0.0.1 /Users/Ashok/weather
└── react-native-maps@0.7.1
/usr/local/Cellar/node/6.1.0/libexec/npm/lib/node_modules/weather -> /Users/Ashok/weather
答案 0 :(得分:1)
1 - 确保您运行:
react-native link
react-native run-ios
2 - 确保google_api_key正确并已启用。
参考:https://github.com/airbnb/react-native-maps/blob/master/docs/installation.md
答案 1 :(得分:0)
再次尝试从头开始安装,但如果不是在从node_modules拖动文件夹,创建podfile和pod安装后,请不要给出react-native链接。