【问题标题】:can't render <MapView/> from react-native-maps无法从 react-native-maps 渲染 <MapView/>
【发布时间】:2018-05-08 05:55:33
【问题描述】:

我正在尝试使用示例中的坐标显示本机地图,但出现错误:

*注意 使用ios和真机调试

错误:

Could not inset compass from edges 9
Could not inset scale from edge 
Could not inset legal attribution from corner 4

代码:

class Map extends Component {
constructor(props) {
    super(props);
}
render() {   
    console.log('map render')    
    return (
            <MapView 
            provider={null}
            initialRegion={{
            latitude: 37.78825,
            longitude: -122.4324,
            latitudeDelta: 0.0922,
            longitudeDelta: 0.0421,
            }}
        />
    );
}}

项目示例:HERE

【问题讨论】:

  • 任何错误或警告?
  • 是的,前三行是我得到的错误

标签: reactjs react-native react-native-ios react-native-maps


【解决方案1】:

样式有问题。我可以用这段代码修复它:

render() {
    return (
      <View style={styles.container}>
        <MapView
        style={styles.map}
          provider={null}
          initialRegion={{
            latitude: 37.78825,
            longitude: -122.4324,
            latitudeDelta: 0.0922,
            longitudeDelta: 0.0421,
          }}
        />
      </View>
    );
  }
}

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,
  },
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-06
    相关资源
    最近更新 更多