我正在使用airbnb的react-native-maps库来开发我的用于android的本机应用程序.此应用程序在主页上显示地图和汽车图标.
它工作正常但是当汽车在行驶并且汽车坐标连续变化时,地图不能平滑地渲染.带有汽车图标的MapView标记沿着路径从一个点跳到另一个点.我的期望是在地图上显示连续移动的物体,就像它在谷歌地图上显示的那样.
这是我的代码:
this.state = {
latitude: 22.55231,
longitude: 88.56772,
angle: 0
}
componentDidMount(){
navigator.geolocation.getCurrentPosition(
position => {
let latitude = position.coords.latitude;
let longitude = position.coords.longitude;
let angle = position.coords.heading;
this.setState({latitude, longitude, angle});
},
error => console.log(error),
{
// enableHighAccuracy: true
}
);
navigator.geolocation.watchPosition(
position => {
let latitude = position.coords.latitude;
let longitude = position.coords.longitude;
let angle = position.coords.heading;
this.setState({latitude, longitude, angle});
},
error => console.log(error),
{
// enableHighAccuracy: true
}
);
}
getMapRegion(){
return {
latitude: this.state.latitude,
longitude: this.state.longitude, …Run Code Online (Sandbox Code Playgroud) javascript react-native react-native-android react-native-maps