react原生hms映射映射为空白



我有一个react原生应用程序,我目前正在努力使其符合华为的HMS APK,以便使用Mate 30或P40设备的用户可以使用我们的应用程序。

我已经删除了本版本的react native映射,并按照华为hms Core Developer Guides for react native中的说明将其替换为react nativehms映射。

当我运行应用程序,导航到渲染地图的屏幕时,只显示一个空白页面。在运行logcat的应用程序时,我能够在日志中指出这个错误:

2020-09-01 23:23:27 23608-23608/? I/MapRender: ERROR MapView.cpp:296: MapView::[SwitchMapType] enter!

我不知道这是否与我的问题有关。

我的react本机代码如下:

import HMSMap from 'react-native-hms-map';
...other code....
render = () => {
const address = this.state.address;
return (
<View style={styles.container}>
<HMSMap
style={styles.map}
initialRegion={{
latitude: 37.78825,
longitude:  -122.4324,
latitudeDelta:  0.0922,
longitudeDelta:  0.0421,
}}
/>
</View>
);
};

我的风格对象看起来是这样的:

container: {
...StyleSheet.absoluteFillObject,
justifyContent: 'flex-end',
alignItems: 'center',
borderColor: 'black',
borderWidth: 2
},
map: {
...StyleSheet.absoluteFillObject
}

你知道我做错了什么吗?

您使用的是旧版本的React Native Map插件4.0.2,它将在2020年7月30日后离线,这导致了此问题。

在文档的"版本更改历史"部分添加了一条注释,请参阅。

您可以参考文章HMS Map Kit Eluciated:Using React Native了解如何在React Nation中集成HMS Map。

最新更新