我的地图运行良好,但是当我放大地图时会产生振动效果,并且不会发生缩放。下面是我的代码:
this.showDirection(this.props.pickUpAddress, this.props.destAddress);
return (
<MapView.Polyline
coordinates={this.state.coords}
strokeWidth={2}
strokeColor={commonColor.brandPrimary}
/>
);
async showDirection(startLoc, destinationLoc) {
try {
let resp = await fetch(
`https://maps.googleapis.com/maps/api/directions/json?origin=${startLoc}&destination=${destinationLoc}`
);
let respJson = await resp.json();
let points = Polyline.decode(respJson.routes[0].overview_polyline.points);
let distance = respJson.routes[0].legs
.map(leg => leg.distance.value)
.reduce((a, c) => a + c);
let coords = points.map((point, index) => {
/*console.log("lat and long are");
console.log(point);*/
return {
latitude: point[0],
longitude: point[1]
};
});
this.setState({ coords: coords });
} catch (error) {
console.log(error);
}
}
谢谢。