如何使用mapquest坐标数据在react-native-maps中渲染方向坐标?

问题描述

我正在尝试使用来自MapQuest REST API的坐标在地图上绘制路线多段线,但是我却无法完全显示多段线在道路顶部。而是显示不同的输出。 我想精确地在道路上绘制多段线。我正在发送以下请求以获取路线(使用MapQuest Directions Route API):

http://www.mapquestapi.com/directions/v2/optimizedroute?key=[API_KEY]&json={%22locations%22:[%2234.0120337,-6.7592364%22]}

然后根据上述请求会话ID,我正在发送另一个请求以获取坐标(使用MapQuest Directions Route Shape API):

http://www.mapquestapi.com/directions/v2/routeshape?key=[API_KEY]&sessionId=[ABOVE_REQUEST_SESSION_ID]&mapWidth=320&mapHeight=240&mapScale=1733371&mapLat=34.0120337&mapLon=-6.7383617

我正在使用数组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>

以下是我正在获取的当前地图的屏幕截图:

enter image description here

解决方法

尝试将generalize选项设置为较低的值,例如0或10。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...