[英]How to enable tilt with react-native-maps?
要倾斜地图并从另一个角度查看,请使用animateToViewingAngle
。
我知道 iOS 本身就支持它,所以你应该期待 iOS 上的默认行为。 但是,我不确定Android。
更多信息,请访问此GitHub 线程。
这是一个对我有用的代码片段
import React from 'react';
import MapView from 'react-native-maps';
import { StyleSheet, Text, View, Dimensions } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<MapView
showsBuildings
ref={ref => { this.map = ref }}
onLayout={() => {
this.map.animateToBearing(125);
this.map.animateToViewingAngle(45);
}}
initialRegion={{
latitude: 41.8781,
longitude: -87.6298,
latitudeDelta: 1 / 300,
longitudeDelta: 2 / 300
}}
style={styles.mapStyle}
/>
</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,
},
});
小吃演示https://snack.expo.io/Sym1DTm0r (工作时间为 2019 年 12 月)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.