簡體   English   中英

如何使用 mapquest 坐標數據在 react-native-maps 中渲染方向坐標?

[英]How to render directions coordinates in react-native-maps using mapquest coordinates data?

我正在嘗試使用 MapQuest REST API 中的坐標在 map 上渲染方向折線,但我得到的折線沒有准確地顯示在道路頂部。 相反,它顯示了一個不同的 output。我想准確地在道路頂部繪制多段線。 我發送以下請求以獲取路線(使用 MapQuest Directions Route API):

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

然后根據上面的請求 session 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 ,我應該如何在 map 的道路上方正確繪制折線?

我正在使用的代碼:

<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>

下面是我得到的當前 map 的屏幕截圖:

在此處輸入圖像描述

嘗試將 generalize 選項設置為較低的值,例如 0 或 10。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM