最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React-Native-Maps how to draw polylines - Stack Overflow

programmeradmin5浏览0评论

I've started using 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

I've started using https://github./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

Share Improve this question asked Oct 13, 2016 at 11:57 douglaswissettdouglaswissett 2411 gold badge4 silver badges14 bronze badges 1
  • How did you get the Array of Lat and Lng ??? [ [lat,lng ],[lat,lng ] ] . .??\ – Beckham_Vinoth Commented Oct 3, 2017 at 9:34
Add a ment  | 

1 Answer 1

Reset to default 2

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 ponent MapMarker for example. Here you can find the source code (linked to the relevant line) and the ponent API.

Hope this will help you,
Marius

发布评论

评论列表(0)

  1. 暂无评论