0

我在这个问题中遇到了同样的问题: 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;
4

1 回答 1

0

尝试像这样重写您的样式:

const styles = StyleSheet.create({
  container: { 
    flex: 1,
  },
  map: {
    flex: 1,
  },
});
于 2016-12-22T16:44:39.177 回答