【发布时间】:2018-05-28 17:57:46
【问题描述】:
【问题讨论】:
标签: reactjs react-native react-native-maps
【问题讨论】:
标签: reactjs react-native react-native-maps
要倾斜地图并从另一个角度查看,请使用animateToViewingAngle。
我知道 iOS 本身就支持它,所以你应该在 iOS 上默认这种行为。但是,我不确定Android。
更多信息,请访问GitHub Thread。
【讨论】:
this.map.animateToRegion 用于渲染下一个带有一点动画的位置。你能详细说明你的问题吗?
pitchEnabled btw。
animateToViewingAngle() 它的工作是我想要的。谢谢你的工作
这是一个适合我的代码 sn-p
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 月)
【讨论】: