Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
134
rated 0 times [  140] [ 6]  / answers: 1 / hits: 17522  / 8 Years ago, thu, october 13, 2016, 12:00:00

I've started using https://github.com/airbnb/react-native-maps and having no luck drawing polylines from an array of array coordinates on the map.



I am not sure if I'm passing in the array of coordinates correctly.



this is how I am rendering the polyline:



      {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 looks like:



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


Thank you for any help/advice :D


More From » reactjs

 Answers
17

I think the coordinates must be an array of type LatLng as it is documented in the API.



How LatLng objects are created can be found in the component MapMarker for example. Here you can find the source code (linked to the relevant line) and the component API.



Hope this will help you,

Marius


[#60409] Tuesday, October 11, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
calicinthias

Total Points: 447
Total Questions: 101
Total Answers: 118

Location: Botswana
Member since Sat, Dec 31, 2022
1 Year ago
calicinthias questions
Sun, Jan 2, 22, 00:00, 2 Years ago
Wed, Jan 13, 21, 00:00, 3 Years ago
Mon, Aug 10, 20, 00:00, 4 Years ago
;