react-native-gmaps选项不起作用

时间:2016-08-20 10:40:06

标签: react-native-android

我使用npm安装了react-native-maps-google软件包,并按照网站上提到的步骤(https://www.npmjs.com/package/react-native-maps-google)进行了操作。目前我只能在屏幕上查看地图。显示的选项如 showUserLocation cameraPosition 不起作用。下面提到了代码段。

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Dimensions
} from 'react-native';
import { GoogleMap } from 'react-native-maps-google';

const percentage = Dimensions.get('window').height * 0.5;

class App extends Component {
  render() {
    return (
      <View style = {styles.container}>
        <GoogleMap style = {styles.map}
        showsUserLocation={true}
        scrollGestures={true}
        zoomGestures={true}
        tiltGestures={true}
        rotateGestures={true}
        consumesGesturesInView={true}
        compassButton={true}
        myLocationButton={true}
        indoorPicker={true}
        allowScrollGesturesDuringRotateOrZoom={true}
         />
      </View>
    );

  }
}

const styles = StyleSheet.create({
  container: {
    position: 'absolute',
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
    justifyContent: 'center',
    alignItems: 'center',
    flex:1,
  },
  map: {
    position: 'absolute',
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
    height: percentage,
    flex:1,
  },
});

AppRegistry.registerComponent('map', () => App);

0 个答案:

没有答案