React-Native-Maps 如何从数组列表中绘制折线?

React-Native-Maps how to draw polylines From Array List?

我已经开始使用 https://github.com/airbnb/react-native-maps 并且无法从地图上的数组坐标数组中绘制多段线。

我不确定我是否正确传递了坐标数组。

这就是我渲染折线的方式:

这是包含坐标的 api link:https://run.mocky.io/v3/e42d76ce-2ac8-4199-9f2c-e5b611960d38

我有这样的代码。

 <MapView
            style={styles.mapStyle}
            provider={PROVIDER_GOOGLE}
            minZoomLevel={0}
            showsTraffic={false}
            showsBuildings={true}
            followUserLocation={false}
            loadingEnabled={true}
            showsUserLocation={true}
            loadingIndicatorColor={'green'}
            initialRegion={{
              latitude: 37.78825,
              longitude: -122.4324,
              latitudeDelta: 0.0922,
              longitudeDelta: 0.0421,
            }}
            zoomEnabled={true}
            showsUserLocation={true}>
              {
                
                
              speed.map((d) =>
              d.segments.map((c) => (
                <Polyline
                  coordinates={c.coordinate}
                  strokeColor="#000" the map-provider
         
                  strokeWidth={6}>
                  <Marker
                    coordinate={{latitude: 37.8025259, longitude: -122.4351431}}
                    title="Flatiron School Atlanta"
                    description="This is where the magic happens!"></Marker>
                </Polyline>
              )),
            )}
          </MapView>

我有这样的坐标,

{"coordinates":[[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867],[43.43522206128157,-79.73892179139867]]}

感谢您的帮助

Polyline中的坐标是 LatLng

的数组

type LatLng { latitude: Number, longitude: Number, }

所以像这样的东西应该可以工作:

d.segments.map((c) => 
    <Polyline
      coordinates={c.coordinates.map(c => ({latitude: c[0], longitude: c[1]}))}
      strokeColor="#000"
      strokeWidth={6}>
    </Polyline>
)