我试图让最基本的地图显示在我的React Native应用中,但它只显示一个空白屏幕。 这是我的代码...
import React from 'react';
import {
StyleSheet,Text,View,Image,Button
} from 'react-native';
//Import map
import MapView from 'react-native-maps';
class TodaysJobs extends React.Component {
render() {
return (
<MapView
initialRegion={{
latitude: 37.78825,longitude: -122.4324,latitudeDelta: 0.0922,longitudeDelta: 0.0421,}}
/>
);
}
}
export default TodaysJobs;
const styles = StyleSheet.create({
logo: {
width: '60%',resizeMode: 'contain'
},navButton: {
width: '60%',marginTop: 20,flex: 1
}
});
如果我尝试使用import { MapView } from 'react-native-maps';
则会收到此错误...
警告:React.createElement:类型无效-预期为字符串(对于内置组件)或类/函数(对于复合组件),但得到:%s。%s%s,未定义,您可能忘记了从其定义的文件中导出组件,或者您可能混淆了默认导入和命名导入。
我的app.json API如下:
"android": {
"config": {
"googleMaps": {
"apiKey": "MYAPIKEYkmdsa;jfpjP(pJPOEFKm;"
}
}
}