如何解决从一页导航到另一页时,更新由Airmap管理的视图的属性“初始区域”时发生错误
项目描述
"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 举报,一经查实,本站将立刻删除。