Tab内的react-native-maps无法正常工作

时间:2017-09-02 05:25:15

标签: react-native react-native-maps

我在标签中显示<MapView />时遇到问题。我正在使用react-native-scrollable-tab-view

即使在使用<MapView />后,...StyleSheet.absoluteFillObject也不会在地图中显示。只有在我修正高度时才可以显示地图。例如:height: 500

以下是我的示例标签屏幕的样子。

styles = StyleSheet.create({
  tabContent: {
    flex: 1,
  },

  map: {
    ...StyleSheet.absoluteFillObject,
  },
});

class HomeTemporary extends Component {
  render() {
    return (
      <ScrollableTabView
        renderTabBar={() => <ScrollableTabBar />}
      >
        <ScrollView tabLabel="List" style={styles.tabContent}>
          <Text>Content Tab One</Text>
        </ScrollView>
        <ScrollView tabLabel="Map" style={styles.tabContent}>
          <MapView
            scrollEnabled
            style={styles.map}
            provider={MapView.PROVIDER_GOOGLE}
            initialRegion={{
              latitude: 25.2048493,
              longitude: 55.2707828,
              latitudeDelta: LATITUDE_DELTA,
              longitudeDelta: LONGITUDE_DELTA,
            }}
          />
        </ScrollView>
      </ScrollableTabView>
    );
  }
}

See picture

1 个答案:

答案 0 :(得分:1)

绝对是什么?如果视图内部的地图,视图组件还必须指定宽度和高度的绝对值。在您的情况下为tabContent