问题描述
项目描述
"react-native": "0.63.3","react-native-maps": "0.27.1"
我创建了两个页面,一个是Splash,另一个是Property details页面。我在“属性详细信息”页面中使用Mapview。如果我直接加载“属性详细信息”页面,则“ Mapview”工作正常,但是从初始页面导航时,会发生此错误。
PropertyDetails.jsx
import React,{ useState } from 'react';
import {
StyleSheet,Text,SafeAreaView,View,Dimensions,} from 'react-native';
import MapView,{ Marker,PROVIDER_GOOGLE } from "react-native-maps";
class PropertyDetails extends React.Component {
constructor(props) {
super(props);
this.state = {
show: false,region: {
latitude: 51.5078788,longitude: -0.0877321,latitudeDelta: 0.009,longitudeDelta: 0.009
}
}
}
componentDidMount() {
}
render() {
return (
<View style={styles.container}>
<MapView
provider={PROVIDER_GOOGLE}
style={styles.map}
region={{
latitude: 37.78825,longitude: -122.4324,latitudeDelta: 0.015,longitudeDelta: 0.0121,}}
>
</MapView>
</View>
);
}
}
export default PropertyDetails;
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,height: 400,width: 400,justifyContent: 'flex-end',alignItems: 'center',},map: {
...StyleSheet.absoluteFillObject,})
在Androidmanifest.xml中,我包含了API密钥和ACCESS_FINE_LOCATION权限。
android / app / build中的依赖项
dependencies {
implementation filetree(dir: "libs",include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation platform('com.google.firebase:firebase-bom:25.12.0')
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms',module: 'play-services-base'
exclude group: 'com.google.android.gms',module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:17.2.1'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'androidx.multidex:multidex:2.0.1'
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3',module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
请指导我我做错了什么。 谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)