问题描述
我正在尝试使用来自MapQuest REST API的坐标在地图上绘制路线多段线,但是我却无法完全显示多段线在道路顶部。而是显示不同的输出。 我想精确地在道路上绘制多段线。我正在发送以下请求以获取路线(使用MapQuest Directions Route API):
然后根据上述请求会话ID,我正在发送另一个请求以获取坐标(使用MapQuest Directions Route Shape API):
我正在使用数组route.shape.shapePoints
,我应该如何正确地在地图上的道路上方绘制折线?
我正在使用的代码:
<MapView
style={{ flex: 1 }}
showsUserLocation
initialRegion={{
latitude,longitude,latitudeDelta: 0.0922,longitudeDelta: 0.0421
}}
>
<MapView.Polyline strokeWidth={2} strokeColor="red" coordinates={this.state.coords}></MapView.Polyline>
</MapView>
以下是我正在获取的当前地图的屏幕截图:
解决方法
尝试将generalize选项设置为较低的值,例如0或10。