2016-10-13 59 views
1

我已經開始使用https://github.com/airbnb/react-native-maps,並且沒有運氣從地圖上的數組座標數組繪製多段線。我不確定是否正確地傳入座標數組。React-Native-Maps如何繪製多段線

這是怎麼了渲染的折線:

 {this.state.polylines.map(polyline => (
     <MapView.Polyline 
      key={polyline.id} 
      coordinates={polyline.coordinates} 
      strokeColor="#000" 
      fillColor="rgba(255,0,0,0.5)" 
      strokeWidth={1}/> 
    ))} 

polyline.coordinates樣子:

 [[lat,lng],[lat,lng],[lat,lng]] 

感謝您的幫助/建議:d

+0

你是怎麼弄到的緯度和液化天然氣的陣列??? [[lat,lng],[lat,lng]]。 。\ –

回答

1

我想座標必須是LatLng的數組,如API中所記錄。

如何創建對象LatLng可以在組件MapMarker中找到。在這裏您可以找到source code(鏈接到相關行)和component API

希望這會幫助你,
馬呂斯

+0

你是對的,MapView.Polyline組件採用一個prop座標,它應該是一個lat/lng座標對對象的數組。 – douglaswissett

+0

謝謝你的幫助! – douglaswissett

+0

不客氣。很高興聽到這可以解決您的問題:) – mrunde