我正在使用react-native-maps在移动应用上实现地图。
我正在尝试在地图上绘制多边形,但目前在地图上不可见。
我正在用fillColor红色在指定坐标处绘制多边形。它应该很明显,但是在我的地图上却看不见。
我的代码有什么问题?
谢谢!
import React from 'react';
import MapView from 'react-native-maps';
import Polygon from 'react-native-maps';
import { Dimensions, StyleSheet, Text, View, Button } from 'react-native';
export default class Buttons extends React.Component {
static navigationOptions = {
title: 'Buttons',
};
render() {
return (
<View style={styles.container}>
<MapView
style={styles.mapStyle}>
<Polygon
coordinates={[
{ latitude: 40.785091, longitude: -73.968285 },
{ latitude: 40.78509386, longitude: -73.968285 },
{ latitude: 40.7678548, longitude: -73.968285 },
{ latitude: 41.7709153, longitude: -78.968285 },
{ latitude: 40.77850605, longitude: -79.968285 },
{ latitude: 40.8025259, longitude: -79.968285 }
]}
fillColor='red'
strokeColor='black'
strokeWidth={100}
/>
</MapView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
mapStyle: {
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
},
});