React-Native-Maps 如何绘制折线
React-Native-Maps how to draw polylines
我已经开始使用 https://github.com/airbnb/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]]
感谢任何 help/advice :D
我认为坐标必须是 LatLng
类型的数组,如 API.
中所述
LatLng
对象是如何创建的,例如可以在组件 MapMarker
中找到。在这里你可以找到 source code (linked to the relevant line) and the component API.
希望对您有所帮助,
马吕斯
我已经开始使用 https://github.com/airbnb/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]]
感谢任何 help/advice :D
我认为坐标必须是 LatLng
类型的数组,如 API.
LatLng
对象是如何创建的,例如可以在组件 MapMarker
中找到。在这里你可以找到 source code (linked to the relevant line) and the component API.
希望对您有所帮助,
马吕斯