我在这个问题中遇到了同样的问题: react-native - How to display map using react-native-maps
有人建议执行react-native link
来解决这个问题,但它对我不起作用。
这个问题还有其他解决方案吗?
屏幕:
import React, { Component } from 'react';
import { StyleSheet, View, Dimensions } from 'react-native';
import MapView from 'react-native-maps';
var { width, height} = Dimensions.get('window');
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,
width: width,
height: height
},
});
class TestMap extends Component {
constructor() {
super();
}
render() {
return (
<View style={ styles.container }>
<MapView
style={ styles.map }
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</View>
);
}
}
export default TestMap;